2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
#include <QWizardPage>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
|
|
#include "wizardhandler.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/jsonwizard/jsonfieldpage.h>
|
|
|
|
|
#include <projectexplorer/jsonwizard/jsonfieldpage_p.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/jsonwizard/jsonprojectpage.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2023-03-21 19:20:55 +01:00
|
|
|
#include <utils/wizard.h>
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
using namespace StudioWelcome;
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
void WizardHandler::reset(const std::shared_ptr<PresetItem> &presetInfo, int presetSelection)
|
2021-11-09 18:58:15 +02:00
|
|
|
{
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
m_preset = presetInfo;
|
|
|
|
|
m_selectedPreset = presetSelection;
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
if (!m_wizard) {
|
|
|
|
|
setupWizard();
|
|
|
|
|
} else {
|
|
|
|
|
QObject::connect(m_wizard, &QObject::destroyed, this, &WizardHandler::onWizardResetting);
|
|
|
|
|
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
// DON'T SET `m_selectedPreset = -1` --- we are switching now to a separate preset.
|
2021-11-09 18:58:15 +02:00
|
|
|
emit deletingWizard();
|
|
|
|
|
|
|
|
|
|
m_wizard->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::destroyWizard()
|
|
|
|
|
{
|
|
|
|
|
emit deletingWizard();
|
|
|
|
|
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
m_selectedPreset = -1;
|
2021-11-09 18:58:15 +02:00
|
|
|
m_wizard->deleteLater();
|
|
|
|
|
m_wizard = nullptr;
|
2021-11-23 17:14:58 +02:00
|
|
|
m_detailsPage = nullptr;
|
2021-11-09 18:58:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::setupWizard()
|
|
|
|
|
{
|
2022-02-23 15:32:34 +02:00
|
|
|
m_wizard = m_preset->create(m_projectLocation);
|
2021-11-09 18:58:15 +02:00
|
|
|
if (!m_wizard) {
|
|
|
|
|
emit wizardCreationFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initializeProjectPage(m_wizard->page(0));
|
|
|
|
|
initializeFieldsPage(m_wizard->page(1));
|
2024-07-11 13:22:36 +02:00
|
|
|
if (!m_detailsPage) {
|
|
|
|
|
emit wizardCreationFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-09 18:58:15 +02:00
|
|
|
auto *screenFactorModel = getScreenFactorModel(m_detailsPage);
|
|
|
|
|
auto *styleModel = getStyleModel(m_detailsPage);
|
|
|
|
|
|
|
|
|
|
emit wizardCreated(screenFactorModel, styleModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::setProjectName(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_wizard, return);
|
|
|
|
|
|
|
|
|
|
QWizardPage *projectPage = m_wizard->page(0);
|
|
|
|
|
auto *jpp = dynamic_cast<ProjectExplorer::JsonProjectPage *>(projectPage);
|
|
|
|
|
QTC_ASSERT(jpp, return);
|
|
|
|
|
|
|
|
|
|
jpp->setProjectName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::setProjectLocation(const Utils::FilePath &location)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_wizard, return);
|
|
|
|
|
|
|
|
|
|
QWizardPage *projectPage = m_wizard->page(0);
|
|
|
|
|
auto *jpp = dynamic_cast<ProjectExplorer::JsonProjectPage *>(projectPage);
|
|
|
|
|
QTC_ASSERT(jpp, return);
|
|
|
|
|
|
|
|
|
|
jpp->setFilePath(location);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::initializeProjectPage(QWizardPage *page)
|
|
|
|
|
{
|
|
|
|
|
auto *jpp = dynamic_cast<ProjectExplorer::JsonProjectPage *>(page);
|
|
|
|
|
QTC_ASSERT(jpp, return);
|
|
|
|
|
|
2022-09-02 16:11:42 +02:00
|
|
|
QObject::connect(jpp, &ProjectExplorer::JsonProjectPage::statusMessageChanged,
|
|
|
|
|
this, &WizardHandler::statusMessageChanged);
|
|
|
|
|
QObject::connect(jpp, &ProjectExplorer::JsonProjectPage::completeChanged,
|
|
|
|
|
this, [this, jpp] { emit projectCanBeCreated(jpp->isComplete()); });
|
2021-11-09 18:58:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::initializeFieldsPage(QWizardPage *page)
|
|
|
|
|
{
|
|
|
|
|
auto fieldsPage = dynamic_cast<ProjectExplorer::JsonFieldPage *>(page); // required for page->jsonField
|
|
|
|
|
QTC_ASSERT(fieldsPage, return);
|
|
|
|
|
m_detailsPage = fieldsPage;
|
|
|
|
|
|
|
|
|
|
fieldsPage->initializePage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItemModel *WizardHandler::getScreenFactorModel(ProjectExplorer::JsonFieldPage *page)
|
|
|
|
|
{
|
|
|
|
|
auto *field = page->jsonField("ScreenFactor");
|
|
|
|
|
if (!field)
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
|
|
|
|
|
QTC_ASSERT(cbfield, return nullptr);
|
|
|
|
|
|
|
|
|
|
return cbfield->model();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
bool WizardHandler::haveStyleModel() const
|
|
|
|
|
{
|
|
|
|
|
return m_wizard->hasField("ControlsStyle");
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 18:58:15 +02:00
|
|
|
QStandardItemModel *WizardHandler::getStyleModel(ProjectExplorer::JsonFieldPage *page)
|
|
|
|
|
{
|
|
|
|
|
auto *field = page->jsonField("ControlsStyle");
|
|
|
|
|
if (!field)
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField*>(field);
|
|
|
|
|
QTC_ASSERT(cbfield, return nullptr);
|
|
|
|
|
|
|
|
|
|
return cbfield->model();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::onWizardResetting()
|
|
|
|
|
{
|
|
|
|
|
m_wizard = nullptr;
|
|
|
|
|
|
|
|
|
|
// if have a wizard request pending => create new wizard
|
|
|
|
|
// note: we always have a wizard request pending here, unless the dialogbox was requested to be destroyed.
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
// if m_selectedPreset != -1 => the wizard was destroyed as a result of reset to a different preset type
|
|
|
|
|
if (m_selectedPreset > -1)
|
2021-11-09 18:58:15 +02:00
|
|
|
setupWizard();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-18 11:54:49 +02:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 18:58:15 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WizardHandler::haveTargetQtVersion() const
|
|
|
|
|
{
|
|
|
|
|
return m_wizard->hasField("TargetQtVersion");
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-01 13:50:14 +03:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 18:58:15 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-23 15:32:34 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 18:58:15 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool WizardHandler::haveVirtualKeyboard() const
|
|
|
|
|
{
|
|
|
|
|
return m_wizard->hasField("UseVirtualKeyboard");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WizardHandler::run(const std::function<void(QWizardPage *)> &processPage)
|
|
|
|
|
{
|
|
|
|
|
m_wizard->restart();
|
|
|
|
|
|
|
|
|
|
int nextId = 0;
|
|
|
|
|
do {
|
|
|
|
|
QWizardPage *page = m_wizard->currentPage();
|
|
|
|
|
QTC_ASSERT(page, return);
|
|
|
|
|
|
|
|
|
|
processPage(page);
|
|
|
|
|
|
|
|
|
|
if (!page->validatePage() || !page->isComplete()) {
|
|
|
|
|
QMessageBox::warning(m_wizard, "New project", "Could not create the project because fields are invalid");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextId = m_wizard->nextId();
|
|
|
|
|
m_wizard->next();
|
|
|
|
|
} while (-1 != nextId);
|
|
|
|
|
|
QDS-5691 Create a tab for Recent choices
The Recents should store presets, rather than normal project items,
while the rest of tabs are to store normal project (i.e. wizard) items
but with the default screen size written under the wizard name.
In this patch I also did a few renames: e.g. the Presets view now uses a
PresetModel rather than ProjectModel, because we now store presets. A
Preset is a higher level concept than Project / Wizard item: it can be a
project/wizard item with pre-defined configurations; and now we can have
multiple presets using the same Wizard factory. Renamed struct
ProjectCategory to WizardCategory, because the items are grouped by the
category of the wizard (i.e. the "category" property of IWizardFactory)
I extracted a class, PresetData, to hold the data that is being shared
by the PresetModel (items in the view) and the PresetCategoryModel
(header/tab items). It stored both information on normal presets and on
recent presets.
Made changes to JsonWizardFactory so that I could extract the list of
screen sizes without requiring to build a wizard object first. This is
important, because multiple JsonWizard objects cannot be created at the
same time and I need to show the screen sizes of multiple presets /
wizards as the Presets view is opened. This also required class
WizardFactories to use JsonWizardFactory instead of Core::IWizardFactory
-- since "screen sizes" are a particularity of the json wizards, not of
all kinds of wizards.
Also, fixed a TODO in WizardHandler::reset() method.
Also, added a few utilities I had need of, in algorithm.h.
Change-Id: Ifd986e2def19b2e112f0aa1ab3db63d522736321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2022-01-10 15:48:29 +02:00
|
|
|
m_selectedPreset = -1;
|
2021-11-09 18:58:15 +02:00
|
|
|
|
|
|
|
|
// Note: don't call `emit deletingWizard()` here.
|
|
|
|
|
|
|
|
|
|
// Note: QWizard::accept calls QObject::deleteLater on the wizard
|
|
|
|
|
m_wizard->accept();
|
|
|
|
|
}
|