Add +/- buttons to zoom slider

This commit is contained in:
Juergen Spitzmueller 2021-03-09 08:42:27 +01:00
parent 3c43a01ba2
commit ebb7ee7d5f
2 changed files with 44 additions and 0 deletions

View File

@ -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<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
{
QVector<GuiWorkArea*> 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());
}

View File

@ -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