mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Zoom slider
This commit is contained in:
parent
2cf86771ed
commit
bdb006543b
@ -318,6 +318,7 @@ public:
|
||||
int defaultZoom = 150;
|
||||
/// Actual zoom factor for screen fonts
|
||||
/// (default zoom plus buffer zoom factor)
|
||||
/// Do not set directly. Use GuiView::setCurrentZoom()
|
||||
int currentZoom = 150;
|
||||
/// Screen font sizes in points for each font size
|
||||
std::string font_sizes[10] = { "5.0", "7.0", "8.0", "9.0", "10.0",
|
||||
|
@ -102,6 +102,7 @@
|
||||
#include <QPoint>
|
||||
#include <QSettings>
|
||||
#include <QShowEvent>
|
||||
#include <QSlider>
|
||||
#include <QSplitter>
|
||||
#include <QStackedWidget>
|
||||
#include <QStatusBar>
|
||||
@ -627,6 +628,18 @@ GuiView::GuiView(int id)
|
||||
connect(busylabel, SIGNAL(clicked()), this, SLOT(checkCancelBackground()));
|
||||
|
||||
QFontMetrics const fm(statusBar()->fontMetrics());
|
||||
|
||||
QSlider * zoomslider = new QSlider(Qt::Horizontal, statusBar());
|
||||
zoomslider->setFixedWidth(fm.horizontalAdvance('x') * 15);
|
||||
// Make the defaultZoom center
|
||||
zoomslider->setRange(10, (lyxrc.defaultZoom * 2) - 10);
|
||||
zoomslider->setValue(lyxrc.currentZoom);
|
||||
zoomslider->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/- or Shift-Mousewheel to adjust."));
|
||||
statusBar()->addPermanentWidget(zoomslider);
|
||||
|
||||
connect(zoomslider, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
|
||||
connect(this, SIGNAL(currentZoomChanged(int)), zoomslider, SLOT(setValue(int)));
|
||||
|
||||
int const iconheight = max(int(d.normalIconSize), fm.height());
|
||||
QSize const iconsize(iconheight, iconheight);
|
||||
|
||||
@ -727,6 +740,16 @@ void GuiView::checkCancelBackground()
|
||||
}
|
||||
|
||||
|
||||
void GuiView::zoomSliderMoved(int value)
|
||||
{
|
||||
DispatchResult dr;
|
||||
dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(value)), dr);
|
||||
currentWorkArea()->scheduleRedraw(true);
|
||||
message(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
|
||||
value, lyxrc.defaultZoom));
|
||||
}
|
||||
|
||||
|
||||
QVector<GuiWorkArea*> GuiView::GuiViewPrivate::guiWorkAreas()
|
||||
{
|
||||
QVector<GuiWorkArea*> areas;
|
||||
@ -845,6 +868,13 @@ void GuiView::saveUISettings() const
|
||||
}
|
||||
|
||||
|
||||
void GuiView::setCurrentZoom(const int v)
|
||||
{
|
||||
lyxrc.currentZoom = v;
|
||||
Q_EMIT currentZoomChanged(v);
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::restoreLayout()
|
||||
{
|
||||
QSettings settings;
|
||||
@ -853,7 +883,7 @@ bool GuiView::restoreLayout()
|
||||
int zoom = (int)(lyxrc.defaultZoom * zoom_ratio_);
|
||||
if (zoom < static_cast<int>(zoom_min_))
|
||||
zoom = zoom_min_;
|
||||
lyxrc.currentZoom = zoom;
|
||||
setCurrentZoom(zoom);
|
||||
devel_mode_ = settings.value("devel_mode", devel_mode_).toBool();
|
||||
settings.beginGroup("views");
|
||||
settings.beginGroup(QString::number(id_));
|
||||
@ -4565,7 +4595,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
if (zoom < static_cast<int>(zoom_min_))
|
||||
zoom = zoom_min_;
|
||||
|
||||
lyxrc.currentZoom = zoom;
|
||||
setCurrentZoom(zoom);
|
||||
|
||||
dr.setMessage(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
|
||||
lyxrc.currentZoom, lyxrc.defaultZoom));
|
||||
|
@ -220,6 +220,8 @@ Q_SIGNALS:
|
||||
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
|
||||
// emitted when the work area or its buffer view changed
|
||||
void bufferViewChanged();
|
||||
/// emitted when zoom is modified
|
||||
void currentZoomChanged(int);
|
||||
|
||||
public Q_SLOTS:
|
||||
///
|
||||
@ -241,6 +243,8 @@ private Q_SLOTS:
|
||||
///
|
||||
void checkCancelBackground();
|
||||
///
|
||||
void zoomSliderMoved(int);
|
||||
///
|
||||
void on_currentWorkAreaChanged(GuiWorkArea *);
|
||||
///
|
||||
void onBufferViewChanged();
|
||||
@ -354,6 +358,8 @@ public:
|
||||
void disconnectDialog(std::string const & name);
|
||||
///
|
||||
bool develMode() const { return devel_mode_; }
|
||||
///
|
||||
void setCurrentZoom(int const v);
|
||||
|
||||
private:
|
||||
/// Saves the layout and geometry of the window
|
||||
|
Loading…
Reference in New Issue
Block a user