4#include <QtCore/qhash.h>
5#include <QtWidgets/qpushbutton.h>
6#include <QtWidgets/qstyle.h>
7#include <QtWidgets/qlayout.h>
8#include <QtWidgets/qdialog.h>
9#include <QtWidgets/qapplication.h>
10#include <private/qwidget_p.h>
11#include <private/qguiapplication_p.h>
12#include <QtGui/qpa/qplatformdialoghelper.h>
13#include <QtGui/qpa/qplatformtheme.h>
14#include <QtGui/qaction.h>
19#include <QtCore/qpointer.h>
118 : orientation(orient), buttonLayout(
nullptr), center(
false)
120 struct EventFilter :
public QObject
135 filter.reset(
new EventFilter(
this));
145 if (createNewLayout) {
162 q->setSizePolicy(
sp);
176 int start = reverse ? buttonList.size() - 1 : 0;
177 int end = reverse ? -1 : buttonList.size();
178 int step = reverse ? -1 : 1;
190 const int MacGap = 36 - 8;
202 static const int M = 5;
206 bool hasModalButton =
false;
207 for (
int i = 0;
i <
M; ++
i) {
209 hasModalButton =
true;
235 if (acceptRoleList.isEmpty())
244 if (acceptRoleList.size() > 1)
292 if (!layoutWidgets.
isEmpty()) {
294 for (
QWidget *here : layoutWidgets) {
380 qWarning(
"QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
383#if QT_CONFIG(shortcut)
385 if (!standardShortcut.isEmpty())
407 switch (layoutRule) {
454 d_func()->initLayout();
480 d_func()->createStandardButtons(
buttons);
490 d->ignoreShowAndHide =
true;
624 return d_func()->orientation;
647 d->standardButtonMap.clear();
649 QList<QAbstractButton *> &
list =
d->buttonLists[
i];
667 return d->allButtons();
672 QList<QAbstractButton *> finalList;
686 ret.push_back(
it.first);
700 const QList<QAbstractButton *> &
list =
d->buttonLists[
i];
773 qWarning(
"QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
792 qWarning(
"QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
810 return d->createButton(
button);
825 const auto oldButtons =
d->standardButtonMap.keys();
826 d->standardButtonMap.clear();
836 for (
const auto value :
d->standardButtonMap.values())
851 for (
const auto &
it : std::as_const(
d->standardButtonMap)) {
852 if (
it.second == which)
879 QPointer<QDialogButtonBox> guard(
q);
896 emit q->helpRequested();
958 if (
d->center != center) {
976 switch (
event->type()) {
978 if (!
d->standardButtonMap.empty()) {
980 for (
auto key :
d->standardButtonMap.keys())
981 key->setStyle(newStyle);
1000 QPushButton *firstAcceptButton = acceptRoleList.isEmpty()
1002 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
1004 if (!firstAcceptButton)
1007 bool hasDefault =
false;
1010 while (
p && !
p->isWindow()) {
1012 if ((
dialog = qobject_cast<QDialog *>(
p)))
1026 if (!hasDefault && firstAcceptButton) {
1040 firstAcceptButton->setFocus();
1048 for (
auto *
button : buttons)
1058 switch (
event->type()) {
1060 d->ensureFirstAcceptIsDefault();
1064 d->retranslateStrings();
1075#include "moc_qdialogbuttonbox.cpp"
static QStyle * style()
Returns the application's style object.
int count() const override
\reimp
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
QLayoutItem * takeAt(int) override
\reimp
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout.
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
QLayoutItem * itemAt(int) const override
\reimp
Type
This enum type defines the valid event types in Qt.
static QPlatformTheme * platformTheme()
The QHBoxLayout class lines up widgets horizontally.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
void setContentsMargins(int left, int top, int right, int bottom)
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
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)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
void installEventFilter(QObject *filterObj)
Installs an event filter filterObj on this object.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void removeEventFilter(QObject *obj)
Removes an event filter object obj from this object.
QList< T > findChildren(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
@ SH_DialogButtonBox_ButtonsHaveIcons
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
StandardPixmap
This enum describes the available standard pixmaps.
@ SP_RestoreDefaultsButton
@ SP_DialogYesToAllButton
@ SE_PushButtonLayoutItem
The QVBoxLayout class lines up widgets vertically.
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
@ WA_WState_OwnSizePolicy
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLdouble GLdouble GLdouble GLdouble top
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLdouble GLdouble GLdouble GLdouble q
QFileDialog dialog(this)
[1]