OSDN Git Service

Ver0.18
[gefu/Gefu.git] / simpleimageview.h
1 #ifndef SIMPLEIMAGEVIEW_H
2 #define SIMPLEIMAGEVIEW_H
3
4 #include <QGraphicsView>
5
6 class SimpleImageView : public QGraphicsView
7 {
8     Q_OBJECT
9 public:
10     explicit SimpleImageView(QWidget *parent = 0);
11
12     bool setSource(const QString &path);
13
14 private:
15     QAction *m_back;
16     QAction *m_fitToWindow;
17     QAction *m_scaleUp;
18     QAction *m_scaleDown;
19     QAction *m_scaleNormal;
20     QAction *m_rot90;
21     QAction *m_rot180;
22     QPixmap m_imgSrc;
23     double m_scaleFactor;
24     int m_rotateDeg;
25
26 private:
27     double scaleFactor(const QSize &size);
28     void updateActions();
29     void sizeChanged();
30     double resizeImage();
31
32 signals:
33     void viewFinished();
34     void fileInfo(const QString &info);
35
36 private slots:
37     void fitToWindow(bool checked);
38     void scaleNormal();
39     void scaleUp();
40     void scaleDown();
41     void rotate90();
42     void rotate180();
43
44     // QWidget interface
45 protected:
46     void keyPressEvent(QKeyEvent *event);
47     void contextMenuEvent(QContextMenuEvent *event);
48     void resizeEvent(QResizeEvent *event);
49 };
50
51 #endif // SIMPLEIMAGEVIEW_H