[rkward/work/preview_with_menu] rkward: Also add menu-button to code preview. In doing so, work around some issues of unlabeled menus, or menu ordering bugs.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Feb 9 13:53:20 UTC 2016


Git commit 9ea2f10f547dac16cef30b7c1317fd88a5c9179a by Thomas Friedrichsmeier.
Committed on 09/02/2016 at 13:52.
Pushed by tfry into branch 'work/preview_with_menu'.

Also add menu-button to code preview. In doing so, work around some issues of unlabeled menus, or menu ordering bugs.

M  +3    -1    rkward/misc/rkxmlguipreviewarea.cpp
M  +1    -3    rkward/plugin/rkpreviewbox.cpp
M  +3    -3    rkward/plugin/rkstandardcomponent.cpp
M  +2    -1    rkward/plugin/rkstandardcomponent.h
M  +9    -2    rkward/plugin/rkstandardcomponentgui.cpp
M  +2    -1    rkward/plugin/rkstandardcomponentgui.h
M  +2    -1    rkward/windows/rkcommandeditorwindowpart.rc
M  +6    -6    rkward/windows/rkstandardactions.rc

http://commits.kde.org/rkward/9ea2f10f547dac16cef30b7c1317fd88a5c9179a

diff --git a/rkward/misc/rkxmlguipreviewarea.cpp b/rkward/misc/rkxmlguipreviewarea.cpp
index d15741d..2deb55b 100644
--- a/rkward/misc/rkxmlguipreviewarea.cpp
+++ b/rkward/misc/rkxmlguipreviewarea.cpp
@@ -91,7 +91,9 @@ void RKXMLGUIPreviewArea::prepareMenu () {
 	QList<QAction*> entries = menuBar ()->actions ();
 	for (int i = 0; i < entries.size (); ++i) {
 		QMenu *smenu = entries[i]->menu ();
-		if (!smenu) continue;
+		if (!smenu) continue;    // Don't think it can happen...
+		if (entries[i]->objectName () == "settings") continue;  // Skip settings menu, entirely
+
 		QList<QAction*> subentries = smenu->actions ();
 		QList<QAction*> entries_to_add;
 		bool menu_empty = true;
diff --git a/rkward/plugin/rkpreviewbox.cpp b/rkward/plugin/rkpreviewbox.cpp
index b6c0c93..3b54d46 100644
--- a/rkward/plugin/rkpreviewbox.cpp
+++ b/rkward/plugin/rkpreviewbox.cpp
@@ -78,9 +78,7 @@ RKPreviewBox::RKPreviewBox (const QDomElement &element, RKComponent *parent_comp
 	if (placement == DockedPreview) {
 		RKStandardComponent *uicomp = topmostStandardComponent ();
 		if (uicomp) {
-			QWidget *container = new RKXMLGUIPreviewArea (0);
-			RKWorkplace::mainWorkplace ()->registerNamedWindow (idprop, this, container);
-			uicomp->addDockedPreview (container, state, toggle_preview_box->text ());
+			uicomp->addDockedPreview (state, toggle_preview_box->text (), idprop);
 
 			if (preview_mode == OutputPreview) {
 				RKGlobals::rInterface ()->issueCommand ("local ({\n"
diff --git a/rkward/plugin/rkstandardcomponent.cpp b/rkward/plugin/rkstandardcomponent.cpp
index 64343b2..7dd73be 100644
--- a/rkward/plugin/rkstandardcomponent.cpp
+++ b/rkward/plugin/rkstandardcomponent.cpp
@@ -362,12 +362,12 @@ void RKStandardComponent::buildAndInitialize (const QDomElement &doc_element, co
 	standardInitializationComplete ();
 }
 
-void RKStandardComponent::addDockedPreview (QWidget* area, RKComponentPropertyBool* controller, const QString& label) {
+RKXMLGUIPreviewArea* RKStandardComponent::addDockedPreview (RKComponentPropertyBool* controller, const QString& label, const QString &id) {
 	RK_TRACE (PLUGIN);
 
 	RK_ASSERT (gui);
-	if (!gui) return;
-	gui->addDockedPreview (area, controller, label);
+	if (!gui) return 0;
+	return gui->addDockedPreview (controller, label, id);
 }
 
 RKComponentBase::ComponentStatus RKStandardComponent::recursiveStatus () {
diff --git a/rkward/plugin/rkstandardcomponent.h b/rkward/plugin/rkstandardcomponent.h
index 372c23d..981a8cf 100644
--- a/rkward/plugin/rkstandardcomponent.h
+++ b/rkward/plugin/rkstandardcomponent.h
@@ -30,6 +30,7 @@ class RKComponentHandle;
 class RKStandardComponentStack;
 class ScriptBackend;
 class QTimer;
+class RKXMLGUIPreviewArea;
 
 /** The standard type of component (i.e. stand-alone), previously known as "plugin". This is the type of component described by an XML-file
 
@@ -83,7 +84,7 @@ public:
 /** Return the GUI-scripting handler (creating it, if needed) */
 	RKComponentScriptingProxy* scriptingProxy ();
 
-	void addDockedPreview (QWidget *area, RKComponentPropertyBool *controller, const QString& label);
+	RKXMLGUIPreviewArea *addDockedPreview (RKComponentPropertyBool *controller, const QString& label, const QString &id = QString ());
 signals:
 	void standardInitializationComplete ();
 public slots:
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 9f9f789..a32199d 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -155,10 +155,11 @@ RKStandardComponentGUI::RKStandardComponentGUI (RKStandardComponent *component,
 
 	if (!enslaved) {
 		// code display
+		RKXMLGUIPreviewArea *area = addDockedPreview (&code_display_visibility, i18n ("Code Preview"), QString (), true);
 		code_display = new RKCommandEditorWindow (0, true, false);
 		code_display->setReadOnly (true);
 		code_display_visibility.setBoolValue (!enslaved && RKSettingsModulePlugins::showCodeByDefault ());
-		addDockedPreview (code_display, &code_display_visibility, i18n ("Code Preview"), true);
+		code_display->setParent (area);  // hm, mysterious breakage when adding via constructor. Whatever...
 
 		KActionCollection *action_collection = new KActionCollection (this);
 		action_collection->addAction (KStandardAction::Copy, this, SLOT (copyCode()));
@@ -298,15 +299,21 @@ void RKStandardComponentGUI::finalize () {
 	}
 }
 
-void RKStandardComponentGUI::addDockedPreview (QWidget *area, RKComponentPropertyBool *controller, const QString& label, bool bottom) {
+RKXMLGUIPreviewArea* RKStandardComponentGUI::addDockedPreview (RKComponentPropertyBool *controller, const QString& label, const QString &id, bool bottom) {
 	RK_TRACE (PLUGIN);
 
+	RKXMLGUIPreviewArea *area = new RKXMLGUIPreviewArea (0);
 	PreviewArea parea;
 	parea.area = area;
 	parea.controller = controller;
 	parea.label = label;
 	parea.position = bottom ? Qt::Vertical : Qt::Horizontal;
 	previews.insert (0, parea);
+
+	if (!id.isEmpty ()) {
+		RKWorkplace::mainWorkplace ()->registerNamedWindow (id, this, area);
+	}
+	return area;
 };
 
 void RKStandardComponentGUI::showEvent (QShowEvent *e) {
diff --git a/rkward/plugin/rkstandardcomponentgui.h b/rkward/plugin/rkstandardcomponentgui.h
index 84ec453..de1546b 100644
--- a/rkward/plugin/rkstandardcomponentgui.h
+++ b/rkward/plugin/rkstandardcomponentgui.h
@@ -67,6 +67,7 @@ class QSplitter;
 class QCloseEvent;
 class QCheckBox;
 class RKExtensionSplitter;
+class RKXMLGUIPreviewArea;
 
 /** contains the standard GUI elements for a top-level RKStandardComponent. The base class creates a dialog interface. For a wizard interface use RKStandardComponentWizard. You *must* call createDialog () after construction, since I can't virualize this for reasons I don't understand!
 
@@ -84,7 +85,7 @@ public:
 	virtual void updateCode ();
 /** reimplemented from QWidget to take care of showing the code display if needed */
 	void showEvent (QShowEvent *e);
-	void addDockedPreview (QWidget *area, RKComponentPropertyBool *controller, const QString& label, bool bottom = false);
+	RKXMLGUIPreviewArea* addDockedPreview (RKComponentPropertyBool *controller, const QString& label, const QString &id=QString (), bool bottom = false);
 /** Do anything needed after the dialog is created and its contents have been built. Base class adds the preview regions to the splitter */
 	virtual void finalize ();
 public slots:
diff --git a/rkward/windows/rkcommandeditorwindowpart.rc b/rkward/windows/rkcommandeditorwindowpart.rc
index 1d7da83..48bef01 100644
--- a/rkward/windows/rkcommandeditorwindowpart.rc
+++ b/rkward/windows/rkcommandeditorwindowpart.rc
@@ -1,6 +1,7 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward_commandeditor" version="640">
+<kpartgui name="rkward_commandeditor" version="650">
 	<MenuBar>
+		<Menu name="file"><test>&File</text></Menu>  <!-- Define placeholder to work around menu ordering bug -->
 		<Menu name="edit"><text>&Edit</text>
 			<Menu name="tools" group="edit_first_merge"><text>&Tools Move</text>
 				<Merge/>
diff --git a/rkward/windows/rkstandardactions.rc b/rkward/windows/rkstandardactions.rc
index a7b1cac..dd85c54 100644
--- a/rkward/windows/rkstandardactions.rc
+++ b/rkward/windows/rkstandardactions.rc
@@ -1,26 +1,26 @@
 <!DOCTYPE kpartgui>
-<kpartgui name="rkward_standardactions" version="640">
+<kpartgui name="rkward_standardactions" version="650">
 <!-- What is this for, wouldn't it be easier to just inline these actions in the parts where they
      end up? Yes, but then they would be separate actions, internally, and each could be assigned
      a shortcut of its own. This is needed to tie them all together. -->
 	<MenuBar>
-		<Menu name="file">
+		<Menu name="file"><text>&File</text>
 			<Action name="copy_lines_to_output"/>
 		</Menu>
-		<Menu name="edit">
+		<Menu name="edit"><text>&Edit</text>
 			<Action name="paste_special" group="after_edit_paste_merge"/>
 		</Menu>
-		<Menu name="run">
+		<Menu name="run"><text>&Run</text>
 			<Action name="run_current" group="run_actions_merge"/>
 			<Action name="run_all" group="run_actions_merge"/>
 			<WeakSeparator group="postrun_actions_merge"/>
 			<Action name="interrupt" group="postrun_actions_merge"/>
 		</Menu>
-		<Menu name="help">
+		<Menu name="help"><text>&Help</text>
 			<Action name="function_reference" group="help_actions_merge"/>
 			<Action name="window_help" group="prehelp_actions_merge"/>
 		</Menu>
-		<Menu name="settings">
+		<Menu name="settings"><text>&Settings</text>
 			<Action name="window_configure"/>
 		</Menu>
 	</MenuBar>



More information about the rkward-tracker mailing list