From: Frank Reininghaus Date: Mon, 9 Nov 2009 17:50:21 +0000 (+0000) Subject: When the Back, Forward and Up buttons in the toolbar are clicked with X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/7ff8c0d89aecc356d66b2aed25804b5ff22fbff9?ds=inline When the Back, Forward and Up buttons in the toolbar are clicked with the middle mouse button, open the URL in a new tab. FEATURE: 190549 svn path=/trunk/KDE/kdebase/apps/; revision=1046785 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 5d990ab55..e55be1d30 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -753,6 +753,32 @@ void DolphinMainWindow::goUp() m_activeViewContainer->urlNavigator()->goUp(); } +void DolphinMainWindow::goBack(Qt::MouseButtons buttons) +{ + // The default case (left button pressed) is handled in goBack(). + if(buttons == Qt::MidButton) { + KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); + openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() + 1)); + } +} + +void DolphinMainWindow::goForward(Qt::MouseButtons buttons) +{ + // The default case (left button pressed) is handled in goForward(). + if(buttons == Qt::MidButton) { + KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator(); + openNewTab(urlNavigator->historyUrl(urlNavigator->historyIndex() - 1)); + } +} + +void DolphinMainWindow::goUp(Qt::MouseButtons buttons) +{ + // The default case (left button pressed) is handled in goUp(). + if(buttons == Qt::MidButton) { + openNewTab(activeViewContainer()->url().upUrl()); + } +} + void DolphinMainWindow::goHome() { clearStatusBar(); @@ -1226,6 +1252,7 @@ void DolphinMainWindow::setupActions() // setup 'Go' menu KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); + connect(backAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons))); KShortcut backShortcut = backAction->shortcut(); backShortcut.setAlternate(Qt::Key_Backspace); backAction->setShortcut(backShortcut); @@ -1243,8 +1270,12 @@ void DolphinMainWindow::setupActions() m_recentTabsMenu->addSeparator(); m_recentTabsMenu->setEnabled(false); - KStandardAction::forward(this, SLOT(goForward()), actionCollection()); - KStandardAction::up(this, SLOT(goUp()), actionCollection()); + KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection()); + connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons))); + + KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection()); + connect(upAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons))); + KStandardAction::home(this, SLOT(goHome()), actionCollection()); // setup 'Tools' menu diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 399b6a2a3..d72c6b938 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -259,6 +259,24 @@ private slots: /** Goes up one hierarchy of the current URL. */ void goUp(); + /** + * Open the previous URL in the URL history in a new tab + * if the middle mouse button is clicked. + */ + void goBack(Qt::MouseButtons buttons); + + /** + * Open the next URL in the URL history in a new tab + * if the middle mouse button is clicked. + */ + void goForward(Qt::MouseButtons buttons); + + /** + * Open the URL one hierarchy above the current URL in a new tab + * if the middle mouse button is clicked. + */ + void goUp(Qt::MouseButtons buttons); + /** Goes to the home URL. */ void goHome();