digiKam
Loading...
Searching...
No Matches
dpreviewimage.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2009-12-13
7 * Description : a widget to preview image effect.
8 *
9 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * SPDX-FileCopyrightText: 2008 by Kare Sars <kare dot sars at iki dot fi>
11 * SPDX-FileCopyrightText: 2012 by Benjamin Girault <benjamin dot girault at gmail dot com>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19// Qt includes
20
21#include <QGraphicsView>
22#include <QGraphicsPixmapItem>
23#include <QString>
24#include <QColor>
25
26// Local includes
27
28#include "digikam_export.h"
29
30class QResizeEvent;
31class QWheelEvent;
32class QMouseEvent;
33class QEvent;
34
35namespace Digikam
36{
37
38class DIGIKAM_EXPORT DSelectionItem : public QGraphicsItem
39{
40public:
41
55
56public:
57
58 explicit DSelectionItem(const QRectF& rect);
59 ~DSelectionItem() override;
60
61public:
62
63 void setMaxRight(qreal maxRight);
64 void setMaxBottom(qreal maxBottom);
65
66 Intersects intersects(QPointF& point);
67
68 void saveZoom(qreal zoom);
69
70 void setRect(const QRectF& rect);
71 QRectF rect() const;
72 QPointF fixTranslation(QPointF dp) const;
73
74public:
75
76 // Graphics Item methods
77
78 QRectF boundingRect() const override;
79 void paint(QPainter* painter,
80 const QStyleOptionGraphicsItem* option,
81 QWidget* widget) override;
82
83private:
84
85 void updateAnchors();
86
87private:
88
89 class Private;
90 Private* const d = nullptr;
91};
92
93// -----------------------------------------------------------------------------------------
94
95class DIGIKAM_EXPORT DPreviewImage : public QGraphicsView
96{
97 Q_OBJECT
98
99public:
100
101 explicit DPreviewImage(QWidget* const parent);
102 ~DPreviewImage() override;
103
104public:
105
106 bool load(const QUrl& file) const;
107 bool setImage(const QImage& img) const;
108 void enableSelectionArea(bool b);
109
115 void setSelectionArea(const QRectF& rectangle);
116 QRectF getSelectionArea() const;
117
118public Q_SLOTS:
119
120 void slotZoomIn();
121 void slotZoomOut();
122// void slotZoomSel(); // TODO: add a button for that purpose
123 void slotZoom2Fit();
124
127
128 void slotSetTLX(float ratio);
129 void slotSetTLY(float ratio);
130 void slotSetBRX(float ratio);
131 void slotSetBRY(float ratio);
132
134
143 void slotSetSelection(float tl_x, float tl_y, float br_x, float br_y);
144 void slotClearActiveSelection();
145
154 void slotSetHighlightArea(float tl_x, float tl_y, float br_x, float br_y);
155
162 void slotSetHighlightShown(int percentage, const QColor& highLightColor = Qt::white);
163
167 void slotClearHighlight();
168
169protected:
170
171 void wheelEvent(QWheelEvent*) override;
172 void mousePressEvent(QMouseEvent*) override;
173 void mouseReleaseEvent(QMouseEvent*) override;
174 void mouseMoveEvent(QMouseEvent*) override;
175 void leaveEvent(QEvent*) override;
176 bool eventFilter(QObject*, QEvent*) override;
177 void resizeEvent(QResizeEvent*) override;
178
179#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
180
181 void enterEvent(QEnterEvent*) override;
182
183#else
184
185 void enterEvent(QEvent*) override;
186
187#endif
188
189 void updateSelVisibility();
190 void updateHighlight();
191
192private:
193
194 class Private;
195 Private* const d = nullptr;
196};
197
198} // namespace Digikam
Definition dpreviewimage.h:96
Definition dpreviewimage.h:39
@ Top
Definition dpreviewimage.h:45
@ None
Definition dpreviewimage.h:44
@ TopLeft
Definition dpreviewimage.h:52
@ TopRight
Definition dpreviewimage.h:46
@ BottomRight
Definition dpreviewimage.h:48
@ BottomLeft
Definition dpreviewimage.h:50
@ Right
Definition dpreviewimage.h:47
@ Bottom
Definition dpreviewimage.h:49
@ Left
Definition dpreviewimage.h:51
Definition datefolderview.cpp:34