QmlProjectManager: Write cmake-generator issues into the issues panel

write qtquickcontrols file if it does not exist
and minor cleanup of the cmake generator.

Change-Id: I9b7523f32e5a9b41904c02a398a6f924623f949a
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2024-04-15 16:39:10 +02:00
parent b5aac705ea
commit e55b5d0a0b
6 changed files with 33 additions and 21 deletions

View File

@@ -9,6 +9,7 @@
<file alias="qmlcomponents">templates/qmlcomponents.tpl</file> <file alias="qmlcomponents">templates/qmlcomponents.tpl</file>
<file alias="environment_h">templates/environment_h.tpl</file> <file alias="environment_h">templates/environment_h.tpl</file>
<file alias="import_qml_components_h">templates/import_qml_components_h.tpl</file> <file alias="import_qml_components_h">templates/import_qml_components_h.tpl</file>
<file alias="qtquickcontrols_conf">templates/qtquickcontrols2_conf.tpl</file>
</qresource> </qresource>
<qresource prefix="/boilerplatetemplates"> <qresource prefix="/boilerplatetemplates">

View File

@@ -9,6 +9,7 @@
#include "projectexplorer/projectmanager.h" #include "projectexplorer/projectmanager.h"
#include "projectexplorer/projectnodes.h" #include "projectexplorer/projectnodes.h"
#include "projectexplorer/taskhub.h"
#include "utils/filenamevalidatinglineedit.h" #include "utils/filenamevalidatinglineedit.h"
@@ -60,10 +61,11 @@ void CMakeGenerator::createMenuAction(QObject *parent)
}); });
} }
void CMakeGenerator::logIssue(const QString &text) void CMakeGenerator::logIssue(ProjectExplorer::Task::TaskType type, const QString &text, const Utils::FilePath &file)
{ {
// TODO: Use Issues panel as soon as it is usable in DS. ProjectExplorer::BuildSystemTask task(type, text, file);
qDebug() << text; ProjectExplorer::TaskHub::addTask(task);
ProjectExplorer::TaskHub::requestPopup();
} }
void CMakeGenerator::updateMenuAction() void CMakeGenerator::updateMenuAction()
@@ -173,8 +175,8 @@ void CMakeGenerator::update(const QSet<QString> &added, const QSet<QString> &rem
if (auto module = findModuleFor(node)) if (auto module = findModuleFor(node))
dirtyModules.insert(module); dirtyModules.insert(module);
} else { } else {
QString text("Failed to find Folder for file: %1"); QString text("Failed to find Folder for file");
logIssue(text.arg(add)); logIssue(ProjectExplorer::Task::Error, text, path);
} }
} }
@@ -338,10 +340,8 @@ bool CMakeGenerator::findFile(const NodePtr &node, const Utils::FilePath &file)
void CMakeGenerator::insertFile(NodePtr &node, const Utils::FilePath &path) const void CMakeGenerator::insertFile(NodePtr &node, const Utils::FilePath &path) const
{ {
QString error; QString error;
if (!Utils::FileNameValidatingLineEdit::validateFileName(path.fileName(), false, &error)) { if (!Utils::FileNameValidatingLineEdit::validateFileName(path.fileName(), false, &error))
QString text(path.path() + error); logIssue(ProjectExplorer::Task::Error, error, path);
logIssue(error);
}
if (path.fileName() == "qmldir") { if (path.fileName() == "qmldir") {
readQmlDir(path, node); readQmlDir(path, node);
@@ -485,9 +485,9 @@ void CMakeGenerator::compareWithFileSystem(const NodePtr &node) const
files.push_back(next); files.push_back(next);
} }
const QString text("File %1 is not part of the project"); const QString text("File is not part of the project");
for (const auto& file : files) for (const auto &file : files)
logIssue(text.arg(file.path())); logIssue(ProjectExplorer::Task::Warning, text, file);
} }
} // namespace GenerateCmake } // namespace GenerateCmake

View File

@@ -5,6 +5,7 @@
#include "cmakewriter.h" #include "cmakewriter.h"
#include "utils/filepath.h" #include "utils/filepath.h"
#include "projectexplorer/task.h"
#include <QObject> #include <QObject>
@@ -25,7 +26,7 @@ class CMakeGenerator : public QObject
public: public:
static void createMenuAction(QObject *parent); static void createMenuAction(QObject *parent);
static void logIssue(const QString &text); static void logIssue(ProjectExplorer::Task::TaskType type, const QString &text, const Utils::FilePath &file);
CMakeGenerator(QmlBuildSystem *bs, QObject *parent = nullptr); CMakeGenerator(QmlBuildSystem *bs, QObject *parent = nullptr);

View File

@@ -240,8 +240,8 @@ void CMakeWriter::writeFile(const Utils::FilePath &path, const QString &content)
QTextStream stream(&fileHandle); QTextStream stream(&fileHandle);
stream << content; stream << content;
} else { } else {
QString text("Failed to write file: %1"); QString text("Failed to write");
CMakeGenerator::logIssue(text.arg(path.path())); CMakeGenerator::logIssue(ProjectExplorer::Task::Error, text, path);
} }
fileHandle.close(); fileHandle.close();
} }

View File

@@ -21,13 +21,10 @@ CMakeWriterV0::CMakeWriterV0(CMakeGenerator *parent)
bool CMakeWriterV0::isPlugin(const NodePtr &node) const bool CMakeWriterV0::isPlugin(const NodePtr &node) const
{ {
if (CMakeWriter::isPlugin(node))
return true;
if (node->type == Node::Type::App) if (node->type == Node::Type::App)
return !node->files.empty() || !node->singletons.empty() || !node->resources.empty(); return !node->files.empty() || !node->singletons.empty() || !node->resources.empty();
return false; return CMakeWriter::isPlugin(node);
} }
void CMakeWriterV0::transformNode(NodePtr &node) const void CMakeWriterV0::transformNode(NodePtr &node) const
@@ -41,8 +38,8 @@ void CMakeWriterV0::transformNode(NodePtr &node) const
} else if (node->type == Node::Type::App) { } else if (node->type == Node::Type::App) {
Utils::FilePath path = node->dir.pathAppended("main.qml"); Utils::FilePath path = node->dir.pathAppended("main.qml");
if (!path.exists()) { if (!path.exists()) {
QString text("Expected File %1 not found."); QString text("Expected File not found.");
CMakeGenerator::logIssue(text.arg(path.path())); CMakeGenerator::logIssue(ProjectExplorer::Task::Error, text, path);
return; return;
} }
if (!parent()->findFile(path)) if (!parent()->findFile(path))
@@ -54,6 +51,12 @@ void CMakeWriterV0::writeRootCMakeFile(const NodePtr &node) const
{ {
QTC_ASSERT(parent(), return); QTC_ASSERT(parent(), return);
const Utils::FilePath quickControlsPath = node->dir.pathAppended("qtquickcontrols2.conf");
if (!quickControlsPath.exists()) {
const QString quickControlsTemplate = readTemplate(":/templates/qtquickcontrols_conf");
writeFile(quickControlsPath, quickControlsTemplate);
}
const Utils::FilePath insightPath = node->dir.pathAppended("insight"); const Utils::FilePath insightPath = node->dir.pathAppended("insight");
if (!insightPath.exists()) { if (!insightPath.exists()) {
const QString insightTemplate = readTemplate(":/templates/insight"); const QString insightTemplate = readTemplate(":/templates/insight");

View File

@@ -0,0 +1,7 @@
; This file can be edited to change the style of the application
; Read "Qt Quick Controls 2 Configuration File" for details:
; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
[Controls]
Style=Basic