[rkward/frameworks] rkward: Instead of creating a second action to open the import menu (which some versions of Qt do not seem to like), fetch the menu-action, and add that into the toolbar buttons.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Sep 15 15:35:31 UTC 2016


Git commit 06186a9ea9ce895695a0e915e6207a9883487af3 by Thomas Friedrichsmeier.
Committed on 15/09/2016 at 15:34.
Pushed by tfry into branch 'frameworks'.

Instead of creating a second action to open the import menu (which some versions of Qt do not seem to like), fetch the menu-action, and add that into the toolbar buttons.

M  +9    -7    rkward/rkward.cpp
M  +1    -1    rkward/rkward.h

http://commits.kde.org/rkward/06186a9ea9ce895695a0e915e6207a9883487af3

diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 8c36993..6e51041 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -153,6 +153,12 @@ RKWardMainWindow::RKWardMainWindow () : KParts::MainWindow ((QWidget *)0, (Qt::W
 	createShellGUI (true);
 	RKXMLGUISyncer::self ()->watchXMLGUIClientUIrc (this);
 
+	// replicate File->import and export menus into the Open/Save toolbar button menus
+	QMenu *menu = dynamic_cast<QMenu*>(guiFactory ()->container ("import", this));
+	if (menu) open_any_action->addAction (menu->menuAction ());
+	menu = dynamic_cast<QMenu*>(guiFactory ()->container ("export", this));
+	save_any_action->addAction (menu->menuAction ());
+
 	RKComponentMap::initialize ();
 
 	// stuff which should wait until the event loop is running
@@ -202,8 +208,6 @@ void RKWardMainWindow::doPostInit () {
 	QString evaluate_code = RKGlobals::startup_options.take ("evaluate").toString ();
 
 	initPlugins ();
-	proxy_import->setMenu (dynamic_cast<QMenu*>(guiFactory ()->container ("import", this)));
-	proxy_export->setMenu (dynamic_cast<QMenu*>(guiFactory ()->container ("export", this)));
 	gui_rebuild_locked = false;
 
 	show ();
@@ -532,7 +536,7 @@ void RKWardMainWindow::initActions() {
 	view_menu_dummy->setEnabled (false);
 
 	// collections for the toolbar:
-	KActionMenu* open_any_action = new KActionMenu (QIcon::fromTheme("document-open-folder"), i18n ("Open..."), this);
+	open_any_action = new KActionMenu (QIcon::fromTheme("document-open-folder"), i18n ("Open..."), this);
 	open_any_action->setDelayed (false);
 	actionCollection ()->addAction ("open_any", open_any_action);
 
@@ -542,8 +546,7 @@ void RKWardMainWindow::initActions() {
 	open_any_action->addAction (fileOpen);
 	open_any_action->addAction (fileOpenRecent);
 	open_any_action->addSeparator ();
-	proxy_import = new QAction (i18n ("Import"), this);
-	open_any_action->addAction (proxy_import);
+	//open_any_action->addAction (proxy_import); -> later
 
 	KActionMenu* new_any_action = new KActionMenu (QIcon::fromTheme("document-new"), i18n ("Create..."), this);
 	new_any_action->setDelayed (false);
@@ -556,13 +559,12 @@ void RKWardMainWindow::initActions() {
 	save_any_action->setDelayed (false);
 	actionCollection ()->addAction ("save_any", save_any_action);
 
-	proxy_export = new QAction (i18n ("Export"), this);
 	save_any_action->addAction (fileSaveWorkspace);
 	save_any_action->addAction (fileSaveWorkspaceAs);
 	save_any_action->addSeparator ();
 // TODO: A way to add R-script-save actions, dynamically, would be nice
 	save_actions_plug_point = save_any_action->addSeparator ();
-	save_any_action->addAction (proxy_export);
+	//save_any_action->addAction (proxy_export); -> later
 }
 
 /*
diff --git a/rkward/rkward.h b/rkward/rkward.h
index 7a7da48..a04cc8e 100644
--- a/rkward/rkward.h
+++ b/rkward/rkward.h
@@ -168,7 +168,7 @@ private:
 	/** used so that if the menu is empty, there is a note in it, explaining that fact */
 	QAction* view_menu_dummy;
 
-	QAction* proxy_export, *proxy_import;
+	KActionMenu* open_any_action;
 	KActionMenu* save_any_action;
 	QAction* save_actions_plug_point;
 	QList<QPointer <QAction> > plugged_save_actions;



More information about the rkward-tracker mailing list