yacreader/YACReader/magnifying_glass.h
Igor Kushnir fdba938fe8 MagnifyingGlass: don't updateImage() needlessly
Not all possible keyboard modifiers of a wheel event change
MagnifyingGlass's pixmap. So in case of e.g. MetaModifier or more than
one modifier, MagnifyingGlass::wheelEvent() calls updateImage() to no
avail.

Move the updateImage() call into the public slots to make them
self-sufficient. This also allows not to call updateImage() when the
pixmap is not changed in case the adjusted parameter has reached its
minimum or maximum value already.
2022-01-15 18:02:30 +02:00

37 lines
823 B
C++

#ifndef __MAGNIFYING_GLASS
#define __MAGNIFYING_GLASS
#include <QLabel>
#include <QtGui>
#include <QMouseEvent>
#include <QWidget>
class MagnifyingGlass : public QLabel
{
Q_OBJECT
private:
float zoomLevel;
void setup(const QSize &size);
void resizeAndUpdate(int w, int h);
void keyPressEvent(QKeyEvent *event) override;
public:
MagnifyingGlass(int width, int height, QWidget *parent);
MagnifyingGlass(const QSize &size, QWidget *parent);
void mouseMoveEvent(QMouseEvent *event) override;
public slots:
void updateImage(int x, int y);
void updateImage();
void wheelEvent(QWheelEvent *event) override;
void zoomIn();
void zoomOut();
void sizeUp();
void sizeDown();
void heightUp();
void heightDown();
void widthUp();
void widthDown();
};
#endif