digiKam
paniconwidget.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 : 2004-08-22
7  * Description : a generic widget to display a panel to choose
8  * a rectangular image area.
9  *
10  * Copyright (C) 1997 by Tim D. Gilman (tdgilman at best dot org)
11  * Copyright (C) 1998-2001 by Mirko Boehm (mirko at kde dot org)
12  * Copyright (C) 2007 by John Layt <john at layt dot net>
13  * Copyright (C) 2004-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
14  *
15  * This program is free software; you can redistribute it
16  * and/or modify it under the terms of the GNU General
17  * Public License as published by the Free Software Foundation;
18  * either version 2, or (at your option)
19  * any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * ============================================================ */
27 
28 #ifndef DIGIKAM_PAN_ICON_WIDGET_H
29 #define DIGIKAM_PAN_ICON_WIDGET_H
30 
31 // Qt includes
32 
33 #include <QWidget>
34 #include <QRect>
35 #include <QImage>
36 #include <QPixmap>
37 #include <QHideEvent>
38 #include <QMouseEvent>
39 #include <QTimerEvent>
40 #include <QPaintEvent>
41 #include <QFrame>
42 
43 // Local includes
44 
45 #include "digikam_export.h"
46 #include "dimg.h"
47 
48 class QToolButton;
49 
50 namespace Digikam
51 {
52 
56 class DIGIKAM_EXPORT PanIconFrame : public QFrame
57 {
58  Q_OBJECT
59 
60 public:
61 
62  explicit PanIconFrame(QWidget* const parent = nullptr);
63  ~PanIconFrame() override;
64 
72  void setMainWidget(QWidget* const main);
73 
77  void popup(const QPoint& pos);
78 
82  int exec(const QPoint& pos);
83 
87  int exec(int x, int y);
88 
93  void resizeEvent(QResizeEvent* resize) override;
94 
95 Q_SIGNALS:
96 
97  void leaveModality();
98 
99 protected:
100 
104  void keyPressEvent(QKeyEvent* e) override;
105 
106 public Q_SLOTS:
107 
112  void close(int r);
113 
114 private:
115 
116  class Private;
117  friend class Private;
118  Private* const d;
119 
120  Q_DISABLE_COPY(PanIconFrame)
121 };
122 
123 // ---------------------------------------------------------------------------------
124 
125 class DIGIKAM_EXPORT PanIconWidget : public QWidget
126 {
127  Q_OBJECT
128 
129 public:
130 
131  explicit PanIconWidget(QWidget* const parent = nullptr);
132  ~PanIconWidget() override;
133 
134  static QToolButton* button();
135 
136  void setImage(int previewWidth, int previewHeight, const QImage& fullOriginalImage);
137  void setImage(int previewWidth, int previewHeight, const DImg& fullOriginalImage);
138  void setImage(const QImage& scaledPreviewImage, const QSize& fullImageSize);
139 
140  void setRegionSelection(const QRect& regionSelection);
141  QRect getRegionSelection() const;
142  void setCenterSelection();
143 
144  void setCursorToLocalRegionSelectionCenter();
145  void setMouseFocus();
146 
147 Q_SIGNALS:
148 
153  void signalSelectionMoved(const QRect& rect, bool targetDone);
154 
156 
157  void signalHidden();
158 
159 public Q_SLOTS:
160 
161  void slotZoomFactorChanged(double);
162 
163 protected:
164 
165  void showEvent(QShowEvent*) override;
166  void hideEvent(QHideEvent*) override;
167  void paintEvent(QPaintEvent*) override;
168  void mousePressEvent(QMouseEvent*) override;
169  void mouseReleaseEvent(QMouseEvent*) override;
170  void mouseMoveEvent(QMouseEvent*) override;
171 
175  void regionSelectionMoved(bool targetDone);
176 
177 protected Q_SLOTS:
178 
179  void slotFlickerTimer();
180 
181 private:
182 
183  class Private;
184  Private* const d;
185 };
186 
187 } // namespace Digikam
188 
189 #endif // DIGIKAM_PAN_ICON_WIDGET_H
int main(int argc, char *argv[])
Definition: main.cpp:98
Definition: dimg.h:62
Definition: paniconwidget.h:57
Definition: paniconwidget.h:126
void signalSelectionMoved(const QRect &rect, bool targetDone)
Definition: datefolderview.cpp:43