forked from qt-creator/qt-creator
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:
@@ -83,6 +83,10 @@
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#endif
|
||||
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlmultilanguageaspect.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -542,7 +546,12 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
|
||||
}
|
||||
} else if (node.isRootNode() && name == "language@Internal") {
|
||||
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});
|
||||
} else if (node.isRootNode() && name == "previewSize@Internal") {
|
||||
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(
|
||||
instanceContainerList,
|
||||
@@ -996,7 +1012,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
|
||||
mockupTypesVector,
|
||||
model()->fileUrl(),
|
||||
m_edit3DToolStates[model()->fileUrl()],
|
||||
DesignerSettings::getValue(DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE).toString()
|
||||
lastUsedLanguage
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -36,17 +36,20 @@
|
||||
|
||||
#include <app/app_version.h>
|
||||
|
||||
#include <coreplugin/messagebox.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/kit.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlmultilanguageaspect.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/environment.h>
|
||||
@@ -162,18 +165,6 @@ QString PuppetCreator::getStyleConfigFileName() const
|
||||
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)
|
||||
|
||||
: m_target(target)
|
||||
@@ -494,11 +485,6 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
|
||||
environment.set("QMLDESIGNER_RC_PATHS", m_qrcMapping);
|
||||
}
|
||||
|
||||
const QString multilanguageDatabaseFilePath = getMultilanguageDatabaseFilePath();
|
||||
|
||||
if (!multilanguageDatabaseFilePath.isEmpty())
|
||||
environment.set("QT_MULTILANGUAGE_DATABASE", multilanguageDatabaseFilePath);
|
||||
|
||||
#ifndef QMLDESIGNER_TEST
|
||||
auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
|
||||
view->emitCustomNotification("PuppetStatus", {}, {QVariant(m_qrcMapping)});
|
||||
@@ -525,6 +511,13 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
|
||||
importPaths.append(designerImports);
|
||||
|
||||
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");
|
||||
|
@@ -102,7 +102,6 @@ protected:
|
||||
|
||||
bool useOnlyFallbackPuppet() const;
|
||||
QString getStyleConfigFileName() const;
|
||||
QString getMultilanguageDatabaseFilePath() const;
|
||||
|
||||
private:
|
||||
mutable QString m_compileLog;
|
||||
|
@@ -85,7 +85,6 @@ void DesignerSettings::fromSettings(QSettings *settings)
|
||||
restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList());
|
||||
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
|
||||
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true);
|
||||
restoreValue(settings, DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE, "en");
|
||||
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
|
@@ -69,7 +69,6 @@ const char ENABLE_TIMELINEVIEW[] = "EnableTimelineView";
|
||||
const char SIMPLE_COLOR_PALETTE_CONTENT[] = "SimpleColorPaletteContent";
|
||||
const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
|
||||
const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
|
||||
const char LAST_USED_TRANSLATION_LANGUAGE[] = "LastUsedTranslationLanguage";
|
||||
}
|
||||
|
||||
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>
|
||||
|
@@ -11,6 +11,7 @@ QTC_PLUGIN_DEPENDS += \
|
||||
qtsupport \
|
||||
projectexplorer \
|
||||
qmakeprojectmanager \
|
||||
qmlprojectmanager \
|
||||
resourceeditor
|
||||
|
||||
INCLUDEPATH *= \
|
||||
|
@@ -48,13 +48,11 @@ const Utils::Icon previewIcon({
|
||||
static void handleAction(const SelectionContext &context)
|
||||
{
|
||||
if (context.view()->isAttached()) {
|
||||
if (context.toggled()) {
|
||||
QmlPreviewPlugin::setLanguageLocale(DesignerSettings::getValue(DesignerSettingsKey::LAST_USED_TRANSLATION_LANGUAGE).toString());
|
||||
if (context.toggled())
|
||||
ProjectExplorerPlugin::runStartupProject(Constants::QML_PREVIEW_RUN_MODE);
|
||||
} else {
|
||||
else
|
||||
QmlPreviewPlugin::stopAllRunControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QmlPreviewAction::QmlPreviewAction() : ModelNodeAction("LivePreview",
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <qmlprojectmanager/qmlproject.h>
|
||||
#include <qmlprojectmanager/qmlmainfileaspect.h>
|
||||
#include <qmlprojectmanager/qmlmultilanguageaspect.h>
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/session.h>
|
||||
@@ -152,10 +153,9 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
|
||||
}
|
||||
}
|
||||
|
||||
if (runControl->project()) {
|
||||
auto multilanguageDatabaseFilePath = runControl->project()->projectDirectory().pathAppended("/multilanguage-experimental-v1.db");
|
||||
if (multilanguageDatabaseFilePath.exists())
|
||||
runnable.environment.set("QT_MULTILANGUAGE_DATABASE", multilanguageDatabaseFilePath.toString());
|
||||
if (auto multiLanguageAspect = runControl->aspect<QmlProjectManager::QmlMultiLanguageAspect>()) {
|
||||
if (!multiLanguageAspect->databaseFilePath().isEmpty())
|
||||
runnable.environment.set("QT_MULTILANGUAGE_DATABASE", multiLanguageAspect->databaseFilePath().toString());
|
||||
}
|
||||
|
||||
Utils::QtcProcess::addArg(&runnable.commandLineArguments,
|
||||
|
@@ -6,6 +6,7 @@ add_qtc_plugin(QmlProjectManager
|
||||
fileformat/qmlprojectfileformat.cpp fileformat/qmlprojectfileformat.h
|
||||
fileformat/qmlprojectitem.cpp fileformat/qmlprojectitem.h
|
||||
qmlmainfileaspect.cpp qmlmainfileaspect.h
|
||||
qmlmultilanguageaspect.cpp qmlmultilanguageaspect.h
|
||||
qmlproject.cpp qmlproject.h
|
||||
qmlproject.qrc
|
||||
qmlprojectconstants.h
|
||||
|
128
src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp
Normal file
128
src/plugins/qmlprojectmanager/qmlmultilanguageaspect.cpp
Normal 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
|
57
src/plugins/qmlprojectmanager/qmlmultilanguageaspect.h
Normal file
57
src/plugins/qmlprojectmanager/qmlmultilanguageaspect.h
Normal 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
|
@@ -7,6 +7,7 @@ DEFINES += QMLPROJECTMANAGER_LIBRARY
|
||||
|
||||
HEADERS += \
|
||||
qmlmainfileaspect.h \
|
||||
qmlmultilanguageaspect.h \
|
||||
qmlproject.h \
|
||||
qmlprojectplugin.h \
|
||||
qmlprojectconstants.h \
|
||||
@@ -17,6 +18,7 @@ HEADERS += \
|
||||
|
||||
SOURCES += \
|
||||
qmlmainfileaspect.cpp \
|
||||
qmlmultilanguageaspect.cpp \
|
||||
qmlproject.cpp \
|
||||
qmlprojectplugin.cpp \
|
||||
qmlprojectnodes.cpp \
|
||||
|
@@ -16,6 +16,7 @@ QtcPlugin {
|
||||
name: "General"
|
||||
files: [
|
||||
"qmlmainfileaspect.cpp", "qmlmainfileaspect.h",
|
||||
"qmlmultilanguageaspect.cpp", "qmlmultilanguageaspect.h",
|
||||
"qmlproject.cpp", "qmlproject.h",
|
||||
"qmlproject.qrc",
|
||||
"qmlprojectconstants.h",
|
||||
|
@@ -34,6 +34,8 @@ const char QML_PROJECT_ID[] = "QmlProjectManager.QmlProject";
|
||||
const char QML_VIEWER_ARGUMENTS_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
|
||||
const char QML_VIEWER_TARGET_DISPLAY_NAME[] = "QML Viewer";
|
||||
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";
|
||||
|
||||
} // namespace Constants
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
#include "qmlmainfileaspect.h"
|
||||
#include "qmlmainfileaspect.h"
|
||||
#include "qmlmultilanguageaspect.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
@@ -59,6 +59,7 @@ using namespace QtSupport;
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlProjectManager {
|
||||
class QmlMultiLanguageAspect;
|
||||
namespace Internal {
|
||||
|
||||
// QmlProjectRunConfiguration
|
||||
@@ -81,30 +82,12 @@ private:
|
||||
|
||||
BaseStringAspect *m_qmlViewerAspect = nullptr;
|
||||
QmlMainFileAspect *m_qmlMainFileAspect = nullptr;
|
||||
QmlMultiLanguageAspect *m_multiLanguageAspect = nullptr;
|
||||
};
|
||||
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id 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->setLabelText(tr("QML Viewer:"));
|
||||
m_qmlViewerAspect->setPlaceHolderText(commandLine().executable().toString());
|
||||
@@ -123,6 +106,34 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
|
||||
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."));
|
||||
update();
|
||||
}
|
||||
@@ -208,6 +219,10 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
|
||||
const QString main = bs->targetFile(FilePath::fromString(mainScript())).toString();
|
||||
if (!main.isEmpty())
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user