]> cloud.milkyroute.net Git - dolphin.git/commitdiff
If the middle mouse button is pressed above an item of the places panel, open the...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 11 May 2008 20:14:50 +0000 (20:14 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 11 May 2008 20:14:50 +0000 (20:14 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=806606

src/dolphinfileplacesview.cpp
src/dolphinfileplacesview.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index a4f801c3abb9ce72e0c9b4c45565d0480f477d01..4165b90490c71eb31d808f3b339c2143620834b6 100644 (file)
 #include <konq_operations.h>
 
 DolphinFilePlacesView::DolphinFilePlacesView(QWidget* parent) :
-    KFilePlacesView(parent)
+    KFilePlacesView(parent),
+    m_mouseButtons(Qt::NoButton)
 {
     setDropOnPlaceEnabled(true);
     connect(this, SIGNAL(urlsDropped(const KUrl&, QDropEvent*, QWidget*)),
             this, SLOT(slotUrlsDropped(const KUrl&, QDropEvent*, QWidget*)));
+    connect(this, SIGNAL(urlChanged(const KUrl&)),
+            this, SLOT(emitExtendedUrlChangedSignal(const KUrl&)));
 }
 
 DolphinFilePlacesView::~DolphinFilePlacesView()
 {
 }
 
+void DolphinFilePlacesView::mousePressEvent(QMouseEvent* event)
+{
+    m_mouseButtons = event->buttons();
+    KFilePlacesView::mousePressEvent(event);
+}
+
 void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
 {
     const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
@@ -44,4 +53,9 @@ void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event,
     dropController.dropUrls(urls, dest);
 }
 
+void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url)
+{
+    emit urlChanged(url, m_mouseButtons);
+}
+
 #include "dolphinfileplacesview.moc"
index 8bad0fa5f115383778bbe00dbdafaf96fd5c43ce..46d574606b2db7bd2901571d08ccd6587585bde5 100644 (file)
@@ -34,8 +34,18 @@ public:
     DolphinFilePlacesView(QWidget* parent);
     virtual ~DolphinFilePlacesView();
 
+signals:
+    void urlChanged(const KUrl& url, Qt::MouseButtons buttons);
+
+protected:
+    virtual void mousePressEvent(QMouseEvent* event);
+
 private slots:
     void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
+    void emitExtendedUrlChangedSignal(const KUrl& url);
+
+private:
+    Qt::MouseButtons m_mouseButtons;
 };
 
 #endif // DOLPHINFILEPLACESVIEW_H
index afa6ea43f71b5f67d4428e5581054db6207eb428..149f58b0f6960e5b5127a105c758b9ed6ee9437d 100644 (file)
@@ -763,6 +763,16 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
     }
 }
 
+void DolphinMainWindow::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
+{
+    if (buttons & Qt::MidButton) {
+        openNewTab(url);
+        m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
+    } else {
+        changeUrl(url);
+    }
+}
+
 void DolphinMainWindow::init()
 {
     DolphinSettings& settings = DolphinSettings::instance();
@@ -1084,8 +1094,8 @@ void DolphinMainWindow::setupDockWidgets()
     actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction());
 
     addDockWidget(Qt::LeftDockWidgetArea, placesDock);
-    connect(placesView, SIGNAL(urlChanged(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
+    connect(placesView, SIGNAL(urlChanged(KUrl, Qt::MouseButtons)),
+            this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
     connect(this, SIGNAL(urlChanged(KUrl)),
             placesView, SLOT(setUrl(KUrl)));
 }
index c03e2404d460ee99743d73d7747dd0dbe62fcf92..71d7b52d187cbbfa6d45005fae280b8f8c9311a9 100644 (file)
@@ -339,6 +339,13 @@ private slots:
      */
     void openTabContextMenu(int index, const QPoint& pos);
 
+    /**
+     * Handles a click on a places item: if the middle mouse button is
+     * clicked, a new tab is opened for \a url, otherwise the current
+     * view is replaced by \a url.
+     */
+    void handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons);
+
 private:
     DolphinMainWindow(int id);
     void init();