mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 02:54:46 -04:00
Save magnifying glass size and zoom level
This commit is contained in:
@ -27,8 +27,8 @@ void Configuration::load(QSettings *settings)
|
||||
settings->setValue(GO_TO_FLOW_SIZE, QSize(126, 200));
|
||||
if (!settings->contains(MAG_GLASS_SIZE))
|
||||
settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
|
||||
if (!settings->contains(ZOOM_LEVEL))
|
||||
settings->setValue(MAG_GLASS_SIZE, QSize(350, 175));
|
||||
if (!settings->contains(MAG_GLASS_ZOOM))
|
||||
settings->setValue(MAG_GLASS_ZOOM, 0.5);
|
||||
if (!settings->contains(FLOW_TYPE))
|
||||
settings->setValue(FLOW_TYPE, 0);
|
||||
if (!settings->contains(FULLSCREEN))
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
void setDefaultPath(QString defaultPath) { settings->setValue(PATH, defaultPath); }
|
||||
QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize(); }
|
||||
void setMagnifyingGlassSize(const QSize &mgs) { settings->setValue(MAG_GLASS_SIZE, mgs); }
|
||||
float getMagnifyingGlassZoom() { return settings->value(MAG_GLASS_ZOOM, 0.5).toFloat(); }
|
||||
void setMagnifyingGlassZoom(float mgz) { settings->setValue(MAG_GLASS_ZOOM, mgz); }
|
||||
QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize(); }
|
||||
void setGotoSlideSize(const QSize &gss) { settings->setValue(GO_TO_FLOW_SIZE, gss); }
|
||||
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat(); }
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget *parent)
|
||||
: QLabel(parent), zoomLevel(0.5)
|
||||
MagnifyingGlass::MagnifyingGlass(int w, int h, float zoomLevel, QWidget *parent)
|
||||
: QLabel(parent), zoomLevel(zoomLevel)
|
||||
{
|
||||
setup(QSize(w, h));
|
||||
}
|
||||
|
||||
MagnifyingGlass::MagnifyingGlass(const QSize &size, QWidget *parent)
|
||||
: QLabel(parent), zoomLevel(0.5)
|
||||
MagnifyingGlass::MagnifyingGlass(const QSize &size, float zoomLevel, QWidget *parent)
|
||||
: QLabel(parent), zoomLevel(zoomLevel)
|
||||
{
|
||||
setup(size);
|
||||
}
|
||||
@ -178,6 +178,7 @@ void MagnifyingGlass::zoomIn()
|
||||
{
|
||||
if (zoomLevel > 0.2f) {
|
||||
zoomLevel -= 0.025f;
|
||||
emit zoomChanged(zoomLevel);
|
||||
updateImage();
|
||||
}
|
||||
}
|
||||
@ -186,6 +187,7 @@ void MagnifyingGlass::zoomOut()
|
||||
{
|
||||
if (zoomLevel < 0.9f) {
|
||||
zoomLevel += 0.025f;
|
||||
emit zoomChanged(zoomLevel);
|
||||
updateImage();
|
||||
}
|
||||
}
|
||||
@ -234,9 +236,17 @@ void MagnifyingGlass::widthDown()
|
||||
resizeAndUpdate(w, height());
|
||||
}
|
||||
|
||||
void MagnifyingGlass::reset()
|
||||
{
|
||||
zoomLevel = 0.5f;
|
||||
emit zoomChanged(zoomLevel);
|
||||
resizeAndUpdate(350, 175);
|
||||
}
|
||||
|
||||
void MagnifyingGlass::resizeAndUpdate(int w, int h)
|
||||
{
|
||||
resize(w, h);
|
||||
emit sizeChanged(size());
|
||||
updateImage();
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,8 @@ private:
|
||||
bool shrinkHeight(int &h) const;
|
||||
|
||||
public:
|
||||
MagnifyingGlass(int width, int height, QWidget *parent);
|
||||
MagnifyingGlass(const QSize &size, QWidget *parent);
|
||||
MagnifyingGlass(int width, int height, float zoomLevel, QWidget *parent);
|
||||
MagnifyingGlass(const QSize &size, float zoomLevel, QWidget *parent);
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
public slots:
|
||||
void updateImage(int x, int y);
|
||||
@ -38,6 +38,11 @@ public slots:
|
||||
void heightDown();
|
||||
void widthUp();
|
||||
void widthDown();
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void sizeChanged(QSize newSize);
|
||||
void zoomChanged(float newZoomLevel);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1187,8 +1187,12 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
auto *const zoomOutMglassAction = addActionWithShortcut(tr("Zoom out magnifying glass"), ZOOM_OUT_MGLASS_ACTION_Y);
|
||||
connect(zoomOutMglassAction, &QAction::triggered, viewer, &Viewer::magnifyingGlassZoomOut);
|
||||
|
||||
auto *const resetMglassAction = addActionWithShortcut(tr("Reset magnifying glass"), RESET_MGLASS_ACTION_Y);
|
||||
connect(resetMglassAction, &QAction::triggered, viewer, &Viewer::resetMagnifyingGlass);
|
||||
|
||||
mglassActions = { sizeUpMglassAction, sizeDownMglassAction,
|
||||
zoomInMglassAction, zoomOutMglassAction };
|
||||
zoomInMglassAction, zoomOutMglassAction,
|
||||
resetMglassAction };
|
||||
|
||||
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), QIcon(":/images/shortcuts_group_mglass.svg"),
|
||||
tmpList = QList<QAction *>()
|
||||
|
@ -61,7 +61,18 @@ Viewer::Viewer(QWidget *parent)
|
||||
palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor());
|
||||
setPalette(palette);
|
||||
//---------------------------------------
|
||||
mglass = new MagnifyingGlass(Configuration::getConfiguration().getMagnifyingGlassSize(), this);
|
||||
mglass = new MagnifyingGlass(
|
||||
Configuration::getConfiguration().getMagnifyingGlassSize(),
|
||||
Configuration::getConfiguration().getMagnifyingGlassZoom(),
|
||||
this);
|
||||
|
||||
connect(mglass, &MagnifyingGlass::sizeChanged, this, [](QSize size) {
|
||||
Configuration::getConfiguration().setMagnifyingGlassSize(size);
|
||||
});
|
||||
connect(mglass, &MagnifyingGlass::zoomChanged, this, [](float zoom) {
|
||||
Configuration::getConfiguration().setMagnifyingGlassZoom(zoom);
|
||||
});
|
||||
|
||||
mglass->hide();
|
||||
content->setMouseTracking(true);
|
||||
setMouseTracking(true);
|
||||
@ -159,6 +170,7 @@ void Viewer::createConnections()
|
||||
connect(this, &Viewer::magnifyingGlassSizeDown, mglass, &MagnifyingGlass::sizeDown);
|
||||
connect(this, &Viewer::magnifyingGlassZoomIn, mglass, &MagnifyingGlass::zoomIn);
|
||||
connect(this, &Viewer::magnifyingGlassZoomOut, mglass, &MagnifyingGlass::zoomOut);
|
||||
connect(this, &Viewer::resetMagnifyingGlass, mglass, &MagnifyingGlass::reset);
|
||||
|
||||
// goToDialog
|
||||
connect(goToDialog, &GoToDialog::goToPage, this, &Viewer::goTo);
|
||||
|
@ -210,6 +210,7 @@ signals:
|
||||
void magnifyingGlassSizeDown();
|
||||
void magnifyingGlassZoomIn();
|
||||
void magnifyingGlassZoomOut();
|
||||
void resetMagnifyingGlass();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user