[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Implementing shift delete in dolphin, some help would be nice.
From: Mark <markg85 () gmail ! com>
Date: 2010-09-13 20:22:22
Message-ID: AANLkTimB3C+EnYJL1TWzPbmspknW8-sDv1sxp74S=rUE () mail ! gmail ! com
[Download RAW message or body]
On Mon, Sep 13, 2010 at 10:00 PM, Mark <markg85@gmail.com> wrote:
> On Mon, Sep 13, 2010 at 9:45 PM, Mark <markg85@gmail.com> wrote:
>
>> Hi,
>>
>> I'm trying to fix this bug:
>> https://bugs.kde.org/show_bug.cgi?id=194275
>>
>> And for that i made this patch:
>> http://pastebin.com/GEi2BJvv
>>
>> However i have a few issues.
>> I'm using "KModifierKeyInfo" :
>> http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKModifierKeyInfo.html 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).
>>
>> 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?
>>
>> I hope this made some sense and that someone can point me in the right
>> direction to solve this issue.
>>
>> Thanx,
>> Mark
>>
>
> Hmm, using pastebin for a mailing list isn't really smart.. Here is the raw
> diff:
>
> Index: src/dolphincontextmenu.cpp
> ===================================================================
> --- src/dolphincontextmenu.cpp (revision 1174907)
> +++ src/dolphincontextmenu.cpp (working copy)
> @@ -69,6 +69,9 @@
> const DolphinView* view = m_mainWindow->activeViewContainer()->view();
> m_selectedUrls = view->selectedUrls();
> m_selectedItems = view->selectedItems();
> + m_keyInfo = new KModifierKeyInfo();
> +
> + connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key,bool)), this,
> SLOT(deleteOrTrashMenuEntry(Qt::Key,bool)));
> }
>
> DolphinContextMenu::~DolphinContextMenu()
> @@ -337,8 +340,8 @@
>
> const KUrl& url = m_mainWindow->activeViewContainer()->url();
> if (url.isLocalFile()) {
> - QAction* moveToTrashAction = collection->action("move_to_trash");
> - popup->addAction(moveToTrashAction);
> + m_deleteOrTrashMenuEntry = collection->action("move_to_trash");
> + popup->addAction(m_deleteOrTrashMenuEntry);
> } else {
> showDeleteCommand = true;
> }
> @@ -439,4 +442,24 @@
> }
> }
>
> +void DolphinContextMenu::deleteOrTrashMenuEntry(Qt::Key key, bool pressed)
> +{
> + // insert 'Move to Trash' and (optionally) 'Delete'
> + KSharedConfig::Ptr globalConfig =
> KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
> + KConfigGroup configGroup(globalConfig, "KDE");
> + bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand",
> false);
> +
> + if(key == Qt::Key_Shift && !showDeleteCommand) {
> + if(pressed) {
> + m_deleteOrTrashMenuEntry =
> m_mainWindow->actionCollection()->action("delete");
> + qDebug() << "DELETE...";
> + }
> + else {
> + m_deleteOrTrashMenuEntry =
> m_mainWindow->actionCollection()->action("move_to_trash");
> + qDebug() << "MOVE TO TRASH...";
> + }
> +
> + }
> +}
> +
> #include "dolphincontextmenu.moc"
> Index: src/dolphincontextmenu.h
> ===================================================================
> --- src/dolphincontextmenu.h (revision 1174907)
> +++ src/dolphincontextmenu.h (working copy)
> @@ -25,6 +25,7 @@
> #include <kservice.h>
> #include <kurl.h>
> #include <konq_copytomenu.h>
> +#include <kmodifierkeyinfo.h>
>
> #include <QtCore/QObject>
>
> @@ -74,6 +75,9 @@
> /** Opens the context menu model. */
> void open();
>
> +public slots:
> + void deleteOrTrashMenuEntry(Qt::Key key, bool pressed);
> +
> private:
> void openTrashContextMenu();
> void openTrashItemContextMenu();
> @@ -130,6 +134,8 @@
> int m_context;
> KonqCopyToMenu m_copyToMenu;
> QList<QAction*> m_customActions;
> + QAction* m_deleteOrTrashMenuEntry;
> + KModifierKeyInfo* m_keyInfo;
> };
>
> #endif
>
> Interesting, just found out that just having an instance
of KModifierKeyInfo (in the earlier diff: "m_keyInfo = new
KModifierKeyInfo();") blocks the GUI when shift is pressed and the right
mouse button.
[Attachment #3 (text/html)]
<div class="gmail_quote">On Mon, Sep 13, 2010 at 10:00 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;">
<div><div></div><div class="h5"><div class="gmail_quote">On Mon, Sep 13, 2010 at 9:45 \
PM, Mark <span dir="ltr"><<a href="mailto:markg85@gmail.com" \
target="_blank">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></div><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 \
style="white-space:pre-wrap"> </span>(revision 1174907)</div><div>+++ \
src/dolphincontextmenu.cpp<span style="white-space:pre-wrap"> </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 style="white-space:pre-wrap"> </span>(revision \
1174907)</div><div>+++ src/dolphincontextmenu.h<span \
style="white-space:pre-wrap"> </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> \
</blockquote></div>Interesting, just found out that just having an instance of \
KModifierKeyInfo (in the earlier diff: "<meta http-equiv="content-type" \
content="text/html; charset=utf-8">m_keyInfo = new KModifierKeyInfo();") blocks \
the GUI when shift is pressed and the right mouse button.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic