mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Disable zoom slider when there is no buffer open (#12185)
This commit is contained in:
parent
0a3f856bc1
commit
cf75003119
@ -629,14 +629,14 @@ GuiView::GuiView(int id)
|
|||||||
|
|
||||||
QFontMetrics const fm(statusBar()->fontMetrics());
|
QFontMetrics const fm(statusBar()->fontMetrics());
|
||||||
|
|
||||||
QSlider * zoomslider = new QSlider(Qt::Horizontal, statusBar());
|
zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
zoomslider->setFixedWidth(fm.horizontalAdvance('x') * 15);
|
zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
|
||||||
#else
|
#else
|
||||||
zoomslider->setFixedWidth(fm.width('x') * 15);
|
zoom_slider_->setFixedWidth(fm.width('x') * 15);
|
||||||
#endif
|
#endif
|
||||||
// Make the defaultZoom center
|
// Make the defaultZoom center
|
||||||
zoomslider->setRange(10, (lyxrc.defaultZoom * 2) - 10);
|
zoom_slider_->setRange(10, (lyxrc.defaultZoom * 2) - 10);
|
||||||
// Initialize proper zoom value
|
// Initialize proper zoom value
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble();
|
zoom_ratio_ = settings.value("zoom_ratio", 1.0).toDouble();
|
||||||
@ -644,19 +644,21 @@ GuiView::GuiView(int id)
|
|||||||
int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_);
|
int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_);
|
||||||
if (zoom < static_cast<int>(zoom_min_))
|
if (zoom < static_cast<int>(zoom_min_))
|
||||||
zoom = zoom_min_;
|
zoom = zoom_min_;
|
||||||
zoomslider->setValue(zoom);
|
zoom_slider_->setValue(zoom);
|
||||||
zoomslider->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust."));
|
zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust."));
|
||||||
zoomslider->setTickPosition(QSlider::TicksBelow);
|
zoom_slider_->setTickPosition(QSlider::TicksBelow);
|
||||||
zoomslider->setTickInterval(lyxrc.defaultZoom - 10);
|
zoom_slider_->setTickInterval(lyxrc.defaultZoom - 10);
|
||||||
statusBar()->addPermanentWidget(zoomslider);
|
statusBar()->addPermanentWidget(zoom_slider_);
|
||||||
|
zoom_slider_->setEnabled(currentBufferView());
|
||||||
|
|
||||||
connect(zoomslider, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
|
connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
|
||||||
connect(zoomslider, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int)));
|
connect(zoom_slider_, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int)));
|
||||||
connect(this, SIGNAL(currentZoomChanged(int)), zoomslider, SLOT(setValue(int)));
|
connect(this, SIGNAL(currentZoomChanged(int)), zoom_slider_, SLOT(setValue(int)));
|
||||||
|
|
||||||
zoom_value_ = new QLabel(statusBar());
|
zoom_value_ = new QLabel(statusBar());
|
||||||
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
|
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
|
||||||
statusBar()->addPermanentWidget(zoom_value_);
|
statusBar()->addPermanentWidget(zoom_value_);
|
||||||
|
zoom_value_->setEnabled(currentBufferView());
|
||||||
|
|
||||||
int const iconheight = max(int(d.normalIconSize), fm.height());
|
int const iconheight = max(int(d.normalIconSize), fm.height());
|
||||||
QSize const iconsize(iconheight, iconheight);
|
QSize const iconsize(iconheight, iconheight);
|
||||||
@ -1358,6 +1360,8 @@ void GuiView::onBufferViewChanged()
|
|||||||
// Buffer-dependent dialogs must be updated. This is done here because
|
// Buffer-dependent dialogs must be updated. This is done here because
|
||||||
// some dialogs require buffer()->text.
|
// some dialogs require buffer()->text.
|
||||||
updateDialogs();
|
updateDialogs();
|
||||||
|
zoom_slider_->setEnabled(currentBufferView());
|
||||||
|
zoom_value_->setEnabled(currentBufferView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class QDragEnterEvent;
|
|||||||
class QDropEvent;
|
class QDropEvent;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
class QSlider;
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -495,6 +496,8 @@ private:
|
|||||||
QLabel * version_control_;
|
QLabel * version_control_;
|
||||||
/// Statusbar widget that shows zoom value
|
/// Statusbar widget that shows zoom value
|
||||||
QLabel * zoom_value_;
|
QLabel * zoom_value_;
|
||||||
|
/// The zoom slider widget
|
||||||
|
QSlider * zoom_slider_;
|
||||||
|
|
||||||
/// The rate from which the actual zoom value is calculated
|
/// The rate from which the actual zoom value is calculated
|
||||||
/// from the default zoom pref
|
/// from the default zoom pref
|
||||||
|
Loading…
Reference in New Issue
Block a user