1 | // Copyright (C) 2023 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 QDIALOGBUTTONBOX_P_H |
5 | #define QDIALOGBUTTONBOX_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 <private/qwidget_p.h> |
19 | #include <qdialogbuttonbox.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class Q_AUTOTEST_EXPORT QDialogButtonBoxPrivate : public QWidgetPrivate |
24 | { |
25 | Q_DECLARE_PUBLIC(QDialogButtonBox) |
26 | |
27 | public: |
28 | enum class RemoveReason { |
29 | HideEvent, |
30 | ManualRemove, |
31 | Destroyed, |
32 | }; |
33 | enum class LayoutRule { |
34 | DoLayout, |
35 | SkipLayout, |
36 | }; |
37 | enum class AddRule { |
38 | Connect, |
39 | SkipConnect, |
40 | }; |
41 | |
42 | QDialogButtonBoxPrivate(Qt::Orientation orient); |
43 | |
44 | QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles]; |
45 | QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash; |
46 | QHash<QAbstractButton *, QDialogButtonBox::ButtonRole> hiddenButtons; |
47 | |
48 | Qt::Orientation orientation; |
49 | QDialogButtonBox::ButtonLayout layoutPolicy; |
50 | QBoxLayout *buttonLayout; |
51 | std::unique_ptr<QObject> filter; |
52 | bool center; |
53 | bool ignoreShowAndHide = false; |
54 | |
55 | void createStandardButtons(QDialogButtonBox::StandardButtons buttons); |
56 | |
57 | void removeButton(QAbstractButton *button, RemoveReason reason); |
58 | void layoutButtons(); |
59 | void initLayout(); |
60 | void resetLayout(); |
61 | QPushButton *createButton(QDialogButtonBox::StandardButton button, |
62 | LayoutRule layoutRule = LayoutRule::DoLayout); |
63 | void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, |
64 | LayoutRule layoutRule = LayoutRule::DoLayout, |
65 | AddRule addRule = AddRule::Connect); |
66 | void handleButtonDestroyed(); |
67 | void handleButtonClicked(); |
68 | bool handleButtonShowAndHide(QAbstractButton *button, QEvent *event); |
69 | void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse); |
70 | void ensureFirstAcceptIsDefault(); |
71 | void retranslateStrings(); |
72 | void disconnectAll(); |
73 | QList<QAbstractButton *> allButtons() const; |
74 | QList<QAbstractButton *> visibleButtons() const; |
75 | QDialogButtonBox::ButtonRole buttonRole(QAbstractButton *button) const; |
76 | }; |
77 | |
78 | QT_END_NAMESPACE |
79 | |
80 | #endif // QDIALOGBUTTONBOX_P_H |
81 | |