From 29e095b81d241a77f43bf4bf293d9428b6caea26 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 5 Mar 2010 23:10:20 +0100 Subject: Add middle click support for next, back and home in the main toolbar --- src/mainwindow.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++------ src/mainwindow.h | 3 +++ 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 60784af0..a2768bb6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,7 +286,8 @@ void MainWindow::setupActions() fullScreenShortcut.setAlternate( Qt::Key_F11 ); a->setShortcut( fullScreenShortcut ); - KStandardAction::home(this, SLOT(homePage()), actionCollection()); + a = actionCollection()->addAction( KStandardAction::Home ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons))); KStandardAction::preferences(this, SLOT(preferences()), actionCollection()); a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection()); @@ -345,14 +346,16 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData())); // ========================= History related actions ============================== - a = KStandardAction::back(this, SLOT(openPrevious()) , actionCollection()); + a = actionCollection()->addAction( KStandardAction::Back ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons))); m_historyBackMenu = new KMenu(this); a->setMenu(m_historyBackMenu); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *))); - KStandardAction::forward(this, SLOT(openNext()) , actionCollection()); + a = actionCollection()->addAction( KStandardAction::Forward ); + connect(a, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons))); // ============================== General Tab Actions ==================================== a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); @@ -929,9 +932,18 @@ void MainWindow::viewPageSource() } +void MainWindow::homePage(Qt::MouseButtons btn) +{ + if(btn == Qt::MidButton) + Application::instance()->loadUrl( KUrl(ReKonfig::homePage()), Rekonq::SettingOpenTab ); + else + currentTab()->view()->load( QUrl(ReKonfig::homePage()) ); +} + + void MainWindow::homePage() { - currentTab()->view()->load( QUrl(ReKonfig::homePage()) ); + homePage(Qt::LeftButton); } @@ -973,18 +985,42 @@ void MainWindow::browserLoading(bool v) void MainWindow::openPrevious() +{ + openPrevious(Qt::LeftButton); +} + + +void MainWindow::openPrevious(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); if (history->canGoBack()) - history->goToItem(history->backItem()); + { + KUrl back = history->backItem().url(); + if(btn == Qt::MidButton) + Application::instance()->loadUrl(back, Rekonq::SettingOpenTab); + else + Application::instance()->loadUrl(back); + } } void MainWindow::openNext() +{ + openNext(Qt::LeftButton); +} + + +void MainWindow::openNext(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); if (history->canGoForward()) - history->goToItem(history->forwardItem()); + { + KUrl next = history->forwardItem().url(); + if(btn == Qt::MidButton) + Application::instance()->loadUrl(next, Rekonq::SettingOpenTab); + else + Application::instance()->loadUrl(next); + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 57b88dfd..9e491c69 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -88,6 +88,7 @@ private: public slots: void homePage(); + void homePage(Qt::MouseButtons); /** * Notifies a message in a popup @@ -123,7 +124,9 @@ private slots: // history related void openPrevious(); + void openPrevious(Qt::MouseButtons); void openNext(); + void openNext(Qt::MouseButtons); // Find Action slots void find(const QString &); -- cgit v1.2.1 From cf5d70ff31a166cb13f5c042f019e6193f97526d Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 14 Mar 2010 00:06:27 +0100 Subject: Use default value instead of a different function --- src/mainwindow.cpp | 18 ------------------ src/mainwindow.h | 9 +++------ 2 files changed, 3 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a2768bb6..4b48157b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -941,12 +941,6 @@ void MainWindow::homePage(Qt::MouseButtons btn) } -void MainWindow::homePage() -{ - homePage(Qt::LeftButton); -} - - MainView *MainWindow::mainView() const { return m_view; @@ -984,12 +978,6 @@ void MainWindow::browserLoading(bool v) } -void MainWindow::openPrevious() -{ - openPrevious(Qt::LeftButton); -} - - void MainWindow::openPrevious(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); @@ -1004,12 +992,6 @@ void MainWindow::openPrevious(Qt::MouseButtons btn) } -void MainWindow::openNext() -{ - openNext(Qt::LeftButton); -} - - void MainWindow::openNext(Qt::MouseButtons btn) { QWebHistory *history = currentTab()->view()->history(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 9e491c69..b693fec1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -87,8 +87,7 @@ private: void setupPanels(); public slots: - void homePage(); - void homePage(Qt::MouseButtons); + void homePage(Qt::MouseButtons = Qt::LeftButton); /** * Notifies a message in a popup @@ -123,10 +122,8 @@ private slots: void updateWindowTitle(const QString &title = QString()); // history related - void openPrevious(); - void openPrevious(Qt::MouseButtons); - void openNext(); - void openNext(Qt::MouseButtons); + void openPrevious(Qt::MouseButtons = Qt::LeftButton); + void openNext(Qt::MouseButtons = Qt::LeftButton); // Find Action slots void find(const QString &); -- cgit v1.2.1