]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Let additional mouse buttons trigger history navigation
authorPeter Penz <peter.penz19@gmail.com>
Mon, 19 Mar 2012 15:47:11 +0000 (16:47 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 19 Mar 2012 15:53:53 +0000 (16:53 +0100)
Thanks to Sebastian Dörner for the patch!

REVIEW: 101335
BUG: 181823
FIXED-IN: 4.9

src/dolphinmainwindow.cpp
src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/views/dolphinview.cpp
src/views/dolphinview.h

index 4c551b2c39c83146bfa69a08ae3b2ab696ce8bde..947db7703f08fc7c7cf1b1df803074af678c46b8 100644 (file)
@@ -2123,6 +2123,10 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
             this, SLOT(enableStopAction()));
     connect(view, SIGNAL(finishedPathLoading(KUrl)),
             this, SLOT(disableStopAction()));
+    connect(view, SIGNAL(goBackRequested()),
+            this, SLOT(goBack()));
+    connect(view, SIGNAL(goForwardRequested()),
+            this, SLOT(goForward()));
 
     const KUrlNavigator* navigator = container->urlNavigator();
     connect(navigator, SIGNAL(urlChanged(KUrl)),
index 1ad760ae2c34b944593716671112e09052bffc24..35d5038676898cb58c66b9618c6afe64f59b200f 100644 (file)
@@ -454,9 +454,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
 
     m_pressedMousePos = transform.map(event->pos());
     m_pressedIndex = m_view->itemAt(m_pressedMousePos);
-    if (m_pressedIndex >= 0) {
-        emit itemPressed(m_pressedIndex, event->button());
-    }
+    emit mouseButtonPressed(m_pressedIndex, event->buttons());
 
     if (m_view->isAboveExpansionToggle(m_pressedIndex, m_pressedMousePos)) {
         m_selectionManager->endAnchoredSelection();
@@ -637,9 +635,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
         return false;
     }
 
-    if (m_pressedIndex >= 0) {
-        emit itemReleased(m_pressedIndex, event->button());
-    }
+    emit mouseButtonReleased(m_pressedIndex, event->buttons());
 
     const bool isAboveSelectionToggle = m_view->isAboveSelectionToggle(m_pressedIndex, m_pressedMousePos);
     if (isAboveSelectionToggle) {
index 9ac4c76e664b17751e65de09a61893664f4cd376..b44fcca3c8447056cc451f86f5266b1fbd5274c0 100644 (file)
@@ -177,14 +177,18 @@ signals:
 
     /**
      * Is emitted if a mouse-button has been pressed above an item.
+     * If the index is smaller than 0, the mouse-button has been pressed
+     * above the viewport.
      */
-    void itemPressed(int index, Qt::MouseButton button);
+    void mouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
 
     /**
      * Is emitted if a mouse-button has been released above an item.
-     * It is assured that the signal itemPressed() has been emitted before.
+     * It is assured that the signal mouseButtonPressed() has been emitted before.
+     * If the index is smaller than 0, the mouse-button has been pressed
+     * above the viewport.
      */
-    void itemReleased(int index, Qt::MouseButton button);
+    void mouseButtonReleased(int itemIndex, Qt::MouseButtons buttons);
 
     void itemExpansionToggleClicked(int index);
 
index 29a132184264c523ef3e03ad2bd044a085b2c0c8..75561a9c69c02a657a03a3d8167656f9bad3439a 100644 (file)
@@ -142,7 +142,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
     connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
     connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
     connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
-    connect(controller, SIGNAL(itemPressed(int,Qt::MouseButton)), this, SLOT(hideToolTip()));
+    connect(controller, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons)));
     connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
     connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
     connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
@@ -889,6 +889,22 @@ void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* prev
     m_versionControlObserver->setModel(fileItemModel);
 }
 
+void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons)
+{
+    hideToolTip();
+
+    if (itemIndex < 0) {
+        // Trigger the history navigation only when clicking on the viewport:
+        // Above an item the XButtons provide a simple way to select items in
+        // the singleClick mode.
+        if (buttons & Qt::XButton1) {
+            emit goBackRequested();
+        } else if (buttons & Qt::XButton2) {
+            emit goForwardRequested();
+        }
+    }
+}
+
 void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
 {
     const int currentCount = current.count();
index 628ab2dc549ed2f5bd0dba888ec85ad7253c44c9..48d0646c46e96a1f06a8084a4d47a676e53e2850 100644 (file)
@@ -511,6 +511,18 @@ signals:
      */
     void writeStateChanged(bool isFolderWritable);
 
+    /**
+     * Is emitted if the URL should be changed to the previous URL of the
+     * history (e.g. because the "back"-mousebutton has been pressed).
+     */
+    void goBackRequested();
+
+    /**
+     * Is emitted if the URL should be changed to the next URL of the
+     * history (e.g. because the "next"-mousebutton has been pressed).
+     */
+    void goForwardRequested();
+
 protected:
     /** Changes the zoom level if Control is pressed during a wheel event. */
     virtual void wheelEvent(QWheelEvent* event);
@@ -535,6 +547,7 @@ private slots:
     void slotItemUnhovered(int index);
     void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
     void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
+    void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
 
     /**
      * Emits the signal \a selectionChanged() with a small delay. This is