[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kfile
From:       Peter Penz <peter.penz () gmx ! at>
Date:       2010-05-04 18:57:54
Message-ID: 20100504185755.028CDAC8AB () svn ! kde ! org
[Download RAW message or body]

SVN commit 1122811 by ppenz:

Allow using the middle-mouse button also on sub-menus and open the URL in a new tab \
(http://reviewboard.kde.org/r/3859). Thanks to Todd for the patch!

CCMAIL: toddrme2178@gmail.com

 M  +10 -0     kurlnavigatorbutton.cpp  
 M  +7 -0      kurlnavigatorbutton_p.h  
 M  +11 -0     kurlnavigatormenu.cpp  
 M  +8 -0      kurlnavigatormenu_p.h  


--- trunk/KDE/kdelibs/kfile/kurlnavigatorbutton.cpp #1122810:1122811
@@ -388,6 +388,14 @@
     urlsDropped(url, event);
 }
 
+void KUrlNavigatorButton::slotMenuActionClicked(QAction* action)
+{
+    const int result = action->data().toInt();
+    KUrl url = m_url;
+    url.addPath(m_subDirs.at(result).first);
+    emit clicked(url, Qt::MidButton);
+}
+
 void KUrlNavigatorButton::statFinished(KJob* job)
 {
     if (m_pendingTextChange) {
@@ -553,6 +561,8 @@
 
 void KUrlNavigatorButton::initMenu(KUrlNavigatorMenu* menu, int startIndex)
 {
+    connect(menu, SIGNAL(middleMouseButtonClicked(QAction*)),
+            this, SLOT(slotMenuActionClicked(QAction*)));
     connect(menu, SIGNAL(urlsDropped(QAction*, QDropEvent*)),
             this, SLOT(urlsDropped(QAction*, QDropEvent*)));
 
--- trunk/KDE/kdelibs/kfile/kurlnavigatorbutton_p.h #1122810:1122811
@@ -147,6 +147,13 @@
     void replaceButton(KJob* job);
 
     void urlsDropped(QAction* action, QDropEvent* event);
+
+    /**
+     * Is called, if an action of a sub-menu has been triggered by
+     * a click with the middle mouse-button.
+     */
+    void slotMenuActionClicked(QAction* action);
+
     void statFinished(KJob*);
 
 private:
--- trunk/KDE/kdelibs/kfile/kurlnavigatormenu.cpp #1122810:1122811
@@ -55,4 +55,15 @@
     }
 }
 
+void KUrlNavigatorMenu::mouseReleaseEvent(QMouseEvent* event)
+{
+    if (event->button() == Qt::MidButton) {
+        QAction* action = actionAt(event->pos());
+        if (action != 0) {
+            emit middleMouseButtonClicked(action);
+        }
+    }
+    KMenu::mouseReleaseEvent(event);
+}
+
 #include "kurlnavigatormenu_p.moc"
--- trunk/KDE/kdelibs/kfile/kurlnavigatormenu_p.h #1122810:1122811
@@ -42,10 +42,18 @@
      */
     void urlsDropped(QAction* action, QDropEvent* event);
 
+    /**
+     * Is emitted, if the action \p action has been clicked
+     * by the middle mouse button (QMenu ignores a click
+     * with the middle mouse button).
+     */
+    void middleMouseButtonClicked(QAction* action);
+
 protected:
     virtual void dragEnterEvent(QDragEnterEvent* event);
     virtual void dragMoveEvent(QDragMoveEvent* event);
     virtual void dropEvent(QDropEvent* event);
+    virtual void mouseReleaseEvent(QMouseEvent* event);
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic