[LyX/master] Add option to toggle zoom slider to zoom statusbar menu

Juergen Spitzmueller spitz at lyx.org
Thu Mar 11 17:36:23 UTC 2021


commit 8a605ca8ad82aab306e5ea94c290b92f13544c6f
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Thu Mar 11 18:41:02 2021 +0100

    Add option to toggle zoom slider to zoom statusbar menu
---
 src/frontends/qt/GuiView.cpp |   26 +++++++++++++++++++++-----
 src/frontends/qt/GuiView.h   |    4 ++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 23252c0..4c62484 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -690,9 +690,12 @@ GuiView::GuiView(int id)
 						       lyxrc.defaultZoom)), this);
 	act_zoom_in_ = new QAction(qt_("Zoom &in"), this);
 	act_zoom_out_ = new QAction(qt_("Zoom &out"), this);
+	act_zoom_show_ = new QAction(qt_("Show zoom slider"));
+	act_zoom_show_->setCheckable(true);
 	zoom_value_->addAction(act_zoom_default_);
 	zoom_value_->addAction(act_zoom_in_);
 	zoom_value_->addAction(act_zoom_out_);
+	zoom_value_->addAction(act_zoom_show_);
 	enableZoomOptions();
 	connect(act_zoom_default_, SIGNAL(triggered()),
 			this, SLOT(resetDefaultZoom()));
@@ -700,6 +703,8 @@ GuiView::GuiView(int id)
 			this, SLOT(zoomInPressed()));
 	connect(act_zoom_out_, SIGNAL(triggered()),
 			this, SLOT(zoomOutPressed()));
+	connect(act_zoom_show_, SIGNAL(triggered()),
+			this, SLOT(toogleZoomSlider()));
 
 	int const iconheight = max(int(d.normalIconSize), fm.height());
 	QSize const iconsize(iconheight, iconheight);
@@ -840,6 +845,13 @@ void GuiView::zoomOutPressed()
 }
 
 
+void GuiView::toogleZoomSlider()
+{
+	DispatchResult dr;
+	dispatch(FuncRequest(LFUN_UI_TOGGLE, "zoomslider"), dr);
+}
+
+
 void GuiView::resetDefaultZoom()
 {
 	zoomValueChanged(lyxrc.defaultZoom);
@@ -993,8 +1005,11 @@ bool GuiView::restoreLayout()
 	//code below is skipped when when ~/.config/LyX is (re)created
 	setIconSize(d.iconSize(settings.value(icon_key).toString()));
 
-	zoom_slider_->setVisible(settings.value("zoom_slider_visible", true).toBool());
-	zoom_value_->setVisible(settings.value("zoom_slider_visible", true).toBool());
+	bool const show_zoom_slider = settings.value("zoom_slider_visible", true).toBool();
+	zoom_slider_->setVisible(show_zoom_slider);
+	act_zoom_show_->setChecked(show_zoom_slider);
+	zoom_in_->setVisible(show_zoom_slider);
+	zoom_out_->setVisible(show_zoom_slider);
 
 	if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
 		QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
@@ -4852,9 +4867,10 @@ bool GuiView::lfunUiToggle(string const & ui_component)
 		menuBar()->setVisible(!menuBar()->isVisible());
 	} else if (ui_component == "zoomslider") {
 		zoom_slider_->setVisible(!zoom_slider_->isVisible());
-		zoom_value_->setVisible(!zoom_value_->isVisible());
-	} else
-	if (ui_component == "frame") {
+		zoom_in_->setVisible(zoom_slider_->isVisible());
+		zoom_out_->setVisible(zoom_slider_->isVisible());
+		act_zoom_show_->setChecked(zoom_slider_->isVisible());
+	} else if (ui_component == "frame") {
 		int const l = contentsMargins().left();
 
 		//are the frames in default state?
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 015f885..849718d 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -256,6 +256,8 @@ private Q_SLOTS:
 	///
 	void resetDefaultZoom();
 	///
+	void toogleZoomSlider();
+	///
 	void on_currentWorkAreaChanged(GuiWorkArea *);
 	///
 	void onBufferViewChanged();
@@ -518,6 +520,8 @@ private:
 	QAction * act_zoom_in_;
 	/// Zoom out menu action
 	QAction * act_zoom_out_;
+	/// Show zoom slider
+	QAction * act_zoom_show_;
 
 	/// The rate from which the actual zoom value is calculated
 	/// from the default zoom pref


More information about the lyx-cvs mailing list