From ebb7ee7d5f8a5aea29142ffc794617e34ee13fb8 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 9 Mar 2021 08:42:27 +0100 Subject: [PATCH] Add +/- buttons to zoom slider --- src/frontends/qt/GuiView.cpp | 35 +++++++++++++++++++++++++++++++++++ src/frontends/qt/GuiView.h | 9 +++++++++ 2 files changed, 44 insertions(+) diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index fb9681b204..1db9bbba49 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -650,12 +650,29 @@ GuiView::GuiView(int id) zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust.")); zoom_slider_->setTickPosition(QSlider::TicksBelow); zoom_slider_->setTickInterval(lyxrc.defaultZoom - 10); + + // Buttons to change zoom stepwise + zoom_in_ = new QPushButton(statusBar()); + zoom_in_->setText("+"); + zoom_in_->setFlat(true); + zoom_in_->setFixedSize(QSize(fm.height(), fm.height())); + zoom_out_ = new QPushButton(statusBar()); + zoom_out_->setText("-"); + zoom_out_->setFixedSize(QSize(fm.height(), fm.height())); + zoom_out_->setFlat(true); + + statusBar()->addPermanentWidget(zoom_out_); + zoom_out_->setEnabled(currentBufferView()); statusBar()->addPermanentWidget(zoom_slider_); zoom_slider_->setEnabled(currentBufferView()); + zoom_out_->setEnabled(currentBufferView()); + statusBar()->addPermanentWidget(zoom_in_); connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int))); connect(zoom_slider_, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int))); connect(this, SIGNAL(currentZoomChanged(int)), zoom_slider_, SLOT(setValue(int))); + connect(zoom_in_, SIGNAL(clicked()), this, SLOT(zoomInPressed())); + connect(zoom_out_, SIGNAL(clicked()), this, SLOT(zoomOutPressed())); zoom_value_ = new QLabel(statusBar()); zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom))); @@ -782,6 +799,22 @@ void GuiView::zoomValueChanged(int value) } +void GuiView::zoomInPressed() +{ + DispatchResult dr; + dispatch(FuncRequest(LFUN_BUFFER_ZOOM_IN), dr); + currentWorkArea()->scheduleRedraw(true); +} + + +void GuiView::zoomOutPressed() +{ + DispatchResult dr; + dispatch(FuncRequest(LFUN_BUFFER_ZOOM_OUT), dr); + currentWorkArea()->scheduleRedraw(true); +} + + QVector GuiView::GuiViewPrivate::guiWorkAreas() { QVector areas; @@ -1369,6 +1402,8 @@ void GuiView::onBufferViewChanged() updateDialogs(); zoom_slider_->setEnabled(currentBufferView()); zoom_value_->setEnabled(currentBufferView()); + zoom_in_->setEnabled(currentBufferView()); + zoom_out_->setEnabled(currentBufferView()); } diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h index 7c876f4af6..728ed0d0d5 100644 --- a/src/frontends/qt/GuiView.h +++ b/src/frontends/qt/GuiView.h @@ -25,6 +25,7 @@ class QCloseEvent; class QDragEnterEvent; class QDropEvent; +class QPushButton; class QLabel; class QShowEvent; class QSlider; @@ -248,6 +249,10 @@ private Q_SLOTS: /// void zoomValueChanged(int); /// + void zoomInPressed(); + /// + void zoomOutPressed(); + /// void on_currentWorkAreaChanged(GuiWorkArea *); /// void onBufferViewChanged(); @@ -498,6 +503,10 @@ private: QLabel * zoom_value_; /// The zoom slider widget QSlider * zoom_slider_; + /// Zoom in ("+") Button + QPushButton * zoom_in_; + /// Zoom out ("-") Button + QPushButton * zoom_out_; /// The rate from which the actual zoom value is calculated /// from the default zoom pref