qml: introduce QmlMultiLanguageAspect

This aspect is only available if the special multilanguage
plugin is available.
Translation changes in that plugin changes this aspect,
which results in environment variables which activate the use
of a multilanguage created sqlite to provide the translations.

Change-Id: I38250b69165eb7ec3e4f82dc34b3cc4ba0a33f8f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tim Jenssen
2020-06-18 08:49:29 +02:00
parent aaf51d1cfb
commit 52316578f8
15 changed files with 264 additions and 53 deletions

View File

@@ -83,6 +83,10 @@
#include <coreplugin/documentmanager.h> #include <coreplugin/documentmanager.h>
#endif #endif
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlmultilanguageaspect.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -542,7 +546,12 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
} }
} else if (node.isRootNode() && name == "language@Internal") { } else if (node.isRootNode() && name == "language@Internal") {
const QString languageAsString = value.toString(); const QString languageAsString = value.toString();
DesignerSettings::setValue(DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE, languageAsString); if (m_currentTarget) {
if (auto rc = m_currentTarget->activeRunConfiguration()) {
if (auto multiLanguageAspect = rc->aspect<QmlProjectManager::QmlMultiLanguageAspect>())
multiLanguageAspect->setLastUsedLanguage(languageAsString);
}
}
nodeInstanceServer()->changeLanguage({languageAsString}); nodeInstanceServer()->changeLanguage({languageAsString});
} else if (node.isRootNode() && name == "previewSize@Internal") { } else if (node.isRootNode() && name == "previewSize@Internal") {
nodeInstanceServer()->changePreviewImageSize(value.toSize()); nodeInstanceServer()->changePreviewImageSize(value.toSize());
@@ -984,6 +993,13 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
} }
} }
QString lastUsedLanguage;
if (m_currentTarget) {
if (auto rc = m_currentTarget->activeRunConfiguration()) {
if (auto multiLanguageAspect = rc->aspect<QmlProjectManager::QmlMultiLanguageAspect>())
lastUsedLanguage = multiLanguageAspect->lastUsedLanguage();
}
}
return CreateSceneCommand( return CreateSceneCommand(
instanceContainerList, instanceContainerList,
@@ -996,7 +1012,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
mockupTypesVector, mockupTypesVector,
model()->fileUrl(), model()->fileUrl(),
m_edit3DToolStates[model()->fileUrl()], m_edit3DToolStates[model()->fileUrl()],
DesignerSettings::getValue(DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE).toString() lastUsedLanguage
); );
} }

View File

@@ -36,17 +36,20 @@
#include <app/app_version.h> #include <app/app_version.h>
#include <coreplugin/messagebox.h>
#include <coreplugin/icore.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <coreplugin/messagebox.h>
#include <coreplugin/icore.h> #include <qmlprojectmanager/qmlmultilanguageaspect.h>
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtsupportconstants.h> #include <qtsupport/qtsupportconstants.h>
#include <coreplugin/icore.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/environment.h> #include <utils/environment.h>
@@ -162,18 +165,6 @@ QString PuppetCreator::getStyleConfigFileName() const
return QString(); return QString();
} }
QString PuppetCreator::getMultilanguageDatabaseFilePath() const
{
#ifndef QMLDESIGNER_TEST
if (m_target) {
auto filePath = m_target->project()->projectDirectory().pathAppended("/multilanguage-experimental-v1.db");
if (filePath.exists())
return filePath.toString();
}
#endif
return {};
}
PuppetCreator::PuppetCreator(ProjectExplorer::Target *target, const Model *model) PuppetCreator::PuppetCreator(ProjectExplorer::Target *target, const Model *model)
: m_target(target) : m_target(target)
@@ -494,11 +485,6 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
environment.set("QMLDESIGNER_RC_PATHS", m_qrcMapping); environment.set("QMLDESIGNER_RC_PATHS", m_qrcMapping);
} }
const QString multilanguageDatabaseFilePath = getMultilanguageDatabaseFilePath();
if (!multilanguageDatabaseFilePath.isEmpty())
environment.set("QT_MULTILANGUAGE_DATABASE", multilanguageDatabaseFilePath);
#ifndef QMLDESIGNER_TEST #ifndef QMLDESIGNER_TEST
auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView(); auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
view->emitCustomNotification("PuppetStatus", {}, {QVariant(m_qrcMapping)}); view->emitCustomNotification("PuppetStatus", {}, {QVariant(m_qrcMapping)});
@@ -525,6 +511,13 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
importPaths.append(designerImports); importPaths.append(designerImports);
customFileSelectors = m_target->additionalData("CustomFileSelectorsData").toStringList(); customFileSelectors = m_target->additionalData("CustomFileSelectorsData").toStringList();
if (auto *rc = m_target->activeRunConfiguration()) {
if (auto multiLanguageAspect = rc->aspect<QmlProjectManager::QmlMultiLanguageAspect>()) {
if (!multiLanguageAspect->databaseFilePath().isEmpty())
environment.set("QT_MULTILANGUAGE_DATABASE", multiLanguageAspect->databaseFilePath().toString());
}
}
} }
customFileSelectors.append("DesignMode"); customFileSelectors.append("DesignMode");

