blob: 20e169dd9576d0b97914f76ac6ad380fdcec8ce7 (
plain)
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
|
// Copyright (C) 2016 Denis Mingulov.
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <QGraphicsView>
QT_FORWARD_DECLARE_CLASS(QImage)
namespace ImageViewer::Internal {
class ImageViewerFile;
struct ExportData {
QString fileName;
QSize size;
};
class ImageView : public QGraphicsView
{
Q_OBJECT
public:
ImageView(ImageViewerFile *file);
~ImageView() override;
void reset();
void createScene();
void exportImage();
void exportMultiImages();
void copyDataUrl();
void setViewBackground(bool enable);
void setViewOutline(bool enable);
void zoomIn();
void zoomOut();
void resetToOriginalSize();
void fitToScreen();
signals:
void scaleFactorChanged(qreal factor);
void imageSizeChanged(const QSize &size);
private:
void emitScaleFactor();
void doScale(qreal factor);
QSize svgSize() const;
QImage renderSvg(const QSize &imageSize) const;
bool exportSvg(const ExportData &ed);
void drawBackground(QPainter *p, const QRectF &rect) override;
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
ImageViewerFile *m_file;
QGraphicsItem *m_imageItem = nullptr;
QGraphicsRectItem *m_backgroundItem = nullptr;
QGraphicsRectItem *m_outlineItem = nullptr;
bool m_showBackground = false;
bool m_showOutline = true;
};
} // ImageViewer::Internal
|