summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJekyll Wu <adaptee@gmail.com>2012-02-10 18:37:37 (GMT)
committerJekyll Wu <adaptee@gmail.com>2012-02-10 18:38:42 (GMT)
commit56acddac933b96c10c782a918a419f6aaf4b2702 (patch)
tree32481477da24a064fb5587e8b492ef9040270867
parenta730d311ae6ec741614625894d87231373353d44 (diff)
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. FEATURE:254976 FEATURE:292518 FIXED-IN:4.9.0 REVIEW:103859 DIGEST:
-rw-r--r--desktop/konsoleui.rc4
-rw-r--r--src/MainWindow.cpp23
-rw-r--r--src/MainWindow.h2
3 files changed, 28 insertions, 1 deletions
diff --git a/desktop/konsoleui.rc b/desktop/konsoleui.rc
index ace6bee..79ff1b1 100644
--- a/desktop/konsoleui.rc
+++ b/desktop/konsoleui.rc
@@ -1,10 +1,12 @@
<!DOCTYPE kpartgui>
-<kpartgui name="konsole" version="8">
+<kpartgui name="konsole" version="9">
<MenuBar>
<Menu name="file"><text>File</text>
<Action name="new-window"/>
<Action name="new-tab"/>
+ <Action name="clone-tab"/>
+ <Separator/>
<DefineGroup name="session-tab-operations"/>
<!-- <Action name="remote-connection"/> !-->
<Separator/>
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 117825c..79d6f0b 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -260,6 +260,13 @@ void MainWindow::setupActions()
connect(_newTabMenuAction, SIGNAL(triggered()), this, SLOT(newTab()));
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->setIcon(KIcon("window-new"));
action->setText(i18n("New &Window"));
@@ -394,6 +401,22 @@ void MainWindow::newTab()
emit newSessionRequest(defaultProfile , activeSessionDir() , _viewManager);
}
+void MainWindow::cloneTab()
+{
+ Q_ASSERT(_pluggedController);
+
+ 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
+ Q_ASSERT(false);
+ newTab();
+ }
+}
+
void MainWindow::newWindow()
{
Profile::Ptr defaultProfile = SessionManager::instance()->defaultProfile();
diff --git a/src/MainWindow.h b/src/MainWindow.h
index d990ccd..4d0d3cb 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -145,6 +145,7 @@ protected:
private slots:
void newTab();
+ void cloneTab();
void newWindow();
void showManageProfilesDialog();
void activateMenuBar();
@@ -185,6 +186,7 @@ private:
BookmarkHandler* _bookmarkHandler;
KToggleAction* _toggleMenuBarAction;
KActionMenu* _newTabMenuAction;
+ KActionMenu* _cloneTabMenuAction;
QPointer<SessionController> _pluggedController;