summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-04-28 00:10:08 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-04-28 00:10:08 +0200
commit033fe621dac20e43047d6c394bb378b9a86ec5f5 (patch)
treee58acb9866f4df50c626cf902391e817e86958f9
parent- A new option to set/unset the current bookmark bar folder in the context menu (diff)
downloadrekonq-033fe621dac20e43047d6c394bb378b9a86ec5f5.tar.xz
Imported Opera feature to load favorite page with number 1..9 by pressing CTRL + 1..9
Courtesy patch by Thomas Murach. Thanks :) Reviewed by Pierre, Felix... and me! RB: 101043 PS: Thomas, I see one corner problem with your patch: Opera has clearly indicated favorites preview number, while rekonq hasn't. Any idea to fill the gap?
-rw-r--r--src/mainview.cpp10
-rw-r--r--src/mainview.h1
-rw-r--r--src/mainwindow.cpp15
3 files changed, 26 insertions, 0 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index b34acc39..19e4aae7 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -679,6 +679,16 @@ void MainView::switchToTab()
}
+void MainView::loadFavorite(const int index)
+{
+ QStringList urls = ReKonfig::previewUrls();
+ if (index < 0 || index > urls.length())
+ return;
+ KUrl url = KUrl(urls.at(index-1));
+ rApp->loadUrl(url);
+}
+
+
QLabel *MainView::animatedLoading(int index, bool addMovie)
{
if (index == -1)
diff --git a/src/mainview.h b/src/mainview.h
index acc2d8c9..d01bb5b8 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -152,6 +152,7 @@ public Q_SLOTS:
void openLastClosedTab();
void openClosedTab();
void switchToTab();
+ void loadFavorite(const int index);
// WEB slot actions
void webReload();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5edea797..1ded9836 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -93,6 +93,8 @@
#include <QtWebKit/QWebHistory>
+#include <QSignalMapper>
+
MainWindow::MainWindow()
: KXmlGuiWindow()
@@ -489,6 +491,19 @@ void MainWindow::setupActions()
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(switchToTab()));
}
+ // shortcuts for loading favorite pages
+ QSignalMapper *signalMapper = 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)));
+ a->setData(QVariant(i));
+ actionCollection()->addAction(QL1S(("switch_favorite_" + QString::number(i)).toAscii()), a);
+ connect(a, SIGNAL(triggered(bool)), signalMapper, SLOT(map()));
+ signalMapper->setMapping(a, i);
+ }
+ connect(signalMapper, SIGNAL(mapped(const int)), m_view, SLOT(loadFavorite(const int)));
+
// ============================== Indexed Tab Actions ====================================
a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this);
a->setShortcuts(KStandardShortcut::close());