[rkward-cvs] SF.net SVN: rkward:[3501] trunk/rkward/rkward/windows
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Mar 30 16:49:38 UTC 2011
Revision: 3501
http://rkward.svn.sourceforge.net/rkward/?rev=3501&view=rev
Author: tfry
Date: 2011-03-30 16:49:38 +0000 (Wed, 30 Mar 2011)
Log Message:
-----------
Another attempt at a workaround for the strange differences in KDE versions with respect to service menu actions.
Modified Paths:
--------------
trunk/rkward/rkward/windows/rkfilebrowser.cpp
trunk/rkward/rkward/windows/rkfilebrowser.h
Modified: trunk/rkward/rkward/windows/rkfilebrowser.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkfilebrowser.cpp 2011-03-29 17:05:50 UTC (rev 3500)
+++ trunk/rkward/rkward/windows/rkfilebrowser.cpp 2011-03-30 16:49:38 UTC (rev 3501)
@@ -35,6 +35,7 @@
#include <QEvent>
#include <QVBoxLayout>
#include <QScrollBar>
+#include <QMenu>
#include "rkworkplace.h"
#include "../rkward.h"
@@ -120,7 +121,6 @@
#if KDE_IS_VERSION(4, 3, 0)
fi_actions = new KFileItemActions (this);
connect (dir, SIGNAL (contextMenuAboutToShow(KFileItem,QMenu*)), this, SLOT (contextMenuHook(KFileItem,QMenu*)));
- actions_added = false;
#endif
connect (dir, SIGNAL (urlEntered (const KUrl &)), this, SLOT (urlChangedInView (const KUrl &)));
@@ -142,10 +142,19 @@
QList<KFileItem> dummy;
dummy.append (item);
fi_actions->setItemListProperties (KFileItemListProperties (dummy));
- if (KDE::version () >= KDE_MAKE_VERSION (4,5,0) && actions_added) return; // in some versions of KDE the actions must be added each time the menu is shown, in others only once
+
+ // some versions of KDE appear to re-use the actions, others don't, and yet other are just plain broken (see this thread: http://www.mail-archive.com/rkward-devel@lists.sourceforge.net/msg01279.html)
+ // Therefore, we remove all actions, explicitly, each time the menu is shown, then add them again.
+ QList<QAction*> menu_actions = menu->actions ();
+ foreach (QAction* act, menu_actions) if (added_service_actions.contains (act)) menu->removeAction (act);
+ added_service_actions.clear ();
+ menu_actions = menu->actions ();
+
fi_actions->addOpenWithActionsTo (menu, QString ());
fi_actions->addServiceActionsTo (menu);
- actions_added = true;
+
+ QList<QAction*> menu_actions_after = menu->actions ();
+ foreach (QAction* act, menu_actions_after) if (!menu_actions.contains (act)) added_service_actions.append (act);
#endif
}
Modified: trunk/rkward/rkward/windows/rkfilebrowser.h
===================================================================
--- trunk/rkward/rkward/windows/rkfilebrowser.h 2011-03-29 17:05:50 UTC (rev 3500)
+++ trunk/rkward/rkward/windows/rkfilebrowser.h 2011-03-30 16:49:38 UTC (rev 3501)
@@ -22,12 +22,15 @@
#include <kvbox.h>
+#include <QList>
+
class KDirOperator;
class RKFileBrowserWidget;
class KUrlComboBox;
class KFileItem;
class KFileItemActions;
class QMenu;
+class QAction;
/** The file browser (tool) window. In order to save some startup time, the file browser is not really created until it is first shown. Hence, this is mostly just a wrapper around RKFileBrowserWidget */
class RKFileBrowser : public RKMDIWindow {
@@ -67,7 +70,7 @@
void saveConfig ();
void contextMenuHook (const KFileItem &item, QMenu *menu);
private:
- bool actions_added;
+ QList<QAction*> added_service_actions;
KDirOperator *dir;
KUrlComboBox *urlbox;
KFileItemActions *fi_actions;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list