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. Fixes: QTBUG-85725 Change-Id: Ia42d93aeb6e1b5c0528564a6c960a35f6710c8eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit ade59ea316dc17ff6c25fb10939a03008a70c11b)
This commit is contained in:
parent
f919d9a2da
commit
ee55cd6b0c
@ -55,6 +55,7 @@
|
|||||||
#include <QtCore/qoperatingsystemversion.h>
|
#include <QtCore/qoperatingsystemversion.h>
|
||||||
#include <QtGui/qpalette.h>
|
#include <QtGui/qpalette.h>
|
||||||
#include <QtGui/qscreen.h>
|
#include <QtGui/qscreen.h>
|
||||||
|
#include <qpa/qplatformdialoghelper.h>
|
||||||
|
|
||||||
#include <objc/runtime.h>
|
#include <objc/runtime.h>
|
||||||
#include <objc/message.h>
|
#include <objc/message.h>
|
||||||
@ -199,7 +200,7 @@ QT_END_NAMESPACE
|
|||||||
- (instancetype)initWithPanelDelegate:(id<QNSPanelDelegate>)panelDelegate;
|
- (instancetype)initWithPanelDelegate:(id<QNSPanelDelegate>)panelDelegate;
|
||||||
- (void)dealloc;
|
- (void)dealloc;
|
||||||
|
|
||||||
- (NSButton *)createButtonWithTitle:(const char *)title;
|
- (NSButton *)createButtonWithTitle:(QPlatformDialogHelper::StandardButton)type;
|
||||||
- (void)layout;
|
- (void)layout;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -394,11 +394,10 @@ QT_END_NAMESPACE
|
|||||||
{
|
{
|
||||||
if ((self = [super initWithFrame:NSZeroRect])) {
|
if ((self = [super initWithFrame:NSZeroRect])) {
|
||||||
// create OK and Cancel buttons and add these as subviews
|
// create OK and Cancel buttons and add these as subviews
|
||||||
_okButton = [self createButtonWithTitle:"&OK"];
|
_okButton = [self createButtonWithTitle:QPlatformDialogHelper::Ok];
|
||||||
_okButton.action = @selector(onOkClicked);
|
_okButton.action = @selector(onOkClicked);
|
||||||
_okButton.target = panelDelegate;
|
_okButton.target = panelDelegate;
|
||||||
|
_cancelButton = [self createButtonWithTitle:QPlatformDialogHelper::Cancel];
|
||||||
_cancelButton = [self createButtonWithTitle:"Cancel"];
|
|
||||||
_cancelButton.action = @selector(onCancelClicked);
|
_cancelButton.action = @selector(onCancelClicked);
|
||||||
_cancelButton.target = panelDelegate;
|
_cancelButton.target = panelDelegate;
|
||||||
|
|
||||||
@ -422,12 +421,13 @@ QT_END_NAMESPACE
|
|||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSButton *)createButtonWithTitle:(const char *)title
|
- (NSButton *)createButtonWithTitle:(QPlatformDialogHelper::StandardButton)type
|
||||||
{
|
{
|
||||||
NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
button.buttonType = NSMomentaryLightButton;
|
button.buttonType = NSMomentaryLightButton;
|
||||||
button.bezelStyle = NSRoundedBezelStyle;
|
button.bezelStyle = NSRoundedBezelStyle;
|
||||||
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
|
// FIXME: Not obvious, from Cocoa's documentation, that QString::toNSString() makes a deep copy
|
||||||
button.title = (NSString *)cleanTitle.toCFString();
|
button.title = (NSString *)cleanTitle.toCFString();
|
||||||
((NSButtonCell *)button.cell).font =
|
((NSButtonCell *)button.cell).font =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user