From d70ae675ec02d347b49169ee7cf551f64263680e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Sun, 10 Feb 2013 22:04:16 +0100 Subject: Add keyboard shortcut support for 'Show Next Tab' and 'Show Previous Tab' Signed-off-by: Andrea Diamantini --- src/tabwindow/tabwindow.cpp | 28 ++++++++++++++++++++++++++++ src/tabwindow/tabwindow.h | 3 +++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index 3910467b..acf84948 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -154,6 +154,16 @@ void TabWindow::init() actionCollection()->addAction(QL1S("close_tab"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(closeTab())); + a = new KAction(i18n("Show Next Tab"), this); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); + actionCollection()->addAction(QL1S("show_next_tab"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(nextTab())); + + a = new KAction(i18n("Show Previous Tab"), this); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); + actionCollection()->addAction(QL1S("show_prev_tab"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(previousTab())); + a = KStandardAction::fullScreen(this, SLOT(setFullScreen(bool)), this, actionCollection()); KShortcut fullScreenShortcut = KStandardShortcut::fullScreen(); fullScreenShortcut.setAlternate(Qt::Key_F11); @@ -722,6 +732,24 @@ void TabWindow::restoreLastClosedTab() } +void TabWindow::nextTab() +{ + int next = currentIndex() + 1; + if (next == count()) + next = 0; + setCurrentIndex(next); +} + + +void TabWindow::previousTab() +{ + int next = currentIndex() - 1; + if (next < 0) + next = count() - 1; + setCurrentIndex(next); +} + + void TabWindow::setFullScreen(bool makeFullScreen) { tabBar()->setVisible(!makeFullScreen); diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h index 3a00ac4a..a273d3b1 100644 --- a/src/tabwindow/tabwindow.h +++ b/src/tabwindow/tabwindow.h @@ -111,6 +111,9 @@ private Q_SLOTS: void reloadAllTabs(); void bookmarkAllTabs(); + void nextTab(); + void previousTab(); + void restoreLastClosedTab(); void setFullScreen(bool); -- cgit v1.2.1