mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Add menu to statusbar zoom value
This commit is contained in:
parent
7a000652c0
commit
f525bded59
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user