1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2004 Antonio Larrosa <larrosa@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KPIXMAPREGIONSELECTORDIALOG_H
9#define KPIXMAPREGIONSELECTORDIALOG_H
10
11#include <QDialog>
12#include <memory>
13
14#include <kwidgetsaddons_export.h>
15
16class KPixmapRegionSelectorWidget;
17
18class QImage;
19
20/*!
21 * \class KPixmapRegionSelectorDialog
22 * \inmodule KWidgetsAddons
23 *
24 * \brief A dialog that uses a KPixmapRegionSelectorWidget to allow the user
25 * to select a region of an image.
26 *
27 * If you want to use special features
28 * like forcing the selected area to have a fixed aspect ratio, you can use
29 * pixmapRegionSelectorWidget() to get the pointer to the
30 * KPixmapRegionSelectorWidget object and set the desired options there.
31 *
32 * There are some convenience methods that allow to easily show a dialog
33 * for the user to select a region of an image, and just care about the selected
34 * image.
35 *
36 * \image kpixmapregionselectordialog.png "KPixmapRegionSelectorDialog"
37 */
38class KWIDGETSADDONS_EXPORT KPixmapRegionSelectorDialog : public QDialog
39{
40 Q_OBJECT
41
42public:
43 /*!
44 * The constructor of an empty KPixmapRegionSelectorDialog, you have to call
45 * later the setPixmap method of the KPixmapRegionSelectorWidget widget of
46 * the new object.
47 */
48 explicit KPixmapRegionSelectorDialog(QWidget *parent = nullptr);
49
50 ~KPixmapRegionSelectorDialog() override;
51
52 /*!
53 * Returns the KPixmapRegionSelectorWidget widget so that additional
54 * parameters can be set by using it.
55 */
56 KPixmapRegionSelectorWidget *pixmapRegionSelectorWidget() const;
57
58 /*!
59 * Creates a modal dialog, lets the user to select a region of the \a pixmap
60 * and returns when the dialog is closed.
61 *
62 * Returns the selected rectangle, or an invalid rectangle if the user
63 * pressed the Cancel button.
64 */
65 static QRect getSelectedRegion(const QPixmap &pixmap, QWidget *parent = nullptr);
66
67 /*!
68 * Creates a modal dialog, lets the user to select a region of the \a pixmap
69 * with the same aspect ratio than \a aspectRatioWidth x \a aspectRatioHeight
70 * and returns when the dialog is closed.
71 *
72 * Returns the selected rectangle, or an invalid rectangle if the user
73 * pressed the Cancel button.
74 */
75 static QRect getSelectedRegion(const QPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, QWidget *parent = nullptr);
76
77 /*!
78 * Creates a modal dialog, lets the user to select a region of the \a pixmap
79 * and returns when the dialog is closed.
80 *
81 * Returns the selected image, or an invalid image if the user
82 * pressed the Cancel button.
83 */
84 static QImage getSelectedImage(const QPixmap &pixmap, QWidget *parent = nullptr);
85
86 /*!
87 * Creates a modal dialog, lets the user to select a region of the \a pixmap
88 * with the same aspect ratio than \a aspectRatioWidth x \a aspectRatioHeight
89 * and returns when the dialog is closed.
90 *
91 * Returns the selected image, or an invalid image if the user
92 * pressed the Cancel button.
93 */
94 static QImage getSelectedImage(const QPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, QWidget *parent = nullptr);
95
96 /*!
97 * \since 4.4.3
98 * Adjusts the size of the KPixmapRegionSelectorWidget to not overflow the screen size
99 */
100 void adjustRegionSelectorWidgetSizeToFitScreen();
101
102private:
103 std::unique_ptr<class KPixmapRegionSelectorDialogPrivate> const d;
104
105 Q_DISABLE_COPY(KPixmapRegionSelectorDialog)
106};
107
108#endif
109

source code of kwidgetsaddons/src/kpixmapregionselectordialog.h