1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QDIALOG_H |
5 | #define QDIALOG_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qwidget.h> |
9 | |
10 | QT_REQUIRE_CONFIG(dialog); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | |
15 | class QPushButton; |
16 | class QDialogPrivate; |
17 | |
18 | class Q_WIDGETS_EXPORT QDialog : public QWidget |
19 | { |
20 | Q_OBJECT |
21 | friend class QPushButton; |
22 | |
23 | Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled) |
24 | Q_PROPERTY(bool modal READ isModal WRITE setModal) |
25 | |
26 | public: |
27 | explicit QDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); |
28 | ~QDialog(); |
29 | |
30 | enum DialogCode { Rejected, Accepted }; |
31 | |
32 | int result() const; |
33 | |
34 | void setVisible(bool visible) override; |
35 | |
36 | QSize sizeHint() const override; |
37 | QSize minimumSizeHint() const override; |
38 | |
39 | void setSizeGripEnabled(bool); |
40 | bool isSizeGripEnabled() const; |
41 | |
42 | void setModal(bool modal); |
43 | void setResult(int r); |
44 | |
45 | Q_SIGNALS: |
46 | void finished(int result); |
47 | void accepted(); |
48 | void rejected(); |
49 | |
50 | public Q_SLOTS: |
51 | virtual void open(); |
52 | virtual int exec(); |
53 | virtual void done(int); |
54 | virtual void accept(); |
55 | virtual void reject(); |
56 | |
57 | protected: |
58 | QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags()); |
59 | |
60 | void keyPressEvent(QKeyEvent *) override; |
61 | void closeEvent(QCloseEvent *) override; |
62 | void showEvent(QShowEvent *) override; |
63 | void resizeEvent(QResizeEvent *) override; |
64 | #ifndef QT_NO_CONTEXTMENU |
65 | void (QContextMenuEvent *) override; |
66 | #endif |
67 | bool eventFilter(QObject *, QEvent *) override; |
68 | void adjustPosition(QWidget*); |
69 | private: |
70 | Q_DECLARE_PRIVATE(QDialog) |
71 | Q_DISABLE_COPY(QDialog) |
72 | }; |
73 | |
74 | QT_END_NAMESPACE |
75 | |
76 | #endif // QDIALOG_H |
77 | |