[LyX/master] Add menu to statusbar zoom value
Juergen Spitzmueller
spitz at lyx.org
Thu Mar 11 17:09:49 UTC 2021
commit f525bded59668218e86dba93240796c49e488e4b
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Thu Mar 11 18:14:46 2021 +0100
Add menu to statusbar zoom value
---
src/frontends/qt/GuiView.cpp | 38 +++++++++++++++++++++++++++++++++++++-
src/frontends/qt/GuiView.h | 13 ++++++++++++-
2 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 48aa13f..ceb3651 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -672,8 +672,12 @@ GuiView::GuiView(int id)
connect(zoom_in_, SIGNAL(clicked()), this, SLOT(zoomInPressed()));
connect(zoom_out_, SIGNAL(clicked()), this, SLOT(zoomOutPressed()));
- zoom_value_ = new QLabel(statusBar());
+ zoom_value_ = new QToolButton(statusBar());
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
+ zoom_value_->setToolButtonStyle(Qt::ToolButtonTextOnly);
+ zoom_value_->setAutoRaise(true);
+ zoom_value_->setPopupMode(QToolButton::InstantPopup);
+ zoom_value_->setFixedHeight(fm.height());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_value_->setMinimumWidth(fm.horizontalAdvance("000%"));
#else
@@ -682,6 +686,21 @@ GuiView::GuiView(int id)
statusBar()->addPermanentWidget(zoom_value_);
zoom_value_->setEnabled(currentBufferView());
+ act_zoom_default_ = new QAction(toqstr(bformat(_("&Reset to default (%1$d%)"),
+ lyxrc.defaultZoom)), this);
+ act_zoom_in_ = new QAction(qt_("Zoom &in"), this);
+ act_zoom_out_ = new QAction(qt_("Zoom &out"), this);
+ zoom_value_->addAction(act_zoom_default_);
+ zoom_value_->addAction(act_zoom_in_);
+ zoom_value_->addAction(act_zoom_out_);
+ enableZoomOptions();
+ connect(act_zoom_default_, SIGNAL(triggered()),
+ this, SLOT(resetDefaultZoom()));
+ connect(act_zoom_in_, SIGNAL(triggered()),
+ this, SLOT(zoomInPressed()));
+ connect(act_zoom_out_, SIGNAL(triggered()),
+ this, SLOT(zoomOutPressed()));
+
int const iconheight = max(int(d.normalIconSize), fm.height());
QSize const iconsize(iconheight, iconheight);
@@ -779,6 +798,15 @@ void GuiView::checkCancelBackground()
}
+void GuiView::enableZoomOptions()
+{
+ act_zoom_default_->setEnabled(zoom_slider_->value() != lyxrc.defaultZoom);
+ FuncStatus status;
+ act_zoom_in_->setEnabled(getStatus(FuncRequest(LFUN_BUFFER_ZOOM_IN), status));
+ act_zoom_out_->setEnabled(getStatus(FuncRequest(LFUN_BUFFER_ZOOM_OUT), status));
+}
+
+
void GuiView::zoomSliderMoved(int value)
{
DispatchResult dr;
@@ -792,6 +820,7 @@ void GuiView::zoomValueChanged(int value)
{
if (value != lyxrc.currentZoom)
zoomSliderMoved(value);
+ enableZoomOptions();
}
@@ -811,6 +840,13 @@ void GuiView::zoomOutPressed()
}
+void GuiView::resetDefaultZoom()
+{
+ zoomValueChanged(lyxrc.defaultZoom);
+ enableZoomOptions();
+}
+
+
QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
{
QVector<GuiWorkArea*> areas;
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 728ed0d..015f885 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -29,6 +29,7 @@ class QPushButton;
class QLabel;
class QShowEvent;
class QSlider;
+class QToolButton;
namespace lyx {
@@ -253,6 +254,8 @@ private Q_SLOTS:
///
void zoomOutPressed();
///
+ void resetDefaultZoom();
+ ///
void on_currentWorkAreaChanged(GuiWorkArea *);
///
void onBufferViewChanged();
@@ -476,6 +479,8 @@ private:
void dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr);
///
void showMessage();
+ ///
+ void enableZoomOptions();
/// This view ID.
int id_;
@@ -500,13 +505,19 @@ private:
/// Statusbar widget that shows version control status
QLabel * version_control_;
/// Statusbar widget that shows zoom value
- QLabel * zoom_value_;
+ QToolButton * zoom_value_;
/// The zoom slider widget
QSlider * zoom_slider_;
/// Zoom in ("+") Button
QPushButton * zoom_in_;
/// Zoom out ("-") Button
QPushButton * zoom_out_;
+ /// Set zoom to default
+ QAction * act_zoom_default_;
+ /// Zoom in menu action
+ QAction * act_zoom_in_;
+ /// Zoom out menu action
+ QAction * act_zoom_out_;
/// The rate from which the actual zoom value is calculated
/// from the default zoom pref
More information about the lyx-cvs
mailing list