-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImageWidget.h
51 lines (45 loc) · 1.1 KB
/
ImageWidget.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
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QImage>
#include <QCursor>
#include <QDropEvent>
#include <QDragEnterEvent>
class ImageWidget : public QWidget
{
Q_OBJECT
public:
ImageWidget(QWidget *parent = 0);
~ImageWidget();
void loadImage(const QString & file);
void fitSize();
void updateCanvas();
double getFitZoom();
void generateBackground(const QSize & size);
protected:
void paintEvent ( QPaintEvent * event );
void wheelEvent ( QWheelEvent * event );
void resizeEvent ( QResizeEvent * event );
void mouseMoveEvent ( QMouseEvent * event );
void mousePressEvent ( QMouseEvent * event );
void mouseReleaseEvent ( QMouseEvent * event );
public slots:
void resetSize();
void setZoom(double zoom);
void clockwise();
void anticlockwise();
private:
private:
QRectF m_viewPort;
QRectF m_oldViewPort;
QRectF m_canvas;
QImage m_image;
QPixmap m_background;
QPointF m_oldPoint;
double m_zoom;
double m_fitZoom;
bool m_mousePressed;
int m_rotate;
Qt::CursorShape m_cursor;
};
#endif // WIDGET_H