]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Workaround for a X11-issue in combination with KModifierKeyInfo: When constructing...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 20 Sep 2010 19:52:40 +0000 (19:52 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 20 Sep 2010 19:52:40 +0000 (19:52 +0000)
CCMAIL: markg85@gmail.com

svn path=/trunk/KDE/kdebase/apps/; revision=1177658

src/dolphincontextmenu.cpp
src/dolphincontextmenu.h
src/dolphinmainwindow.cpp

index 2a29940868f72226df93a6ea155352ec78a8d28b..116edf4f0b9f942f16bf7f147decb9ca7e59aa68 100644 (file)
@@ -53,6 +53,8 @@
 #include "views/dolphinview.h"
 #include "views/viewmodecontroller.h"
 
+KModifierKeyInfo* DolphinContextMenu::m_keyInfo = 0;
+
 DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
                                        const KFileItem& fileInfo,
                                        const KUrl& baseUrl) :
@@ -65,7 +67,6 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
     m_customActions(),
     m_popup(new KMenu(m_mainWindow)),
     m_shiftPressed(false),
-    m_keyInfo(),
     m_removeAction(0)
 {
     // The context menu either accesses the URLs of the selected items
@@ -74,13 +75,14 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
     m_selectedUrls = view->selectedUrls();
     m_selectedItems = view->selectedItems();
 
-    if (m_keyInfo.isKeyPressed(Qt::Key_Shift) || m_keyInfo.isKeyLatched(Qt::Key_Shift)) {
-        m_shiftPressed = true;
+    if (m_keyInfo != 0) {
+        if (m_keyInfo->isKeyPressed(Qt::Key_Shift) || m_keyInfo->isKeyLatched(Qt::Key_Shift)) {
+            m_shiftPressed = true;
+        }
+        connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)),
+                this, SLOT(slotKeyModifierPressed(Qt::Key, bool)));
     }
 
-    connect(&m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)),
-            this, SLOT(slotKeyModifierPressed(Qt::Key, bool)));
-
     m_removeAction = new QAction(this);
     connect(m_removeAction, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
 }
@@ -123,6 +125,13 @@ void DolphinContextMenu::open()
     }
 }
 
+void DolphinContextMenu::initializeModifierKeyInfo()
+{
+    if (m_keyInfo == 0) {
+        m_keyInfo = new KModifierKeyInfo();
+    }
+}
+
 void DolphinContextMenu::slotKeyModifierPressed(Qt::Key key, bool pressed)
 {
     m_shiftPressed = (key == Qt::Key_Shift) && pressed;
index ff8d1321031a60a8dca9bdd2a44bc54ff312a13e..028dc46495734a5abd5b2a082dd21eea0058f074 100644 (file)
@@ -77,6 +77,17 @@ public:
     /** Opens the context menu model. */
     void open();
 
+    /**
+     * TODO: This method is a workaround for a X11-issue in combination
+     * with KModifierKeyInfo: When constructing KModifierKeyInfo in the
+     * constructor of the context menu, the user interface might freeze.
+     * To bypass this, the KModifierKeyInfo is constructed in DolphinMainWindow
+     * directly after starting the application. Remove this method, if
+     * the X11-issue got fixed (contact the maintainer of KModifierKeyInfo for
+     * more details).
+     */
+    static void initializeModifierKeyInfo();
+
 private slots:
     /**
      * Is invoked if a key modifier has been pressed and updates the context
@@ -155,8 +166,9 @@ private:
     QScopedPointer<KMenu> m_popup;
 
     bool m_shiftPressed;
-    KModifierKeyInfo m_keyInfo;
     QAction* m_removeAction; // Action that represents either 'Move To Trash' or 'Delete'
+
+    static KModifierKeyInfo* m_keyInfo;
 };
 
 #endif
index 722a90f9383a4b5883cafb7c28ba40a952f16e4c..e72c52bfc25f0f5d5b4c220d5ecd5c6e46efe04f 100644 (file)
@@ -116,6 +116,11 @@ DolphinMainWindow::DolphinMainWindow(int id) :
     m_settingsDialog(0),
     m_lastHandleUrlStatJob(0)
 {
+    // Workaround for a X11-issue in combination with KModifierInfo
+    // (see DolphinContextMenu::initializeModifierKeyInfo() for
+    // more information):
+    DolphinContextMenu::initializeModifierKeyInfo();
+
     setObjectName("Dolphin#");
 
     m_viewTab.append(ViewTab());