View File

@@ -102,7 +102,6 @@ protected:
bool useOnlyFallbackPuppet() const; bool useOnlyFallbackPuppet() const;
QString getStyleConfigFileName() const; QString getStyleConfigFileName() const;
QString getMultilanguageDatabaseFilePath() const;
private: private:
mutable QString m_compileLog; mutable QString m_compileLog;

View File

@@ -85,7 +85,6 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList()); restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList());
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true); restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true); restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true);
restoreValue(settings, DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE, "en");
settings->endGroup(); settings->endGroup();
settings->endGroup(); settings->endGroup();

View File

@@ -69,7 +69,6 @@ const char ENABLE_TIMELINEVIEW[] = "EnableTimelineView";
const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent"; const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent";
const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode"; const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer"; const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
const char LAST_USED_TRANSLATION_LANGUAGE[] = "LastUsedTranslationLanguage";
} }
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant> class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>

View File

@@ -11,6 +11,7 @@ QTC_PLUGIN_DEPENDS += \
qtsupport \ qtsupport \
projectexplorer \ projectexplorer \
qmakeprojectmanager \ qmakeprojectmanager \
qmlprojectmanager \
resourceeditor resourceeditor
INCLUDEPATH *= \ INCLUDEPATH *= \

View File

@@ -48,13 +48,11 @@ const Utils::Icon previewIcon({
static void handleAction(const SelectionContext &context) static void handleAction(const SelectionContext &context)
{ {
if (context.view()->isAttached()) { if (context.view()->isAttached()) {
if (context.toggled()) { if (context.toggled())
QmlPreviewPlugin::setLanguageLocale(DesignerSettings::getValue(DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE).toString());
ProjectExplorerPlugin::runStartupProject(Constants::QML_PREVIEW_RUN_MODE); ProjectExplorerPlugin::runStartupProject(Constants::QML_PREVIEW_RUN_MODE);
} else { else
QmlPreviewPlugin::stopAllRunControls(); QmlPreviewPlugin::stopAllRunControls();
} }
}
} }
QmlPreviewAction::QmlPreviewAction() : ModelNodeAction("LivePreview", QmlPreviewAction::QmlPreviewAction() : ModelNodeAction("LivePreview",

View File

@@ -27,6 +27,7 @@
#include <qmlprojectmanager/qmlproject.h> #include <qmlprojectmanager/qmlproject.h>
#include <qmlprojectmanager/qmlmainfileaspect.h> #include <qmlprojectmanager/qmlmainfileaspect.h>
#include <qmlprojectmanager/qmlmultilanguageaspect.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
@@ -152,10 +153,9 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
} }
} }
if (runControl->project()) { if (auto multiLanguageAspect = runControl->aspect<QmlProjectManager::QmlMultiLanguageAspect>()) {
auto multilanguageDatabaseFilePath = runControl->project()->projectDirectory().pathAppended("/multilanguage-experimental-v1.db"); if (!multiLanguageAspect->databaseFilePath().isEmpty())
if (multilanguageDatabaseFilePath.exists()) runnable.environment.set("QT_MULTILANGUAGE_DATABASE", multiLanguageAspect->databaseFilePath().toString());
runnable.environment.set("QT_MULTILANGUAGE_DATABASE", multilanguageDatabaseFilePath.toString());
} }
Utils::QtcProcess::addArg(&runnable.commandLineArguments, Utils::QtcProcess::addArg(&runnable.commandLineArguments,

View File

@@ -6,6 +6,7 @@ add_qtc_plugin(QmlProjectManager
fileformat/qmlprojectfileformat.cpp fileformat/qmlprojectfileformat.h fileformat/qmlprojectfileformat.cpp fileformat/qmlprojectfileformat.h
fileformat/qmlprojectitem.cpp fileformat/qmlprojectitem.h fileformat/qmlprojectitem.cpp fileformat/qmlprojectitem.h
qmlmainfileaspect.cpp qmlmainfileaspect.h qmlmainfileaspect.cpp qmlmainfileaspect.h
qmlmultilanguageaspect.cpp qmlmultilanguageaspect.h
qmlproject.cpp qmlproject.h qmlproject.cpp qmlproject.h
qmlproject.qrc qmlproject.qrc
qmlprojectconstants.h qmlprojectconstants.h

View File

@@ -0,0 +1,128 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** 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-3.0.html.
**
****************************************************************************/
#include "qmlmultilanguageaspect.h"
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
static bool isMultilanguagePresent()
{
const QVector<ExtensionSystem::PluginSpec *> specs = ExtensionSystem::PluginManager::plugins();
return std::find_if(specs.begin(),
specs.end(),
[](ExtensionSystem::PluginSpec *spec) {
return spec->name() == "MultiLanguage";
})
!= specs.end();
}
static Utils::FilePath getMultilanguageDatabaseFilePath(ProjectExplorer::Target *target)
{
if (target) {
auto filePath = target->project()->projectDirectory().pathAppended("/multilanguage-experimental-v1.db");
if (filePath.exists())
return filePath;
}
return {};
}
static QObject *getPreviewPlugin()
{
auto pluginIt = std::find_if(ExtensionSystem::PluginManager::plugins().begin(),
ExtensionSystem::PluginManager::plugins().end(),
[](const ExtensionSystem::PluginSpec *p) {
return p->name() == "QmlPreview";
});
if (pluginIt != ExtensionSystem::PluginManager::plugins().constEnd())
return (*pluginIt)->plugin();
return nullptr;
}
namespace QmlProjectManager {
QmlMultiLanguageAspect::QmlMultiLanguageAspect(ProjectExplorer::Target *target)
: m_target(target)
{
setVisible(isMultilanguagePresent());
setSettingsKey(Constants::USE_MULTILANGUAGE_KEY);
setLabel(tr("Use MultiLanguage translation database."), BaseBoolAspect::LabelPlacement::AtCheckBox);
setToolTip(tr("Enable loading application with special desktop SQLite translation database."));
setDefaultValue(!databaseFilePath().isEmpty());
QVariantMap getDefaultValues;
fromMap(getDefaultValues);
if (auto previewPlugin = getPreviewPlugin())
connect(previewPlugin, SIGNAL(localeChanged(QString)), this, SLOT(setLastUsedLanguage(QString)));
}
QmlMultiLanguageAspect::~QmlMultiLanguageAspect()
{
}
void QmlMultiLanguageAspect::setLastUsedLanguage(const QString &language)
{
if (auto previewPlugin = getPreviewPlugin())
previewPlugin->setProperty("locale", language);
if (m_lastUsedLanguage != language) {
m_lastUsedLanguage = language;
emit changed();
}
}
QString QmlMultiLanguageAspect::lastUsedLanguage() const
{
return m_lastUsedLanguage;
}
Utils::FilePath QmlMultiLanguageAspect::databaseFilePath() const
{
if (m_databaseFilePath.isEmpty())
m_databaseFilePath = getMultilanguageDatabaseFilePath(m_target);
return m_databaseFilePath;
}
void QmlMultiLanguageAspect::toMap(QVariantMap &map) const
{
BaseBoolAspect::toMap(map);
if (!m_lastUsedLanguage.isEmpty())
map.insert(Constants::LAST_USED_LANGUAGE, m_lastUsedLanguage);
}
void QmlMultiLanguageAspect::fromMap(const QVariantMap &map)
{
BaseBoolAspect::fromMap(map);
setLastUsedLanguage(map.value(Constants::LAST_USED_LANGUAGE, "en").toString());
}
} // namespace QmlProjectManager

View File

@@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** 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-3.0.html.
**
****************************************************************************/
#pragma once
#include "qmlprojectmanager_global.h"
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
#include <projectexplorer/runconfigurationaspects.h>
namespace QmlProjectManager {
class QMLPROJECTMANAGER_EXPORT QmlMultiLanguageAspect : public ProjectExplorer::BaseBoolAspect
{
Q_OBJECT
public:
explicit QmlMultiLanguageAspect(ProjectExplorer::Target *target);
~QmlMultiLanguageAspect() override;
QString lastUsedLanguage() const;
Utils::FilePath databaseFilePath() const;
void toMap(QVariantMap &map) const final;
void fromMap(const QVariantMap &map) final;
public slots:
void setLastUsedLanguage(const QString &language);
private:
ProjectExplorer::Target *m_target = nullptr;
mutable Utils::FilePath m_databaseFilePath;
QString m_lastUsedLanguage;
};
} // namespace QmlProjectManager

View File

@@ -7,6 +7,7 @@ DEFINES += QMLPROJECTMANAGER_LIBRARY
HEADERS += \ HEADERS += \
qmlmainfileaspect.h \ qmlmainfileaspect.h \
qmlmultilanguageaspect.h \
qmlproject.h \ qmlproject.h \
qmlprojectplugin.h \ qmlprojectplugin.h \
qmlprojectconstants.h \ qmlprojectconstants.h \
@@ -17,6 +18,7 @@ HEADERS += \
SOURCES += \ SOURCES += \
qmlmainfileaspect.cpp \ qmlmainfileaspect.cpp \
qmlmultilanguageaspect.cpp \
qmlproject.cpp \ qmlproject.cpp \
qmlprojectplugin.cpp \ qmlprojectplugin.cpp \
qmlprojectnodes.cpp \ qmlprojectnodes.cpp \

View File

@@ -16,6 +16,7 @@ QtcPlugin {
name: "General" name: "General"
files: [ files: [
"qmlmainfileaspect.cpp", "qmlmainfileaspect.h", "qmlmainfileaspect.cpp", "qmlmainfileaspect.h",
"qmlmultilanguageaspect.cpp", "qmlmultilanguageaspect.h",
"qmlproject.cpp", "qmlproject.h", "qmlproject.cpp", "qmlproject.h",
"qmlproject.qrc", "qmlproject.qrc",
"qmlprojectconstants.h", "qmlprojectconstants.h",

View File

@@ -34,6 +34,8 @@ const char QML_PROJECT_ID[] = "QmlProjectManager.QmlProject";
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments"; const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer"; const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer";
const char QML_MAINSCRIPT_KEY[] = "QmlProjectManager.QmlRunConfiguration.MainScript"; const char QML_MAINSCRIPT_KEY[] = "QmlProjectManager.QmlRunConfiguration.MainScript";
const char USE_MULTILANGUAGE_KEY[] = "QmlProjectManager.QmlRunConfiguration.UseMultiLanguage";
const char LAST_USED_LANGUAGE[] = "QmlProjectManager.QmlRunConfiguration.LastUsedLanguage";
const char USER_ENVIRONMENT_CHANGES_KEY[] = "QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges"; const char USER_ENVIRONMENT_CHANGES_KEY[] = "QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges";
} // namespace Constants } // namespace Constants

View File

@@ -27,7 +27,7 @@
#include "qmlproject.h" #include "qmlproject.h"
#include "qmlprojectmanagerconstants.h" #include "qmlprojectmanagerconstants.h"
#include "qmlmainfileaspect.h" #include "qmlmainfileaspect.h"
#include "qmlmainfileaspect.h" #include "qmlmultilanguageaspect.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
@@ -59,6 +59,7 @@ using namespace QtSupport;
using namespace Utils; using namespace Utils;
namespace QmlProjectManager { namespace QmlProjectManager {
class QmlMultiLanguageAspect;
namespace Internal { namespace Internal {
// QmlProjectRunConfiguration // QmlProjectRunConfiguration
@@ -81,30 +82,12 @@ private:
BaseStringAspect *m_qmlViewerAspect = nullptr; BaseStringAspect *m_qmlViewerAspect = nullptr;
QmlMainFileAspect *m_qmlMainFileAspect = nullptr; QmlMainFileAspect *m_qmlMainFileAspect = nullptr;
QmlMultiLanguageAspect *m_multiLanguageAspect = nullptr;
}; };
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<EnvironmentAspect>();
auto envModifier = [this](Environment env) {
if (auto bs = dynamic_cast<const QmlBuildSystem *>(activeBuildSystem()))
env.modify(bs->environment());
return env;
};
const Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target->kit());
if (deviceTypeId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
envAspect->addPreferredBaseEnvironment(tr("System Environment"), [envModifier] {
return envModifier(Environment::systemEnvironment());
});
}
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), [envModifier] {
return envModifier(Environment());
});
m_qmlViewerAspect = addAspect<BaseStringAspect>(); m_qmlViewerAspect = addAspect<BaseStringAspect>();
m_qmlViewerAspect->setLabelText(tr("QML Viewer:")); m_qmlViewerAspect->setLabelText(tr("QML Viewer:"));
m_qmlViewerAspect->setPlaceHolderText(commandLine().executable().toString()); m_qmlViewerAspect->setPlaceHolderText(commandLine().executable().toString());
@@ -123,6 +106,34 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
connect(target, &Target::kitChanged, this, &RunConfiguration::update); connect(target, &Target::kitChanged, this, &RunConfiguration::update);
m_multiLanguageAspect = addAspect<QmlMultiLanguageAspect>(target);
auto envAspect = addAspect<EnvironmentAspect>();
connect(m_multiLanguageAspect, &QmlMultiLanguageAspect::changed, envAspect, &EnvironmentAspect::environmentChanged);
auto envModifier = [this](Environment env) {
if (auto bs = dynamic_cast<const QmlBuildSystem *>(activeBuildSystem()))
env.modify(bs->environment());
if (m_multiLanguageAspect && m_multiLanguageAspect->value() && !m_multiLanguageAspect->databaseFilePath().isEmpty()) {
env.set("QT_MULTILANGUAGE_DATABASE", m_multiLanguageAspect->databaseFilePath().toString());
env.set("QT_MULTILANGUAGE_LANGUAGE", m_multiLanguageAspect->lastUsedLanguage());
}
return env;
};
const Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target->kit());
if (deviceTypeId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
envAspect->addPreferredBaseEnvironment(tr("System Environment"), [envModifier] {
return envModifier(Environment::systemEnvironment());
});
}
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), [envModifier] {
Environment environment;
return envModifier(environment);
});
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name.")); setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
update(); update();
} }
@@ -208,6 +219,10 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
const QString main = bs->targetFile(FilePath::fromString(mainScript())).toString(); const QString main = bs->targetFile(FilePath::fromString(mainScript())).toString();
if (!main.isEmpty()) if (!main.isEmpty())
QtcProcess::addArg(&args, main, osType); QtcProcess::addArg(&args, main, osType);
if (m_multiLanguageAspect && m_multiLanguageAspect->value())
QtcProcess::addArg(&args, "-qmljsdebugger=file:unused_if_debugger_arguments_added,services:DebugTranslation", osType);
return args; return args;
} }