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_P_H
5#define QDIALOG_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "private/qwidget_p.h"
20#include "QtCore/qeventloop.h"
21#include "QtCore/qpointer.h"
22#include "QtWidgets/qdialog.h"
23#if QT_CONFIG(pushbutton)
24#include "QtWidgets/qpushbutton.h"
25#endif
26#include <qpa/qplatformdialoghelper.h>
27
28QT_REQUIRE_CONFIG(dialog);
29
30QT_BEGIN_NAMESPACE
31
32class QSizeGrip;
33
34class Q_WIDGETS_EXPORT QDialogPrivate : public QWidgetPrivate
35{
36 Q_DECLARE_PUBLIC(QDialog)
37public:
38
39 QDialogPrivate()
40 :
41#if QT_CONFIG(pushbutton)
42 mainDef(nullptr),
43#endif
44 orientation(Qt::Horizontal),extension(nullptr), doShowExtension(false),
45#if QT_CONFIG(sizegrip)
46 resizer(nullptr),
47 sizeGripEnabled(false),
48#endif
49 rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(nullptr),
50 nativeDialogInUse(false), m_platformHelper(nullptr), m_platformHelperCreated(false)
51 {}
52 ~QDialogPrivate();
53
54 virtual void setVisible(bool visible);
55
56 QWindow *transientParentWindow() const;
57 bool setNativeDialogVisible(bool visible);
58 QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
59
60#if QT_CONFIG(pushbutton)
61 QPointer<QPushButton> mainDef;
62#endif
63 Qt::Orientation orientation;
64 QWidget *extension;
65 bool doShowExtension;
66 QSize size, min, max;
67#if QT_CONFIG(sizegrip)
68 QSizeGrip *resizer;
69 bool sizeGripEnabled;
70#endif
71 QPoint lastRMBPress;
72
73#if QT_CONFIG(pushbutton)
74 void setDefault(QPushButton *);
75 void setMainDefault(QPushButton *);
76 void hideDefault();
77#endif
78 void resetModalitySetByOpen();
79
80 int rescode;
81 int resetModalityTo;
82 bool wasModalitySet;
83
84 QPointer<QEventLoop> eventLoop;
85
86 bool nativeDialogInUse;
87 QPlatformDialogHelper *platformHelper() const;
88 virtual bool canBeNativeDialog() const;
89
90 void close(int resultCode);
91
92protected:
93 virtual int dialogCode() const { return rescode; }
94
95private:
96 virtual void initHelper(QPlatformDialogHelper *) {}
97 virtual void helperPrepareShow(QPlatformDialogHelper *) {}
98 virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) {}
99
100 mutable QPlatformDialogHelper *m_platformHelper;
101 mutable bool m_platformHelperCreated;
102};
103
104template <typename T>
105class QAutoPointer {
106 QPointer<T> o;
107public:
108 Q_NODISCARD_CTOR explicit QAutoPointer(T *t) noexcept : o(t) {}
109 ~QAutoPointer() { delete o; }
110
111 T *operator->() const noexcept { return get(); }
112 T *get() const noexcept { return o; }
113 T &operator*() const { return *get(); }
114 explicit operator bool() const noexcept { return !o.isNull(); }
115 bool operator!() const noexcept { return !o; }
116private:
117 Q_DISABLE_COPY(QAutoPointer);
118};
119
120QT_END_NAMESPACE
121
122#endif // QDIALOG_P_H
123

source code of qtbase/src/widgets/dialogs/qdialog_p.h