Skip to content

Commit

Permalink
Make zoom level in titlebar update more frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpurcell committed Dec 21, 2024
1 parent 6aacb3c commit e0239b8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ MainWindow::MainWindow(QWidget *parent) :
slideshowTimer = new QTimer(this);
connect(slideshowTimer, &QTimer::timeout, this, &MainWindow::slideshowAction);

// Timer for updating titlebar after zoom change
zoomTitlebarUpdateTimer = new QTimer(this);
zoomTitlebarUpdateTimer->setSingleShot(true);
zoomTitlebarUpdateTimer->setInterval(50);
connect(zoomTitlebarUpdateTimer, &QTimer::timeout, this, &MainWindow::buildWindowTitle);

// Context menu
auto &actionManager = qvApp->getActionManager();

Expand Down Expand Up @@ -389,7 +395,8 @@ void MainWindow::fileChanged()

void MainWindow::zoomLevelChanged()
{
buildWindowTitle();
if (!zoomTitlebarUpdateTimer->isActive())
zoomTitlebarUpdateTimer->start();
}

void MainWindow::disableActions()
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected slots:
QMenu *virtualMenu;

QTimer *slideshowTimer;
QTimer *zoomTitlebarUpdateTimer;

QShortcut *escShortcut;

Expand Down
7 changes: 1 addition & 6 deletions src/qvgraphicsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ QVGraphicsView::QVGraphicsView(QWidget *parent) : QGraphicsView(parent)
expensiveScaleTimer->setInterval(50);
connect(expensiveScaleTimer, &QTimer::timeout, this, [this]{applyExpensiveScaling();});

emitZoomLevelChangedTimer = new QTimer(this);
emitZoomLevelChangedTimer->setSingleShot(true);
emitZoomLevelChangedTimer->setInterval(50);
connect(emitZoomLevelChangedTimer, &QTimer::timeout, this, [this]{emit zoomLevelChanged();});

loadedPixmapItem = new QGraphicsPixmapItem();
scene->addItem(loadedPixmapItem);

Expand Down Expand Up @@ -332,7 +327,7 @@ void QVGraphicsView::zoomAbsolute(const qreal absoluteLevel, const QPoint &pos)
if (isScalingEnabled)
expensiveScaleTimer->start();

emitZoomLevelChangedTimer->start();
emit zoomLevelChanged();
}

void QVGraphicsView::applyExpensiveScaling()
Expand Down
1 change: 0 additions & 1 deletion src/qvgraphicsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,5 @@ private slots:
QVImageCore imageCore { this };

QTimer *expensiveScaleTimer;
QTimer *emitZoomLevelChangedTimer;
};
#endif // QVGRAPHICSVIEW_H

0 comments on commit e0239b8

Please sign in to comment.