diff options
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 13 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qdialogbuttonbox.cpp | 7 |
5 files changed, 22 insertions, 6 deletions
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index eef8b817fd..931c784d08 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -671,6 +671,19 @@ QString QPlatformTheme::standardButtonText(int button) const return QPlatformTheme::defaultStandardButtonText(button); } +/*! + Returns the mnemonic that should be used for a standard \a button. + + \since 5.9 + \sa QPlatformDialogHelper::StandardButton + */ + +QKeySequence QPlatformTheme::standardButtonShortcut(int button) const +{ + Q_UNUSED(button) + return QKeySequence(); +} + QString QPlatformTheme::defaultStandardButtonText(int button) { switch (button) { diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 4135e31517..2ba2f8669f 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -312,6 +312,7 @@ public: #endif virtual QString standardButtonText(int button) const; + virtual QKeySequence standardButtonShortcut(int button) const; static QVariant defaultThemeHint(ThemeHint hint); static QString defaultStandardButtonText(int button); diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index d47e620fbb..27c071a8cd 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -74,6 +74,7 @@ public: QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; QString standardButtonText(int button) const Q_DECL_OVERRIDE; + QKeySequence standardButtonShortcut(int button) const Q_DECL_OVERRIDE; static const char *name; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 4d74c11581..d2345f9abc 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -344,6 +344,12 @@ QString QCocoaTheme::standardButtonText(int button) const return button == QPlatformDialogHelper::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button); } +QKeySequence QCocoaTheme::standardButtonShortcut(int button) const +{ + return button == QPlatformDialogHelper::Discard ? QKeySequence(Qt::CTRL | Qt::Key_Delete) + : QPlatformTheme::standardButtonShortcut(button); +} + QPlatformMenuItem *QCocoaTheme::createPlatformMenuItem() const { return new QCocoaMenuItem(); diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 23158cf82f..61ef8e8c93 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -411,12 +411,7 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut else addButton(button, static_cast<QDialogButtonBox::ButtonRole>(role), doLayout); -#if 0 // Used to be included in Qt4 for Q_WS_MAC - // Since mnemonics is off by default on Mac, we add a Cmd-D - // shortcut here to e.g. make the "Don't Save" button work nativly: - if (sbutton == QDialogButtonBox::Discard) - button->setShortcut(QKeySequence(QLatin1String("Ctrl+D"))); -#endif + button->setShortcut(QGuiApplicationPrivate::platformTheme()->standardButtonShortcut(sbutton)); return button; } |