-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageViewer.h
88 lines (71 loc) · 2.04 KB
/
ImageViewer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef ImageViewerH
#define ImageViewerH
//============================================================================
/// \file ImageViewer.h
/// \author Uwe Kindler
/// \date 04.11.2022
/// \brief Declaration of CImageViewer
//============================================================================
//============================================================================
// INCLUDES
//============================================================================
#include <QScrollArea>
QT_BEGIN_NAMESPACE
class QLabel;
QT_END_NAMESPACE
struct ImageViewerPrivate;
/**
* Tiny simple image viewer for showing images in demo
*/
class CImageViewer : public QScrollArea
{
Q_OBJECT
public:
using Super = QScrollArea;
explicit CImageViewer(QWidget *parent = nullptr);
virtual ~CImageViewer();
bool loadFile(const QString& Filename);
void setImage(const QImage &newImage);
public Q_SLOTS:
void open();
void zoomIn();
void zoomOut();
void normalSize();
void fitToWindow();
protected:
/**
* @brief Reimplemented from QScrollArea to adjust image scaling if m_AutoFit is
* true.
*/
virtual void resizeEvent(QResizeEvent* ResizeEvent);
/**
* @brief Handle mouse press events.
*/
virtual void mousePressEvent(QMouseEvent* Event);
/**
* @brief Handles mouse release events.
*/
virtual void mouseReleaseEvent(QMouseEvent* Event);
/**
* @brief Handle mouse move events.
*/
virtual void mouseMoveEvent(QMouseEvent* Event);
/**
* @brief Use mouse wheel to change scaling of the image.
*/
virtual void wheelEvent(QWheelEvent* Event);
private:
/**
* @brief Create the wiget actions.
*/
void createActions();
/**
* @brief Adjust size of render widget in case of image size change.
* @param[in] Image The new image that may have a different image size.
*/
void adjustDisplaySize(const QImage& Image);
ImageViewerPrivate* d;
friend ImageViewerPrivate;
};
//---------------------------------------------------------------------------
#endif // ImageViewerH