blob: 08d495dc89b45d71794c5b79be964e2dd9534eec (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright (C) 2016 Denis Mingulov.
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <utils/filepath.h>
#include <QGraphicsView>
QT_BEGIN_NAMESPACE
class QImage;
QT_END_NAMESPACE
namespace ImageViewer::Internal {
class ImageViewerFile;
struct ExportData {
Utils::FilePath filePath;
QSize size;
};
class ImageView : public QGraphicsView
{
Q_OBJECT
public:
struct Settings
{
bool showBackground = false;
bool showOutline = true;
bool fitToScreen = false;
};
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 setFitToScreen(bool fit);
void readSettings();
void writeSettings() const;
Settings settings() const;
signals:
void scaleFactorChanged(qreal factor);
void imageSizeChanged(const QSize &size);
void fitToScreenChanged(bool fit);
private:
void doFitToScreen();
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;
void resizeEvent(QResizeEvent *event) override;
ImageViewerFile *m_file;
QGraphicsItem *m_imageItem = nullptr;
QGraphicsRectItem *m_backgroundItem = nullptr;
QGraphicsRectItem *m_outlineItem = nullptr;
Settings m_settings;
};
} // ImageViewer::Internal
|