Add QPlatformTheme::standardButtonShortcut()
It allows to set shortcuts for the standard buttons in QDialogButtonBox. Restore Qt4's behavior for the "Don't Save" button on macOS by setting a shortcut for it (it was Cmd-D before Lion, now it's Cmd-Delete). Change-Id: I6b56f68f37670962178693a8983d9fe550540856 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
2f103bde11
commit
de63bbd2f8
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue