From 00e6863552ab3519e8a9a9ecb6cb56bb6a024041 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 5 Mar 2017 18:54:15 +0100 Subject: Add feature.pushbutton Change-Id: I654d91635e60b177df16f6dfe00acc940132f66a Reviewed-by: Lars Knoll --- src/widgets/dialogs/qdialog.cpp | 9 ++++++++- src/widgets/dialogs/qdialog_p.h | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index e5715ecd57..8e74c659fa 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -43,7 +43,6 @@ #include "qevent.h" #include "qdesktopwidget.h" -#include "qpushbutton.h" #include "qapplication.h" #include "qlayout.h" #include "qsizegrip.h" @@ -367,6 +366,7 @@ QDialog::~QDialog() default default button becomes the default button. This is what a push button calls when it loses focus. */ +#if QT_CONFIG(pushbutton) void QDialogPrivate::setDefault(QPushButton *pushButton) { Q_Q(QDialog); @@ -411,6 +411,7 @@ void QDialogPrivate::hideDefault() list.at(i)->setDefault(false); } } +#endif void QDialogPrivate::resetModalitySetByOpen() { @@ -644,6 +645,7 @@ void QDialog::keyPressEvent(QKeyEvent *e) #endif if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { switch (e->key()) { +#if QT_CONFIG(pushbutton) case Qt::Key_Enter: case Qt::Key_Return: { QList list = findChildren(); @@ -657,6 +659,7 @@ void QDialog::keyPressEvent(QKeyEvent *e) } } break; +#endif default: e->ignore(); return; @@ -716,6 +719,7 @@ void QDialog::setVisible(bool visible) and actually catches most cases... If not, then they simply have to use [widget*]->setFocus() themselves... */ +#if QT_CONFIG(pushbutton) if (d->mainDef && fw->focusPolicy() == Qt::NoFocus) { QWidget *first = fw; while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus) @@ -733,6 +737,7 @@ void QDialog::setVisible(bool visible) } } } +#endif if (fw && !fw->hasFocus()) { QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); QApplication::sendEvent(fw, &e); @@ -760,10 +765,12 @@ void QDialog::setVisible(bool visible) d->eventLoop->exit(); } +#if QT_CONFIG(pushbutton) const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); if (d->mainDef && isActiveWindow() && theme->themeHint(QPlatformTheme::DialogSnapToDefaultButton).toBool()) QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); +#endif } /*!\reimp */ diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index ae9e3bcc93..6723edae38 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -56,7 +56,9 @@ #include "QtCore/qeventloop.h" #include "QtCore/qpointer.h" #include "QtWidgets/qdialog.h" +#if QT_CONFIG(pushbutton) #include "QtWidgets/qpushbutton.h" +#endif #include QT_BEGIN_NAMESPACE @@ -69,7 +71,11 @@ class Q_WIDGETS_EXPORT QDialogPrivate : public QWidgetPrivate public: QDialogPrivate() - : mainDef(0), orientation(Qt::Horizontal),extension(0), doShowExtension(false), + : +#if QT_CONFIG(pushbutton) + mainDef(0), +#endif + orientation(Qt::Horizontal),extension(0), doShowExtension(false), #ifndef QT_NO_SIZEGRIP resizer(0), sizeGripEnabled(false), @@ -84,7 +90,9 @@ public: QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const; void deletePlatformHelper(); +#if QT_CONFIG(pushbutton) QPointer mainDef; +#endif Qt::Orientation orientation; QWidget *extension; bool doShowExtension; @@ -95,9 +103,11 @@ public: #endif QPoint lastRMBPress; +#if QT_CONFIG(pushbutton) void setDefault(QPushButton *); void setMainDefault(QPushButton *); void hideDefault(); +#endif void resetModalitySetByOpen(); int rescode; -- cgit v1.2.3