diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2023-08-01 13:50:14 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2023-08-01 11:08:20 +0000 |
commit | 855c27de2a06667c9a8dae6e9a38a38581a63624 (patch) | |
tree | 7e76d7edfd1c7d5aa03215406be449f47c2688f9 /src/plugins/studiowelcome | |
parent | d1623c38c6e7c41d6d8c1420855217e024b58949 (diff) |
QmlDesigner: Fix Qt version handling in new project dialog
Different wizards may have different options for target Qt version,
so don't hardcode them, but query them from the wizard.
Also initialize the default target Qt version index to correct value
in 3D wizard.
Fixes: QDS-10223
Change-Id: I75f6bf60655692c52b1350182bf3ac122efc1c74
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'src/plugins/studiowelcome')
-rw-r--r-- | src/plugins/studiowelcome/qdsnewdialog.cpp | 25 | ||||
-rw-r--r-- | src/plugins/studiowelcome/qdsnewdialog.h | 3 | ||||
-rw-r--r-- | src/plugins/studiowelcome/wizardhandler.cpp | 15 | ||||
-rw-r--r-- | src/plugins/studiowelcome/wizardhandler.h | 1 |
4 files changed, 29 insertions, 15 deletions
diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 4bd6293c19a..91c03828d26 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -191,21 +191,16 @@ void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandar auto userPreset = m_currentPreset->asUserPreset(); if (m_qmlDetailsLoaded) { - if (m_currentPreset->isUserPreset()) { - if (m_wizard.haveVirtualKeyboard()) - setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard); - - if (m_wizard.haveTargetQtVersion()) { - int index = m_wizard.targetQtVersionIndex(userPreset->qtVersion); - if (index != -1) - setTargetQtVersionIndex(index); - } - } else { - if (m_wizard.haveTargetQtVersion()) { - int index = m_wizard.targetQtVersionIndex(); - if (index != -1) - setTargetQtVersionIndex(index); - } + 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) + : m_wizard.targetQtVersionIndex(); + emit targetQtVersionsChanged(); + if (index != -1) + setTargetQtVersionIndex(index); } emit haveVirtualKeyboardChanged(); diff --git a/src/plugins/studiowelcome/qdsnewdialog.h b/src/plugins/studiowelcome/qdsnewdialog.h index f63ec4748dc..f4f24d1810a 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.h +++ b/src/plugins/studiowelcome/qdsnewdialog.h @@ -41,6 +41,7 @@ public: Q_PROPERTY(QString statusType MEMBER m_qmlStatusType READ getStatusType NOTIFY statusTypeChanged) Q_PROPERTY(bool fieldsValid MEMBER m_qmlFieldsValid READ getFieldsValid NOTIFY fieldsValidChanged) Q_PROPERTY(QString presetName MEMBER m_qmlPresetName) + Q_PROPERTY(QStringList targetQtVersions MEMBER m_targetQtVersions NOTIFY targetQtVersionsChanged) Q_PROPERTY(bool detailsLoaded MEMBER m_qmlDetailsLoaded) Q_PROPERTY(bool stylesLoaded MEMBER m_qmlStylesLoaded) @@ -108,6 +109,7 @@ signals: void targetQtVersionIndexChanged(); void userPresetSaved(); void lastUserPresetRemoved(); + void targetQtVersionsChanged(); private slots: void onStatusMessageChanged(Utils::InfoLabel::InfoType type, const QString &message); @@ -174,6 +176,7 @@ private: WizardHandler m_wizard; UserPresetsStore m_recentsStore; UserPresetsStore m_userPresetsStore; + QStringList m_targetQtVersions; }; } //namespace StudioWelcome diff --git a/src/plugins/studiowelcome/wizardhandler.cpp b/src/plugins/studiowelcome/wizardhandler.cpp index d6d750d39eb..961fb701eeb 100644 --- a/src/plugins/studiowelcome/wizardhandler.cpp +++ b/src/plugins/studiowelcome/wizardhandler.cpp @@ -220,6 +220,21 @@ QString WizardHandler::targetQtVersionName(int index) const return text; } +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; +} + int WizardHandler::targetQtVersionIndex(const QString &qtVersionName) const { auto *field = m_detailsPage->jsonField("TargetQtVersion"); diff --git a/src/plugins/studiowelcome/wizardhandler.h b/src/plugins/studiowelcome/wizardhandler.h index 1ceadd3a79b..e6009dd9362 100644 --- a/src/plugins/studiowelcome/wizardhandler.h +++ b/src/plugins/studiowelcome/wizardhandler.h @@ -35,6 +35,7 @@ public: void setTargetQtVersionIndex(int index); bool haveTargetQtVersion() const; QString targetQtVersionName(int index) const; + QStringList targetQtVersionNames() const; void setStyleIndex(int index); int styleIndex() const; |