X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt%2FGuiView.cpp;h=3fafd20e87980eb2242ffc8f5e2023f2b3e7feea;hb=f2e33b8c3e63fba3188c913ccf915011d1f205d2;hp=f8929a227ac048a26c12c9c0eb3c833a140f9711;hpb=be6dc7dd5dc10f79efaaaa2525b2ba77d0b02c46;p=features.git diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index f8929a227a..3fafd20e87 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -629,14 +629,16 @@ GuiView::GuiView(int id) QFontMetrics const fm(statusBar()->fontMetrics()); - QSlider * zoomslider = new QSlider(Qt::Horizontal, statusBar()); + zoom_slider_ = new QSlider(Qt::Horizontal, statusBar()); + // Small size slider for macOS to prevent the status bar from enlarging + zoom_slider_->setAttribute(Qt::WA_MacSmallSize); #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) - zoomslider->setFixedWidth(fm.horizontalAdvance('x') * 15); + zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15); #else - zoomslider->setFixedWidth(fm.width('x') * 15); + zoom_slider_->setFixedWidth(fm.width('x') * 15); #endif // Make the defaultZoom center - zoomslider->setRange(10, (lyxrc.defaultZoom * 2) - 10); + zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10); // Initialize proper zoom value QSettings settings; zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble(); @@ -644,19 +646,43 @@ GuiView::GuiView(int id) int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_); if (zoom < static_cast(zoom_min_)) zoom = zoom_min_; - zoomslider->setValue(zoom); - zoomslider->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust.")); - zoomslider->setTickPosition(QSlider::TicksBelow); - zoomslider->setTickInterval(lyxrc.defaultZoom - 10); - statusBar()->addPermanentWidget(zoomslider); - - connect(zoomslider, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int))); - connect(zoomslider, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int))); - connect(this, SIGNAL(currentZoomChanged(int)), zoomslider, SLOT(setValue(int))); + zoom_slider_->setValue(zoom); + 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(QString(0x2212)); + 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))); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + zoom_value_->setMinimumWidth(fm.horizontalAdvance("000%")); +#else + zoom_value_->setMinimumWidth(fm.width("000%")); +#endif statusBar()->addPermanentWidget(zoom_value_); + zoom_value_->setEnabled(currentBufferView()); int const iconheight = max(int(d.normalIconSize), fm.height()); QSize const iconsize(iconheight, iconheight); @@ -773,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; @@ -894,6 +936,7 @@ void GuiView::saveUISettings() const void GuiView::setCurrentZoom(const int v) { lyxrc.currentZoom = v; + zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), v))); Q_EMIT currentZoomChanged(v); } @@ -1357,6 +1400,10 @@ void GuiView::onBufferViewChanged() // Buffer-dependent dialogs must be updated. This is done here because // some dialogs require buffer()->text. updateDialogs(); + zoom_slider_->setEnabled(currentBufferView()); + zoom_value_->setEnabled(currentBufferView()); + zoom_in_->setEnabled(currentBufferView()); + zoom_out_->setEnabled(currentBufferView()); }