2022-05-06 14:27:58 +03:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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 "qdslandingpage.h"
|
2022-05-23 10:35:18 +03:00
|
|
|
#include "qdslandingpagetheme.h"
|
2022-05-06 14:27:58 +03:00
|
|
|
#include "utils/algorithm.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <QtQml/QQmlEngine>
|
2022-06-01 17:33:39 +03:00
|
|
|
#include <QHBoxLayout>
|
2022-05-06 14:27:58 +03:00
|
|
|
#include <QQuickItem>
|
|
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
const char QMLRESOURCEPATH[] = "qmldesigner/propertyEditorQmlSources/imports";
|
|
|
|
|
const char LANDINGPAGEPATH[] = "qmldesigner/landingpage";
|
|
|
|
|
|
2022-06-01 17:33:39 +03:00
|
|
|
QdsLandingPageWidget::QdsLandingPageWidget(QWidget* parent)
|
|
|
|
|
: QWidget(parent)
|
2022-05-06 14:27:58 +03:00
|
|
|
{
|
2022-06-01 17:33:39 +03:00
|
|
|
setLayout(new QHBoxLayout());
|
|
|
|
|
layout()->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QdsLandingPageWidget::~QdsLandingPageWidget()
|
|
|
|
|
{
|
|
|
|
|
if (m_widget)
|
|
|
|
|
m_widget->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QQuickWidget *QdsLandingPageWidget::widget()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget) {
|
|
|
|
|
m_widget = new QQuickWidget();
|
|
|
|
|
layout()->addWidget(m_widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QdsLandingPage::QdsLandingPage(QdsLandingPageWidget *widget, QWidget *parent)
|
|
|
|
|
: m_widget{widget->widget()}
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
|
|
|
|
|
|
setParent(m_widget);
|
2022-05-06 14:27:58 +03:00
|
|
|
|
|
|
|
|
const QString resourcePath = Core::ICore::resourcePath(QMLRESOURCEPATH).toString();
|
|
|
|
|
const QString landingPath = Core::ICore::resourcePath(LANDINGPAGEPATH).toString();
|
|
|
|
|
|
|
|
|
|
qmlRegisterSingletonInstance<QdsLandingPage>("LandingPageApi", 1, 0, "LandingPageApi", this);
|
2022-06-01 17:33:39 +03:00
|
|
|
QdsLandingPageTheme::setupTheme(m_widget->engine());
|
|
|
|
|
|
|
|
|
|
m_widget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
|
|
|
|
m_widget->engine()->addImportPath(landingPath + "/imports");
|
|
|
|
|
m_widget->engine()->addImportPath(resourcePath);
|
|
|
|
|
m_widget->setSource(QUrl::fromLocalFile(landingPath + "/main.qml"));
|
|
|
|
|
|
|
|
|
|
if (m_widget->rootObject()) { // main.qml only works with Qt6
|
|
|
|
|
connect(m_widget->rootObject(), SIGNAL(openQtc(bool)), this, SIGNAL(openCreator(bool)));
|
|
|
|
|
connect(m_widget->rootObject(), SIGNAL(openQds(bool)), this, SIGNAL(openDesigner(bool)));
|
|
|
|
|
connect(m_widget->rootObject(), SIGNAL(installQds()), this, SIGNAL(installDesigner()));
|
|
|
|
|
connect(m_widget->rootObject(), SIGNAL(generateCmake()), this, SIGNAL(generateCmake()));
|
|
|
|
|
connect(m_widget->rootObject(), SIGNAL(generateProjectFile()), this, SIGNAL(generateProjectFile()));
|
2022-05-18 08:58:43 +02:00
|
|
|
}
|
2022-06-01 17:33:39 +03:00
|
|
|
m_widget->hide();
|
2022-05-06 14:27:58 +03:00
|
|
|
}
|
|
|
|
|
|
2022-06-01 17:33:39 +03:00
|
|
|
QWidget *QdsLandingPage::widget()
|
2022-05-06 14:27:58 +03:00
|
|
|
{
|
2022-06-01 17:33:39 +03:00
|
|
|
return m_widget;
|
2022-05-06 14:27:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::show()
|
|
|
|
|
{
|
2022-06-01 17:33:39 +03:00
|
|
|
m_widget->rootObject()->setProperty("qdsInstalled", m_qdsInstalled);
|
|
|
|
|
m_widget->rootObject()->setProperty("projectFileExists", m_projectFileExists);
|
|
|
|
|
m_widget->rootObject()->setProperty("qtVersion", m_qtVersion);
|
|
|
|
|
m_widget->rootObject()->setProperty("qdsVersion", m_qdsVersion);
|
|
|
|
|
m_widget->rootObject()->setProperty("cmakeLists", m_cmakeResources);
|
|
|
|
|
m_widget->rootObject()->setProperty("rememberSelection", Qt::Unchecked);
|
|
|
|
|
m_widget->show();
|
2022-05-06 14:27:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::hide()
|
|
|
|
|
{
|
2022-06-01 17:33:39 +03:00
|
|
|
m_widget->hide();
|
2022-05-06 14:27:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QdsLandingPage::qdsInstalled() const
|
|
|
|
|
{
|
|
|
|
|
return m_qdsInstalled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setQdsInstalled(bool installed)
|
|
|
|
|
{
|
|
|
|
|
m_qdsInstalled = installed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QdsLandingPage::projectFileExists() const
|
|
|
|
|
{
|
|
|
|
|
return m_projectFileExists;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setProjectFileExists(bool exists)
|
|
|
|
|
{
|
|
|
|
|
m_projectFileExists = exists;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QdsLandingPage::qtVersion() const
|
|
|
|
|
{
|
|
|
|
|
return m_qtVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setQtVersion(const QString &version)
|
|
|
|
|
{
|
|
|
|
|
m_qtVersion = version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QdsLandingPage::qdsVersion() const
|
|
|
|
|
{
|
|
|
|
|
return m_qdsVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setQdsVersion(const QString &version)
|
|
|
|
|
{
|
|
|
|
|
m_qdsVersion = version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QStringList QdsLandingPage::cmakeResources() const
|
|
|
|
|
{
|
|
|
|
|
return m_cmakeResources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setCmakeResources(const Utils::FilePaths &resources)
|
|
|
|
|
{
|
|
|
|
|
QStringList strings = Utils::transform(resources,
|
|
|
|
|
[](const Utils::FilePath &path)
|
|
|
|
|
{ return path.fileName(); });
|
|
|
|
|
setCmakeResources(strings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QdsLandingPage::setCmakeResources(const QStringList &resources)
|
|
|
|
|
{
|
|
|
|
|
m_cmakeResources = resources;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|