mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Viewer::keyPressEvent()'s and MagnifyingGlass::keyPressEvent()'s custom matching of these shortcuts is the same as MainWindowViewer::keyPressEvent()'s before the recent commit "Reader: make 3 keyboard shortcuts work with non-Latin layouts". That commit's message details the issues with the custom code. The Magnifying glass actions are now enabled/disabled when loadedComicActions are enabled/disabled - for the same reason (see the recent "Reader: make 12 keyboard shortcuts work with non-Latin layouts" commit). In addition, Viewer::keyPressEvent() propagated the Magnifying glass shortcuts to MagnifyingGlass only when it was visible. Therefore showing/hiding Magnifying glass also enables/disables these actions. Note that Viewer::showMagnifyingGlass() shows Magnifying glass only if render->hasLoadedComic() returns true, so MainWindowViewer::setMglassActionsEnabled slot can be connected directly to Viewer::magnifyingGlassVisibilityChanged signal without checking this condition again.
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
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);
|
|
|
|
// The following 4 functions increase/decrease their argument and return true,
|
|
// unless the maximum dimension value has been reached, in which case they
|
|
// do not modify the argument and return false.
|
|
bool growWidth(int &w) const;
|
|
bool shrinkWidth(int &w) const;
|
|
bool growHeight(int &h) const;
|
|
bool shrinkHeight(int &h) const;
|
|
|
|
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
|