macOS: Move translations to their respective source files
lupdate can deal with Objective-C++ sources nowadays, most likely due to appending them to SOURCES instead of the deprecated OBJECTIVE_SOURCES. Task-number: QTBUG-30125 Change-Id: Ifc6b06f13e0f679a011d999f11c2e6d25dcf27ed Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
bfb9b02d3b
commit
10c1625cd8
@ -31,8 +31,7 @@ SOURCES += main.mm \
|
|||||||
qcocoaintrospection.mm \
|
qcocoaintrospection.mm \
|
||||||
qcocoakeymapper.mm \
|
qcocoakeymapper.mm \
|
||||||
qcocoamimetypes.mm \
|
qcocoamimetypes.mm \
|
||||||
qiosurfacegraphicsbuffer.mm \
|
qiosurfacegraphicsbuffer.mm
|
||||||
messages.cpp
|
|
||||||
|
|
||||||
HEADERS += qcocoaintegration.h \
|
HEADERS += qcocoaintegration.h \
|
||||||
qcocoascreen.h \
|
qcocoascreen.h \
|
||||||
@ -63,7 +62,6 @@ HEADERS += qcocoaintegration.h \
|
|||||||
qcocoasystemtrayicon.h \
|
qcocoasystemtrayicon.h \
|
||||||
qcocoaintrospection.h \
|
qcocoaintrospection.h \
|
||||||
qcocoakeymapper.h \
|
qcocoakeymapper.h \
|
||||||
messages.h \
|
|
||||||
qiosurfacegraphicsbuffer.h \
|
qiosurfacegraphicsbuffer.h \
|
||||||
qcocoamimetypes.h
|
qcocoamimetypes.h
|
||||||
|
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2018 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 3 requirements
|
|
||||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 2.0 or (at your option) the GNU General
|
|
||||||
** Public license version 3 or any later version approved by the KDE Free
|
|
||||||
** Qt Foundation. The licenses are as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
||||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "messages.h"
|
|
||||||
|
|
||||||
#include <QtCore/qcoreapplication.h>
|
|
||||||
#include <QtCore/qregularexpression.h>
|
|
||||||
|
|
||||||
// Translatable messages should go into this .cpp file for them to be picked up by lupdate.
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
QString msgAboutQt()
|
|
||||||
{
|
|
||||||
return QCoreApplication::translate("QCocoaMenuItem", "About Qt");
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *application_menu_strings[] =
|
|
||||||
{
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
|
|
||||||
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1")
|
|
||||||
};
|
|
||||||
|
|
||||||
QString qt_mac_applicationmenu_string(int type)
|
|
||||||
{
|
|
||||||
QString menuString = QString::fromLatin1(application_menu_strings[type]);
|
|
||||||
const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]);
|
|
||||||
if (translated != menuString) {
|
|
||||||
return translated;
|
|
||||||
} else {
|
|
||||||
return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
|
|
||||||
{
|
|
||||||
QString captionNoAmpersand(caption);
|
|
||||||
captionNoAmpersand.remove(QLatin1Char('&'));
|
|
||||||
const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
|
|
||||||
if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) {
|
|
||||||
static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption);
|
|
||||||
if (captionNoAmpersand.contains(qtRegExp))
|
|
||||||
return QPlatformMenuItem::AboutQtRole;
|
|
||||||
return QPlatformMenuItem::AboutRole;
|
|
||||||
}
|
|
||||||
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
|
|
||||||
return QPlatformMenuItem::PreferencesRole;
|
|
||||||
}
|
|
||||||
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive)
|
|
||||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) {
|
|
||||||
return QPlatformMenuItem::QuitRole;
|
|
||||||
}
|
|
||||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive))
|
|
||||||
return QPlatformMenuItem::CutRole;
|
|
||||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive))
|
|
||||||
return QPlatformMenuItem::CopyRole;
|
|
||||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive))
|
|
||||||
return QPlatformMenuItem::PasteRole;
|
|
||||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive))
|
|
||||||
return QPlatformMenuItem::SelectAllRole;
|
|
||||||
return QPlatformMenuItem::NoRole;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString msgDialogButtonDiscard()
|
|
||||||
{
|
|
||||||
return QCoreApplication::translate("QCocoaTheme", "Don't Save");
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
@ -1,69 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2018 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:LGPL$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
|
||||||
** packaging of this file. Please review the following information to
|
|
||||||
** ensure the GNU Lesser General Public License version 3 requirements
|
|
||||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 2.0 or (at your option) the GNU General
|
|
||||||
** Public license version 3 or any later version approved by the KDE Free
|
|
||||||
** Qt Foundation. The licenses are as published by the Free Software
|
|
||||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
|
||||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MESSAGES_H
|
|
||||||
#define MESSAGES_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <qpa/qplatformmenu.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
enum {
|
|
||||||
AboutAppMenuItem = 0,
|
|
||||||
PreferencesAppMenuItem,
|
|
||||||
ServicesAppMenuItem,
|
|
||||||
HideAppMenuItem,
|
|
||||||
HideOthersAppMenuItem,
|
|
||||||
ShowAllAppMenuItem,
|
|
||||||
QuitAppMenuItem
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
QString msgAboutQt();
|
|
||||||
|
|
||||||
QString qt_mac_applicationmenu_string(int type);
|
|
||||||
|
|
||||||
QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption);
|
|
||||||
|
|
||||||
QString msgDialogButtonDiscard();
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // MESSAGES_H
|
|
@ -53,6 +53,18 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AboutAppMenuItem = 0,
|
||||||
|
PreferencesAppMenuItem,
|
||||||
|
ServicesAppMenuItem,
|
||||||
|
HideAppMenuItem,
|
||||||
|
HideOthersAppMenuItem,
|
||||||
|
ShowAllAppMenuItem,
|
||||||
|
QuitAppMenuItem
|
||||||
|
};
|
||||||
|
|
||||||
|
QString qt_mac_applicationmenu_string(int type);
|
||||||
|
|
||||||
class QCocoaMenu;
|
class QCocoaMenu;
|
||||||
|
|
||||||
class QCocoaMenuObject
|
class QCocoaMenuObject
|
||||||
|
@ -45,18 +45,40 @@
|
|||||||
#include "qcocoansmenu.h"
|
#include "qcocoansmenu.h"
|
||||||
#include "qcocoamenu.h"
|
#include "qcocoamenu.h"
|
||||||
#include "qcocoamenubar.h"
|
#include "qcocoamenubar.h"
|
||||||
#include "messages.h"
|
|
||||||
#include "qcocoahelpers.h"
|
#include "qcocoahelpers.h"
|
||||||
#include "qt_mac_p.h"
|
#include "qt_mac_p.h"
|
||||||
#include "qcocoaapplication.h" // for custom application category
|
#include "qcocoaapplication.h" // for custom application category
|
||||||
#include "qcocoamenuloader.h"
|
#include "qcocoamenuloader.h"
|
||||||
#include <QtGui/private/qcoregraphics_p.h>
|
#include <QtGui/private/qcoregraphics_p.h>
|
||||||
|
#include <QtCore/qregularexpression.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QRegExp>
|
#include <QtCore/QRegExp>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
static const char *application_menu_strings[] =
|
||||||
|
{
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1"),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
|
||||||
|
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1")
|
||||||
|
};
|
||||||
|
|
||||||
|
QString qt_mac_applicationmenu_string(int type)
|
||||||
|
{
|
||||||
|
QString menuString = QString::fromLatin1(application_menu_strings[type]);
|
||||||
|
const QString translated = QCoreApplication::translate("QMenuBar", application_menu_strings[type]);
|
||||||
|
if (translated != menuString) {
|
||||||
|
return translated;
|
||||||
|
} else {
|
||||||
|
return QCoreApplication::translate("MAC_APPLICATION_MENU", application_menu_strings[type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static quint32 constructModifierMask(quint32 accel_key)
|
static quint32 constructModifierMask(quint32 accel_key)
|
||||||
{
|
{
|
||||||
quint32 ret = 0;
|
quint32 ret = 0;
|
||||||
@ -226,6 +248,40 @@ void QCocoaMenuItem::setNativeContents(WId item)
|
|||||||
m_itemView.needsDisplay = YES;
|
m_itemView.needsDisplay = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
|
||||||
|
{
|
||||||
|
QString captionNoAmpersand(caption);
|
||||||
|
captionNoAmpersand.remove(QLatin1Char('&'));
|
||||||
|
const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
|
||||||
|
if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) {
|
||||||
|
static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption);
|
||||||
|
if (captionNoAmpersand.contains(qtRegExp))
|
||||||
|
return QPlatformMenuItem::AboutQtRole;
|
||||||
|
return QPlatformMenuItem::AboutRole;
|
||||||
|
}
|
||||||
|
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
|
||||||
|
return QPlatformMenuItem::PreferencesRole;
|
||||||
|
}
|
||||||
|
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive)
|
||||||
|
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) {
|
||||||
|
return QPlatformMenuItem::QuitRole;
|
||||||
|
}
|
||||||
|
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive))
|
||||||
|
return QPlatformMenuItem::CutRole;
|
||||||
|
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive))
|
||||||
|
return QPlatformMenuItem::CopyRole;
|
||||||
|
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive))
|
||||||
|
return QPlatformMenuItem::PasteRole;
|
||||||
|
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive))
|
||||||
|
return QPlatformMenuItem::SelectAllRole;
|
||||||
|
return QPlatformMenuItem::NoRole;
|
||||||
|
}
|
||||||
|
|
||||||
NSMenuItem *QCocoaMenuItem::sync()
|
NSMenuItem *QCocoaMenuItem::sync()
|
||||||
{
|
{
|
||||||
if (m_isSeparator != m_native.separatorItem) {
|
if (m_isSeparator != m_native.separatorItem) {
|
||||||
@ -354,7 +410,7 @@ QString QCocoaMenuItem::mergeText()
|
|||||||
return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName());
|
return qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName());
|
||||||
} else if (m_native== [loader aboutQtMenuItem]) {
|
} else if (m_native== [loader aboutQtMenuItem]) {
|
||||||
if (m_text == QString("About Qt"))
|
if (m_text == QString("About Qt"))
|
||||||
return msgAboutQt();
|
return QCoreApplication::translate("QCocoaMenuItem", "About Qt");
|
||||||
else
|
else
|
||||||
return m_text;
|
return m_text;
|
||||||
} else if (m_native == [loader preferencesMenuItem]) {
|
} else if (m_native == [loader preferencesMenuItem]) {
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
|
|
||||||
#include "qcocoamenuloader.h"
|
#include "qcocoamenuloader.h"
|
||||||
|
|
||||||
#include "messages.h"
|
|
||||||
#include "qcocoahelpers.h"
|
#include "qcocoahelpers.h"
|
||||||
#include "qcocoansmenu.h"
|
#include "qcocoansmenu.h"
|
||||||
#include "qcocoamenubar.h"
|
#include "qcocoamenubar.h"
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
#include "qcocoatheme.h"
|
#include "qcocoatheme.h"
|
||||||
#include "messages.h"
|
|
||||||
|
|
||||||
#include <QtCore/QOperatingSystemVersion>
|
#include <QtCore/QOperatingSystemVersion>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
@ -547,7 +546,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
|||||||
|
|
||||||
QString QCocoaTheme::standardButtonText(int button) const
|
QString QCocoaTheme::standardButtonText(int button) const
|
||||||
{
|
{
|
||||||
return button == QPlatformDialogHelper::Discard ? msgDialogButtonDiscard() : QPlatformTheme::standardButtonText(button);
|
return button == QPlatformDialogHelper::Discard ?
|
||||||
|
QCoreApplication::translate("QCocoaTheme", "Don't Save")
|
||||||
|
: QPlatformTheme::standardButtonText(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
QKeySequence QCocoaTheme::standardButtonShortcut(int button) const
|
QKeySequence QCocoaTheme::standardButtonShortcut(int button) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user