3#include <QQmlComponent>
5#include "qml_material/control/panel.hpp"
6#include "qml_material/control/abstract_button.hpp"
10class DialogButtonBoxAttached;
11class QML_MATERIAL_API DialogButtonBox :
public Panel {
13 QML_NAMED_ELEMENT(DialogButtonBoxBase)
14 QML_ATTACHED(DialogButtonBoxAttached)
15 Q_PROPERTY(
int standardButtons READ standardButtons WRITE setStandardButtons NOTIFY
16 standardButtonsChanged FINAL)
17 Q_PROPERTY(QQmlComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
18 Q_PROPERTY(
int count READ count NOTIFY countChanged FINAL)
20 Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged FINAL)
42 RestoreDefaults = 0x8000000
44 Q_ENUM(StandardButton)
59 explicit DialogButtonBox(QQuickItem* parent =
nullptr);
60 ~DialogButtonBox()
override;
61 static DialogButtonBoxAttached* qmlAttachedProperties(QObject*);
62 int standardButtons()
const {
return m_standard_buttons; }
63 void setStandardButtons(
int);
64 QQmlComponent* delegate()
const {
return m_delegate; }
65 void setDelegate(QQmlComponent*);
66 int count()
const {
return m_buttons.size(); }
67 Qt::Alignment alignment()
const {
return m_alignment; }
68 void setAlignment(Qt::Alignment);
69 Q_INVOKABLE AbstractButton* standardButton(
int)
const;
70 Q_INVOKABLE AbstractButton* itemAt(
int)
const;
71 Q_INVOKABLE
void addItem(AbstractButton*);
72 Q_INVOKABLE
void removeItem(AbstractButton*);
73 Q_SIGNAL
void standardButtonsChanged();
74 Q_SIGNAL
void delegateChanged();
75 Q_SIGNAL
void countChanged();
76 Q_SIGNAL
void alignmentChanged();
77 Q_SIGNAL
void clicked(AbstractButton*);
78 Q_SIGNAL
void accepted();
79 Q_SIGNAL
void rejected();
80 Q_SIGNAL
void applied();
81 Q_SIGNAL
void reset();
82 Q_SIGNAL
void discarded();
83 Q_SIGNAL
void helpRequested();
86 void componentComplete()
override;
87 void updatePolish()
override;
92 void activate(AbstractButton*);
93 QPointer<QQmlComponent> m_delegate;
94 QHash<int, QPointer<AbstractButton>> m_standard_items;
95 QList<QPointer<AbstractButton>> m_buttons;
96 QList<QMetaObject::Connection> m_connections;
97 int m_standard_buttons = NoButton;
98 Qt::Alignment m_alignment = Qt::AlignRight;
99 bool m_complete =
false;
100 bool m_rebuilding =
false;
101 quint64 m_observation = 0;
103class QML_MATERIAL_API DialogButtonBoxAttached :
public QObject {
105 Q_PROPERTY(DialogButtonBox* buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL)
106 Q_PROPERTY(DialogButtonBox::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY
107 buttonRoleChanged FINAL)
109 explicit DialogButtonBoxAttached(QObject* parent): QObject(parent) {}
110 DialogButtonBox* buttonBox()
const {
return m_box; }
111 DialogButtonBox::ButtonRole buttonRole()
const {
return m_role; }
112 void setButtonRole(DialogButtonBox::ButtonRole role) {
113 if (m_role == role)
return;
115 Q_EMIT buttonRoleChanged();
117 Q_SIGNAL
void buttonBoxChanged();
118 Q_SIGNAL
void buttonRoleChanged();
121 friend class DialogButtonBox;
122 QPointer<DialogButtonBox> m_box;
123 DialogButtonBox::ButtonRole m_role = DialogButtonBox::InvalidRole;
126QML_DECLARE_TYPEINFO(qml_material::DialogButtonBox, QML_HAS_ATTACHED_PROPERTIES)