From dfd4c14c798d0ec5b6c99c5055e07bf22b8d59f0 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sat, 24 Sep 2011 10:58:33 -0400 Subject: [PATCH] Add action to jump to last tab. Allows user to select a shortcut to jump to the far right tab. There is no default shortcut. Patch by Francesco Cecconi REVIEW: 102687 BUG: 279166 FIXED-IN: 4.8 --- src/ViewContainer.cpp | 5 +++++ src/ViewContainer.h | 3 +++ src/ViewManager.cpp | 17 +++++++++++++++++ src/ViewManager.h | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index 4359dd44a..17d301d69 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -228,6 +228,11 @@ void ViewContainer::activateNextView() setActiveView( _views.at(index) ); } +void ViewContainer::activateLastView() +{ + setActiveView(_views.at(_views.count()-1)); +} + void ViewContainer::activatePreviousView() { QWidget* active = activeView(); diff --git a/src/ViewContainer.h b/src/ViewContainer.h index f936abf5c..39f833a4b 100644 --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -203,6 +203,9 @@ public: /** Changes the active view to the previous view */ void activatePreviousView(); + /** Changes the active view to the last view */ + void activateLastView(); + /** * This enum describes the directions * in which views can be re-arranged within the container diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 30d09b2ec..727b591bd 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -137,6 +137,7 @@ void ViewManager::setupActions() KAction* nextViewAction = new KAction( i18n("Next Tab") , this ); KAction* previousViewAction = new KAction( i18n("Previous Tab") , this ); + KAction* lastViewAction = new KAction( i18n("Switch to Last Tab") , this); KAction* nextContainerAction = new KAction( i18n("Next View Container") , this); KAction* moveViewLeftAction = new KAction( i18n("Move Tab Left") , this ); @@ -207,6 +208,7 @@ void ViewManager::setupActions() // Next / Previous View , Next Container collection->addAction("next-view",nextViewAction); collection->addAction("previous-view",previousViewAction); + collection->addAction("last-tab",lastViewAction); collection->addAction("next-container",nextContainerAction); collection->addAction("move-view-left",moveViewLeftAction); collection->addAction("move-view-right",moveViewRightAction); @@ -254,6 +256,9 @@ void ViewManager::setupActions() moveViewRightAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_Right) ); connect( moveViewRightAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewRight()) ); _viewSplitter->addAction(moveViewRightAction); + + connect( lastViewAction, SIGNAL(triggered()) , this , SLOT(lastView())); + _viewSplitter->addAction(lastViewAction); } void ViewManager::switchToView(int index) { @@ -314,6 +319,15 @@ void ViewManager::previousView() container->activatePreviousView(); } +void ViewManager::lastView() +{ + ViewContainer* container = _viewSplitter->activeContainer(); + + Q_ASSERT( container ); + + container->activateLastView(); +} + void ViewManager::detachActiveView() { // find the currently active view and remove it from its container @@ -715,6 +729,9 @@ void ViewManager::setNavigationMethod(NavigationMethod method) action = collection->action( "previous-view" ); if ( action ) action->setEnabled( _navigationMethod != NoNavigation ); + action = collection->action( "last-tab" ); + if ( action ) action->setEnabled( _navigationMethod != NoNavigation ); + action = collection->action( "split-view-left-right" ); if ( action ) action->setEnabled( _navigationMethod != NoNavigation ); diff --git a/src/ViewManager.h b/src/ViewManager.h index 5b227d501..aaebad0e4 100644 --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -292,6 +292,9 @@ private slots: // called when "Previous View" shortcut is activated void previousView(); + // called when "Switch to last tab" shortcut is activated + void lastView(); + // called when "Next View Container" shortcut is activated void nextContainer();