forked from qt-creator/qt-creator
CMake generator: Make only some files selected by default
Task-number: QDS-5561 Change-Id: I1a76385f55681ba60bdb43eafdede6697893598f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -30,6 +30,8 @@ add_qtc_plugin(QmlDesigner
|
|||||||
cmakegeneratordialog.h cmakegeneratordialog.cpp
|
cmakegeneratordialog.h cmakegeneratordialog.cpp
|
||||||
generateresource.cpp generateresource.h
|
generateresource.cpp generateresource.h
|
||||||
generatecmakelists.cpp generatecmakelists.h
|
generatecmakelists.cpp generatecmakelists.h
|
||||||
|
generatecmakelistsconstants.h
|
||||||
|
checkablefilelistmodel.cpp checkablefilelistmodel.h
|
||||||
openuiqmlfiledialog.cpp openuiqmlfiledialog.h openuiqmlfiledialog.ui
|
openuiqmlfiledialog.cpp openuiqmlfiledialog.h openuiqmlfiledialog.ui
|
||||||
qmldesignerconstants.h
|
qmldesignerconstants.h
|
||||||
qmldesignericons.h
|
qmldesignericons.h
|
||||||
|
111
src/plugins/qmldesigner/checkablefilelistmodel.cpp
Normal file
111
src/plugins/qmldesigner/checkablefilelistmodel.cpp
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Design Tooling
|
||||||
|
**
|
||||||
|
** 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 "checkablefilelistmodel.h"
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
CheckableFileListModel::CheckableFileListModel(const FilePath &rootDir, const FilePaths &files, bool checkedByDefault, QObject *parent)
|
||||||
|
:QStandardItemModel(parent),
|
||||||
|
rootDir(rootDir)
|
||||||
|
{
|
||||||
|
for (const FilePath &file: files) {
|
||||||
|
appendRow(new CheckableStandardItem(file.toString(), checkedByDefault));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<CheckableStandardItem*> CheckableFileListModel::checkedItems() const
|
||||||
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
QList<QStandardItem*> allItems = findItems("*", Qt::MatchWildcard);
|
||||||
|
#else
|
||||||
|
QList<QStandardItem*> allItems = findItems(".*", Qt::MatchRegularExpression);
|
||||||
|
#endif
|
||||||
|
QList<CheckableStandardItem*> checkedItems;
|
||||||
|
for (QStandardItem *standardItem : allItems) {
|
||||||
|
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(standardItem);
|
||||||
|
if (item->isChecked())
|
||||||
|
checkedItems.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkedItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant CheckableFileListModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (index.isValid()) {
|
||||||
|
if (role == Qt::CheckStateRole) {
|
||||||
|
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(QStandardItemModel::item(index.row()));
|
||||||
|
return item->isChecked() ? Qt::Checked : Qt::Unchecked;
|
||||||
|
}
|
||||||
|
else if (role == Qt::DisplayRole) {
|
||||||
|
QVariant data = QStandardItemModel::data(index, role);
|
||||||
|
FilePath fullPath = FilePath::fromString(data.toString());
|
||||||
|
FilePath relativePath = fullPath.relativeChildPath(rootDir);
|
||||||
|
return QVariant(relativePath.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStandardItemModel::data(index, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckableFileListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
if (index.isValid() && role == Qt::CheckStateRole)
|
||||||
|
{
|
||||||
|
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(QStandardItemModel::item(index.row()));
|
||||||
|
item->setChecked(value.value<bool>());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QStandardItemModel::setData(index, value, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckableStandardItem::CheckableStandardItem(const QString &text, bool checked)
|
||||||
|
:QStandardItem(text),
|
||||||
|
checked(checked)
|
||||||
|
{
|
||||||
|
setFlags(flags() |= Qt::ItemIsUserCheckable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckableStandardItem::setChecked(bool checked)
|
||||||
|
{
|
||||||
|
this->checked = checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckableStandardItem::isChecked() const
|
||||||
|
{
|
||||||
|
return this->checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CheckableStandardItem::type() const
|
||||||
|
{
|
||||||
|
return QStandardItem::UserType + 0x74d4f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //QmlDesigner
|
65
src/plugins/qmldesigner/checkablefilelistmodel.h
Normal file
65
src/plugins/qmldesigner/checkablefilelistmodel.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Design Tooling
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CHECKABLEFILELISTMODEL_H
|
||||||
|
#define CHECKABLEFILELISTMODEL_H
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
class CheckableStandardItem : public QStandardItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CheckableStandardItem(const QString &text = QString(), bool checked = false);
|
||||||
|
bool isChecked() const;
|
||||||
|
void setChecked(bool checked);
|
||||||
|
int type() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool checked;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CheckableFileListModel : public QStandardItemModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CheckableFileListModel(const Utils::FilePath &rootDir,
|
||||||
|
const Utils::FilePaths &files,
|
||||||
|
bool checkedByDefault = false,
|
||||||
|
QObject *parent = nullptr);
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
QList<CheckableStandardItem*> checkedItems() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Utils::FilePath rootDir;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //QmlDesigner
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QmlDesigner::CheckableStandardItem)
|
||||||
|
|
||||||
|
#endif // CHECKABLEFILELISTMODEL_H
|
@@ -23,8 +23,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "cmakegeneratordialog.h"
|
#include "cmakegeneratordialog.h"
|
||||||
|
#include "generatecmakelistsconstants.h"
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@@ -51,7 +51,7 @@ CmakeGeneratorDialog::CmakeGeneratorDialog(const FilePath &rootDir, const FilePa
|
|||||||
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
model = new CheckableFileListModel(rootDir, files, this);
|
model = new CMakeGeneratorDialogModel(rootDir, files, this);
|
||||||
|
|
||||||
QListView *list = new QListView(this);
|
QListView *list = new QListView(this);
|
||||||
list->setModel(model);
|
list->setModel(model);
|
||||||
@@ -72,82 +72,35 @@ FilePaths CmakeGeneratorDialog::getFilePaths()
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckableFileListModel::CheckableFileListModel(const FilePath &rootDir, const FilePaths &files, QObject *parent)
|
CMakeGeneratorDialogModel::CMakeGeneratorDialogModel(const Utils::FilePath &rootDir, const Utils::FilePaths &files, QObject *parent)
|
||||||
:QStandardItemModel(parent),
|
:CheckableFileListModel(rootDir, files, parent)
|
||||||
rootDir(rootDir)
|
|
||||||
{
|
{
|
||||||
for (const FilePath &file: files) {
|
for (int i=0; i<rowCount(); i++) {
|
||||||
appendRow(new CheckableStandardItem(file.toString(), true));
|
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(QStandardItemModel::item(i));
|
||||||
|
item->setChecked(CMakeGeneratorDialogModel::checkedByDefault(FilePath::fromString(item->text())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CheckableStandardItem*> CheckableFileListModel::checkedItems() const
|
bool CMakeGeneratorDialogModel::checkedByDefault(const FilePath &path) const
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
if (path.exists()) {
|
||||||
QList<QStandardItem*> allItems = findItems("*", Qt::MatchWildcard);
|
QString relativePath = path.relativeChildPath(rootDir).toString();
|
||||||
#else
|
if (relativePath.compare(QmlDesigner::GenerateCmake::Constants::FILENAME_CMAKELISTS) == 0)
|
||||||
QList<QStandardItem*> allItems = findItems(".*", Qt::MatchRegularExpression);
|
return false;
|
||||||
#endif
|
if (relativePath.endsWith(QmlDesigner::GenerateCmake::Constants::FILENAME_CMAKELISTS)
|
||||||
QList<CheckableStandardItem*> checkedItems;
|
&& relativePath.length() > QString(QmlDesigner::GenerateCmake::Constants::FILENAME_CMAKELISTS).length())
|
||||||
for (QStandardItem *standardItem : allItems) {
|
return true;
|
||||||
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(standardItem);
|
if (relativePath.compare(QmlDesigner::GenerateCmake::Constants::FILENAME_MODULES) == 0)
|
||||||
if (item->isChecked())
|
return true;
|
||||||
checkedItems.append(item);
|
if (relativePath.compare(
|
||||||
|
FilePath::fromString(QmlDesigner::GenerateCmake::Constants::DIRNAME_CPP)
|
||||||
|
.pathAppended(QmlDesigner::GenerateCmake::Constants::FILENAME_MAINCPP_HEADER)
|
||||||
|
.toString())
|
||||||
|
== 0)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkedItems;
|
return !path.exists();
|
||||||
}
|
|
||||||
|
|
||||||
CheckableStandardItem::CheckableStandardItem(const QString &text, bool checked)
|
|
||||||
:QStandardItem(text),
|
|
||||||
checked(checked)
|
|
||||||
{
|
|
||||||
setFlags(flags() |= Qt::ItemIsUserCheckable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckableStandardItem::setChecked(bool checked)
|
|
||||||
{
|
|
||||||
this->checked = checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckableStandardItem::isChecked() const
|
|
||||||
{
|
|
||||||
return this->checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CheckableStandardItem::type() const
|
|
||||||
{
|
|
||||||
return QStandardItem::UserType + 0x74d4f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant CheckableFileListModel::data(const QModelIndex &index, int role) const
|
|
||||||
{
|
|
||||||
if (index.isValid()) {
|
|
||||||
if (role == Qt::CheckStateRole) {
|
|
||||||
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(QStandardItemModel::item(index.row()));
|
|
||||||
return item->isChecked() ? Qt::Checked : Qt::Unchecked;
|
|
||||||
}
|
|
||||||
else if (role == Qt::DisplayRole) {
|
|
||||||
QVariant data = QStandardItemModel::data(index, role);
|
|
||||||
QString relativePath = data.toString().remove(rootDir.toString());
|
|
||||||
return QVariant(relativePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QStandardItemModel::data(index, role);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckableFileListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
|
||||||
{
|
|
||||||
if (index.isValid() && role == Qt::CheckStateRole)
|
|
||||||
{
|
|
||||||
CheckableStandardItem *item = static_cast<CheckableStandardItem*>(QStandardItemModel::item(index.row()));
|
|
||||||
item->setChecked(value.value<bool>());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QStandardItemModel::setData(index, value, role);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,36 +27,22 @@
|
|||||||
#ifndef CMAKEGENERATORDIALOG_H
|
#ifndef CMAKEGENERATORDIALOG_H
|
||||||
#define CMAKEGENERATORDIALOG_H
|
#define CMAKEGENERATORDIALOG_H
|
||||||
|
|
||||||
|
#include "checkablefilelistmodel.h"
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStandardItemModel>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace GenerateCmake {
|
namespace GenerateCmake {
|
||||||
|
|
||||||
class CheckableStandardItem : public QStandardItem
|
class CMakeGeneratorDialogModel : public CheckableFileListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CheckableStandardItem(const QString &text = QString(), bool checked = false);
|
CMakeGeneratorDialogModel(const Utils::FilePath &rootDir, const Utils::FilePaths &files, QObject *parent = nullptr);
|
||||||
bool isChecked() const;
|
protected:
|
||||||
void setChecked(bool checked);
|
virtual bool checkedByDefault(const Utils::FilePath &file) const;
|
||||||
int type() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool checked;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CheckableFileListModel : public QStandardItemModel
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CheckableFileListModel(const Utils::FilePath &rootDir, const Utils::FilePaths &files, QObject *parent = nullptr);
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
||||||
QList<CheckableStandardItem*> checkedItems() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Utils::FilePath rootDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CmakeGeneratorDialog : public QDialog
|
class CmakeGeneratorDialog : public QDialog
|
||||||
@@ -72,6 +58,4 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QmlDesigner::GenerateCmake::CheckableStandardItem)
|
|
||||||
|
|
||||||
#endif // CMAKEGENERATORDIALOG_H
|
#endif // CMAKEGENERATORDIALOG_H
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "generatecmakelists.h"
|
#include "generatecmakelists.h"
|
||||||
|
#include "generatecmakelistsconstants.h"
|
||||||
#include "cmakegeneratordialog.h"
|
#include "cmakegeneratordialog.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
using namespace QmlDesigner::GenerateCmake::Constants;
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -118,17 +120,6 @@ bool isErrorFatal(int error)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char DIRNAME_CONTENT[] = "content";
|
|
||||||
const char DIRNAME_IMPORT[] = "imports";
|
|
||||||
const char DIRNAME_CPP[] = "src";
|
|
||||||
|
|
||||||
const char FILENAME_CMAKELISTS[] = "CMakeLists.txt";
|
|
||||||
const char FILENAME_APPMAINQML[] = "App.qml";
|
|
||||||
const char FILENAME_MAINQML[] = "main.qml";
|
|
||||||
const char FILENAME_MAINCPP[] = "main.cpp";
|
|
||||||
const char FILENAME_MAINCPP_HEADER[] = "import_qml_plugins.h";
|
|
||||||
const char FILENAME_MODULES[] = "qmlmodules";
|
|
||||||
|
|
||||||
int isProjectCorrectlyFormed(const FilePath &rootDir)
|
int isProjectCorrectlyFormed(const FilePath &rootDir)
|
||||||
{
|
{
|
||||||
int errors = NoError;
|
int errors = NoError;
|
||||||
@@ -292,8 +283,6 @@ QStringList moduleNames;
|
|||||||
const QDir::Filters FILES_ONLY = QDir::Files;
|
const QDir::Filters FILES_ONLY = QDir::Files;
|
||||||
const QDir::Filters DIRS_ONLY = QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot;
|
const QDir::Filters DIRS_ONLY = QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot;
|
||||||
|
|
||||||
const char QMLDIRFILENAME[] = "qmldir";
|
|
||||||
|
|
||||||
const char MAIN_CMAKEFILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmaincmakelists.tpl";
|
const char MAIN_CMAKEFILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmaincmakelists.tpl";
|
||||||
const char QMLMODULES_FILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmodules.tpl";
|
const char QMLMODULES_FILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmodules.tpl";
|
||||||
|
|
||||||
@@ -325,7 +314,7 @@ void generateMainCmake(const FilePath &rootDir)
|
|||||||
modulesAsPlugins.append(" " + moduleName + "plugin\n");
|
modulesAsPlugins.append(" " + moduleName + "plugin\n");
|
||||||
|
|
||||||
QString moduleFileContent = GenerateCmake::readTemplate(QMLMODULES_FILE_TEMPLATE_PATH).arg(appName).arg(modulesAsPlugins);
|
QString moduleFileContent = GenerateCmake::readTemplate(QMLMODULES_FILE_TEMPLATE_PATH).arg(appName).arg(modulesAsPlugins);
|
||||||
GenerateCmake::queueFile(rootDir.pathAppended(GenerateCmake::FILENAME_MODULES), moduleFileContent);
|
GenerateCmake::queueFile(rootDir.pathAppended(FILENAME_MODULES), moduleFileContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char DO_NOT_EDIT_FILE_COMMENT[] = "### This file is automatically generated by Qt Design Studio.\n### Do not change\n\n";
|
const char DO_NOT_EDIT_FILE_COMMENT[] = "### This file is automatically generated by Qt Design Studio.\n### Do not change\n\n";
|
||||||
@@ -353,7 +342,7 @@ const char MODULEFILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmodule
|
|||||||
void generateModuleCmake(const FilePath &dir)
|
void generateModuleCmake(const FilePath &dir)
|
||||||
{
|
{
|
||||||
QString fileTemplate = GenerateCmake::readTemplate(MODULEFILE_TEMPLATE_PATH);
|
QString fileTemplate = GenerateCmake::readTemplate(MODULEFILE_TEMPLATE_PATH);
|
||||||
const QStringList qmldirFilesOnly(QMLDIRFILENAME);
|
const QStringList qmldirFilesOnly(FILENAME_QMLDIR);
|
||||||
|
|
||||||
QString singletonContent;
|
QString singletonContent;
|
||||||
FilePaths qmldirFileList = dir.dirEntries(qmldirFilesOnly, FILES_ONLY);
|
FilePaths qmldirFileList = dir.dirEntries(qmldirFilesOnly, FILES_ONLY);
|
||||||
@@ -467,14 +456,14 @@ QStringList getDirectoryTreeResources(const FilePath &dir)
|
|||||||
|
|
||||||
void queueCmakeFile(const FilePath &dir, const QString &content)
|
void queueCmakeFile(const FilePath &dir, const QString &content)
|
||||||
{
|
{
|
||||||
FilePath filePath = dir.pathAppended(GenerateCmake::FILENAME_CMAKELISTS);
|
FilePath filePath = dir.pathAppended(FILENAME_CMAKELISTS);
|
||||||
GenerateCmake::queueFile(filePath, content);
|
GenerateCmake::queueFile(filePath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isFileBlacklisted(const QString &fileName)
|
bool isFileBlacklisted(const QString &fileName)
|
||||||
{
|
{
|
||||||
return (!fileName.compare(QMLDIRFILENAME) ||
|
return (!fileName.compare(FILENAME_QMLDIR) ||
|
||||||
!fileName.compare(GenerateCmake::FILENAME_CMAKELISTS));
|
!fileName.compare(FILENAME_CMAKELISTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -494,10 +483,10 @@ const char MAIN_CPPFILE_HEADER_PLUGIN_LINE[] = "Q_IMPORT_QML_PLUGIN(%1)\n";
|
|||||||
|
|
||||||
bool generateMainCpp(const FilePath &dir)
|
bool generateMainCpp(const FilePath &dir)
|
||||||
{
|
{
|
||||||
FilePath srcDir = dir.pathAppended(GenerateCmake::DIRNAME_CPP);
|
FilePath srcDir = dir.pathAppended(DIRNAME_CPP);
|
||||||
|
|
||||||
QString cppContent = GenerateCmake::readTemplate(MAIN_CPPFILE_TEMPLATE_PATH);
|
QString cppContent = GenerateCmake::readTemplate(MAIN_CPPFILE_TEMPLATE_PATH);
|
||||||
FilePath cppFilePath = srcDir.pathAppended(GenerateCmake::FILENAME_MAINCPP);
|
FilePath cppFilePath = srcDir.pathAppended(FILENAME_MAINCPP);
|
||||||
bool cppOk = GenerateCmake::queueFile(cppFilePath, cppContent);
|
bool cppOk = GenerateCmake::queueFile(cppFilePath, cppContent);
|
||||||
|
|
||||||
QString modulesAsPlugins;
|
QString modulesAsPlugins;
|
||||||
@@ -507,7 +496,7 @@ bool generateMainCpp(const FilePath &dir)
|
|||||||
|
|
||||||
QString headerContent = GenerateCmake::readTemplate(MAIN_CPPFILE_HEADER_TEMPLATE_PATH)
|
QString headerContent = GenerateCmake::readTemplate(MAIN_CPPFILE_HEADER_TEMPLATE_PATH)
|
||||||
.arg(modulesAsPlugins);
|
.arg(modulesAsPlugins);
|
||||||
FilePath headerFilePath = srcDir.pathAppended(GenerateCmake::FILENAME_MAINCPP_HEADER);
|
FilePath headerFilePath = srcDir.pathAppended(FILENAME_MAINCPP_HEADER);
|
||||||
bool headerOk = GenerateCmake::queueFile(headerFilePath, headerContent);
|
bool headerOk = GenerateCmake::queueFile(headerFilePath, headerContent);
|
||||||
|
|
||||||
return cppOk && headerOk;
|
return cppOk && headerOk;
|
||||||
@@ -518,7 +507,7 @@ const char MAIN_QMLFILE_TEMPLATE_PATH[] = ":/boilerplatetemplates/qmlprojectmain
|
|||||||
bool generateMainQml(const FilePath &dir)
|
bool generateMainQml(const FilePath &dir)
|
||||||
{
|
{
|
||||||
QString content = GenerateCmake::readTemplate(MAIN_QMLFILE_TEMPLATE_PATH);
|
QString content = GenerateCmake::readTemplate(MAIN_QMLFILE_TEMPLATE_PATH);
|
||||||
FilePath filePath = dir.pathAppended(GenerateCmake::FILENAME_MAINQML);
|
FilePath filePath = dir.pathAppended(FILENAME_MAINQML);
|
||||||
return GenerateCmake::queueFile(filePath, content);
|
return GenerateCmake::queueFile(filePath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
51
src/plugins/qmldesigner/generatecmakelistsconstants.h
Normal file
51
src/plugins/qmldesigner/generatecmakelistsconstants.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2021 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Design Tooling
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef GENERATECMAKELISTSCONSTANTS_H
|
||||||
|
#define GENERATECMAKELISTSCONSTANTS_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace QmlDesigner {
|
||||||
|
namespace GenerateCmake {
|
||||||
|
namespace Constants {
|
||||||
|
|
||||||
|
const char DIRNAME_CONTENT[] = "content";
|
||||||
|
const char DIRNAME_IMPORT[] = "imports";
|
||||||
|
const char DIRNAME_CPP[] = "src";
|
||||||
|
|
||||||
|
const char FILENAME_CMAKELISTS[] = "CMakeLists.txt";
|
||||||
|
const char FILENAME_APPMAINQML[] = "App.qml";
|
||||||
|
const char FILENAME_MAINQML[] = "main.qml";
|
||||||
|
const char FILENAME_MAINCPP[] = "main.cpp";
|
||||||
|
const char FILENAME_MAINCPP_HEADER[] = "import_qml_plugins.h";
|
||||||
|
const char FILENAME_MODULES[] = "qmlmodules";
|
||||||
|
const char FILENAME_QMLDIR[] = "qmldir";
|
||||||
|
|
||||||
|
} //Constants
|
||||||
|
} //GenerateCmake
|
||||||
|
} //QmlDesigner
|
||||||
|
|
||||||
|
#endif // GENERATECMAKELISTSCONSTANTS_H
|
@@ -6,6 +6,8 @@ HEADERS += $$PWD/qmldesignerconstants.h \
|
|||||||
$$PWD/editorproxy.h \
|
$$PWD/editorproxy.h \
|
||||||
$$PWD/generateresource.h \
|
$$PWD/generateresource.h \
|
||||||
$$PWD/generatecmakelists.h \
|
$$PWD/generatecmakelists.h \
|
||||||
|
$$PWD/generatecmakelistsconstants.h \
|
||||||
|
$$PWD/checkablefilelistmodel.h \
|
||||||
$$PWD/cmakegeneratordialog.h \
|
$$PWD/cmakegeneratordialog.h \
|
||||||
$$PWD/settingspage.h \
|
$$PWD/settingspage.h \
|
||||||
$$PWD/designmodecontext.h \
|
$$PWD/designmodecontext.h \
|
||||||
@@ -23,6 +25,7 @@ SOURCES += $$PWD/qmldesignerplugin.cpp \
|
|||||||
$$PWD/editorproxy.cpp \
|
$$PWD/editorproxy.cpp \
|
||||||
$$PWD/generateresource.cpp \
|
$$PWD/generateresource.cpp \
|
||||||
$$PWD/generatecmakelists.cpp \
|
$$PWD/generatecmakelists.cpp \
|
||||||
|
$$PWD/checkablefilelistmodel.cpp \
|
||||||
$$PWD/cmakegeneratordialog.cpp \
|
$$PWD/cmakegeneratordialog.cpp \
|
||||||
$$PWD/settingspage.cpp \
|
$$PWD/settingspage.cpp \
|
||||||
$$PWD/designmodecontext.cpp \
|
$$PWD/designmodecontext.cpp \
|
||||||
|
@@ -1011,6 +1011,9 @@ Project {
|
|||||||
"generateresource.h",
|
"generateresource.h",
|
||||||
"generatecmakelists.cpp",
|
"generatecmakelists.cpp",
|
||||||
"generatecmakelists.h",
|
"generatecmakelists.h",
|
||||||
|
"generatecmakelistsconstants.h",
|
||||||
|
"checkablefilelistmodel.cpp",
|
||||||
|
"checkablefilelistmodel.h",
|
||||||
"cmakegeneratordialog.cpp",
|
"cmakegeneratordialog.cpp",
|
||||||
"cmakegeneratordialog.h",
|
"cmakegeneratordialog.h",
|
||||||
"designersettings.cpp",
|
"designersettings.cpp",
|
||||||
|
Reference in New Issue
Block a user