┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2017-08-24 15:45:28 +0200
committerKai Uwe Broulik <[email protected]>2017-08-24 15:45:28 +0200
commit101884841659cf7b1d735e894477415cddd1787f (patch)
tree48a53b83e7f726e03afcbe8862bf360134bf3e52 /src/dolphinmainwindow.cpp
parent24baf24f5fe089302850c7844f1ecdfd60fbb0f1 (diff)
Support middle clicking of Back/Forward/Up/Home toolbar buttons
This opens the resulting page in a new tab. BUG: 358649 Differential Revision: https://phabricator.kde.org/D7390
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 6701fbcfa..9369b3c77 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -29,6 +29,7 @@
#include "dolphintabwidget.h"
#include "dolphinviewcontainer.h"
#include "dolphintabpage.h"
+#include "middleclickactioneventfilter.h"
#include "panels/folders/folderspanel.h"
#include "panels/places/placespanel.h"
#include "panels/information/informationpanel.h"
@@ -170,6 +171,11 @@ DolphinMainWindow::DolphinMainWindow() :
if (!showMenu) {
createControlButton();
}
+
+ // enable middle-click on back/forward/up to open in a new tab
+ auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
+ connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotToolBarActionMiddleClicked);
+ toolBar()->installEventFilter(middleClickEventFilter);
}
DolphinMainWindow::~DolphinMainWindow()
@@ -501,6 +507,19 @@ void DolphinMainWindow::slotDirectoryLoadingCompleted()
updatePasteAction();
}
+void DolphinMainWindow::slotToolBarActionMiddleClicked(QAction *action)
+{
+ if (action == actionCollection()->action(QStringLiteral("go_back"))) {
+ goBackInNewTab();
+ } else if (action == actionCollection()->action(QStringLiteral("go_forward"))) {
+ goForwardInNewTab();
+ } else if (action == actionCollection()->action(QStringLiteral("go_up"))) {
+ goUpInNewTab();
+ } else if (action == actionCollection()->action(QStringLiteral("go_home"))) {
+ goHomeInNewTab();
+ }
+}
+
void DolphinMainWindow::selectAll()
{
clearStatusBar();
@@ -626,40 +645,29 @@ void DolphinMainWindow::goHome()
m_activeViewContainer->urlNavigator()->goHome();
}
-void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
+void DolphinMainWindow::goBackInNewTab()
{
- // The default case (left button pressed) is handled in goBack().
- if (buttons == Qt::MiddleButton) {
- KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
- const int index = urlNavigator->historyIndex() + 1;
- openNewTab(urlNavigator->locationUrl(index));
- }
+ KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+ const int index = urlNavigator->historyIndex() + 1;
+ openNewTab(urlNavigator->locationUrl(index));
}
-void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
+void DolphinMainWindow::goForwardInNewTab()
{
- // The default case (left button pressed) is handled in goForward().
- if (buttons == Qt::MiddleButton) {
- KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
- const int index = urlNavigator->historyIndex() - 1;
- openNewTab(urlNavigator->locationUrl(index));
- }
+ KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
+ const int index = urlNavigator->historyIndex() - 1;
+ openNewTab(urlNavigator->locationUrl(index));
}
-void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
+void DolphinMainWindow::goUpInNewTab()
{
- // The default case (left button pressed) is handled in goUp().
- if (buttons == Qt::MiddleButton) {
- openNewTab(KIO::upUrl(activeViewContainer()->url()));
- }
+ const QUrl currentUrl = activeViewContainer()->urlNavigator()->locationUrl();
+ openNewTab(KIO::upUrl(currentUrl));
}
-void DolphinMainWindow::goHome(Qt::MouseButtons buttons)
+void DolphinMainWindow::goHomeInNewTab()
{
- // The default case (left button pressed) is handled in goHome().
- if (buttons == Qt::MiddleButton) {
- openNewTab(Dolphin::homeUrl());
- }
+ openNewTab(Dolphin::homeUrl());
}
void DolphinMainWindow::compareFiles()