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>
This commit is contained in:
Miikka Heikkinen
2023-08-01 13:50:14 +03:00
parent d1623c38c6
commit 855c27de2a
6 changed files with 31 additions and 23 deletions

View File

@@ -397,13 +397,7 @@ Item {
currentIndex: BackendApi.targetQtVersionIndex currentIndex: BackendApi.targetQtVersionIndex
font.pixelSize: DialogValues.defaultPixelSize font.pixelSize: DialogValues.defaultPixelSize
model: ListModel { model: BackendApi.targetQtVersions
ListElement { name: "Qt 5.15" }
ListElement { name: "Qt 6.2" }
ListElement { name: "Qt 6.3" }
ListElement { name: "Qt 6.4" }
ListElement { name: "Qt 6.5" }
}
onActivated: (index) => { onActivated: (index) => {
BackendApi.targetQtVersionIndex = index BackendApi.targetQtVersionIndex = index

View File

@@ -238,7 +238,7 @@
"type": "ComboBox", "type": "ComboBox",
"data": "data":
{ {
"index": 4, "index": 3,
"items": "items":
[ [
{ {

View File

@@ -191,22 +191,17 @@ void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandar
auto userPreset = m_currentPreset->asUserPreset(); auto userPreset = m_currentPreset->asUserPreset();
if (m_qmlDetailsLoaded) { if (m_qmlDetailsLoaded) {
if (m_currentPreset->isUserPreset()) { m_targetQtVersions.clear();
if (m_wizard.haveVirtualKeyboard()) if (m_currentPreset->isUserPreset() && m_wizard.haveVirtualKeyboard())
setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard); setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard);
if (m_wizard.haveTargetQtVersion()) { if (m_wizard.haveTargetQtVersion()) {
int index = m_wizard.targetQtVersionIndex(userPreset->qtVersion); m_targetQtVersions = m_wizard.targetQtVersionNames();
int index = m_currentPreset->isUserPreset() ? m_wizard.targetQtVersionIndex(userPreset->qtVersion)
: m_wizard.targetQtVersionIndex();
emit targetQtVersionsChanged();
if (index != -1) if (index != -1)
setTargetQtVersionIndex(index); setTargetQtVersionIndex(index);
} }
} else {
if (m_wizard.haveTargetQtVersion()) {
int index = m_wizard.targetQtVersionIndex();
if (index != -1)
setTargetQtVersionIndex(index);
}
}
emit haveVirtualKeyboardChanged(); emit haveVirtualKeyboardChanged();
emit haveTargetQtVersionChanged(); emit haveTargetQtVersionChanged();

View File

@@ -41,6 +41,7 @@ public:
Q_PROPERTY(QString statusType MEMBER m_qmlStatusType READ getStatusType NOTIFY statusTypeChanged) Q_PROPERTY(QString statusType MEMBER m_qmlStatusType READ getStatusType NOTIFY statusTypeChanged)
Q_PROPERTY(bool fieldsValid MEMBER m_qmlFieldsValid READ getFieldsValid NOTIFY fieldsValidChanged) Q_PROPERTY(bool fieldsValid MEMBER m_qmlFieldsValid READ getFieldsValid NOTIFY fieldsValidChanged)
Q_PROPERTY(QString presetName MEMBER m_qmlPresetName) 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 detailsLoaded MEMBER m_qmlDetailsLoaded)
Q_PROPERTY(bool stylesLoaded MEMBER m_qmlStylesLoaded) Q_PROPERTY(bool stylesLoaded MEMBER m_qmlStylesLoaded)
@@ -108,6 +109,7 @@ signals:
void targetQtVersionIndexChanged(); void targetQtVersionIndexChanged();
void userPresetSaved(); void userPresetSaved();
void lastUserPresetRemoved(); void lastUserPresetRemoved();
void targetQtVersionsChanged();
private slots: private slots:
void onStatusMessageChanged(Utils::InfoLabel::InfoType type, const QString &message); void onStatusMessageChanged(Utils::InfoLabel::InfoType type, const QString &message);
@@ -174,6 +176,7 @@ private:
WizardHandler m_wizard; WizardHandler m_wizard;
UserPresetsStore m_recentsStore; UserPresetsStore m_recentsStore;
UserPresetsStore m_userPresetsStore; UserPresetsStore m_userPresetsStore;
QStringList m_targetQtVersions;
}; };
} //namespace StudioWelcome } //namespace StudioWelcome

View File

@@ -220,6 +220,21 @@ QString WizardHandler::targetQtVersionName(int index) const
return text; 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 int WizardHandler::targetQtVersionIndex(const QString &qtVersionName) const
{ {
auto *field = m_detailsPage->jsonField("TargetQtVersion"); auto *field = m_detailsPage->jsonField("TargetQtVersion");

View File

@@ -35,6 +35,7 @@ public:
void setTargetQtVersionIndex(int index); void setTargetQtVersionIndex(int index);
bool haveTargetQtVersion() const; bool haveTargetQtVersion() const;
QString targetQtVersionName(int index) const; QString targetQtVersionName(int index) const;
QStringList targetQtVersionNames() const;
void setStyleIndex(int index); void setStyleIndex(int index);
int styleIndex() const; int styleIndex() const;