From b96d7a83dc5f25429b378fb4a4c3cf9399830491 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 2 Jan 2013 11:32:23 +0100 Subject: Restore rekonq 1.x shortcuts ALT + #number to change tabs CTRL + #number to load favorites BUG: 312341 --- src/kspellplugin.cpp | 1 + src/tabwindow/tabwindow.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/tabwindow/tabwindow.h | 2 ++ 3 files changed, 40 insertions(+) diff --git a/src/kspellplugin.cpp b/src/kspellplugin.cpp index 7b20b4a4..244c2a1d 100644 --- a/src/kspellplugin.cpp +++ b/src/kspellplugin.cpp @@ -27,6 +27,7 @@ // Self Includes #include "kspellplugin.h" +#include "kspellplugin.moc" // KDE Includes #include diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index f05d8142..04a47b5e 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -171,6 +171,31 @@ void TabWindow::init() _addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + + // ---------------------------------------------------------------------------------------------- + // shortcuts for quickly switching to a tab + QSignalMapper *tabSignalMapper = new QSignalMapper(this); + for (int i = 0; i < 9; i++) + { + a = new KAction(i18n("Switch to Tab %1", i+1), this); + a->setShortcut(KShortcut(QString("Alt+%1").arg(i+1))); + actionCollection()->addAction(QL1S(QString("switch_tab_" + QString::number(i+1)).toAscii()), a); + connect(a, SIGNAL(triggered(bool)), tabSignalMapper, SLOT(map())); + tabSignalMapper->setMapping(a, i); + } + connect(tabSignalMapper, SIGNAL(mapped(int)), this, SLOT(setCurrentIndex(int))); + + // shortcuts for loading favorite pages + QSignalMapper *favoritesSignalMapper = new QSignalMapper(this); + for (int i = 1; i <= 9; ++i) + { + a = new KAction(i18n("Switch to Favorite Page %1", i), this); + a->setShortcut(KShortcut(QString("Ctrl+%1").arg(i))); + actionCollection()->addAction(QL1S(QString("switch_favorite_" + QString::number(i)).toAscii()), a); + connect(a, SIGNAL(triggered(bool)), favoritesSignalMapper, SLOT(map())); + favoritesSignalMapper->setMapping(a, i); + } + connect(favoritesSignalMapper, SIGNAL(mapped(int)), this, SLOT(loadFavorite(int))); } @@ -672,3 +697,15 @@ bool TabWindow::isPrivateBrowsingWindowMode() { return _isPrivateBrowsing; } + + +void TabWindow::loadFavorite(const int index) +{ + QStringList urls = ReKonfig::previewUrls(); + if (index < 0 || index > urls.length()) + return; + + KUrl url = KUrl(urls.at(index - 1)); + loadUrl(url); + currentWebWindow()->setFocus(); +} diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h index 018ad0e7..c3df016c 100644 --- a/src/tabwindow/tabwindow.h +++ b/src/tabwindow/tabwindow.h @@ -114,6 +114,8 @@ private Q_SLOTS: void setFullScreen(bool); + void loadFavorite(const int); + private: // the new tab button QToolButton *_addTabButton; -- cgit v1.2.1