Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickmessagedialogimpl.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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
6
7#include <QtQuickTemplates2/private/qquickdialogbuttonbox_p_p.h>
8
10
12
14{
16
17 if (const QQuickMessageDialogImplAttached *attached = attachedOrWarn()) {
21
22 emit q->buttonClicked(standardButton, role);
23 }
24
26}
27
29{
32 qmlAttachedPropertiesObject<QQuickMessageDialogImpl>(q));
33 if (!attached)
34 qmlWarning(q) << "Expected MessageDialogImpl attached object to be present on" << this;
35 return attached;
36}
37
40{
41}
42
44{
45 Q_D(const QQuickMessageDialogImpl);
46 return d->options;
47}
48
50{
52 d->options = options;
53
54 QQuickMessageDialogImplAttached *attached = d->attachedOrWarn();
55
56 if (options && attached) {
57 attached->detailedTextButton()->setVisible(!d->options->detailedText().isEmpty());
58 attached->buttonBox()->setStandardButtons(d->options->standardButtons());
59 }
60
61 if (showDetailedText())
63
65}
66
68{
69 Q_D(const QQuickMessageDialogImpl);
70 return d->options ? d->options->text() : QString();
71}
72
74{
75 Q_D(const QQuickMessageDialogImpl);
76 return d->options ? d->options->informativeText() : QString();
77}
78
80{
81 Q_D(const QQuickMessageDialogImpl);
82 return d->options ? d->options->detailedText() : QString();
83}
84
86{
87 Q_D(const QQuickMessageDialogImpl);
88 return d->m_showDetailedText;
89}
90
92{
94 d->m_showDetailedText = !d->m_showDetailedText;
96}
97
99{
100 return new QQuickMessageDialogImplAttached(object);
101}
102
105{
106 if (!qobject_cast<QQuickMessageDialogImpl *>(parent)) {
107 qmlWarning(this) << "MessageDialogImpl attached properties should only be "
108 << "accessed through the root MessageDialogImpl instance";
109 }
110}
111
113{
115 return d->buttonBox;
116}
117
119{
121 if (d->buttonBox == buttons)
122 return;
123
124 if (d->buttonBox) {
125 QQuickMessageDialogImpl *messageDialogImpl =
126 qobject_cast<QQuickMessageDialogImpl *>(parent());
127 if (messageDialogImpl) {
128 auto dialogPrivate = QQuickDialogPrivate::get(messageDialogImpl);
130 dialogPrivate, &QQuickDialogPrivate::handleAccept);
132 dialogPrivate, &QQuickDialogPrivate::handleReject);
135 }
136 }
137
138 d->buttonBox = buttons;
139
140 if (d->buttonBox) {
141 QQuickMessageDialogImpl *messageDialogImpl =
142 qobject_cast<QQuickMessageDialogImpl *>(parent());
143 if (messageDialogImpl) {
144 auto dialogPrivate = QQuickDialogPrivate::get(messageDialogImpl);
149 QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::clicked, dialogPrivate,
151 }
152 }
153
155}
156
158{
160 return d->detailedTextButton;
161}
163{
165
166 if (d->detailedTextButton == detailedTextButton)
167 return;
168
169 if (d->detailedTextButton) {
170 QQuickMessageDialogImpl *messageDialogImpl =
171 qobject_cast<QQuickMessageDialogImpl *>(parent());
172 if (messageDialogImpl)
173 disconnect(d->detailedTextButton, &QQuickAbstractButton::clicked, messageDialogImpl,
175 }
176
177 d->detailedTextButton = detailedTextButton;
178
179 if (d->detailedTextButton) {
180 QQuickMessageDialogImpl *messageDialogImpl =
181 qobject_cast<QQuickMessageDialogImpl *>(parent());
182 if (messageDialogImpl)
183 connect(d->detailedTextButton, &QQuickAbstractButton::clicked, messageDialogImpl,
185 }
186
188}
189
191
192#include "moc_qquickmessagedialogimpl_p.cpp"
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:298
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
Definition qobject_p.h:327
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
static QQuickDialogButtonBoxPrivate * get(QQuickDialogButtonBox *box)
QPlatformDialogHelper::StandardButton standardButton(QQuickAbstractButton *button) const
void clicked(QQuickAbstractButton *button)
void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
virtual void handleClick(QQuickAbstractButton *button)
static QQuickDialogPrivate * get(QQuickDialog *dialog)
virtual void handleAccept()
static QPlatformDialogHelper::ButtonRole buttonRole(QQuickAbstractButton *button)
Popup dialog with standard buttons and a title, used for short-term interaction with the user.
virtual void handleReject()
void setVisible(bool)
void setButtonBox(QQuickDialogButtonBox *buttons)
QQuickMessageDialogImplAttached(QObject *parent=nullptr)
void setDetailedTextButton(QQuickButton *detailedTextButton)
QQuickMessageDialogImplAttached * attachedOrWarn()
void handleClick(QQuickAbstractButton *button) override
void setOptions(const QSharedPointer< QMessageDialogOptions > &options)
static QQuickMessageDialogImplAttached * qmlAttachedProperties(QObject *object)
QQuickMessageDialogImpl(QObject *parent=nullptr)
QSharedPointer< QMessageDialogOptions > options() const
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QPushButton * button
[2]
Combined button and popup list for selecting options.
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
#define emit
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent