summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-08-18 07:34:26 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-08-19 15:01:45 +0200
commitade59ea316dc17ff6c25fb10939a03008a70c11b (patch)
treea26e996775524f3cdb1ccfea4429d23d546d6210 /src/plugins
parente93ec716bf839686f7ffffc33958d90a58725e9b (diff)
Cocoa: Translate the buttons used for the native font and color dialogs
Use the QPlatformDialogHelper standard buttons to get the translated button text as then this will already have been translated for those loading a translation. Pick-to: 5.15 5.12 Fixes: QTBUG-85725 Change-Id: Ia42d93aeb6e1b5c0528564a6c960a35f6710c8eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm10
2 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index d85db6d9e1..d78aaadd4e 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -55,6 +55,7 @@
#include <QtCore/qloggingcategory.h>
#include <QtGui/qpalette.h>
#include <QtGui/qscreen.h>
+#include <qpa/qplatformdialoghelper.h>
#include <objc/runtime.h>
#include <objc/message.h>
@@ -211,7 +212,7 @@ QT_END_NAMESPACE
- (instancetype)initWithPanelDelegate:(id<QNSPanelDelegate>)panelDelegate;
- (void)dealloc;
-- (NSButton *)createButtonWithTitle:(const char *)title;
+- (NSButton *)createButtonWithTitle:(QPlatformDialogHelper::StandardButton)type;
- (void)layout;
@end
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 446c23be81..3e37010497 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -392,11 +392,10 @@ QT_END_NAMESPACE
{
if ((self = [super initWithFrame:NSZeroRect])) {
// create OK and Cancel buttons and add these as subviews
- _okButton = [self createButtonWithTitle:"&OK"];
+ _okButton = [self createButtonWithTitle:QPlatformDialogHelper::Ok];
_okButton.action = @selector(onOkClicked);
_okButton.target = panelDelegate;
-
- _cancelButton = [self createButtonWithTitle:"Cancel"];
+ _cancelButton = [self createButtonWithTitle:QPlatformDialogHelper::Cancel];
_cancelButton.action = @selector(onCancelClicked);
_cancelButton.target = panelDelegate;
@@ -420,12 +419,13 @@ QT_END_NAMESPACE
[super dealloc];
}
-- (NSButton *)createButtonWithTitle:(const char *)title
+- (NSButton *)createButtonWithTitle:(QPlatformDialogHelper::StandardButton)type
{
NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
button.buttonType = NSButtonTypeMomentaryLight;
button.bezelStyle = NSBezelStyleRounded;
- const QString &cleanTitle = QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", title));
+ const QString &cleanTitle =
+ QPlatformTheme::removeMnemonics(QGuiApplicationPrivate::platformTheme()->standardButtonText(type));
// FIXME: Not obvious, from Cocoa's documentation, that QString::toNSString() makes a deep copy
button.title = (NSString *)cleanTitle.toCFString();
((NSButtonCell *)button.cell).font =