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="environment_h">templates/environment_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 prefix="/boilerplatetemplates">

View File

@@ -9,6 +9,7 @@
#include "projectexplorer/projectmanager.h"
#include "projectexplorer/projectnodes.h"
#include "projectexplorer/taskhub.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.
qDebug() << text;
ProjectExplorer::BuildSystemTask task(type, text, file);
ProjectExplorer::TaskHub::addTask(task);
ProjectExplorer::TaskHub::requestPopup();
}
void CMakeGenerator::updateMenuAction()
@@ -173,8 +175,8 @@ void CMakeGenerator::update(const QSet<QString> &added, const QSet<QString> &rem
if (auto module = findModuleFor(node))
dirtyModules.insert(module);
} else {
QString text("Failed to find Folder for file: %1");
logIssue(text.arg(add));
QString text("Failed to find Folder for file");
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
{
QString error;
if (!Utils::FileNameValidatingLineEdit::validateFileName(path.fileName(), false, &error)) {
QString text(path.path() + error);
logIssue(error);
}
if (!Utils::FileNameValidatingLineEdit::validateFileName(path.fileName(), false, &error))
logIssue(ProjectExplorer::Task::Error, error, path);
if (path.fileName() == "qmldir") {
readQmlDir(path, node);
@@ -485,9 +485,9 @@ void CMakeGenerator::compareWithFileSystem(const NodePtr &node) const
files.push_back(next);
}
const QString text("File %1 is not part of the project");
for (const auto& file : files)
logIssue(text.arg(file.path()));
const QString text("File is not part of the project");
for (const auto &file : files)
logIssue(ProjectExplorer::Task::Warning, text, file);
}
} // namespace GenerateCmake

View File

@@ -5,6 +5,7 @@
#include "cmakewriter.h"
#include "utils/filepath.h"
#include "projectexplorer/task.h"
#include <QObject>
@@ -25,7 +26,7 @@ class CMakeGenerator : public QObject
public:
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);

View File

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

View File

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