Commit 56acddac authored by Jekyll Wu's avatar Jekyll Wu
Browse files

Add 'Clone Tab' action for cloning current tab

This action will create new tab/session using the same settings(command,
colors, etc) used in current tab/session.

At this moment, this action does not always clone current tab/session
100%. For example, If you change the scrollback setting of current
session temporarily through context menu or dbus method, this action
won't clone the temporary change. Another example is the tab title.

On the other hand, this action works quite well with command line
options(-e, -p, etc) and the 'konsoleprofile' utility.



parent a730d311
<!DOCTYPE kpartgui> <!DOCTYPE kpartgui>
<kpartgui name="konsole" version="8"> <kpartgui name="konsole" version="9">
<MenuBar> <MenuBar>
<Menu name="file"><text>File</text> <Menu name="file"><text>File</text>
<Action name="new-window"/> <Action name="new-window"/>
<Action name="new-tab"/> <Action name="new-tab"/>
<Action name="clone-tab"/>
<DefineGroup name="session-tab-operations"/> <DefineGroup name="session-tab-operations"/>
<!-- <Action name="remote-connection"/> !--> <!-- <Action name="remote-connection"/> !-->
<Separator/> <Separator/>
...@@ -260,6 +260,13 @@ void MainWindow::setupActions() ...@@ -260,6 +260,13 @@ void MainWindow::setupActions()
connect(_newTabMenuAction, SIGNAL(triggered()), this, SLOT(newTab())); connect(_newTabMenuAction, SIGNAL(triggered()), this, SLOT(newTab()));
collection->addAction("new-tab", _newTabMenuAction); collection->addAction("new-tab", _newTabMenuAction);
action = collection->addAction("clone-tab");
action->setIcon( KIcon("tab-duplicate") );
action->setText( i18n("&Clone Tab") );
action->setShortcut( QKeySequence() );
action->setAutoRepeat( false );
connect( action , SIGNAL(triggered()) , this , SLOT(cloneTab()) );
action = collection->addAction("new-window"); action = collection->addAction("new-window");
action->setIcon(KIcon("window-new")); action->setIcon(KIcon("window-new"));
action->setText(i18n("New &Window")); action->setText(i18n("New &Window"));
...@@ -394,6 +401,22 @@ void MainWindow::newTab() ...@@ -394,6 +401,22 @@ void MainWindow::newTab()
emit newSessionRequest(defaultProfile , activeSessionDir() , _viewManager); emit newSessionRequest(defaultProfile , activeSessionDir() , _viewManager);
} }
void MainWindow::cloneTab()
Session* session = _pluggedController->session();
Profile::Ptr profile = SessionManager::instance()->sessionProfile(session);
if ( profile) {
emit newSessionRequest( profile , activeSessionDir() , _viewManager);
else {
// something must be wrong: every session should be associated with profile
void MainWindow::newWindow() void MainWindow::newWindow()
{ {
Profile::Ptr defaultProfile = SessionManager::instance()->defaultProfile(); Profile::Ptr defaultProfile = SessionManager::instance()->defaultProfile();
...@@ -145,6 +145,7 @@ protected: ...@@ -145,6 +145,7 @@ protected:
private slots: private slots:
void newTab(); void newTab();
void cloneTab();
void newWindow(); void newWindow();
void showManageProfilesDialog(); void showManageProfilesDialog();
void activateMenuBar(); void activateMenuBar();
...@@ -185,6 +186,7 @@ private: ...@@ -185,6 +186,7 @@ private:
BookmarkHandler* _bookmarkHandler; BookmarkHandler* _bookmarkHandler;
KToggleAction* _toggleMenuBarAction; KToggleAction* _toggleMenuBarAction;
KActionMenu* _newTabMenuAction; KActionMenu* _newTabMenuAction;
KActionMenu* _cloneTabMenuAction;
QPointer<SessionController> _pluggedController; QPointer<SessionController> _pluggedController;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment