forked from qt-creator/qt-creator
Fix ui language for custom wizards.
Introduces a ICore::userInterfaceLanguage method, which centralizes the previous qApp property hack for help and designer integration. Reviewed-by: Friedemann Kleint
This commit is contained in:
@@ -164,6 +164,11 @@ QPrinter *CoreImpl::printer() const
|
|||||||
return m_mainwindow->printer();
|
return m_mainwindow->printer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CoreImpl::userInterfaceLanguage() const
|
||||||
|
{
|
||||||
|
return qApp->property("qtc_locale").toString();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
# define SHARE_PATH "/../Resources"
|
# define SHARE_PATH "/../Resources"
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public:
|
|||||||
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
|
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
|
||||||
SettingsDatabase *settingsDatabase() const;
|
SettingsDatabase *settingsDatabase() const;
|
||||||
QPrinter *printer() const;
|
QPrinter *printer() const;
|
||||||
|
QString userInterfaceLanguage() const;
|
||||||
|
|
||||||
QString resourcePath() const;
|
QString resourcePath() const;
|
||||||
QString userResourcePath() const;
|
QString userResourcePath() const;
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ public:
|
|||||||
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
|
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
|
||||||
virtual SettingsDatabase *settingsDatabase() const = 0;
|
virtual SettingsDatabase *settingsDatabase() const = 0;
|
||||||
virtual QPrinter *printer() const = 0;
|
virtual QPrinter *printer() const = 0;
|
||||||
|
virtual QString userInterfaceLanguage() const = 0;
|
||||||
|
|
||||||
virtual QString resourcePath() const = 0;
|
virtual QString resourcePath() const = 0;
|
||||||
virtual QString userResourcePath() const = 0;
|
virtual QString userResourcePath() const = 0;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
addAutoReleasedObject(new FormEditorFactory);
|
addAutoReleasedObject(new FormEditorFactory);
|
||||||
|
|
||||||
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
// Ensure that loading designer translations is done before FormEditorW is instantiated
|
||||||
const QString locale = qApp->property("qtc_locale").toString();
|
const QString locale = Core::ICore::instance()->userInterfaceLanguage();
|
||||||
if (!locale.isEmpty()) {
|
if (!locale.isEmpty()) {
|
||||||
QTranslator *qtr = new QTranslator(this);
|
QTranslator *qtr = new QTranslator(this);
|
||||||
const QString &creatorTrPath =
|
const QString &creatorTrPath =
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
||||||
Core::Context modecontext(Constants::C_MODE_HELP);
|
Core::Context modecontext(Constants::C_MODE_HELP);
|
||||||
|
|
||||||
const QString &locale = qApp->property("qtc_locale").toString();
|
const QString &locale = m_core->userInterfaceLanguage();
|
||||||
if (!locale.isEmpty()) {
|
if (!locale.isEmpty()) {
|
||||||
QTranslator *qtr = new QTranslator(this);
|
QTranslator *qtr = new QTranslator(this);
|
||||||
QTranslator *qhelptr = new QTranslator(this);
|
QTranslator *qhelptr = new QTranslator(this);
|
||||||
|
|||||||
@@ -507,10 +507,9 @@ static inline QString attributeValue(const QXmlStreamReader &r, const char *name
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
|
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
|
||||||
static inline QString localeLanguage()
|
static inline QString languageSetting()
|
||||||
{
|
{
|
||||||
QLocale loc;
|
QString name = Core::ICore::instance()->userInterfaceLanguage();
|
||||||
QString name = loc.name();
|
|
||||||
const int underScorePos = name.indexOf(QLatin1Char('_'));
|
const int underScorePos = name.indexOf(QLatin1Char('_'));
|
||||||
if (underScorePos != -1)
|
if (underScorePos != -1)
|
||||||
name.truncate(underScorePos);
|
name.truncate(underScorePos);
|
||||||
@@ -538,7 +537,7 @@ CustomWizardParameters::ParseResult
|
|||||||
clear();
|
clear();
|
||||||
bp->clear();
|
bp->clear();
|
||||||
bp->setKind(Core::IWizard::ProjectWizard);
|
bp->setKind(Core::IWizard::ProjectWizard);
|
||||||
const QString language = localeLanguage();
|
const QString language = languageSetting();
|
||||||
CustomWizardField field;
|
CustomWizardField field;
|
||||||
do {
|
do {
|
||||||
token = reader.readNext();
|
token = reader.readNext();
|
||||||
|
|||||||
Reference in New Issue
Block a user