forked from qt-creator/qt-creator
QmlDesigner: Enable 'automatic cmake generation' by wizard
Task-number: QDS-13344 Change-Id: Ie3e5baf42e31375df8d2d00cb5bf916b2b8bd2ad Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -391,6 +391,21 @@ Item {
|
||||
visible: BackendApi.haveVirtualKeyboard
|
||||
}
|
||||
|
||||
StudioControls.CheckBox {
|
||||
id: enableCMakeGeneration
|
||||
actionIndicatorVisible: false
|
||||
text: qsTr("Enable Cmake Generation")
|
||||
font.pixelSize: DialogValues.defaultPixelSize
|
||||
checked: BackendApi.enableCMakeGeneration
|
||||
visible: BackendApi.hasCMakeGeneration
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: BackendApi
|
||||
property: "enableCMakeGeneration"
|
||||
value: enableCMakeGeneration.checked
|
||||
}
|
||||
|
||||
RowLayout { // Target Qt Version
|
||||
width: parent.width
|
||||
visible: BackendApi.haveTargetQtVersion
|
||||
|
@@ -32,6 +32,7 @@
|
||||
{ "key": "ScreenWidth", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenWidth : value('CustomScreenWidth')}" },
|
||||
{ "key": "ScreenHeight", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenHeight : value('CustomScreenHeight')}" },
|
||||
{ "key": "UseVirtualKeyboardDefault", "value": "%{JS: false}" },
|
||||
{ "key": "EnableCMakeGenerationDefault", "value": "%{JS: true}" },
|
||||
{ "key": "QtQuick3DVersion", "value": "%{JS: %{TargetQtVersion}.TargetQuick3DVersion}" }
|
||||
],
|
||||
|
||||
@@ -208,6 +209,15 @@
|
||||
"checked": "%{UseVirtualKeyboardDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "EnableCMakeGeneration",
|
||||
"trDisplayName": "Enable CMake Genertion",
|
||||
"type": "CheckBox",
|
||||
"data":
|
||||
{
|
||||
"checked": "%{EnableCMakeGenerationDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CustomScreenWidth",
|
||||
"trDisplayName": "Custom screen width:",
|
||||
|
@@ -32,6 +32,7 @@
|
||||
{ "key": "ScreenWidth", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenWidth : value('CustomScreenWidth')}" },
|
||||
{ "key": "ScreenHeight", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenHeight : value('CustomScreenHeight')}" },
|
||||
{ "key": "UseVirtualKeyboardDefault", "value": "%{JS: false}" },
|
||||
{ "key": "EnableCMakeGenerationDefault", "value": "%{JS: true}" },
|
||||
{ "key": "QtQuick3DVersion", "value": "%{JS: %{TargetQtVersion}.TargetQuick3DVersion}" }
|
||||
],
|
||||
|
||||
@@ -208,6 +209,15 @@
|
||||
"checked": "%{UseVirtualKeyboardDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "EnableCMakeGeneration",
|
||||
"trDisplayName": "Enable CMake Genertion",
|
||||
"type": "CheckBox",
|
||||
"data":
|
||||
{
|
||||
"checked": "%{EnableCMakeGenerationDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CustomScreenWidth",
|
||||
"trDisplayName": "Custom screen width:",
|
||||
|
@@ -31,6 +31,7 @@
|
||||
{ "key": "ScreenWidth", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenWidth : value('CustomScreenWidth')}" },
|
||||
{ "key": "ScreenHeight", "value": "%{JS: value('UseStandardResolution') === 'true' ? %{ScreenFactor}.ScreenHeight : value('CustomScreenHeight')}" },
|
||||
{ "key": "UseVirtualKeyboardDefault", "value": "%{JS: false}" },
|
||||
{ "key": "EnableCMakeGenerationDefault", "value": "%{JS: true}" },
|
||||
{ "key": "DefaultStyle", "value": "Basic" }
|
||||
],
|
||||
|
||||
@@ -207,6 +208,15 @@
|
||||
"checked": "%{UseVirtualKeyboardDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "EnableCMakeGeneration",
|
||||
"trDisplayName": "Enable CMake Genertion",
|
||||
"type": "CheckBox",
|
||||
"data":
|
||||
{
|
||||
"checked": "%{EnableCMakeGenerationDefault}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "CustomScreenWidth",
|
||||
"trDisplayName": "Custom screen width:",
|
||||
|
@@ -103,6 +103,10 @@ Project {
|
||||
/* Required for deployment */
|
||||
targetDirectory: "/opt/%{ProjectName}"
|
||||
|
||||
@if %{EnableCMakeGeneration}
|
||||
enableCMakeGeneration: true
|
||||
@endif
|
||||
|
||||
qdsVersion: "4.6"
|
||||
|
||||
quickVersion: "%{QtQuickVersion}"
|
||||
|
@@ -4,6 +4,7 @@ add_qtc_plugin(StudioWelcome
|
||||
PLUGIN_DEPENDS Core ProjectExplorer QtSupport QmlDesigner
|
||||
DEFINES STUDIO_QML_PATH="${CMAKE_CURRENT_SOURCE_DIR}/qml/"
|
||||
SOURCES
|
||||
fieldhelper.cpp fieldhelper.h
|
||||
studiowelcomeplugin.cpp studiowelcomeplugin.h
|
||||
newprojectdialogimageprovider.cpp newprojectdialogimageprovider.h
|
||||
presetmodel.cpp presetmodel.h
|
||||
|
@@ -43,6 +43,9 @@ void CreateProject::processFieldPage(ProjectExplorer::JsonFieldPage *page)
|
||||
if (page->jsonField("UseVirtualKeyboard"))
|
||||
m_wizard.setUseVirtualKeyboard(m_useVirtualKeyboard);
|
||||
|
||||
if (page->jsonField("EnableCMakeGeneration"))
|
||||
m_wizard.enableCMakeGeneration(m_enableCMakeGeneration);
|
||||
|
||||
auto widthField = dynamic_cast<ProjectExplorer::LineEditField *>(page->jsonField("CustomScreenWidth"));
|
||||
auto heightField = dynamic_cast<ProjectExplorer::LineEditField *>(page->jsonField("CustomScreenHeight"));
|
||||
|
||||
|
@@ -28,6 +28,11 @@ public:
|
||||
|
||||
CreateProject &withStyle(int styleIndex) { m_styleIndex = styleIndex; return *this; }
|
||||
CreateProject &useQtVirtualKeyboard(bool value) { m_useVirtualKeyboard = value; return *this; }
|
||||
CreateProject &enableCMakeGeneration(bool value)
|
||||
{
|
||||
m_enableCMakeGeneration = value;
|
||||
return *this;
|
||||
}
|
||||
CreateProject &saveAsDefaultLocation(bool value) { m_saveAsDefaultLocation = value; return *this; }
|
||||
CreateProject &withTargetQtVersion(int targetQtVersionIndex)
|
||||
{ m_targetQtVersionIndex = targetQtVersionIndex; return *this; }
|
||||
@@ -48,6 +53,7 @@ private:
|
||||
QString m_customHeight;
|
||||
int m_styleIndex = -1;
|
||||
bool m_useVirtualKeyboard = false;
|
||||
bool m_enableCMakeGeneration = false;
|
||||
bool m_saveAsDefaultLocation = false;
|
||||
int m_targetQtVersionIndex = -1;
|
||||
};
|
||||
|
89
src/plugins/studiowelcome/fieldhelper.cpp
Normal file
89
src/plugins/studiowelcome/fieldhelper.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "fieldhelper.h"
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonfieldpage.h>
|
||||
#include <projectexplorer/jsonwizard/jsonfieldpage_p.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace StudioWelcome::FieldHelper;
|
||||
|
||||
CheckBoxHelper::CheckBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName)
|
||||
: m_field(dynamic_cast<ProjectExplorer::CheckBoxField *>(detailsPage->jsonField(fieldName)))
|
||||
{}
|
||||
|
||||
void CheckBoxHelper::setChecked(bool value)
|
||||
{
|
||||
QTC_ASSERT(m_field, return);
|
||||
|
||||
m_field->setChecked(value);
|
||||
}
|
||||
|
||||
ComboBoxHelper::ComboBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName)
|
||||
: m_field(dynamic_cast<ProjectExplorer::ComboBoxField *>(detailsPage->jsonField(fieldName)))
|
||||
{}
|
||||
|
||||
void ComboBoxHelper::selectIndex(int index)
|
||||
{
|
||||
QTC_ASSERT(m_field, return);
|
||||
|
||||
m_field->selectRow(index);
|
||||
}
|
||||
|
||||
QString ComboBoxHelper::text(int index) const
|
||||
{
|
||||
QTC_ASSERT(m_field, return {});
|
||||
|
||||
QStandardItemModel *model = m_field->model();
|
||||
if (index < 0 || index >= model->rowCount())
|
||||
return {};
|
||||
|
||||
return model->item(index)->text();
|
||||
}
|
||||
|
||||
int ComboBoxHelper::indexOf(const QString &text) const
|
||||
{
|
||||
QTC_ASSERT(m_field, return -1);
|
||||
|
||||
const QStandardItemModel *model = m_field->model();
|
||||
for (int i = 0; i < model->rowCount(); ++i) {
|
||||
const QStandardItem *item = model->item(i, 0);
|
||||
const QString text = item->text();
|
||||
|
||||
if (text == text)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ComboBoxHelper::selectedIndex() const
|
||||
{
|
||||
QTC_ASSERT(m_field, return -1);
|
||||
|
||||
return m_field->selectedRow();
|
||||
}
|
||||
|
||||
QStandardItemModel *ComboBoxHelper::model() const
|
||||
{
|
||||
QTC_ASSERT(m_field, return {});
|
||||
|
||||
return m_field->model();
|
||||
}
|
||||
|
||||
QStringList ComboBoxHelper::allTexts() const
|
||||
{
|
||||
QTC_ASSERT(m_field, return {});
|
||||
|
||||
QStandardItemModel *model = m_field->model();
|
||||
const int rows = model->rowCount();
|
||||
QStringList result;
|
||||
result.reserve(rows);
|
||||
|
||||
for (int i = 0; i < rows; ++i)
|
||||
result.append(model->item(i)->text());
|
||||
|
||||
return result;
|
||||
}
|
46
src/plugins/studiowelcome/fieldhelper.h
Normal file
46
src/plugins/studiowelcome/fieldhelper.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QStandardItemModel)
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class JsonFieldPage;
|
||||
class CheckBoxField;
|
||||
class ComboBoxField;
|
||||
}
|
||||
|
||||
namespace StudioWelcome::FieldHelper {
|
||||
|
||||
class CheckBoxHelper
|
||||
{
|
||||
public:
|
||||
CheckBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName);
|
||||
|
||||
void setChecked(bool value);
|
||||
|
||||
private:
|
||||
ProjectExplorer::CheckBoxField *m_field = nullptr;
|
||||
};
|
||||
|
||||
class ComboBoxHelper
|
||||
{
|
||||
public:
|
||||
ComboBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName);
|
||||
|
||||
void selectIndex(int index);
|
||||
|
||||
QString text(int index) const;
|
||||
int indexOf(const QString &text) const;
|
||||
int selectedIndex() const;
|
||||
QStandardItemModel *model() const;
|
||||
QStringList allTexts() const;
|
||||
|
||||
private:
|
||||
ProjectExplorer::ComboBoxField *m_field = nullptr;
|
||||
};
|
||||
|
||||
} // namespace StudioWelcome::FieldHelper
|
@@ -93,6 +93,7 @@ PresetItems PresetData::makeUserPresets(const PresetItems &wizardPresets,
|
||||
presetItem->qtVersion = userPresetData.qtVersion;
|
||||
presetItem->styleName = userPresetData.styleName;
|
||||
presetItem->useQtVirtualKeyboard = userPresetData.useQtVirtualKeyboard;
|
||||
presetItem->enableCMakeGeneration = userPresetData.enableCMakeGeneration;
|
||||
|
||||
presetItem->create = foundPreset->create;
|
||||
presetItem->description = foundPreset->description;
|
||||
|
@@ -80,6 +80,7 @@ struct UserPresetItem : public PresetItem
|
||||
public:
|
||||
QString userName;
|
||||
bool useQtVirtualKeyboard;
|
||||
bool enableCMakeGeneration;
|
||||
QString qtVersion;
|
||||
QString styleName;
|
||||
};
|
||||
|
@@ -133,6 +133,15 @@ void QdsNewDialog::setProjectLocation(const QString &location)
|
||||
m_wizard.setProjectLocation(m_qmlProjectLocation);
|
||||
}
|
||||
|
||||
void QdsNewDialog::setHasCMakeGeneration(bool haveCmakeGen)
|
||||
{
|
||||
if (m_qmlHasCMakeGeneration == haveCmakeGen)
|
||||
return;
|
||||
|
||||
m_qmlHasCMakeGeneration = haveCmakeGen;
|
||||
emit hasCMakeGenerationChanged();
|
||||
}
|
||||
|
||||
void QdsNewDialog::onStatusMessageChanged(Utils::InfoLabel::InfoType type, const QString &message)
|
||||
{
|
||||
switch (type) {
|
||||
@@ -192,9 +201,16 @@ void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandar
|
||||
auto userPreset = m_currentPreset->asUserPreset();
|
||||
|
||||
if (m_qmlDetailsLoaded) {
|
||||
setHasCMakeGeneration(m_wizard.hasCMakeGeneration());
|
||||
|
||||
if (m_currentPreset->isUserPreset()) {
|
||||
if (getHaveVirtualKeyboard())
|
||||
setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard);
|
||||
if (hasCMakeGeneration())
|
||||
setEnableCMakeGeneration(userPreset->enableCMakeGeneration);
|
||||
}
|
||||
|
||||
m_targetQtVersions.clear();
|
||||
if (m_currentPreset->isUserPreset() && m_wizard.haveVirtualKeyboard())
|
||||
setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard);
|
||||
if (m_wizard.haveTargetQtVersion()) {
|
||||
m_targetQtVersions = m_wizard.targetQtVersionNames();
|
||||
int index = m_currentPreset->isUserPreset() ? m_wizard.targetQtVersionIndex(userPreset->qtVersion)
|
||||
@@ -227,6 +243,15 @@ void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandar
|
||||
}
|
||||
}
|
||||
|
||||
void QdsNewDialog::setEnableCMakeGeneration(bool newQmlEnableCMakeGeneration)
|
||||
{
|
||||
if (m_qmlEnableCMakeGeneration == newQmlEnableCMakeGeneration)
|
||||
return;
|
||||
|
||||
m_qmlEnableCMakeGeneration = newQmlEnableCMakeGeneration;
|
||||
emit enableCMakeGenerationChanged();
|
||||
}
|
||||
|
||||
QString QdsNewDialog::currentPresetQmlPath() const
|
||||
{
|
||||
if (!m_currentPreset || m_currentPreset->qmlPath.isEmpty())
|
||||
@@ -385,6 +410,11 @@ bool QdsNewDialog::getHaveTargetQtVersion() const
|
||||
return m_wizard.haveTargetQtVersion();
|
||||
}
|
||||
|
||||
bool QdsNewDialog::hasCMakeGeneration() const
|
||||
{
|
||||
return m_qmlHasCMakeGeneration;
|
||||
}
|
||||
|
||||
void QdsNewDialog::accept()
|
||||
{
|
||||
CreateProject create{m_wizard};
|
||||
@@ -395,6 +425,7 @@ void QdsNewDialog::accept()
|
||||
.withScreenSizes(m_qmlScreenSizeIndex, m_qmlCustomWidth, m_qmlCustomHeight)
|
||||
.withStyle(getStyleIndex())
|
||||
.useQtVirtualKeyboard(m_qmlUseVirtualKeyboard)
|
||||
.enableCMakeGeneration(m_qmlEnableCMakeGeneration)
|
||||
.saveAsDefaultLocation(m_qmlSaveAsDefaultLocation)
|
||||
.withTargetQtVersion(m_qmlTargetQtVersionIndex)
|
||||
.execute();
|
||||
@@ -446,6 +477,7 @@ UserPresetData QdsNewDialog::currentUserPresetData(const QString &displayName) c
|
||||
QString targetQtVersion = "";
|
||||
QString styleName = "";
|
||||
bool useVirtualKeyboard = false;
|
||||
bool enableCMakeGeneration = false;
|
||||
|
||||
if (m_wizard.haveTargetQtVersion())
|
||||
targetQtVersion = m_wizard.targetQtVersionName(m_qmlTargetQtVersionIndex);
|
||||
@@ -456,13 +488,18 @@ UserPresetData QdsNewDialog::currentUserPresetData(const QString &displayName) c
|
||||
if (m_wizard.haveVirtualKeyboard())
|
||||
useVirtualKeyboard = m_qmlUseVirtualKeyboard;
|
||||
|
||||
UserPresetData preset = {m_currentPreset->categoryId,
|
||||
m_currentPreset->wizardName,
|
||||
displayName,
|
||||
screenSize,
|
||||
useVirtualKeyboard,
|
||||
targetQtVersion,
|
||||
styleName};
|
||||
if (m_wizard.hasCMakeGeneration())
|
||||
enableCMakeGeneration = m_qmlEnableCMakeGeneration;
|
||||
|
||||
UserPresetData preset{
|
||||
m_currentPreset->categoryId,
|
||||
m_currentPreset->wizardName,
|
||||
displayName,
|
||||
screenSize,
|
||||
useVirtualKeyboard,
|
||||
enableCMakeGeneration,
|
||||
targetQtVersion,
|
||||
styleName};
|
||||
|
||||
return preset;
|
||||
}
|
||||
|
@@ -34,7 +34,13 @@ public:
|
||||
Q_PROPERTY(QString customHeight MEMBER m_qmlCustomHeight)
|
||||
Q_PROPERTY(int styleIndex MEMBER m_qmlStyleIndex READ getStyleIndex WRITE setStyleIndex)
|
||||
Q_PROPERTY(bool useVirtualKeyboard MEMBER m_qmlUseVirtualKeyboard READ getUseVirtualKeyboard WRITE setUseVirtualKeyboard NOTIFY useVirtualKeyboardChanged)
|
||||
Q_PROPERTY(
|
||||
bool enableCMakeGeneration
|
||||
MEMBER m_qmlEnableCMakeGeneration
|
||||
WRITE setEnableCMakeGeneration
|
||||
NOTIFY enableCMakeGenerationChanged)
|
||||
Q_PROPERTY(bool haveVirtualKeyboard MEMBER m_qmlHaveVirtualKeyboard READ getHaveVirtualKeyboard NOTIFY haveVirtualKeyboardChanged)
|
||||
Q_PROPERTY(bool hasCMakeGeneration READ hasCMakeGeneration NOTIFY hasCMakeGenerationChanged)
|
||||
Q_PROPERTY(bool haveTargetQtVersion MEMBER m_qmlHaveTargetQtVersion READ getHaveTargetQtVersion NOTIFY haveTargetQtVersionChanged)
|
||||
Q_PROPERTY(int targetQtVersionIndex MEMBER m_qmlTargetQtVersionIndex READ getTargetQtVersionIndex WRITE setTargetQtVersionIndex NOTIFY targetQtVersionIndexChanged)
|
||||
Q_PROPERTY(bool saveAsDefaultLocation MEMBER m_qmlSaveAsDefaultLocation WRITE setSaveAsDefaultLocation)
|
||||
@@ -85,12 +91,15 @@ public:
|
||||
bool getFieldsValid() const { return m_qmlFieldsValid; }
|
||||
bool getHaveVirtualKeyboard() const;
|
||||
bool getHaveTargetQtVersion() const;
|
||||
bool hasCMakeGeneration() const;
|
||||
|
||||
void setSaveAsDefaultLocation(bool value) { m_qmlSaveAsDefaultLocation = value; }
|
||||
|
||||
QString getStatusMessage() const { return m_qmlStatusMessage; }
|
||||
QString getStatusType() const { return m_qmlStatusType; }
|
||||
|
||||
void setEnableCMakeGeneration(bool newQmlEnableCMakeGeneration);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
void reject();
|
||||
@@ -102,7 +111,9 @@ signals:
|
||||
void projectLocationChanged();
|
||||
void projectDescriptionChanged();
|
||||
void useVirtualKeyboardChanged();
|
||||
void enableCMakeGenerationChanged();
|
||||
void haveVirtualKeyboardChanged();
|
||||
void hasCMakeGenerationChanged();
|
||||
void haveTargetQtVersionChanged();
|
||||
void statusMessageChanged();
|
||||
void statusTypeChanged();
|
||||
@@ -129,6 +140,8 @@ private:
|
||||
emit projectDescriptionChanged();
|
||||
}
|
||||
|
||||
void setHasCMakeGeneration(bool haveCmakeGen);
|
||||
|
||||
QString projectDescription() const { return m_qmlProjectDescription; }
|
||||
|
||||
void updateScreenSizes();
|
||||
@@ -156,7 +169,9 @@ private:
|
||||
// m_qmlStyleIndex is like a cache, so it needs to be updated on get()
|
||||
mutable int m_qmlStyleIndex = -1;
|
||||
bool m_qmlUseVirtualKeyboard = false;
|
||||
bool m_qmlEnableCMakeGeneration = false;
|
||||
bool m_qmlHaveVirtualKeyboard = false;
|
||||
bool m_qmlHasCMakeGeneration = false;
|
||||
bool m_qmlHaveTargetQtVersion = false;
|
||||
bool m_qmlSaveAsDefaultLocation = false;
|
||||
bool m_qmlFieldsValid = false;
|
||||
|
@@ -67,13 +67,16 @@ void UserPresetsStore::savePresets(const std::vector<UserPresetData> &presetItem
|
||||
QJsonArray jsonArray;
|
||||
|
||||
for (const auto &preset : presetItems) {
|
||||
QJsonObject obj({{"categoryId", preset.categoryId},
|
||||
{"wizardName", preset.wizardName},
|
||||
{"name", preset.name},
|
||||
{"screenSize", preset.screenSize},
|
||||
{"useQtVirtualKeyboard", preset.useQtVirtualKeyboard},
|
||||
{"qtVersion", preset.qtVersion},
|
||||
{"styleName", preset.styleName}});
|
||||
QJsonObject obj{
|
||||
{"categoryId", preset.categoryId},
|
||||
{"wizardName", preset.wizardName},
|
||||
{"name", preset.name},
|
||||
{"screenSize", preset.screenSize},
|
||||
{"useQtVirtualKeyboard", preset.useQtVirtualKeyboard},
|
||||
{"enableCMakeGeneration", preset.enableCMakeGeneration},
|
||||
{"qtVersion", preset.qtVersion},
|
||||
{"styleName", preset.styleName},
|
||||
};
|
||||
|
||||
jsonArray.append(QJsonValue{obj});
|
||||
}
|
||||
@@ -164,6 +167,7 @@ std::vector<UserPresetData> UserPresetsStore::fetchAll() const
|
||||
preset.name = obj["name"].toString();
|
||||
preset.screenSize = obj["screenSize"].toString();
|
||||
preset.useQtVirtualKeyboard = obj["useQtVirtualKeyboard"].toBool();
|
||||
preset.enableCMakeGeneration = obj["enableCMakeGeneration"].toBool();
|
||||
preset.qtVersion = obj["qtVersion"].toString();
|
||||
preset.styleName = obj["styleName"].toString();
|
||||
|
||||
|
@@ -20,6 +20,7 @@ struct UserPresetData
|
||||
QString screenSize;
|
||||
|
||||
bool useQtVirtualKeyboard;
|
||||
bool enableCMakeGeneration;
|
||||
QString qtVersion;
|
||||
QString styleName;
|
||||
|
||||
@@ -36,6 +37,7 @@ inline QDebug &operator<<(QDebug &d, const UserPresetData &preset)
|
||||
d << "UserPreset{category = " << preset.categoryId;
|
||||
d << "; wizardName = " << preset.wizardName;
|
||||
d << "; name = " << preset.name;
|
||||
d << "; cmakeGeneration = " << preset.enableCMakeGeneration;
|
||||
d << "; screenSize = " << preset.screenSize;
|
||||
d << "; keyboard = " << preset.useQtVirtualKeyboard;
|
||||
d << "; qt = " << preset.qtVersion;
|
||||
@@ -48,9 +50,10 @@ inline QDebug &operator<<(QDebug &d, const UserPresetData &preset)
|
||||
inline bool operator==(const UserPresetData &lhs, const UserPresetData &rhs)
|
||||
{
|
||||
return lhs.categoryId == rhs.categoryId && lhs.wizardName == rhs.wizardName
|
||||
&& lhs.name == rhs.name && lhs.screenSize == rhs.screenSize
|
||||
&& lhs.enableCMakeGeneration == rhs.enableCMakeGeneration && lhs.name == rhs.name
|
||||
&& lhs.screenSize == rhs.screenSize
|
||||
&& lhs.useQtVirtualKeyboard == rhs.useQtVirtualKeyboard && lhs.qtVersion == rhs.qtVersion
|
||||
&& lhs.styleName == rhs.styleName;;
|
||||
&& lhs.styleName == rhs.styleName;
|
||||
}
|
||||
|
||||
enum class StorePolicy {UniqueNames, UniqueValues};
|
||||
|
@@ -1,20 +1,21 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QWizardPage>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "wizardhandler.h"
|
||||
#include "fieldhelper.h"
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonfieldpage.h>
|
||||
#include <projectexplorer/jsonwizard/jsonfieldpage_p.h>
|
||||
|
||||
#include <projectexplorer/jsonwizard/jsonprojectpage.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/wizard.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QWizardPage>
|
||||
|
||||
using namespace StudioWelcome;
|
||||
using namespace StudioWelcome::FieldHelper;
|
||||
|
||||
void WizardHandler::reset(const std::shared_ptr<PresetItem> &presetInfo, int presetSelection)
|
||||
{
|
||||
@@ -57,8 +58,8 @@ void WizardHandler::setupWizard()
|
||||
emit wizardCreationFailed();
|
||||
return;
|
||||
}
|
||||
auto *screenFactorModel = getScreenFactorModel(m_detailsPage);
|
||||
auto *styleModel = getStyleModel(m_detailsPage);
|
||||
auto *screenFactorModel = getScreenFactorModel();
|
||||
auto *styleModel = getStyleModel();
|
||||
|
||||
emit wizardCreated(screenFactorModel, styleModel);
|
||||
}
|
||||
@@ -105,16 +106,9 @@ void WizardHandler::initializeFieldsPage(QWizardPage *page)
|
||||
fieldsPage->initializePage();
|
||||
}
|
||||
|
||||
QStandardItemModel *WizardHandler::getScreenFactorModel(ProjectExplorer::JsonFieldPage *page)
|
||||
QStandardItemModel *WizardHandler::getScreenFactorModel()
|
||||
{
|
||||
auto *field = page->jsonField("ScreenFactor");
|
||||
if (!field)
|
||||
return nullptr;
|
||||
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return nullptr);
|
||||
|
||||
return cbfield->model();
|
||||
return ComboBoxHelper(m_detailsPage, "ScreenFactor").model();
|
||||
}
|
||||
|
||||
bool WizardHandler::haveStyleModel() const
|
||||
@@ -122,16 +116,9 @@ bool WizardHandler::haveStyleModel() const
|
||||
return m_wizard->hasField("ControlsStyle");
|
||||
}
|
||||
|
||||
QStandardItemModel *WizardHandler::getStyleModel(ProjectExplorer::JsonFieldPage *page)
|
||||
QStandardItemModel *WizardHandler::getStyleModel()
|
||||
{
|
||||
auto *field = page->jsonField("ControlsStyle");
|
||||
if (!field)
|
||||
return nullptr;
|
||||
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField*>(field);
|
||||
QTC_ASSERT(cbfield, return nullptr);
|
||||
|
||||
return cbfield->model();
|
||||
return ComboBoxHelper(m_detailsPage, "ControlsStyle").model();
|
||||
}
|
||||
|
||||
void WizardHandler::onWizardResetting()
|
||||
@@ -147,61 +134,27 @@ void WizardHandler::onWizardResetting()
|
||||
|
||||
void WizardHandler::setScreenSizeIndex(int index)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ScreenFactor");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return);
|
||||
|
||||
cbfield->selectRow(index);
|
||||
ComboBoxHelper(m_detailsPage, "ScreenFactor").selectIndex(index);
|
||||
}
|
||||
|
||||
QString WizardHandler::screenSizeName(int index) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ScreenFactor");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return "");
|
||||
|
||||
QStandardItemModel *model = cbfield->model();
|
||||
if (index < 0 || index >= model->rowCount())
|
||||
return {};
|
||||
|
||||
QString text = model->item(index)->text();
|
||||
return text;
|
||||
return ComboBoxHelper(m_detailsPage, "ScreenFactor").text(index);
|
||||
}
|
||||
|
||||
int WizardHandler::screenSizeIndex() const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ScreenFactor");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
return cbfield->selectedRow();
|
||||
return ComboBoxHelper(m_detailsPage, "ScreenFactor").selectedIndex();
|
||||
}
|
||||
|
||||
int WizardHandler::screenSizeIndex(const QString &sizeName) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ScreenFactor");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return false);
|
||||
|
||||
const QStandardItemModel *model = cbfield->model();
|
||||
for (int i = 0; i < model->rowCount(); ++i) {
|
||||
const QStandardItem *item = model->item(i, 0);
|
||||
const QString text = item->text();
|
||||
|
||||
if (text == sizeName)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ComboBoxHelper(m_detailsPage, "ScreenFactor").indexOf(sizeName);
|
||||
}
|
||||
|
||||
void WizardHandler::setTargetQtVersionIndex(int index)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return);
|
||||
|
||||
cbfield->selectRow(index);
|
||||
ComboBoxHelper(m_detailsPage, "TargetQtVersion").selectIndex(index);
|
||||
}
|
||||
|
||||
bool WizardHandler::haveTargetQtVersion() const
|
||||
@@ -211,117 +164,47 @@ bool WizardHandler::haveTargetQtVersion() const
|
||||
|
||||
QString WizardHandler::targetQtVersionName(int index) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return "");
|
||||
|
||||
QStandardItemModel *model = cbfield->model();
|
||||
if (index < 0 || index >= model->rowCount())
|
||||
return {};
|
||||
|
||||
QString text = model->item(index)->text();
|
||||
return text;
|
||||
return ComboBoxHelper(m_detailsPage, "TargetQtVersion").text(index);
|
||||
}
|
||||
|
||||
QStringList WizardHandler::targetQtVersionNames() const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return {});
|
||||
|
||||
QStandardItemModel *model = cbfield->model();
|
||||
QStringList targetVersions;
|
||||
|
||||
for (int i = 0; i < model->rowCount(); ++i)
|
||||
targetVersions.append(model->item(i)->text());
|
||||
|
||||
return targetVersions;
|
||||
return ComboBoxHelper(m_detailsPage, "TargetQtVersion").allTexts();
|
||||
}
|
||||
|
||||
int WizardHandler::targetQtVersionIndex(const QString &qtVersionName) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
const QStandardItemModel *model = cbfield->model();
|
||||
for (int i = 0; i < model->rowCount(); ++i) {
|
||||
const QStandardItem *item = model->item(i, 0);
|
||||
const QString text = item->text();
|
||||
|
||||
if (text == qtVersionName)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ComboBoxHelper(m_detailsPage, "TargetQtVersion").indexOf(qtVersionName);
|
||||
}
|
||||
|
||||
int WizardHandler::targetQtVersionIndex() const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
return cbfield->selectedRow();
|
||||
return ComboBoxHelper(m_detailsPage, "TargetQtVersion").selectedIndex();
|
||||
}
|
||||
|
||||
void WizardHandler::setStyleIndex(int index)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ControlsStyle");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return);
|
||||
|
||||
cbfield->selectRow(index);
|
||||
ComboBoxHelper(m_detailsPage, "ControlsStyle").selectIndex(index);
|
||||
}
|
||||
|
||||
int WizardHandler::styleIndex() const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ControlsStyle");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
return cbfield->selectedRow();
|
||||
return ComboBoxHelper(m_detailsPage, "ControlsStyle").selectedIndex();
|
||||
}
|
||||
|
||||
int WizardHandler::styleIndex(const QString &styleName) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ControlsStyle");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
const QStandardItemModel *model = cbfield->model();
|
||||
for (int i = 0; i < model->rowCount(); ++i) {
|
||||
const QStandardItem *item = model->item(i, 0);
|
||||
const QString text = item->text();
|
||||
|
||||
if (text == styleName)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ComboBoxHelper(m_detailsPage, "ControlsStyle").indexOf(styleName);
|
||||
}
|
||||
|
||||
QString WizardHandler::styleName(int index) const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ControlsStyle");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return "");
|
||||
|
||||
QStandardItemModel *model = cbfield->model();
|
||||
if (index < 0 || index >= model->rowCount())
|
||||
return {};
|
||||
|
||||
QString text = model->item(index)->text();
|
||||
return text;
|
||||
return ComboBoxHelper(m_detailsPage, "ControlsStyle").text(index);
|
||||
}
|
||||
|
||||
void WizardHandler::setUseVirtualKeyboard(bool value)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("UseVirtualKeyboard");
|
||||
auto *cbfield = dynamic_cast<ProjectExplorer::CheckBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return);
|
||||
|
||||
cbfield->setChecked(value);
|
||||
CheckBoxHelper(m_detailsPage, "UseVirtualKeyboard").setChecked(value);
|
||||
}
|
||||
|
||||
bool WizardHandler::haveVirtualKeyboard() const
|
||||
@@ -329,6 +212,16 @@ bool WizardHandler::haveVirtualKeyboard() const
|
||||
return m_wizard->hasField("UseVirtualKeyboard");
|
||||
}
|
||||
|
||||
void WizardHandler::enableCMakeGeneration(bool value)
|
||||
{
|
||||
CheckBoxHelper(m_detailsPage, "EnableCMakeGeneration").setChecked(value);
|
||||
}
|
||||
|
||||
bool WizardHandler::hasCMakeGeneration() const
|
||||
{
|
||||
return m_wizard->hasField("EnableCMakeGeneration");
|
||||
}
|
||||
|
||||
void WizardHandler::run(const std::function<void(QWizardPage *)> &processPage)
|
||||
{
|
||||
m_wizard->restart();
|
||||
|
@@ -48,6 +48,9 @@ public:
|
||||
void setUseVirtualKeyboard(bool value);
|
||||
bool haveVirtualKeyboard() const;
|
||||
|
||||
void enableCMakeGeneration(bool value);
|
||||
bool hasCMakeGeneration() const;
|
||||
|
||||
void setProjectName(const QString &name);
|
||||
void setProjectLocation(const Utils::FilePath &location);
|
||||
|
||||
@@ -67,8 +70,8 @@ private:
|
||||
void initializeProjectPage(QWizardPage *page);
|
||||
void initializeFieldsPage(QWizardPage *page);
|
||||
|
||||
QStandardItemModel *getScreenFactorModel(ProjectExplorer::JsonFieldPage *page);
|
||||
QStandardItemModel *getStyleModel(ProjectExplorer::JsonFieldPage *page);
|
||||
QStandardItemModel *getScreenFactorModel();
|
||||
QStandardItemModel *getStyleModel();
|
||||
|
||||
private slots:
|
||||
void onWizardResetting();
|
||||
|
Reference in New Issue
Block a user