Merge remote-tracking branch 'origin/13.0' into qds/dev

Change-Id: I242c01e82fc1b0db1f5e88c35d526f91dd022337
This commit is contained in:
Tim Jenssen
2024-02-13 13:55:47 +01:00
2530 changed files with 84766 additions and 55874 deletions

View File

@@ -16,7 +16,6 @@ add_qtc_plugin(QmlProjectManager
qmlprojectconstants.h
qmlprojectmanager_global.h
qmlprojectmanagertr.h
qmlprojectmanagerconstants.h
qmlprojectplugin.cpp qmlprojectplugin.h
qmlprojectrunconfiguration.cpp qmlprojectrunconfiguration.h
buildsystem/qmlbuildsystem.cpp buildsystem/qmlbuildsystem.h

View File

@@ -223,7 +223,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
{
QmlJS::SimpleReader simpleQmlJSReader;
const QmlJS::SimpleReaderNode::Ptr rootNode = simpleQmlJSReader.readFile(projectFile.toString());
const QmlJS::SimpleReaderNode::Ptr rootNode = simpleQmlJSReader.readFile(projectFile.toFSPathString());
if (!simpleQmlJSReader.errors().isEmpty() || !rootNode->isValid()) {
qCritical() << "Unable to parse:" << projectFile;
@@ -260,7 +260,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
bool qtForMCUs = false;
// convert the the non-object props
// convert the non-object props
for (const QString &propName : rootNode->propertyNames()) {
QJsonObject *currentObj = &rootObject;
QString objKey = QString(propName).remove("QDS.", Qt::CaseInsensitive);
@@ -314,7 +314,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
rootObject.insert("otherProperties", otherProperties);
// convert the the object props
// convert the object props
for (const QmlJS::SimpleReaderNode::Ptr &childNode : rootNode->children()) {
if (childNode->name().contains("files", Qt::CaseInsensitive)) {
QString childNodeName = childNode->name().remove("qds.", Qt::CaseInsensitive);

View File

@@ -73,8 +73,8 @@ void QmlProjectItem::setupFileFilters()
fileFilterItem->setDirectory(directory);
fileFilterItem->setFilters(fileGroup["filters"].toVariant().toStringList());
fileFilterItem->setRecursive(true);
fileFilterItem->setDefaultDirectory(m_projectFile.parentDir().toString());
fileFilterItem->setDefaultDirectory(m_projectFile.parentDir().toFSPathString());
#ifndef TESTS_ENABLED_QMLPROJECTITEM
connect(fileFilterItem.get(),
&FileFilterItem::filesChanged,

View File

@@ -90,7 +90,7 @@ QmlBuildSystem::QmlBuildSystem(Target *target)
m_cmakeGen->initialize(qmlProject());
updateMcuBuildStep(target, qtForMCUs());
});
connect(target->project(), &Project::projectFileIsDirty, this, [this]() {
connect(target->project(), &Project::projectFileIsDirty, this, [this] {
refresh(RefreshOptions::Project);
m_cmakeGen->initialize(qmlProject());
updateMcuBuildStep(project()->activeTarget(), qtForMCUs());
@@ -239,9 +239,9 @@ void QmlBuildSystem::parseProjectFiles()
}
Utils::FilePath mainFilePath{Utils::FilePath::fromString(m_projectItem->mainFile())};
if (!mainFilePath.isEmpty()) {
mainFilePath = canonicalProjectDir().resolvePath(m_projectItem->mainFile());
const QString mainFileName = m_projectItem->mainFile();
if (!mainFileName.isEmpty()) {
Utils::FilePath mainFilePath = canonicalProjectDir().resolvePath(mainFileName);
Utils::FileReader reader;
QString errorMessage;
if (!reader.fetch(mainFilePath, &errorMessage)) {

View File

@@ -15,8 +15,7 @@
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/buildsystem/qmlbuildsystem.h>
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
#include <qmlprojectmanager/qmlprojectconstants.h>
#include <QAction>
#include <QMessageBox>
@@ -121,7 +120,7 @@ bool CmakeProjectConverter::convertProject(const QmlProjectManager::QmlProject *
if (retVal) {
QMessageBox::information(Core::ICore::dialogParent(), SUCCESS_TITLE, SUCCESS_TEXT);
ProjectExplorer::ProjectExplorerPlugin::OpenProjectResult result
ProjectExplorer::OpenProjectResult result
= ProjectExplorer::ProjectExplorerPlugin::openProject(newProjectFile());
if (!result)
ProjectExplorer::ProjectExplorerPlugin::showOpenProjectError(result);

View File

@@ -19,7 +19,7 @@
#include <qmlprojectmanager/buildsystem/qmlbuildsystem.h>
#include <qmlprojectmanager/qmlmainfileaspect.h>
#include <qmlprojectmanager/qmlproject.h>
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
#include <qmlprojectmanager/qmlprojectconstants.h>
#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginmanager.h>

View File

@@ -87,7 +87,7 @@ void QdsLandingPage::openQds(bool rememberSelection)
auto editor = Core::EditorManager::currentEditor();
if (editor)
QmlProjectPlugin::openInQDSWithProject(editor->document()->filePath());
openInQDSWithProject(editor->document()->filePath());
}
void QdsLandingPage::installQds()

View File

@@ -4,7 +4,7 @@
#include "qmlmainfileaspect.h"
#include "qmlproject.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagertr.h"
#include <qmljstools/qmljstoolsconstants.h>
@@ -18,6 +18,7 @@
#include <utils/algorithm.h>
#include <utils/layoutbuilder.h>
#include <utils/mimeconstants.h>
#include <utils/mimeutils.h>
#include <utils/qtcassert.h>
@@ -216,25 +217,25 @@ bool QmlMainFileAspect::isQmlFilePresent()
{
bool qmlFileFound = false;
if (mainScriptSource() == FileInEditor && !mainScript().isEmpty()) {
using namespace Utils::Constants;
IDocument *document = EditorManager::currentDocument();
const MimeType mainScriptMimeType = mimeTypeForFile(mainScript());
if (document) {
m_currentFileFilename = document->filePath();
if (mainScriptMimeType.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|| mainScriptMimeType.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
if (mainScriptMimeType.matchesName(QML_MIMETYPE)
|| mainScriptMimeType.matchesName(QMLUI_MIMETYPE)) {
qmlFileFound = true;
}
}
if (!document
|| mainScriptMimeType.matchesName(QmlJSTools::Constants::QMLPROJECT_MIMETYPE)) {
|| mainScriptMimeType.matchesName(QMLPROJECT_MIMETYPE)) {
// find a qml file with lowercase filename. This is slow, but only done
// in initialization/other border cases.
const FilePaths files = m_target->project()->files(Project::SourceFiles);
for (const FilePath &filename : files) {
if (!filename.isEmpty() && filename.baseName().at(0).isLower()) {
const MimeType type = mimeTypeForFile(filename);
if (type.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|| type.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
if (type.matchesName(QML_MIMETYPE) || type.matchesName(QMLUI_MIMETYPE)) {
m_currentFileFilename = filename;
qmlFileFound = true;
break;

View File

@@ -5,7 +5,7 @@
#include "qmlprojectmanager_global.h"
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
#include <qmlprojectmanager/qmlprojectconstants.h>
#include <projectexplorer/runconfigurationaspects.h>

View File

@@ -19,7 +19,6 @@
#include "projectexplorer/devicesupport/idevice.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectmanagertr.h"
#include "utils/algorithm.h"
#include <qmljs/qmljsmodelmanagerinterface.h>
@@ -28,6 +27,7 @@
#include <utils/algorithm.h>
#include <utils/infobar.h>
#include <utils/mimeconstants.h>
#include <utils/process.h>
#include <utils/qtcassert.h>
@@ -44,7 +44,7 @@ using namespace Utils;
namespace QmlProjectManager {
QmlProject::QmlProject(const Utils::FilePath &fileName)
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
: Project(Utils::Constants::QMLPROJECT_MIMETYPE, fileName)
{
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
setProjectLanguages(Core::Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
@@ -177,13 +177,13 @@ Tasks QmlProject::projectIssues(const Kit *k) const
result.append(createProjectTask(Task::TaskType::Warning, Tr::tr("No Qt version set in kit.")));
IDevice::ConstPtr dev = DeviceKitAspect::device(k);
if (dev.isNull())
if (!dev)
result.append(createProjectTask(Task::TaskType::Error, Tr::tr("Kit has no device.")));
if (version && version->qtVersion() < QVersionNumber(5, 0, 0))
result.append(createProjectTask(Task::TaskType::Error, Tr::tr("Qt version is too old.")));
if (dev.isNull() || !version)
if (!dev || !version)
return result; // No need to check deeper than this
if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {

View File

@@ -3,12 +3,8 @@
#pragma once
#include <qmljstools/qmljstoolsconstants.h>
namespace QmlProjectManager::Constants {
namespace QmlProjectManager {
namespace Constants {
const char * const QMLPROJECT_MIMETYPE = QmlJSTools::Constants::QMLPROJECT_MIMETYPE;
const char customFileSelectorsData[] = "CustomFileSelectorsData";
const char supportedLanguagesData[] = "SupportedLanguagesData";
const char primaryLanguageData[] = "PrimaryLanguageData";
@@ -25,5 +21,19 @@ const char enviromentLaunchedQDS[] = "QTC_LAUNCHED_QDS";
const char ALWAYS_OPEN_UI_MODE[] = "J.QtQuick/QmlJSEditor.openUiQmlMode";
const char QML_RESOURCE_PATH[] = "qmldesigner/propertyEditorQmlSources/imports";
const char LANDING_PAGE_PATH[] = "qmldesigner/landingpage";
} // namespace Constants
} // namespace QmlProjectManager
const char QML_PROJECT_ID[] = "QmlProjectManager.QmlProject";
const char QML_RUNCONFIG_ID[] = "QmlProjectManager.QmlRunConfiguration.Qml";
const char QML_VIEWER_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewer";
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";
const char EXPORT_MENU[] = "QmlDesigner.ExportMenu";
const char G_EXPORT_GENERATE[] = "QmlDesigner.Group.GenerateProject";
const char G_EXPORT_CONVERT[] = "QmlDesigner.Group.ConvertProject";
} // QmlProjectManager::Constants

View File

@@ -25,7 +25,6 @@ QtcPlugin {
"qmlproject.qrc",
"qmlprojectconstants.h",
"qmlprojectmanager_global.h", "qmlprojectmanagertr.h",
"qmlprojectmanagerconstants.h",
"qmlprojectplugin.cpp", "qmlprojectplugin.h",
"qmlprojectrunconfiguration.cpp", "qmlprojectrunconfiguration.h",
project.ide_source_tree + "/src/share/3rdparty/studiofonts/studiofonts.qrc"

View File

@@ -1,25 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <qglobal.h>
namespace QmlProjectManager {
namespace Constants {
const char QML_PROJECT_ID[] = "QmlProjectManager.QmlProject";
const char QML_VIEWER_KEY[] = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewer";
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";
const char EXPORT_MENU[] = "QmlDesigner.ExportMenu";
const char G_EXPORT_GENERATE[] = "QmlDesigner.Group.GenerateProject";
const char G_EXPORT_CONVERT[] = "QmlDesigner.Group.ConvertProject";
} // namespace Constants
} // namespace QmlProjectManager

View File

@@ -1,8 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qdslandingpage.h"
#include "qmlprojectplugin.h"
#include "qdslandingpage.h"
#include "qmlproject.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagertr.h"
@@ -20,6 +21,10 @@
#include <coreplugin/messagebox.h>
#include <coreplugin/modemanager.h>
#include <debugger/debuggerruncontrol.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/projectnodes.h>
@@ -28,6 +33,8 @@
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <qmlprofiler/qmlprofilerruncontrol.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljseditor/qmljseditor.h>
@@ -35,11 +42,14 @@
#include <qmljstools/qmljstoolsconstants.h>
#include <qmlpreview/qmlpreviewruncontrol.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <utils/fileutils.h>
#include <utils/fsengine/fileiconprovider.h>
#include <utils/mimeconstants.h>
#include <utils/process.h>
#include <utils/qtcsettings.h>
@@ -50,6 +60,10 @@
#include <QPushButton>
#include <QTimer>
using namespace Core;
using namespace QmlPreview;
using namespace QmlProfiler;
using namespace Debugger;
using namespace ProjectExplorer;
using namespace Utils;
@@ -72,58 +86,40 @@ static bool qmlDesignerEnabled()
static QString alwaysOpenWithMode()
{
return Core::ICore::settings()
return ICore::settings()
->value(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE, "")
.toString();
}
static void setAlwaysOpenWithMode(const QString &mode)
{
Core::ICore::settings()->setValue(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE, mode);
ICore::settings()->setValue(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE, mode);
}
static void clearAlwaysOpenWithMode()
{
Core::ICore::settings()->remove(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE);
ICore::settings()->remove(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE);
}
class QmlProjectPluginPrivate
{
public:
QmlProjectRunConfigurationFactory runConfigFactory;
SimpleTargetRunnerFactory runWorkerFactory{{runConfigFactory.runConfigurationId()}};
QPointer<QMessageBox> lastMessageBox;
QdsLandingPage *landingPage = nullptr;
QdsLandingPageWidget *landingPageWidget = nullptr;
};
QmlProjectPlugin::~QmlProjectPlugin()
void openQDS(const FilePath &fileName)
{
QTC_ASSERT(d, return);
if (d->lastMessageBox)
d->lastMessageBox->deleteLater();
if (d->landingPage)
d->landingPage->deleteLater();
if (d->landingPageWidget)
d->landingPageWidget->deleteLater();
delete d;
}
void QmlProjectPlugin::openQDS(const Utils::FilePath &fileName)
{
const Utils::FilePath &qdsPath = QmlProjectPlugin::qdsInstallationEntry();
const FilePath qdsPath = qdsInstallationEntry();
bool qdsStarted = false;
qputenv(Constants::enviromentLaunchedQDS, "true");
//-a and -client arguments help to append project to open design studio application
if (Utils::HostOsInfo::isMacHost())
qdsStarted = Utils::Process::startDetached(
if (HostOsInfo::isMacHost())
qdsStarted = Process::startDetached(
{"/usr/bin/open", {"-a", qdsPath.path(), fileName.toString()}});
else
qdsStarted = Utils::Process::startDetached({qdsPath, {"-client", fileName.toString()}});
qdsStarted = Process::startDetached({qdsPath, {"-client", fileName.toString()}});
if (!qdsStarted) {
QMessageBox::warning(Core::ICore::dialogParent(),
QMessageBox::warning(ICore::dialogParent(),
fileName.fileName(),
Tr::tr("Failed to start Qt Design Studio."));
if (alwaysOpenWithMode() == Core::Constants::MODE_DESIGN)
@@ -131,20 +127,20 @@ void QmlProjectPlugin::openQDS(const Utils::FilePath &fileName)
}
}
Utils::FilePath QmlProjectPlugin::qdsInstallationEntry()
FilePath qdsInstallationEntry()
{
QtcSettings *settings = Core::ICore::settings();
QtcSettings *settings = ICore::settings();
const Key qdsInstallationEntry = "QML/Designer/DesignStudioInstallation"; //set in installer
return Utils::FilePath::fromUserInput(settings->value(qdsInstallationEntry).toString());
return FilePath::fromUserInput(settings->value(qdsInstallationEntry).toString());
}
bool QmlProjectPlugin::qdsInstallationExists()
bool qdsInstallationExists()
{
return qdsInstallationEntry().exists();
}
bool QmlProjectPlugin::checkIfEditorIsuiQml(Core::IEditor *editor)
bool checkIfEditorIsuiQml(IEditor *editor)
{
if (editor
&& (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
@@ -158,18 +154,18 @@ bool QmlProjectPlugin::checkIfEditorIsuiQml(Core::IEditor *editor)
return false;
}
const Utils::FilePath findQmlProject(const Utils::FilePath &folder)
const FilePath findQmlProject(const FilePath &folder)
{
const Utils::FilePaths files = folder.dirEntries({QStringList("*.qmlproject"), QDir::Files});
const FilePaths files = folder.dirEntries({QStringList("*.qmlproject"), QDir::Files});
if (files.isEmpty())
return {};
return files.constFirst();
}
const Utils::FilePath findQmlProjectUpwards(const Utils::FilePath &folder)
const FilePath findQmlProjectUpwards(const FilePath &folder)
{
auto ret = findQmlProject(folder);
FilePath ret = findQmlProject(folder);
if (ret.exists())
return ret;
@@ -179,41 +175,37 @@ const Utils::FilePath findQmlProjectUpwards(const Utils::FilePath &folder)
return {};
}
static bool findAndOpenProject(const Utils::FilePath &filePath)
static bool findAndOpenProject(const FilePath &filePath)
{
ProjectExplorer::Project *project
= ProjectExplorer::ProjectManager::projectForFile(filePath);
if (project) {
if (Project *project = ProjectManager::projectForFile(filePath)) {
if (project->projectFilePath().suffix() == "qmlproject") {
QmlProjectPlugin::openQDS(project->projectFilePath());
openQDS(project->projectFilePath());
return true;
}
FilePath projectFolder = project->rootProjectDirectory();
FilePath qmlProjectFile = findQmlProject(projectFolder);
if (qmlProjectFile.exists()) {
openQDS(qmlProjectFile);
return true;
} else {
auto projectFolder = project->rootProjectDirectory();
auto qmlProjectFile = findQmlProject(projectFolder);
if (qmlProjectFile.exists()) {
QmlProjectPlugin::openQDS(qmlProjectFile);
return true;
}
}
}
auto qmlProjectFile = findQmlProjectUpwards(filePath);
FilePath qmlProjectFile = findQmlProjectUpwards(filePath);
if (qmlProjectFile.exists()) {
QmlProjectPlugin::openQDS(qmlProjectFile);
openQDS(qmlProjectFile);
return true;
}
return false;
}
void QmlProjectPlugin::openInQDSWithProject(const Utils::FilePath &filePath)
void openInQDSWithProject(const FilePath &filePath)
{
if (findAndOpenProject(filePath)) {
openQDS(filePath);
//The first one might be ignored when QDS is starting up
QTimer::singleShot(4000, [filePath] { openQDS(filePath); });
} else {
Core::AsynchronousMessageBox::warning(
AsynchronousMessageBox::warning(
Tr::tr("Qt Design Studio"),
Tr::tr("No project file (*.qmlproject) found for Qt Design "
"Studio.\nQt Design Studio requires a .qmlproject "
@@ -227,7 +219,7 @@ static QmlBuildSystem *qmlBuildSystemforFileNode(const FileNode *fileNode)
return nullptr;
if (QmlProject *qmlProject = qobject_cast<QmlProject*>(fileNode->getProject())) {
auto target = qmlProject->activeTarget();
Target *target = qmlProject->activeTarget();
if (!target)
return nullptr;
@@ -238,36 +230,78 @@ static QmlBuildSystem *qmlBuildSystemforFileNode(const FileNode *fileNode)
return nullptr;
}
class QmlProjectPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProjectManager.json")
public:
~QmlProjectPlugin()
{
if (m_lastMessageBox)
m_lastMessageBox->deleteLater();
if (m_landingPage)
m_landingPage->deleteLater();
if (m_landingPageWidget)
m_landingPageWidget->deleteLater();
}
public slots:
void editorModeChanged(Utils::Id newMode, Utils::Id oldMode);
void openQtc(bool permanent = false);
void openQds(bool permanent = false);
private:
void initialize() final;
void extensionsInitialized() final
{
// These rely on the base tool factories being present:
static SimpleTargetRunnerFactory runWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimpleQmlProfilerRunnerFactory qmlProfilerRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimpleDebugRunnerFactory debugRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimplePreviewRunnerFactory previewRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
}
void displayQmlLandingPage();
void hideQmlLandingPage();
void updateQmlLandingPageProjectInfo(const Utils::FilePath &projectFile);
QPointer<QMessageBox> m_lastMessageBox;
QdsLandingPage *m_landingPage = nullptr;
QdsLandingPageWidget *m_landingPageWidget = nullptr;
};
void QmlProjectPlugin::initialize()
{
d = new QmlProjectPluginPrivate;
setupQmlProjectRunConfiguration();
if (!qmlDesignerEnabled()) {
d->landingPage = new QdsLandingPage();
m_landingPage = new QdsLandingPage();
qmlRegisterSingletonInstance<QdsLandingPage>("LandingPageApi",
1,
0,
"LandingPageApi",
d->landingPage);
m_landingPage);
d->landingPageWidget = new QdsLandingPageWidget();
m_landingPageWidget = new QdsLandingPageWidget();
const QStringList mimeTypes = {QmlJSTools::Constants::QMLUI_MIMETYPE};
auto context = new Internal::DesignModeContext(d->landingPageWidget);
Core::ICore::addContextObject(context);
const QStringList mimeTypes = {Utils::Constants::QMLUI_MIMETYPE};
auto context = new Internal::DesignModeContext(m_landingPageWidget);
ICore::addContextObject(context);
Core::DesignMode::registerDesignWidget(d->landingPageWidget, mimeTypes, context->context());
DesignMode::registerDesignWidget(m_landingPageWidget, mimeTypes, context->context());
connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged,
connect(ModeManager::instance(), &ModeManager::currentModeChanged,
this, &QmlProjectPlugin::editorModeChanged);
}
ProjectManager::registerProjectType<QmlProject>(QmlJSTools::Constants::QMLPROJECT_MIMETYPE);
Utils::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png",
"qmlproject");
ProjectManager::registerProjectType<QmlProject>(Utils::Constants::QMLPROJECT_MIMETYPE);
FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png",
"qmlproject");
if (Core::ICore::isQtDesignStudio()) {
Core::ActionContainer *menu = Core::ActionManager::actionContainer(
if (ICore::isQtDesignStudio()) {
ActionContainer *menu = ActionManager::actionContainer(
ProjectExplorer::Constants::M_FILECONTEXT);
QAction *mainfileAction = new QAction(Tr::tr("Set as Main .qml File"), this);
mainfileAction->setEnabled(false);
@@ -278,17 +312,17 @@ void QmlProjectPlugin::initialize()
|| currentNode->asFileNode()->fileType() != FileType::QML)
return;
const Utils::FilePath file = currentNode->filePath();
const FilePath file = currentNode->filePath();
QmlBuildSystem *buildSystem = qmlBuildSystemforFileNode(currentNode->asFileNode());
if (buildSystem)
buildSystem->setMainFileInProjectFile(file);
});
menu->addAction(Core::ActionManager::registerAction(
menu->addAction(ActionManager::registerAction(
mainfileAction,
"QmlProject.setMainFile",
Core::Context(ProjectExplorer::Constants::C_PROJECT_TREE)),
Context(ProjectExplorer::Constants::C_PROJECT_TREE)),
ProjectExplorer::Constants::G_FILE_OTHER);
mainfileAction->setVisible(false);
connect(ProjectTree::instance(),
@@ -321,14 +355,14 @@ void QmlProjectPlugin::initialize()
|| currentNode->asFileNode()->fileType() != FileType::QML)
return;
const Utils::FilePath file = currentNode->filePath();
const FilePath file = currentNode->filePath();
QmlBuildSystem *buildSystem = qmlBuildSystemforFileNode(currentNode->asFileNode());
if (buildSystem)
buildSystem->setMainUiFileInProjectFile(file);
});
menu->addAction(Core::ActionManager::registerAction(
menu->addAction(ActionManager::registerAction(
mainUifileAction,
"QmlProject.setMainUIFile",
Core::Context(ProjectExplorer::Constants::C_PROJECT_TREE)),
@@ -355,37 +389,37 @@ void QmlProjectPlugin::initialize()
}
GenerateCmake::generateMenuEntry(this);
if (Core::ICore::isQtDesignStudio())
if (ICore::isQtDesignStudio())
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
}
void QmlProjectPlugin::displayQmlLandingPage()
{
if (!d->landingPage)
if (!m_landingPage)
return;
d->landingPage->setWidget(d->landingPageWidget->widget());
m_landingPage->setWidget(m_landingPageWidget->widget());
updateQmlLandingPageProjectInfo(projectFilePath());
d->landingPage->setQdsInstalled(qdsInstallationExists());
d->landingPage->setCmakeResources(ProjectFileContentTools::rootCmakeFiles());
d->landingPage->show();
m_landingPage->setQdsInstalled(qdsInstallationExists());
m_landingPage->setCmakeResources(ProjectFileContentTools::rootCmakeFiles());
m_landingPage->show();
}
void QmlProjectPlugin::hideQmlLandingPage()
{
if (d->landingPage)
d->landingPage->hide();
if (m_landingPage)
m_landingPage->hide();
}
static bool isDesignerMode(Utils::Id mode)
static bool isDesignerMode(Id mode)
{
return mode == Core::Constants::MODE_DESIGN;
}
void QmlProjectPlugin::editorModeChanged(Utils::Id newMode, Utils::Id oldMode)
void QmlProjectPlugin::editorModeChanged(Id newMode, Id oldMode)
{
Core::IEditor *currentEditor = Core::EditorManager::currentEditor();
IEditor *currentEditor = EditorManager::currentEditor();
if (checkIfEditorIsuiQml(currentEditor)) {
if (isDesignerMode(newMode)) {
if (alwaysOpenWithMode() == Core::Constants::MODE_DESIGN)
@@ -405,10 +439,10 @@ void QmlProjectPlugin::openQtc(bool permanent)
if (permanent)
setAlwaysOpenWithMode(Core::Constants::MODE_EDIT);
if (d->landingPage)
if (m_landingPage)
hideQmlLandingPage();
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
ModeManager::activateMode(Core::Constants::MODE_EDIT);
}
void QmlProjectPlugin::openQds(bool permanent)
@@ -416,35 +450,35 @@ void QmlProjectPlugin::openQds(bool permanent)
if (permanent)
setAlwaysOpenWithMode(Core::Constants::MODE_DESIGN);
if (d->landingPage)
if (m_landingPage)
hideQmlLandingPage();
auto editor = Core::EditorManager::currentEditor();
if (editor)
if (IEditor *editor = EditorManager::currentEditor())
openInQDSWithProject(editor->document()->filePath());
}
void QmlProjectPlugin::updateQmlLandingPageProjectInfo(const Utils::FilePath &projectFile)
void QmlProjectPlugin::updateQmlLandingPageProjectInfo(const FilePath &projectFile)
{
if (!d->landingPage)
if (!m_landingPage)
return;
const QString qtVersionString = ProjectFileContentTools::qtVersion(projectFile);
const QString qdsVersionString = ProjectFileContentTools::qdsVersion(projectFile);
d->landingPage->setProjectFileExists(projectFile.exists());
d->landingPage->setQtVersion(qtVersionString);
d->landingPage->setQdsVersion(qdsVersionString);
m_landingPage->setProjectFileExists(projectFile.exists());
m_landingPage->setQtVersion(qtVersionString);
m_landingPage->setQdsVersion(qdsVersionString);
}
Utils::FilePath QmlProjectPlugin::projectFilePath()
FilePath projectFilePath()
{
auto project = ProjectExplorer::ProjectManager::startupProject();
const QmlProjectManager::QmlProject *qmlProject = qobject_cast<const QmlProjectManager::QmlProject*>(project);
if (qmlProject) {
Project *project = ProjectManager::startupProject();
if (const QmlProject *qmlProject = qobject_cast<const QmlProject*>(project))
return qmlProject->projectFilePath();
} else if (project) {
auto projectFolder = project->rootProjectDirectory();
auto qmlProjectFile = findQmlProject(projectFolder);
if (project) {
FilePath projectFolder = project->rootProjectDirectory();
FilePath qmlProjectFile = findQmlProject(projectFolder);
if (qmlProjectFile.exists())
return qmlProjectFile;
}
@@ -453,3 +487,5 @@ Utils::FilePath QmlProjectPlugin::projectFilePath()
}
} // QmlProjectManager::Internal
#include "qmlprojectplugin.moc"

View File

@@ -3,46 +3,21 @@
#pragma once
#include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/iplugin.h>
#include <utils/filepath.h>
namespace QmlProjectManager {
namespace Internal {
namespace Core { class IEditor; }
class QmlProjectPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProjectManager.json")
namespace QmlProjectManager::Internal {
public:
QmlProjectPlugin() = default;
~QmlProjectPlugin() final;
void openQDS(const Utils::FilePath &fileName);
Utils::FilePath qdsInstallationEntry();
bool qdsInstallationExists();
bool checkIfEditorIsuiQml(Core::IEditor *editor);
Utils::FilePath projectFilePath();
Utils::FilePaths rootCmakeFiles();
QString qtVersion(const Utils::FilePath &projectFilePath);
QString qdsVersion(const Utils::FilePath &projectFilePath);
void openInQDSWithProject(const Utils::FilePath &filePath);
const QString readFileContents(const Utils::FilePath &filePath);
static void openQDS(const Utils::FilePath &fileName);
static Utils::FilePath qdsInstallationEntry();
static bool qdsInstallationExists();
static bool checkIfEditorIsuiQml(Core::IEditor *editor);
static Utils::FilePath projectFilePath();
static Utils::FilePaths rootCmakeFiles();
static QString qtVersion(const Utils::FilePath &projectFilePath);
static QString qdsVersion(const Utils::FilePath &projectFilePath);
static void openInQDSWithProject(const Utils::FilePath &filePath);
static const QString readFileContents(const Utils::FilePath &filePath);
public slots:
void editorModeChanged(Utils::Id newMode, Utils::Id oldMode);
void openQtc(bool permanent = false);
void openQds(bool permanent = false);
private:
void initialize() final;
void displayQmlLandingPage();
void hideQmlLandingPage();
void updateQmlLandingPageProjectInfo(const Utils::FilePath &projectFile);
class QmlProjectPluginPrivate *d = nullptr;
};
} // namespace Internal
} // namespace QmlProject
} // QmlProject::Internal

View File

@@ -1,18 +1,19 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmlprojectrunconfiguration.h"
#include "buildsystem/qmlbuildsystem.h"
#include "qmlmainfileaspect.h"
#include "qmlmultilanguageaspect.h"
#include "qmlproject.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagertr.h"
#include "qmlprojectrunconfiguration.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/environmentaspect.h>
@@ -20,6 +21,7 @@
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
@@ -55,8 +57,8 @@ public:
QmlProjectRunConfiguration(Target *target, Id id);
private:
QString disabledReason() const final;
bool isEnabled() const final;
QString disabledReason(Utils::Id runMode) const final;
bool isEnabled(Utils::Id) const final;
FilePath mainScript() const;
FilePath qmlRuntimeFilePath() const;
@@ -178,7 +180,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
update();
}
QString QmlProjectRunConfiguration::disabledReason() const
QString QmlProjectRunConfiguration::disabledReason(Utils::Id runMode) const
{
if (mainScript().isEmpty())
return Tr::tr("No script file to execute.");
@@ -191,7 +193,7 @@ QString QmlProjectRunConfiguration::disabledReason() const
}
if (viewer.isEmpty())
return Tr::tr("No QML utility specified for target device.");
return RunConfiguration::disabledReason();
return RunConfiguration::disabledReason(runMode);
}
FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
@@ -211,7 +213,7 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
if (!qmlRuntime.isEmpty())
return qmlRuntime;
}
auto hasDeployStep = [this]() {
auto hasDeployStep = [this] {
return target()->activeDeployConfiguration() &&
!target()->activeDeployConfiguration()->stepList()->isEmpty();
};
@@ -304,7 +306,7 @@ void QmlProjectRunConfiguration::setupQtVersionAspect()
}
}
bool QmlProjectRunConfiguration::isEnabled() const
bool QmlProjectRunConfiguration::isEnabled(Id) const
{
return const_cast<QmlProjectRunConfiguration *>(this)->qmlMainFile.isQmlFilePresent()
&& !commandLine().executable().isEmpty()
@@ -318,12 +320,20 @@ FilePath QmlProjectRunConfiguration::mainScript() const
// QmlProjectRunConfigurationFactory
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory()
: FixedRunConfigurationFactory(Tr::tr("QML Runtime"), false)
class QmlProjectRunConfigurationFactory final : public FixedRunConfigurationFactory
{
registerRunConfiguration<QmlProjectRunConfiguration>
("QmlProjectManager.QmlRunConfiguration.Qml");
addSupportedProjectType(QmlProjectManager::Constants::QML_PROJECT_ID);
public:
QmlProjectRunConfigurationFactory()
: FixedRunConfigurationFactory(Tr::tr("QML Runtime"), false)
{
registerRunConfiguration<QmlProjectRunConfiguration>(Constants::QML_RUNCONFIG_ID);
addSupportedProjectType(Constants::QML_PROJECT_ID);
}
};
void setupQmlProjectRunConfiguration()
{
static QmlProjectRunConfigurationFactory theQmlProjectRunConfigurationFactory;
}
} // QmlProjectManager::Internal

View File

@@ -3,16 +3,8 @@
#pragma once
#include <projectexplorer/runconfiguration.h>
namespace QmlProjectManager::Internal {
namespace QmlProjectManager {
namespace Internal {
void setupQmlProjectRunConfiguration();
class QmlProjectRunConfigurationFactory final : public ProjectExplorer::FixedRunConfigurationFactory
{
public:
QmlProjectRunConfigurationFactory();
};
} // namespace Internal
} // namespace QmlProjectManager
} // QmlProjectManager::Internal