<div class="gmail_quote">On Mon, Sep 13, 2010 at 9:45 PM, Mark <span dir="ltr"><<a href="mailto:markg85@gmail.com">markg85@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi,<div><br></div><div>I'm trying to fix this bug:</div><div><a href="https://bugs.kde.org/show_bug.cgi?id=194275" target="_blank">https://bugs.kde.org/show_bug.cgi?id=194275</a></div>
<div><br></div><div>And for that i made this patch:</div><div><a href="http://pastebin.com/GEi2BJvv" target="_blank">http://pastebin.com/GEi2BJvv</a></div><div><br></div>
<div>However i have a few issues.</div><div>I'm using "KModifierKeyInfo" : <a href="http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKModifierKeyInfo.html" target="_blank">http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKModifierKeyInfo.html</a> but am having issues getting it to work. The way it's used in the patch blocks the gui. This is what happens, in the patch i listen to "shift" key pressed while opening the context menu however, the effect is that the gui now simply blocks when you press shift on a selected file followed by a right click (to open the context menu).</div>


<div><br></div><div>Another issue i have is: How can can change the "Move to trash" to "Delete"? I made a class wide for it: "m_deleteOrTrashMenuEntry" but if i change it to some other menu entry while the context menu is open it simply remains what is was before i changed it... I guess i need to repaint something but what?</div>


<div><br></div><div>I hope this made some sense and that someone can point me in the right direction to solve this issue.</div><div><br></div><div>Thanx,</div><div>Mark</div>
</blockquote></div><br><div>Hmm, using pastebin for a mailing list isn't really smart.. Here is the raw diff:</div><div><br></div><div><div>Index: src/dolphincontextmenu.cpp</div><div>===================================================================</div>

<div>--- src/dolphincontextmenu.cpp<span class="Apple-tab-span" style="white-space:pre">        </span>(revision 1174907)</div><div>+++ src/dolphincontextmenu.cpp<span class="Apple-tab-span" style="white-space:pre">     </span>(working copy)</div>

<div>@@ -69,6 +69,9 @@</div><div>     const DolphinView* view = m_mainWindow->activeViewContainer()->view();</div><div>     m_selectedUrls = view->selectedUrls();</div><div>     m_selectedItems = view->selectedItems();</div>

<div>+    m_keyInfo = new KModifierKeyInfo();</div><div>+</div><div>+    connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key,bool)), this, SLOT(deleteOrTrashMenuEntry(Qt::Key,bool)));</div><div> }</div><div> </div><div> DolphinContextMenu::~DolphinContextMenu()</div>

<div>@@ -337,8 +340,8 @@</div><div> </div><div>     const KUrl& url = m_mainWindow->activeViewContainer()->url();</div><div>     if (url.isLocalFile()) {</div><div>-        QAction* moveToTrashAction = collection->action("move_to_trash");</div>

<div>-        popup->addAction(moveToTrashAction);</div><div>+        m_deleteOrTrashMenuEntry = collection->action("move_to_trash");</div><div>+        popup->addAction(m_deleteOrTrashMenuEntry);</div>

<div>     } else {</div><div>         showDeleteCommand = true;</div><div>     }</div><div>@@ -439,4 +442,24 @@</div><div>     }</div><div> }</div><div> </div><div>+void DolphinContextMenu::deleteOrTrashMenuEntry(Qt::Key key, bool pressed)</div>

<div>+{</div><div>+    // insert 'Move to Trash' and (optionally) 'Delete'</div><div>+    KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);</div>

<div>+    KConfigGroup configGroup(globalConfig, "KDE");</div><div>+    bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);</div><div>+</div><div>+    if(key == Qt::Key_Shift && !showDeleteCommand) {</div>

<div>+        if(pressed) {</div><div>+            m_deleteOrTrashMenuEntry = m_mainWindow->actionCollection()->action("delete");</div><div>+            qDebug() << "DELETE...";</div><div>
+        }</div>
<div>+        else {</div><div>+            m_deleteOrTrashMenuEntry = m_mainWindow->actionCollection()->action("move_to_trash");</div><div>+            qDebug() << "MOVE TO TRASH...";</div>

<div>+        }</div><div>+</div><div>+    }</div><div>+}</div><div>+</div><div> #include "dolphincontextmenu.moc"</div><div>Index: src/dolphincontextmenu.h</div><div>===================================================================</div>

<div>--- src/dolphincontextmenu.h<span class="Apple-tab-span" style="white-space:pre">  </span>(revision 1174907)</div><div>+++ src/dolphincontextmenu.h<span class="Apple-tab-span" style="white-space:pre">       </span>(working copy)</div>

<div>@@ -25,6 +25,7 @@</div><div> #include <kservice.h></div><div> #include <kurl.h></div><div> #include <konq_copytomenu.h></div><div>+#include <kmodifierkeyinfo.h></div><div> </div><div> #include <QtCore/QObject></div>

<div> </div><div>@@ -74,6 +75,9 @@</div><div>     /** Opens the context menu model. */</div><div>     void open();</div><div> </div><div>+public slots:</div><div>+    void deleteOrTrashMenuEntry(Qt::Key key, bool pressed);</div>

<div>+</div><div> private:</div><div>     void openTrashContextMenu();</div><div>     void openTrashItemContextMenu();</div><div>@@ -130,6 +134,8 @@</div><div>     int m_context;</div><div>     KonqCopyToMenu m_copyToMenu;</div>

<div>     QList<QAction*> m_customActions;</div><div>+    QAction* m_deleteOrTrashMenuEntry;</div><div>+    KModifierKeyInfo* m_keyInfo;</div><div> };</div><div> </div><div> #endif</div></div><div><br></div>