Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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()) {
19 QQuickDialogButtonBoxPrivate::get(attached->buttonBox())->standardButton(button);
21
22 emit q->buttonClicked(standardButton, role);
23 }
24}
25
27{
30 qmlAttachedPropertiesObject<QQuickMessageDialogImpl>(q));
31 if (!attached)
32 qmlWarning(q) << "Expected MessageDialogImpl attached object to be present on" << this;
33 return attached;
34}
35
40
41QSharedPointer<QMessageDialogOptions> QQuickMessageDialogImpl::options() const
42{
43 Q_D(const QQuickMessageDialogImpl);
44 return d->options;
45}
46
47void QQuickMessageDialogImpl::setOptions(const QSharedPointer<QMessageDialogOptions> &options)
48{
50 d->options = options;
51
52 QQuickMessageDialogImplAttached *attached = d->attachedOrWarn();
53
54 if (options && attached) {
55 attached->detailedTextButton()->setVisible(!d->options->detailedText().isEmpty());
56 attached->buttonBox()->setStandardButtons(d->options->standardButtons());
57 }
58
59 if (showDetailedText())
61
63}
64
66{
67 Q_D(const QQuickMessageDialogImpl);
68 return d->options ? d->options->text() : QString();
69}
70
72{
73 Q_D(const QQuickMessageDialogImpl);
74 return d->options ? d->options->informativeText() : QString();
75}
76
78{
79 Q_D(const QQuickMessageDialogImpl);
80 return d->options ? d->options->detailedText() : QString();
81}
82
84{
85 Q_D(const QQuickMessageDialogImpl);
86 return d->m_showDetailedText;
87}
88
90{
92 d->m_showDetailedText = !d->m_showDetailedText;
94}
95
100
103{
104 if (!qobject_cast<QQuickMessageDialogImpl *>(parent)) {
105 qmlWarning(this) << "MessageDialogImpl attached properties should only be "
106 << "accessed through the root MessageDialogImpl instance";
107 }
108}
109
115
117{
119 if (d->buttonBox == buttons)
120 return;
121
122 if (d->buttonBox) {
123 QQuickMessageDialogImpl *messageDialogImpl =
124 qobject_cast<QQuickMessageDialogImpl *>(parent());
125 if (messageDialogImpl) {
126 auto dialogPrivate = QQuickMessageDialogImplPrivate::get(messageDialogImpl);
129 }
130 }
131
132 d->buttonBox = buttons;
133
134 if (d->buttonBox) {
135 QQuickMessageDialogImpl *messageDialogImpl =
136 qobject_cast<QQuickMessageDialogImpl *>(parent());
137 if (messageDialogImpl) {
138 auto dialogPrivate = QQuickMessageDialogImplPrivate::get(messageDialogImpl);
139 QObjectPrivate::connect(d->buttonBox, &QQuickDialogButtonBox::clicked, dialogPrivate,
141 }
142 }
143
145}
146
148{
150 return d->detailedTextButton;
151}
153{
155
156 if (d->detailedTextButton == detailedTextButton)
157 return;
158
159 if (d->detailedTextButton) {
160 QQuickMessageDialogImpl *messageDialogImpl =
161 qobject_cast<QQuickMessageDialogImpl *>(parent());
162 if (messageDialogImpl)
163 disconnect(d->detailedTextButton, &QQuickAbstractButton::clicked, messageDialogImpl,
165 }
166
167 d->detailedTextButton = detailedTextButton;
168
169 if (d->detailedTextButton) {
170 QQuickMessageDialogImpl *messageDialogImpl =
171 qobject_cast<QQuickMessageDialogImpl *>(parent());
172 if (messageDialogImpl)
173 connect(d->detailedTextButton, &QQuickAbstractButton::clicked, messageDialogImpl,
175 }
176
178}
179
181
182#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:299
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:328
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
static QQuickDialogButtonBoxPrivate * get(QQuickDialogButtonBox *box)
void clicked(QQuickAbstractButton *button)
void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
static QPlatformDialogHelper::ButtonRole buttonRole(QQuickAbstractButton *button)
Popup dialog with standard buttons and a title, used for short-term interaction with the user.
void setVisible(bool)
void setButtonBox(QQuickDialogButtonBox *buttons)
QQuickMessageDialogImplAttached(QObject *parent=nullptr)
void setDetailedTextButton(QQuickButton *detailedTextButton)
static QQuickMessageDialogImplPrivate * get(QQuickMessageDialogImpl *dialog)
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
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
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]