Add Ctrl-Tab to switch tabs in chronological order

Summary:
This patch adds the possibility to navigate between the last
accessed tabs with a keyboard shortcut.

Test Plan: Open several tabs, use Ctrl-Tab to switch to the previous used one.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, ngraham, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D16884
This commit is contained in:
Thomas Surrel
2018-11-30 08:44:43 -05:00
committed by Kurt Hindenburg
parent 4e83457c06
commit 0709fdcbb5
4 changed files with 106 additions and 2 deletions

View File

@@ -132,6 +132,9 @@ void ViewManager::setupActions()
QAction *previousViewAction = new QAction(i18nc("@action Shortcut entry", "Previous Tab"), this);
QAction *lastViewAction = new QAction(i18nc("@action Shortcut entry",
"Switch to Last Tab"), this);
QAction *lastUsedViewAction = new QAction(i18nc("@action Shortcut entry", "Last Used Tabs"), this);
QAction *lastUsedViewReverseAction = new QAction(i18nc("@action Shortcut entry",
"Last Used Tabs (Reverse)"), this);
QAction *nextContainerAction = new QAction(i18nc("@action Shortcut entry",
"Next View Container"), this);
@@ -218,6 +221,8 @@ void ViewManager::setupActions()
collection->addAction(QStringLiteral("next-view"), nextViewAction);
collection->addAction(QStringLiteral("previous-view"), previousViewAction);
collection->addAction(QStringLiteral("last-tab"), lastViewAction);
collection->addAction(QStringLiteral("last-used-tab"), lastUsedViewAction);
collection->addAction(QStringLiteral("last-used-tab-reverse"), lastUsedViewReverseAction);
collection->addAction(QStringLiteral("next-container"), nextContainerAction);
collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction);
collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction);
@@ -275,6 +280,14 @@ void ViewManager::setupActions()
connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView);
_viewSplitter->addAction(lastViewAction);
collection->setDefaultShortcut(lastUsedViewAction, Qt::CTRL + Qt::Key_Tab);
connect(lastUsedViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastUsedView);
_viewSplitter->addAction(lastUsedViewAction);
collection->setDefaultShortcut(lastUsedViewReverseAction, Qt::CTRL + Qt::SHIFT + Qt::Key_Tab);
connect(lastUsedViewReverseAction, &QAction::triggered, this, &Konsole::ViewManager::lastUsedViewReverse);
_viewSplitter->addAction(lastUsedViewReverseAction);
}
void ViewManager::switchToView(int index)
@@ -342,6 +355,20 @@ void ViewManager::lastView()
container->activateLastView();
}
void ViewManager::lastUsedView()
{
TabbedViewContainer *container = _viewSplitter->activeContainer();
Q_ASSERT(container);
container->activateLastUsedView(false);
}
void ViewManager::lastUsedViewReverse()
{
TabbedViewContainer *container = _viewSplitter->activeContainer();
Q_ASSERT(container);
container->activateLastUsedView(true);
}
void ViewManager::detachActiveView()
{
// find the currently active view and remove it from its container
@@ -716,6 +743,8 @@ void ViewManager::setNavigationMethod(NavigationMethod method)
enableAction(QStringLiteral("next-view"));
enableAction(QStringLiteral("previous-view"));
enableAction(QStringLiteral("last-tab"));
enableAction(QStringLiteral("last-used-tab"));
enableAction(QStringLiteral("last-used-tab-reverse"));
enableAction(QStringLiteral("split-view-left-right"));
enableAction(QStringLiteral("split-view-top-bottom"));
enableAction(QStringLiteral("rename-session"));