forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -38,18 +38,17 @@
|
||||
|
||||
using namespace StudioWelcome;
|
||||
|
||||
void WizardHandler::reset(const ProjectItem &projectInfo, int projectSelection, const Utils::FilePath &location)
|
||||
void WizardHandler::reset(const PresetItem &presetInfo, int presetSelection)
|
||||
{
|
||||
m_projectItem = projectInfo;
|
||||
m_projectLocation = location;
|
||||
m_selectedProject = projectSelection;
|
||||
m_preset = presetInfo;
|
||||
m_selectedPreset = presetSelection;
|
||||
|
||||
if (!m_wizard) {
|
||||
setupWizard();
|
||||
} else {
|
||||
QObject::connect(m_wizard, &QObject::destroyed, this, &WizardHandler::onWizardResetting);
|
||||
|
||||
// DON'T SET `m_selectedProject = -1` --- we are switching now to a separate project.
|
||||
// DON'T SET `m_selectedPreset = -1` --- we are switching now to a separate preset.
|
||||
emit deletingWizard();
|
||||
|
||||
m_wizard->deleteLater();
|
||||
@@ -60,7 +59,7 @@ void WizardHandler::destroyWizard()
|
||||
{
|
||||
emit deletingWizard();
|
||||
|
||||
m_selectedProject = -1;
|
||||
m_selectedPreset = -1;
|
||||
m_wizard->deleteLater();
|
||||
m_wizard = nullptr;
|
||||
m_detailsPage = nullptr;
|
||||
@@ -68,7 +67,7 @@ void WizardHandler::destroyWizard()
|
||||
|
||||
void WizardHandler::setupWizard()
|
||||
{
|
||||
m_wizard = m_projectItem.create(m_projectLocation);
|
||||
m_wizard = m_preset.create(m_projectLocation);
|
||||
if (!m_wizard) {
|
||||
emit wizardCreationFailed();
|
||||
return;
|
||||
@@ -161,8 +160,8 @@ void WizardHandler::onWizardResetting()
|
||||
|
||||
// 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.
|
||||
// if m_selectedProject != -1 => the wizard was destroyed as a result of reset to a different project type
|
||||
if (m_selectedProject > -1)
|
||||
// if m_selectedPreset != -1 => the wizard was destroyed as a result of reset to a different preset type
|
||||
if (m_selectedPreset > -1)
|
||||
setupWizard();
|
||||
}
|
||||
|
||||
@@ -175,6 +174,20 @@ void WizardHandler::setScreenSizeIndex(int index)
|
||||
cbfield->selectRow(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;
|
||||
}
|
||||
|
||||
int WizardHandler::screenSizeIndex() const
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("ScreenFactor");
|
||||
@@ -184,6 +197,24 @@ int WizardHandler::screenSizeIndex() const
|
||||
return cbfield->selectedRow();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void WizardHandler::setTargetQtVersionIndex(int index)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
@@ -250,7 +281,7 @@ void WizardHandler::run(const std::function<void(QWizardPage *)> &processPage)
|
||||
m_wizard->next();
|
||||
} while (-1 != nextId);
|
||||
|
||||
m_selectedProject = -1;
|
||||
m_selectedPreset = -1;
|
||||
|
||||
// Note: don't call `emit deletingWizard()` here.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user