1// Copyright (C) 2017 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 QQUICKDIALOGBUTTONBOX_P_H
5#define QQUICKDIALOGBUTTONBOX_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 <QtQuickTemplates2/private/qquickabstractbutton_p.h>
19#include <QtQuickTemplates2/private/qquickcontainer_p.h>
20#include <QtGui/qpa/qplatformdialoghelper.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQmlComponent;
25class QQuickDialogButtonBoxPrivate;
26class QQuickDialogButtonBoxAttached;
27class QQuickDialogButtonBoxAttachedPrivate;
28
29class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBox : public QQuickContainer
30{
31 Q_OBJECT
32 Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL)
33 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment RESET resetAlignment NOTIFY alignmentChanged FINAL)
34 Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL)
35 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
36 // 2.5 (Qt 5.12)
37 Q_PROPERTY(QPlatformDialogHelper::ButtonLayout buttonLayout READ buttonLayout WRITE setButtonLayout RESET resetButtonLayout NOTIFY buttonLayoutChanged FINAL REVISION(2, 5))
38 QML_NAMED_ELEMENT(DialogButtonBox)
39 QML_ATTACHED(QQuickDialogButtonBoxAttached)
40 QML_EXTENDED_NAMESPACE(QPlatformDialogHelper)
41 QML_ADDED_IN_VERSION(2, 1)
42
43public:
44 explicit QQuickDialogButtonBox(QQuickItem *parent = nullptr);
45 ~QQuickDialogButtonBox();
46
47 enum Position {
48 Header,
49 Footer
50 };
51 Q_ENUM(Position)
52
53 Position position() const;
54 void setPosition(Position position);
55
56 Qt::Alignment alignment() const;
57 void setAlignment(Qt::Alignment alignment);
58 void resetAlignment();
59
60 QPlatformDialogHelper::StandardButtons standardButtons() const;
61 void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons);
62 Q_INVOKABLE QQuickAbstractButton *standardButton(QPlatformDialogHelper::StandardButton button) const;
63
64 QQmlComponent *delegate() const;
65 void setDelegate(QQmlComponent *delegate);
66
67 static QQuickDialogButtonBoxAttached *qmlAttachedProperties(QObject *object);
68
69 QPlatformDialogHelper::ButtonLayout buttonLayout() const;
70 void setButtonLayout(QPlatformDialogHelper::ButtonLayout layout);
71 void resetButtonLayout();
72
73Q_SIGNALS:
74 void accepted();
75 void rejected();
76 void helpRequested();
77 void clicked(QQuickAbstractButton *button);
78 void positionChanged();
79 void alignmentChanged();
80 void standardButtonsChanged();
81 void delegateChanged();
82 // 2.3 (Qt 5.10)
83 Q_REVISION(2, 3) void applied();
84 Q_REVISION(2, 3) void reset();
85 Q_REVISION(2, 3) void discarded();
86 // 2.5 (Qt 5.12)
87 Q_REVISION(2, 5) void buttonLayoutChanged();
88
89protected:
90 void updatePolish() override;
91 void componentComplete() override;
92 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
93 void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
94 bool isContent(QQuickItem *item) const override;
95 void itemAdded(int index, QQuickItem *item) override;
96 void itemRemoved(int index, QQuickItem *item) override;
97
98#if QT_CONFIG(accessibility)
99 QAccessible::Role accessibleRole() const override;
100#endif
101 bool event(QEvent *e) override;
102
103private:
104 Q_DISABLE_COPY(QQuickDialogButtonBox)
105 Q_DECLARE_PRIVATE(QQuickDialogButtonBox)
106};
107
108class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBoxAttached : public QObject
109{
110 Q_OBJECT
111 Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL)
112 Q_PROPERTY(QPlatformDialogHelper::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY buttonRoleChanged FINAL)
113
114public:
115 explicit QQuickDialogButtonBoxAttached(QObject *parent = nullptr);
116
117 QQuickDialogButtonBox *buttonBox() const;
118
119 QPlatformDialogHelper::ButtonRole buttonRole() const;
120 void setButtonRole(QPlatformDialogHelper::ButtonRole role);
121
122Q_SIGNALS:
123 void buttonBoxChanged();
124 void buttonRoleChanged();
125
126private:
127 Q_DISABLE_COPY(QQuickDialogButtonBoxAttached)
128 Q_DECLARE_PRIVATE(QQuickDialogButtonBoxAttached)
129};
130
131QT_END_NAMESPACE
132
133QML_DECLARE_TYPE(QQuickDialogButtonBox)
134
135#endif // QQUICKDIALOGBUTTONBOX_P_H
136

source code of qtdeclarative/src/quicktemplates/qquickdialogbuttonbox_p.h