forked from qt-creator/qt-creator
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:
@@ -397,13 +397,7 @@ Item {
|
||||
currentIndex: BackendApi.targetQtVersionIndex
|
||||
font.pixelSize: DialogValues.defaultPixelSize
|
||||
|
||||
model: ListModel {
|
||||
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" }
|
||||
}
|
||||
model: BackendApi.targetQtVersions
|
||||
|
||||
onActivated: (index) => {
|
||||
BackendApi.targetQtVersionIndex = index
|
||||
|
@@ -238,7 +238,7 @@
|
||||
"type": "ComboBox",
|
||||
"data":
|
||||
{
|
||||
"index": 4,
|
||||
"index": 3,
|
||||
"items":
|
||||
[
|
||||
{
|
||||
|
@@ -191,22 +191,17 @@ void QdsNewDialog::onWizardCreated(QStandardItemModel *screenSizeModel, QStandar
|
||||
auto userPreset = m_currentPreset->asUserPreset();
|
||||
|
||||
if (m_qmlDetailsLoaded) {
|
||||
if (m_currentPreset->isUserPreset()) {
|
||||
if (m_wizard.haveVirtualKeyboard())
|
||||
m_targetQtVersions.clear();
|
||||
if (m_currentPreset->isUserPreset() && m_wizard.haveVirtualKeyboard())
|
||||
setUseVirtualKeyboard(userPreset->useQtVirtualKeyboard);
|
||||
|
||||
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)
|
||||
setTargetQtVersionIndex(index);
|
||||
}
|
||||
} else {
|
||||
if (m_wizard.haveTargetQtVersion()) {
|
||||
int index = m_wizard.targetQtVersionIndex();
|
||||
if (index != -1)
|
||||
setTargetQtVersionIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
emit haveVirtualKeyboardChanged();
|
||||
emit haveTargetQtVersionChanged();
|
||||
|
@@ -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
|
||||
|
@@ -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");
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user