1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QDIALOG_P_H
41#define QDIALOG_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtWidgets/private/qtwidgetsglobal_p.h>
55#include "private/qwidget_p.h"
56#include "QtCore/qeventloop.h"
57#include "QtCore/qpointer.h"
58#include "QtWidgets/qdialog.h"
59#if QT_CONFIG(pushbutton)
60#include "QtWidgets/qpushbutton.h"
61#endif
62#include <qpa/qplatformdialoghelper.h>
63
64QT_REQUIRE_CONFIG(dialog);
65
66QT_BEGIN_NAMESPACE
67
68class QSizeGrip;
69
70class Q_WIDGETS_EXPORT QDialogPrivate : public QWidgetPrivate
71{
72 Q_DECLARE_PUBLIC(QDialog)
73public:
74
75 QDialogPrivate()
76 :
77#if QT_CONFIG(pushbutton)
78 mainDef(nullptr),
79#endif
80 orientation(Qt::Horizontal),extension(nullptr), doShowExtension(false),
81#if QT_CONFIG(sizegrip)
82 resizer(nullptr),
83 sizeGripEnabled(false),
84#endif
85 rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(nullptr),
86 nativeDialogInUse(false), m_platformHelper(nullptr), m_platformHelperCreated(false)
87 {}
88 ~QDialogPrivate();
89
90 QWindow *transientParentWindow() const;
91 bool setNativeDialogVisible(bool visible);
92 QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
93 void deletePlatformHelper();
94
95#if QT_CONFIG(pushbutton)
96 QPointer<QPushButton> mainDef;
97#endif
98 Qt::Orientation orientation;
99 QWidget *extension;
100 bool doShowExtension;
101 QSize size, min, max;
102#if QT_CONFIG(sizegrip)
103 QSizeGrip *resizer;
104 bool sizeGripEnabled;
105#endif
106 QPoint lastRMBPress;
107
108#if QT_CONFIG(pushbutton)
109 void setDefault(QPushButton *);
110 void setMainDefault(QPushButton *);
111 void hideDefault();
112#endif
113 void resetModalitySetByOpen();
114
115 int rescode;
116 int resetModalityTo;
117 bool wasModalitySet;
118
119 QPointer<QEventLoop> eventLoop;
120
121 bool nativeDialogInUse;
122 QPlatformDialogHelper *platformHelper() const;
123 virtual bool canBeNativeDialog() const;
124
125 void hide(int resultCode);
126 void finalize(int resultCode, int dialogCode);
127
128private:
129 virtual void initHelper(QPlatformDialogHelper *) {}
130 virtual void helperPrepareShow(QPlatformDialogHelper *) {}
131 virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) {}
132
133 mutable QPlatformDialogHelper *m_platformHelper;
134 mutable bool m_platformHelperCreated;
135};
136
137template <typename T>
138class QAutoPointer {
139 QPointer<T> o;
140 struct internal { void func() {} };
141 typedef void (internal::*RestrictedBool)();
142public:
143 explicit QAutoPointer(T *t) noexcept : o(t) {}
144 ~QAutoPointer() { delete o; }
145
146 T *operator->() const noexcept { return get(); }
147 T *get() const noexcept { return o; }
148 T &operator*() const { return *get(); }
149 operator RestrictedBool() const noexcept { return o ? &internal::func : nullptr; }
150 bool operator!() const noexcept { return !o; }
151private:
152 Q_DISABLE_COPY(QAutoPointer);
153};
154
155QT_END_NAMESPACE
156
157#endif // QDIALOG_P_H
158

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