diff options
author | Svetlana Abramenkova <sabramenkova@luxoft.com> | 2018-07-11 18:10:35 +0300 |
---|---|---|
committer | Svetlana Abramenkova <sabramenkova@luxoft.com> | 2018-07-19 09:24:43 +0000 |
commit | e400161c6ec932c180e8b9fe5e5d00a593ee254a (patch) | |
tree | c8e19d1bf8ea1056174c45e9df5027480cfe7707 | |
parent | a0f2af7fc25b49d082111f6c853e64188e6b4743 (diff) |
QmlLive project concept
Make it easier to create and manage workspace projects with QmlLive
based on a common project format based on a JSON format.
Change-Id: I6b17329c655786ea8b7ca4c4b1bc539f23b3e719
Task-Id: AUTOSUITE-589
Reviewed-by: Ilya A, Galkin <igalkin@luxoft.com>
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | src/bench/bench.pro | 6 | ||||
-rw-r--r-- | src/bench/mainwindow.cpp | 84 | ||||
-rw-r--r-- | src/bench/mainwindow.h | 14 | ||||
-rw-r--r-- | src/bench/newprojectwizard.cpp | 246 | ||||
-rw-r--r-- | src/bench/newprojectwizard.h | 106 | ||||
-rw-r--r-- | src/projectmanager.cpp | 160 | ||||
-rw-r--r-- | src/projectmanager.h | 63 | ||||
-rw-r--r-- | src/src.pri | 6 |
9 files changed, 677 insertions, 10 deletions
diff --git a/.qmake.conf b/.qmake.conf index 03d3435..10f313d 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ SOURCE_DIR=$$PWD BUILD_DIR=$$shadowed($$PWD) QMAKEFEATURES=$$SOURCE_DIR/qmake-features -VERSION = 1.0.0 +VERSION = 1.1.0 diff --git a/src/bench/bench.pro b/src/bench/bench.pro index d6a94ae..038da41 100644 --- a/src/bench/bench.pro +++ b/src/bench/bench.pro @@ -27,7 +27,8 @@ SOURCES += \ importpathoptionpage.cpp \ hostdiscoverymanager.cpp \ autodiscoveryhostsdialog.cpp \ - options.cpp + options.cpp \ + newprojectwizard.cpp HEADERS += \ aboutdialog.h \ @@ -48,7 +49,8 @@ HEADERS += \ httpproxyoptionpage.h \ hostdiscoverymanager.h \ autodiscoveryhostsdialog.h \ - options.h + options.h \ + newprojectwizard.h FORMS += \ optionsdialog.ui \ diff --git a/src/bench/mainwindow.cpp b/src/bench/mainwindow.cpp index bd7063a..982d962 100644 --- a/src/bench/mainwindow.cpp +++ b/src/bench/mainwindow.cpp @@ -48,13 +48,15 @@ #include "allhostswidget.h" #include "hostdiscoverymanager.h" #include "options.h" +#include "newprojectwizard.h" +#include "projectmanager.h" class ErrorBar : public QFrame { Q_OBJECT public: - ErrorBar(QWidget *parent = 0) + ErrorBar(QWidget *parent = nullptr) : QFrame(parent) { setFrameShape(QFrame::StyledPanel); @@ -101,6 +103,8 @@ MainWindow::MainWindow(QWidget *parent) , m_allHosts(new AllHostsWidget(this)) , m_hub(new LiveHubEngine(this)) , m_node(new BenchLiveNodeEngine(this)) + , m_newProjectWizard(new NewProjectWizard(this)) + , m_projectManager(new ProjectManager(this)) { setupContent(); setupMenuBar(); @@ -128,6 +132,7 @@ MainWindow::MainWindow(QWidget *parent) connect(m_allHosts, &AllHostsWidget::refreshAll, m_hostManager, &HostManager::refreshAll); connect(m_hostManager, &HostManager::logWidgetAdded, this, &MainWindow::onLogWidgetAdded); connect(m_hostManager, &HostManager::openHostConfig, this, &MainWindow::openPreferences); + connect(m_newProjectWizard, &NewProjectWizard::accepted, this, &MainWindow::newProject); m_qmlDefaultimportList = m_node->qmlEngine()->importPathList(); } @@ -250,10 +255,24 @@ void MainWindow::setupMenuBar() { QMenu *file = menuBar()->addMenu(tr("&File")); #if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) - m_openWorkspace = file->addAction(QIcon::fromTheme("folder-open"), tr("&Open Workspace..."), this, SLOT(openWorkspace()), QKeySequence::Open); + m_createProject = file->addAction(QIcon::fromTheme("folder-new"), tr("&New Project"), this, SLOT(newProject()), QKeySequence::New); +#else + m_createProject = file->addAction(QIcon::fromTheme("folder-new"), tr("&New Project"), + this, &MainWindow::newProjectWizard, QKeySequence::New); +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + m_openProject = file->addAction(QIcon::fromTheme("folder-open"), tr("&Open Project..."), this, SLOT(openProject()), QKeySequence::Open); +#else + m_openProject = file->addAction(QIcon::fromTheme("folder-open"), tr("&Open Project..."), + this, &MainWindow::openProject, QKeySequence::Open); +#endif + +#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) + m_openWorkspace = file->addAction(QIcon::fromTheme("folder-open"), tr("&Open Workspace..."), this, SLOT(openWorkspace()), QKeySequence("Ctrl+W")); #else m_openWorkspace = file->addAction(QIcon::fromTheme("folder-open"), tr("&Open Workspace..."), - this, &MainWindow::openWorkspace, QKeySequence::Open); + this, &MainWindow::openWorkspace, QKeySequence("Ctrl+W")); #endif m_recentMenu = file->addMenu(QIcon::fromTheme("document-open-recent"), "&Recent"); m_recentMenu->setEnabled(false); @@ -414,6 +433,8 @@ void MainWindow::setupToolBar() m_toolBar = addToolBar("ToolBar"); m_toolBar->setObjectName("toolbar"); m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_toolBar->addAction(m_createProject); + m_toolBar->addAction(m_openProject); m_toolBar->addAction(m_openWorkspace); m_toolBar->addSeparator(); m_toolBar->addAction(m_refresh); @@ -591,4 +612,61 @@ void MainWindow::stayOnTop() show(); } +void MainWindow::openProject() +{ + QString filter = tr("QmlLive (*.qmllive);; All files (*.*)"); + QString path = QFileDialog::getOpenFileName(this, "Open Project", filter, filter); + if (path.isEmpty()) { + return; + } + if (m_projectManager->read(path)) + { + QStringList paths; + QSettings s; + int count = s.beginReadArray("imports"); + for (int i=0; i<count; i++) { + s.setArrayIndex(i); + paths.append(s.value("path").toString()); + } + s.endArray(); + paths.append(m_projectManager->imports()); + paths.removeDuplicates(); + + //write Application settings + s.beginWriteArray("imports"); + for (int i = 0; i < paths.count(); i++) { + s.setArrayIndex(i); + s.setValue("path", paths.at(i)); + } + s.endArray(); + + setImportPaths(paths); + setWorkspace(m_projectManager->workspace()); + activateDocument(LiveDocument(m_projectManager->mainDocument())); + } +} + +void MainWindow::newProjectWizard() +{ + if (!m_newProjectWizard) { + m_newProjectWizard = new NewProjectWizard(this); + } else { + m_newProjectWizard->restart(); + } + m_newProjectWizard->show(); +} + +void MainWindow::newProject() +{ + m_projectManager->setImports(m_newProjectWizard->imports()); + m_projectManager->setMainDocument(m_newProjectWizard->mainDocument()); + m_projectManager->setWorkspace(m_newProjectWizard->workspace()); + + m_projectManager->create(m_newProjectWizard->projectName()); + + setImportPaths(m_newProjectWizard->imports()); + setWorkspace(m_newProjectWizard->workspace()); + activateDocument(LiveDocument(m_newProjectWizard->mainDocument())); +} + #include "mainwindow.moc" diff --git a/src/bench/mainwindow.h b/src/bench/mainwindow.h index 4a7e8f1..c3725a2 100644 --- a/src/bench/mainwindow.h +++ b/src/bench/mainwindow.h @@ -50,13 +50,16 @@ class AllHostsWidget; class Host; class HostDiscoveryManager; class Options; +class NewProjectWizard; +class ProjectManager; + QT_FORWARD_DECLARE_CLASS(QToolBar); class MainWindow : public QMainWindow { Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); + explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); void activateDocument(const LiveDocument &path); void setWorkspace(const QString& path, bool activateRootPath = true); @@ -88,10 +91,13 @@ private slots: void openWorkspace(); void logQuitEvent(); void updateWindowTitle(); - void openPreferences(Host *host = 0); + void openPreferences(Host *host = nullptr); void openRecentFolder(); void clearRecentFolder(); void stayOnTop(); + void openProject(); + void newProjectWizard(); + void newProject(); void onActiveWindowChanged(QQuickWindow *activeWindow); @@ -126,4 +132,8 @@ private: QAction *m_clipRootObject; QToolBar* m_toolBar; QStringList m_qmlDefaultimportList; + QAction *m_openProject; + QAction *m_createProject; + NewProjectWizard *m_newProjectWizard; + ProjectManager *m_projectManager; }; diff --git a/src/bench/newprojectwizard.cpp b/src/bench/newprojectwizard.cpp new file mode 100644 index 0000000..f2fcbbc --- /dev/null +++ b/src/bench/newprojectwizard.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** 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. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include "newprojectwizard.h" + +#include <QGridLayout> +#include <QListWidget> +#include <QPushButton> +#include <QFileDialog> +#include "livedocument.h" + +NewProjectWizard::NewProjectWizard(QWidget *parent) + : QWizard(parent) + , m_importListWidget(nullptr) + , m_projectPage(new ProjectPage()) + , m_workspacePage(new WorkspacePage()) + , m_mainDocumentPage(new MainDocumentPage()) +{ + setWizardStyle(QWizard::ClassicStyle); + setOptions(QWizard::NoBackButtonOnStartPage); + addPage(m_projectPage); + addPage(m_workspacePage); + addPage(createImportsPage()); + addPage(m_mainDocumentPage); +} + +MainDocumentPage::MainDocumentPage(QWidget *parent) + : QWizardPage (parent) +{ + setTitle("Main Document"); + QGridLayout *layout = new QGridLayout; + + QLabel *label = new QLabel("Main document: "); + layout->addWidget(label, 0, 0); + + m_mainDocumentField = new QLineEdit; + registerField("mainDocument*", m_mainDocumentField); + layout->addWidget(m_mainDocumentField, 0, 1); + + layout->setColumnStretch(1, 1); + layout->setRowStretch(1, 1); + setLayout(layout); + +} + +QString MainDocumentPage::mainDocument() const +{ + if (m_mainDocumentField) { + return m_mainDocumentField->text(); + } + return ""; +} + +WorkspacePage::WorkspacePage(QWidget *parent) + : QWizardPage (parent) +{ + setTitle("Select Workspace"); + QGridLayout *layout = new QGridLayout; + + QLabel *label = new QLabel("Workspace: "); + layout->addWidget(label, 0, 0); + + m_workspaceField = new QLineEdit; + registerField("workspace*", m_workspaceField); + layout->addWidget(m_workspaceField, 0, 1); + + QPushButton *button = new QPushButton("Select"); + layout->addWidget(button, 0, 2); + connect(button, SIGNAL(clicked()), this, SLOT(selectWorkspacePath())); + + m_warningLabel = new QLabel; + layout->addWidget(m_warningLabel, 1, 0, 1, 3, Qt::AlignTop); + + layout->setColumnStretch(1, 1); + layout->setRowStretch(1, 1); + setLayout(layout); +} + +QString WorkspacePage::workspace() const +{ + if (m_workspaceField) { + return m_workspaceField->text(); + } + return ""; +} + +void WorkspacePage::selectWorkspacePath() +{ + m_warningLabel->setText(""); + QString workspace = QFileDialog::getExistingDirectory(this, "Select Workspace"); + if (!workspace.isEmpty() && m_workspaceField) { + m_workspaceField->setText(workspace); + } +} + +bool WorkspacePage::validatePage() +{ + if (QDir(workspace()).exists()) { + m_warningLabel->setText(""); + return true; + } else { + m_warningLabel->setText("The path you entered does not exist."); + return false; + } +} + +QWizardPage *NewProjectWizard::createImportsPage() +{ + QWizardPage *page = new QWizardPage; + page->setTitle("Imports"); + QGridLayout *layout = new QGridLayout; + + m_importListWidget = new QListWidget; + layout->addWidget(m_importListWidget, 0, 0, 4, 1); + + QPushButton *add = new QPushButton("Add"); + connect(add, SIGNAL(clicked()), this, SLOT(addImportPath())); + layout->addWidget(add, 0, 1); + + QPushButton *edit = new QPushButton("Edit"); + connect(edit, SIGNAL(clicked()), this, SLOT(editImportPath())); + layout->addWidget(edit, 1, 1); + + QPushButton *remove = new QPushButton("Remove"); + connect(remove, SIGNAL(clicked()), this, SLOT(removeImportPath())); + layout->addWidget(remove, 2, 1); + + layout->setRowStretch(4, 1); + page->setLayout(layout); + return page; +} + +ProjectPage::ProjectPage(QWidget *parent) + : QWizardPage (parent) +{ + setTitle("Project Name"); + setSubTitle("This wizard generates a Qt QmlLive project. The QmlLive project file shall describe the" + "common options for a QmlLive project by specifying the workspace folder, the main document" + "and the import paths relative to the project document location."); + + QGridLayout *layout = new QGridLayout; + + QLabel *label = new QLabel("Project name: "); + layout->addWidget(label, 0, 0); + + m_projectField = new QLineEdit; + registerField("projectName*", m_projectField); + m_projectField->setPlaceholderText("MyQmlLiveProject"); + layout->addWidget(m_projectField, 0, 1); + + layout->setColumnStretch(1, 1); + layout->setRowStretch(1, 1); + setLayout(layout); +} + +QString ProjectPage::projectName() const +{ + if (m_projectField) { + return m_projectField->text(); + } + return ""; +} + +QString NewProjectWizard::mainDocument() const +{ + return m_mainDocumentPage->mainDocument(); +} + +QString NewProjectWizard::workspace() const +{ + return m_workspacePage->workspace(); +} + +QStringList NewProjectWizard::imports() const +{ + QStringList list; + if (m_importListWidget) { + for (int i = 0; i < m_importListWidget->count(); i++) { + list.append(m_importListWidget->takeItem(i)->text()); + } + } + + return list; +} + +QString NewProjectWizard::projectName() const +{ + return m_projectPage->projectName(); +} + +void NewProjectWizard::addImportPath() +{ + QString path = QFileDialog::getExistingDirectory(this, "Add Import Path"); + if (path.isEmpty()) { + return; + } + QListWidgetItem *item = new QListWidgetItem(path); + item->setFlags(item->flags () | Qt::ItemIsEditable); + m_importListWidget->addItem(item); + +} + +void NewProjectWizard::editImportPath() +{ + QListWidgetItem *item = m_importListWidget->currentItem(); + if (item) { + m_importListWidget->editItem(item); + } + +} + +void NewProjectWizard::removeImportPath() +{ + QListWidgetItem *item = m_importListWidget->currentItem(); + if (item) { + delete item; + } +} diff --git a/src/bench/newprojectwizard.h b/src/bench/newprojectwizard.h new file mode 100644 index 0000000..b2f5fd6 --- /dev/null +++ b/src/bench/newprojectwizard.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** 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. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#pragma once + +#include <QWizard> +#include <QWizardPage> +#include <QLineEdit> +#include <QListWidget> +#include <QLabel> + +class ProjectPage : public QWizardPage +{ + Q_OBJECT + +public: + ProjectPage(QWidget *parent = nullptr); + QString projectName() const; + +private: + QLineEdit *m_projectField; +}; + +class WorkspacePage : public QWizardPage +{ + Q_OBJECT + +public: + WorkspacePage(QWidget *parent = nullptr); + QString workspace() const; + bool validatePage() override; + +private slots: + void selectWorkspacePath(); + +private: + QLineEdit *m_workspaceField; + QLabel *m_warningLabel; +}; + +class MainDocumentPage : public QWizardPage +{ + Q_OBJECT + +public: + MainDocumentPage(QWidget *parent = nullptr); + QString mainDocument() const; + +private: + QLineEdit *m_mainDocumentField; +}; + +class NewProjectWizard : public QWizard +{ + Q_OBJECT +public: + explicit NewProjectWizard(QWidget *parent = 0); + QWizardPage* createMainDocumentPage(); + QWizardPage* createWorkspacePage(); + QWizardPage* createImportsPage(); + QWizardPage* createProjectPage(); + + QString mainDocument() const; + QString workspace() const; + QStringList imports() const; + QString projectName() const; + +private slots: + void addImportPath(); + void editImportPath(); + void removeImportPath(); + +private: + QListWidget *m_importListWidget; + ProjectPage *m_projectPage; + WorkspacePage *m_workspacePage; + MainDocumentPage *m_mainDocumentPage; +}; diff --git a/src/projectmanager.cpp b/src/projectmanager.cpp new file mode 100644 index 0000000..514ffec --- /dev/null +++ b/src/projectmanager.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** 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. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include "projectmanager.h" + +#include <QFile> +#include <QDebug> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonArray> + +const QLatin1String MainKey("main"); +const QLatin1String WorkspaceKey("workspace"); +const QLatin1String ImportsKey("imports"); +const QLatin1String QmlLiveExtension(".qmllive"); + +ProjectManager::ProjectManager(QObject *parent) + : QObject(parent) + , m_mainDocument("main.qml") + , m_workspace("") + , m_projectName("") +{ + +} + +bool ProjectManager::read(const QString &path) +{ + reset(); + + QFile file(path); + if (!file.open(QIODevice::ReadOnly)) { + qWarning() << "Unable to open document " << path; + return false; + } + m_projectName = file.fileName(); + QByteArray data = file.readAll(); + QJsonParseError error; + QJsonDocument document = QJsonDocument::fromJson(data, &error); + if (error.error) { + qWarning() << "error parsing JSON document" << error.errorString(); + return false; + } + if (!document.isObject()) { + qWarning() << "Document must be a JSON object"; + return false; + } + QJsonObject root = document.object(); + if (root.contains(MainKey)) + m_mainDocument = root.value(MainKey).toString(); + if (root.contains(WorkspaceKey)) + { + QString workspace = root.value(WorkspaceKey).toString(); + if ((workspace.compare(".") == 0) || (workspace.compare("./") == 0)) { + m_workspace = QFileInfo(path).absolutePath(); + } + else { + m_workspace = QDir(workspace).absolutePath(); + } + } + if (root.contains(ImportsKey) && root.value(ImportsKey).isArray()) { + QJsonArray imports = root.value(ImportsKey).toArray(); + for (QJsonValue value : imports) + m_imports.append(value.toString()); + } + return true; +} + +void ProjectManager::write(const QString &path) +{ + QFile file(path); + if (!file.open(QIODevice::WriteOnly)) { + qWarning() << "Unable to write to document: " << path; + return; + } + QJsonObject root; + root.insert(MainKey, QJsonValue(m_mainDocument)); + root.insert(WorkspaceKey, QJsonValue(m_workspace)); + QJsonArray imports; + for (const QString &import : m_imports) + imports.append(QJsonValue(import)); + root.insert(ImportsKey, imports); + QJsonDocument document(root); + file.write(document.toJson()); +} + +void ProjectManager::create(const QString &projectName) +{ + m_projectName = projectName; + QString path = QString(m_workspace).append(QDir::separator()).append(projectName).append(QmlLiveExtension); + qWarning() << path; + write(path); +} + +QString ProjectManager::mainDocument() const +{ + return m_mainDocument; +} + +QString ProjectManager::workspace() const +{ + return m_workspace; +} + +QStringList ProjectManager::imports() const +{ + return m_imports; +} + +void ProjectManager::reset() +{ + m_mainDocument = QString("main.qml"); + m_workspace = QString(""); + m_imports.clear(); +} + +void ProjectManager::setProjectName(const QString &projectName) +{ + m_projectName = projectName; +} +void ProjectManager::setMainDocument(const QString &mainDocument) +{ + m_mainDocument = mainDocument; +} +void ProjectManager::setWorkspace(const QString &workspace) +{ + m_workspace = workspace; +} +void ProjectManager::setImports(const QStringList &imports) +{ + m_imports = imports; +} + diff --git a/src/projectmanager.h b/src/projectmanager.h new file mode 100644 index 0000000..d8d10d1 --- /dev/null +++ b/src/projectmanager.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite 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 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** 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. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#pragma once + +#include <QtCore> + +#include "qmllive_global.h" + +class QMLLIVESHARED_EXPORT ProjectManager : public QObject +{ + Q_OBJECT +public: + explicit ProjectManager(QObject *parent = nullptr); + + bool read(const QString &path); + void write(const QString &path=QString()); + void create(const QString &projectName); + QString mainDocument() const; + QString workspace() const; + QStringList imports() const; + + void setProjectName(const QString &projectName); + void setMainDocument(const QString &mainDocument); + void setWorkspace(const QString &workspace); + void setImports(const QStringList &imports); +private: + void reset(); + +private: + QString m_mainDocument; + QString m_workspace; + QStringList m_imports; + QString m_projectName; +}; diff --git a/src/src.pri b/src/src.pri index 1af18e4..38504b4 100644 --- a/src/src.pri +++ b/src/src.pri @@ -20,7 +20,8 @@ SOURCES += \ $$PWD/logger.cpp \ $$PWD/remotelogger.cpp \ $$PWD/logreceiver.cpp \ - $$PWD/fontadapter.cpp + $$PWD/fontadapter.cpp \ + $$PWD/projectmanager.cpp public_headers += \ $$PWD/livedocument.h \ @@ -33,7 +34,8 @@ public_headers += \ $$PWD/remotepublisher.h \ $$PWD/remotereceiver.h \ $$PWD/contentadapterinterface.h \ - $$PWD/remotelogger.h + $$PWD/remotelogger.h \ + $$PWD/projectmanager.h HEADERS += \ $$public_headers \ |