[rkward/work/preview_with_menu] rkward/windows: Trim down menu shown for plot previews

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Feb 3 19:44:10 UTC 2016


Git commit 559bea8a70b7040a8f7be695c6cbd555321fcb39 by Thomas Friedrichsmeier.
Committed on 03/02/2016 at 19:44.
Pushed by tfry into branch 'work/preview_with_menu'.

Trim down menu shown for plot previews

M  +25   -0    rkward/windows/rkwindowcatcher.cpp
M  +2    -0    rkward/windows/rkwindowcatcher.h

http://commits.kde.org/rkward/559bea8a70b7040a8f7be695c6cbd555321fcb39

diff --git a/rkward/windows/rkwindowcatcher.cpp b/rkward/windows/rkwindowcatcher.cpp
index dfbb613..86820f5 100644
--- a/rkward/windows/rkwindowcatcher.cpp
+++ b/rkward/windows/rkwindowcatcher.cpp
@@ -271,6 +271,16 @@ RKCaughtX11Window::~RKCaughtX11Window () {
 	error_dialog->autoDeleteWhenDone ();
 }
 
+void RKCaughtX11Window::setWindowStyleHint (const QString& hint) {
+	RK_TRACE (MISC);
+
+	if (hint == "preview") {
+		for (int i = actions_not_for_preview.count () - 1; i >= 0; --i) {
+			actions_not_for_preview[i]->setVisible (false);
+		}
+	}
+}
+
 void RKCaughtX11Window::forceClose () {
 	killed_in_r = true;
 	if (capture) {
@@ -602,44 +612,56 @@ RKCaughtX11WindowPart::RKCaughtX11WindowPart (RKCaughtX11Window *window) : KPart
 	window->dynamic_size_action = new KToggleAction (i18n ("Draw area follows size of window"), window);
 	connect (window->dynamic_size_action, SIGNAL (triggered()), window, SLOT (fixedSizeToggled()));
 	actionCollection ()->addAction ("toggle_fixed_size", window->dynamic_size_action);
+	window->actions_not_for_preview.append (window->dynamic_size_action);
 
 	QAction *action;
 	action = actionCollection ()->addAction ("set_fixed_size_1", window, SLOT (setFixedSize1()));
 	action->setText (i18n ("Set fixed size 500x500"));
+	window->actions_not_for_preview.append (action);
 	action = actionCollection ()->addAction ("set_fixed_size_2", window, SLOT (setFixedSize2()));
 	action->setText (i18n ("Set fixed size 1000x1000"));
+	window->actions_not_for_preview.append (action);
 	action = actionCollection ()->addAction ("set_fixed_size_3", window, SLOT (setFixedSize3()));
 	action->setText (i18n ("Set fixed size 2000x2000"));
+	window->actions_not_for_preview.append (action);
 	action = actionCollection ()->addAction ("set_fixed_size_manual", window, SLOT (setFixedSizeManual()));
 	action->setText (i18n ("Set specified fixed size..."));
+	window->actions_not_for_preview.append (action);
 
 	action = actionCollection ()->addAction ("plot_prev", window, SLOT (previousPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("Previous plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveLeft));
 	window->plot_prev_action = (KAction*) action;
 	action = actionCollection ()->addAction ("plot_first", window, SLOT (firstPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("First plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveFirst));
 	window->plot_first_action = (KAction*) action;
 	action = actionCollection ()->addAction ("plot_next", window, SLOT (nextPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("Next plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveRight));
 	window->plot_next_action = (KAction*) action;
 	action = actionCollection ()->addAction ("plot_last", window, SLOT (lastPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("Last plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionMoveLast));
 	window->plot_last_action = (KAction*) action;
 	action = window->plot_list_action = new KSelectAction (i18n ("Go to plot"), 0);
+	window->actions_not_for_preview.append (action);
 	window->plot_list_action->setToolBarMode (KSelectAction::MenuMode);
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionListPlots));
 	actionCollection ()->addAction ("plot_list", action);
 	connect (action, SIGNAL (triggered(int)), window, SLOT (gotoPlot(int)));
 
 	action = actionCollection ()->addAction ("plot_force_append", window, SLOT (forceAppendCurrentPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("Append this plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionSnapshot));
 	window->plot_force_append_action = (KAction*) action;
 	action = actionCollection ()->addAction ("plot_remove", window, SLOT (removeCurrentPlot()));
+	window->actions_not_for_preview.append (action);
  	action->setText (i18n ("Remove this plot"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionRemovePlot));
 	window->plot_remove_action = (KAction*) action;
@@ -648,15 +670,18 @@ RKCaughtX11WindowPart::RKCaughtX11WindowPart (RKCaughtX11Window *window) : KPart
 	window->plot_clear_history_action = (KAction*) action;
  	action->setText (i18n ("Clear history"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionClear));
+	window->actions_not_for_preview.append (action);
 
 	action = actionCollection ()->addAction ("plot_properties", window, SLOT (showPlotInfo()));
 	window->plot_properties_action = (KAction*) action;
 	action->setText (i18n ("Plot properties"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionDocumentInfo));
+	window->actions_not_for_preview.append (action);
 
 	action = actionCollection ()->addAction ("device_activate", window, SLOT (activateDevice()));
 	action->setText (i18n ("Make active"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionFlagGreen));
+	window->actions_not_for_preview.append (action);
 	action = actionCollection ()->addAction ("device_copy_to_output", window, SLOT (copyDeviceToOutput()));
 	action->setText (i18n ("Copy to output"));
 	action->setIcon (RKStandardIcons::getIcon (RKStandardIcons::WindowOutput));
diff --git a/rkward/windows/rkwindowcatcher.h b/rkward/windows/rkwindowcatcher.h
index 632148d..6db344e 100644
--- a/rkward/windows/rkwindowcatcher.h
+++ b/rkward/windows/rkwindowcatcher.h
@@ -152,6 +152,7 @@ public slots:
 /** reimplemented to keep window alive while saving history */
 	bool close (bool also_delete);
 	void setKilledInR () { killed_in_r = true; };
+	void setWindowStyleHint (const QString& hint); // KF5 TODO: add override keyword
 private slots:
 	void doEmbed ();
 private:
@@ -192,6 +193,7 @@ private:
 	KSelectAction *plot_list_action;
 	KAction *stop_interaction;
 
+	QList<QAction*> actions_not_for_preview;
 	int history_length;
 	int history_position;
 };



More information about the rkward-tracker mailing list