forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/qds/dev' into 12.0
Conflicts: share/qtcreator/qmldesigner/connectionseditor/SuggestionPopup.qml share/qtcreator/themes/dark.creatortheme share/qtcreator/themes/default.creatortheme share/qtcreator/themes/flat-dark.creatortheme share/qtcreator/themes/flat-light.creatortheme share/qtcreator/themes/flat.creatortheme src/libs/utils/CMakeLists.txt src/plugins/CMakeLists.txt src/plugins/qmlprojectmanager/qmlproject.cpp src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp Change-Id: Idd87c281e1aa7b7fd2702473ad55e18563cbfb21
This commit is contained in:
@@ -272,7 +272,7 @@ QJsonObject qmlProjectTojson(const Utils::FilePath &projectFile)
|
||||
if (childNode->name().contains("files", Qt::CaseInsensitive)) {
|
||||
PropsPair propsPair;
|
||||
FileProps fileProps;
|
||||
const QString childNodeName = childNode->name().toLower();
|
||||
const QString childNodeName = childNode->name().toLower().remove("qds.");
|
||||
const QmlJS::SimpleReaderNode::Property childNodeFilter = childNode->property("filter");
|
||||
const QmlJS::SimpleReaderNode::Property childNodeDirectory = childNode->property(
|
||||
"directory");
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "cmakegeneratordialog.h"
|
||||
#include "cmakegeneratordialogtreemodel.h"
|
||||
#include "generatecmakelistsconstants.h"
|
||||
#include "../qmlprojectmanagertr.h"
|
||||
#include "cmakegeneratordialogtreemodel.h"
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/detailswidget.h>
|
||||
@@ -21,10 +20,10 @@ using namespace Utils;
|
||||
namespace QmlProjectManager {
|
||||
namespace GenerateCmake {
|
||||
|
||||
CmakeGeneratorDialog::CmakeGeneratorDialog(const FilePath &rootDir, const FilePaths &files)
|
||||
: QDialog(),
|
||||
m_rootDir(rootDir),
|
||||
m_files(files)
|
||||
CmakeGeneratorDialog::CmakeGeneratorDialog(const FilePath &rootDir,
|
||||
const FilePaths &files,
|
||||
const FilePaths invalidFiles)
|
||||
: QDialog(), m_rootDir(rootDir), m_files(files), m_invalidFiles(invalidFiles)
|
||||
{
|
||||
setWindowTitle(Tr::tr("Select Files to Generate"));
|
||||
|
||||
@@ -106,6 +105,8 @@ FilePaths CmakeGeneratorDialog::getFilePaths()
|
||||
|
||||
const QString FILE_CREATE_NOTIFICATION = Tr::tr("File %1 will be created.\n");
|
||||
const QString FILE_OVERWRITE_NOTIFICATION = Tr::tr("File %1 will be overwritten.\n");
|
||||
const QString FILE_INVALID_NOTIFICATION = Tr::tr(
|
||||
"File %1 contains invalid characters and will be skipped.\n");
|
||||
|
||||
void CmakeGeneratorDialog::refreshNotificationText()
|
||||
{
|
||||
@@ -119,6 +120,11 @@ void CmakeGeneratorDialog::refreshNotificationText()
|
||||
|
||||
QList<CheckableFileTreeItem*> nodes = m_model->items();
|
||||
|
||||
for (const auto &file : m_invalidFiles) {
|
||||
cursor.insertImage(iformat);
|
||||
cursor.insertText(QString(FILE_INVALID_NOTIFICATION).arg(file.displayName()));
|
||||
}
|
||||
|
||||
for (CheckableFileTreeItem *node : nodes) {
|
||||
if (!m_files.contains(node->toFilePath()))
|
||||
continue;
|
||||
|
||||
@@ -22,7 +22,9 @@ class CmakeGeneratorDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CmakeGeneratorDialog(const Utils::FilePath &rootDir, const Utils::FilePaths &files);
|
||||
CmakeGeneratorDialog(const Utils::FilePath &rootDir,
|
||||
const Utils::FilePaths &files,
|
||||
const Utils::FilePaths invalidFiles);
|
||||
Utils::FilePaths getFilePaths();
|
||||
|
||||
public slots:
|
||||
@@ -40,6 +42,7 @@ private:
|
||||
QVariant m_warningIcon;
|
||||
Utils::FilePath m_rootDir;
|
||||
Utils::FilePaths m_files;
|
||||
Utils::FilePaths m_invalidFiles;
|
||||
};
|
||||
|
||||
} //GenerateCmake
|
||||
|
||||
@@ -142,7 +142,7 @@ void onGenerateCmakeLists()
|
||||
for (const GeneratableFile &file: cmakeGen.fileQueue().queuedFiles())
|
||||
allFiles.append(file.filePath);
|
||||
|
||||
CmakeGeneratorDialog dialog(rootDir, allFiles);
|
||||
CmakeGeneratorDialog dialog(rootDir, allFiles, cmakeGen.invalidFileNames());
|
||||
if (dialog.exec()) {
|
||||
FilePaths confirmedFiles = dialog.getFilePaths();
|
||||
cmakeGen.filterFileQueue(confirmedFiles);
|
||||
@@ -334,6 +334,11 @@ bool CmakeFileGenerator::execute()
|
||||
return m_fileQueue.writeQueuedFiles();
|
||||
}
|
||||
|
||||
FilePaths CmakeFileGenerator::invalidFileNames() const
|
||||
{
|
||||
return m_invalidFileNames;
|
||||
}
|
||||
|
||||
const char DO_NOT_EDIT_FILE_COMMENT[] = "### This file is automatically generated by Qt Design Studio.\n### Do not change\n\n";
|
||||
const char ADD_SUBDIR[] = "add_subdirectory(%1)\n";
|
||||
|
||||
@@ -491,8 +496,7 @@ QStringList CmakeFileGenerator::getDirectoryResources(const FilePath &dir)
|
||||
|
||||
FilePaths allFiles = dir.dirEntries(FILES_ONLY);
|
||||
for (FilePath &file : allFiles) {
|
||||
if (!file.fileName().endsWith(".qml", Qt::CaseInsensitive) &&
|
||||
includeFile(file)) {
|
||||
if (!file.fileName().endsWith(".qml", Qt::CaseInsensitive) && includeFile(file)) {
|
||||
moduleFiles.append(file.fileName());
|
||||
}
|
||||
}
|
||||
@@ -519,10 +523,20 @@ QStringList CmakeFileGenerator::getDirectoryTreeQmls(const FilePath &dir)
|
||||
return qmlFileList;
|
||||
}
|
||||
|
||||
static void appendWidthQuotes(QStringList &list, const QString &string)
|
||||
{
|
||||
if (string.contains(' '))
|
||||
list.append("\"" + string + "\"");
|
||||
else
|
||||
list.append(string);
|
||||
}
|
||||
|
||||
QStringList CmakeFileGenerator::getDirectoryTreeResources(const FilePath &dir)
|
||||
{
|
||||
QStringList resourceFileList;
|
||||
|
||||
//for (const auto &string : getDirectoryResources(dir))
|
||||
// appendWidthQuotes(resourceFileList, string);
|
||||
resourceFileList.append(getDirectoryResources(dir));
|
||||
|
||||
FilePaths subDirsList = dir.dirEntries(DIRS_ONLY);
|
||||
@@ -531,9 +545,8 @@ QStringList CmakeFileGenerator::getDirectoryTreeResources(const FilePath &dir)
|
||||
continue;
|
||||
QStringList subDirResources = getDirectoryTreeResources(subDir);
|
||||
for (QString &resource : subDirResources) {
|
||||
resourceFileList.append(subDir.fileName().append('/').append(resource));
|
||||
appendWidthQuotes(resourceFileList, subDir.fileName().append('/').append(resource));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return resourceFileList;
|
||||
@@ -556,6 +569,18 @@ bool CmakeFileGenerator::isDirBlacklisted(const FilePath &dir)
|
||||
return (!dir.fileName().compare(DIRNAME_DESIGNER));
|
||||
}
|
||||
|
||||
bool CmakeFileGenerator::validFileName(const Utils::FilePath &filePath)
|
||||
{
|
||||
QStringList invalidChars = {"!", "\"", "£", "$", "%", "!", "^", "&", "*", "(", ")", "=", "+",
|
||||
"'", ",", ";", ":", "#", "~", "{", "{", "[", "]", "<", ">", "?"};
|
||||
const QString baseName = filePath.baseName();
|
||||
for (const auto &c : invalidChars) {
|
||||
if (baseName.contains(c))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CmakeFileGenerator::includeFile(const FilePath &filePath)
|
||||
{
|
||||
if (m_checkFileIsInProject) {
|
||||
@@ -564,7 +589,12 @@ bool CmakeFileGenerator::includeFile(const FilePath &filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isFileBlacklisted(filePath.fileName());
|
||||
if (validFileName(filePath))
|
||||
return !isFileBlacklisted(filePath.fileName());
|
||||
else
|
||||
m_invalidFileNames.append(filePath);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CmakeFileGenerator::generateEntryPointFiles(const FilePath &dir)
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
const FileQueue fileQueue() const;
|
||||
void filterFileQueue(const Utils::FilePaths &keepFiles);
|
||||
bool execute();
|
||||
Utils::FilePaths invalidFileNames() const;
|
||||
|
||||
private:
|
||||
void generateMainCmake(const Utils::FilePath &rootDir);
|
||||
@@ -63,12 +64,15 @@ private:
|
||||
bool isFileBlacklisted(const QString &fileName);
|
||||
bool isDirBlacklisted(const Utils::FilePath &dir);
|
||||
bool includeFile(const Utils::FilePath &filePath);
|
||||
bool validFileName(const Utils::FilePath &filePath);
|
||||
|
||||
private:
|
||||
FileQueue m_fileQueue;
|
||||
QStringList m_resourceFileLocations;
|
||||
QStringList m_moduleNames;
|
||||
bool m_checkFileIsInProject;
|
||||
|
||||
Utils::FilePaths m_invalidFileNames;
|
||||
};
|
||||
|
||||
} //GenerateCmake
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
cmake_minimum_required(VERSION 3.21.1)
|
||||
|
||||
option(LINK_INSIGHT "Link Qt Insight Tracker library" ON)
|
||||
option(BUILD_QDS_COMPONENTS "Build design studio components" ON)
|
||||
|
||||
project(%1 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(Qt6 COMPONENTS Gui Qml Quick)
|
||||
find_package(Qt6 6.2 REQUIRED COMPONENTS Core Gui Qml Quick)
|
||||
|
||||
if (Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
|
||||
qt_standard_project_setup()
|
||||
endif()
|
||||
|
||||
qt_add_executable(%1 src/main.cpp)
|
||||
|
||||
qt_add_resources(%1 "configuration"
|
||||
@@ -20,5 +28,20 @@ target_link_libraries(%1 PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Qml
|
||||
)
|
||||
|
||||
if (BUILD_QDS_COMPONENTS)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules)
|
||||
|
||||
if (LINK_INSIGHT)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/insight)
|
||||
endif ()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS CppExampleApp
|
||||
BUNDLE DESTINATION .
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
setNeedsBuildConfigurations(false);
|
||||
setBuildSystemCreator([](Target *t) { return new QmlBuildSystem(t); });
|
||||
|
||||
if (QmlProject::isQtDesignStudio()) {
|
||||
if (Core::ICore::isQtDesignStudio()) {
|
||||
if (allowOnlySingleProject()) {
|
||||
EditorManager::closeAllDocuments();
|
||||
ProjectManager::closeAllProjects();
|
||||
@@ -113,7 +113,7 @@ Project::RestoreResult QmlProject::fromMap(const Store &map, QString *errorMessa
|
||||
|
||||
// FIXME: are there any other way?
|
||||
// What if it's not a Design Studio project? What should we do then?
|
||||
if (QmlProject::isQtDesignStudio()) {
|
||||
if (Core::ICore::isQtDesignStudio()) {
|
||||
int preferedVersion = preferedQtTarget(activeTarget());
|
||||
|
||||
setKitWithVersion(preferedVersion, kits);
|
||||
@@ -207,13 +207,6 @@ Tasks QmlProject::projectIssues(const Kit *k) const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool QmlProject::isQtDesignStudio()
|
||||
{
|
||||
QtcSettings *settings = Core::ICore::settings();
|
||||
const Key qdsStandaloneEntry = "QML/Designer/StandAloneMode";
|
||||
return settings->value(qdsStandaloneEntry, false).toBool();
|
||||
}
|
||||
|
||||
bool QmlProject::isQtDesignStudioStartedFromQtC()
|
||||
{
|
||||
return qEnvironmentVariableIsSet(Constants::enviromentLaunchedQDS);
|
||||
@@ -226,7 +219,7 @@ DeploymentKnowledge QmlProject::deploymentKnowledge() const
|
||||
|
||||
bool QmlProject::isEditModePreferred() const
|
||||
{
|
||||
return !isQtDesignStudio();
|
||||
return !Core::ICore::isQtDesignStudio();
|
||||
}
|
||||
|
||||
int QmlProject::preferedQtTarget(Target *target)
|
||||
|
||||
@@ -17,7 +17,6 @@ class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
|
||||
public:
|
||||
explicit QmlProject(const Utils::FilePath &filename);
|
||||
|
||||
static bool isQtDesignStudio();
|
||||
static bool isQtDesignStudioStartedFromQtC();
|
||||
bool isEditModePreferred() const override;
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ void QmlProjectPlugin::initialize()
|
||||
Utils::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png",
|
||||
"qmlproject");
|
||||
|
||||
if (QmlProject::isQtDesignStudio()) {
|
||||
if (Core::ICore::isQtDesignStudio()) {
|
||||
Core::ActionContainer *menu = Core::ActionManager::actionContainer(
|
||||
ProjectExplorer::Constants::M_FILECONTEXT);
|
||||
QAction *mainfileAction = new QAction(Tr::tr("Set as Main .qml File"), this);
|
||||
@@ -355,7 +355,7 @@ void QmlProjectPlugin::initialize()
|
||||
}
|
||||
|
||||
GenerateCmake::generateMenuEntry(this);
|
||||
if (QmlProject::isQtDesignStudio())
|
||||
if (Core::ICore::isQtDesignStudio())
|
||||
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/environmentaspect.h>
|
||||
#include <projectexplorer/kitaspects.h>
|
||||
@@ -125,7 +126,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
qmlMainFile.setTarget(target);
|
||||
connect(&qmlMainFile, &BaseAspect::changed, this, &RunConfiguration::update);
|
||||
|
||||
if (QmlProject::isQtDesignStudio())
|
||||
if (Core::ICore::isQtDesignStudio())
|
||||
setupQtVersionAspect();
|
||||
else
|
||||
qtversion.setVisible(false);
|
||||
@@ -210,13 +211,17 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
if (!qmlRuntime.isEmpty())
|
||||
return qmlRuntime;
|
||||
}
|
||||
auto hasDeployStep = [this]() {
|
||||
return target()->activeDeployConfiguration() &&
|
||||
!target()->activeDeployConfiguration()->stepList()->isEmpty();
|
||||
};
|
||||
|
||||
// The Qt version might know, but we need to make sure
|
||||
// that the device can reach it.
|
||||
if (QtVersion *version = QtKitAspect::qtVersion(kit)) {
|
||||
// look for puppet as qmlruntime only in QtStudio Qt versions
|
||||
if (version->features().contains("QtStudio") &&
|
||||
version->qtVersion().majorVersion() > 5) {
|
||||
version->qtVersion().majorVersion() > 5 && !hasDeployStep()) {
|
||||
|
||||
auto [workingDirectoryPath, puppetPath] = QmlDesigner::QmlPuppetPaths::qmlPuppetPaths(
|
||||
target(), QmlDesigner::QmlDesignerBasePlugin::settings());
|
||||
@@ -237,6 +242,9 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
|
||||
void QmlProjectRunConfiguration::setupQtVersionAspect()
|
||||
{
|
||||
if (!Core::ICore::isQtDesignStudio())
|
||||
return;
|
||||
|
||||
qtversion.setSettingsKey("QmlProjectManager.kit");
|
||||
qtversion.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
||||
qtversion.setLabelText(Tr::tr("Qt Version:"));
|
||||
|
||||
Reference in New Issue
Block a user