diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml index 786f17db064..7399db69149 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml @@ -192,25 +192,29 @@ Item { SC.ComboBox { // Screen Size ComboBox id: screenSizeComboBox actionIndicatorVisible: false - currentIndex: 1 + currentIndex: -1 model: screenSizeModel textRole: "display" width: parent.width font.pixelSize: DialogValues.defaultPixelSize onActivated: (index) => { - // NOTE: item 0 is activated when the screenSizeModel is reset - dialogBox.setScreenSizeIndex(index); + dialogBox.setScreenSizeIndex(index); - var r = screenSizeModel.screenSizes(index); - widthField.realValue = r.width; - heightField.realValue = r.height; - } + var size = screenSizeModel.screenSizes(index); + widthField.realValue = size.width; + heightField.realValue = size.height; + } Connections { target: screenSizeModel function onModelReset() { - screenSizeComboBox.activated(screenSizeComboBox.currentIndex) + var newIndex = screenSizeComboBox.currentIndex > -1 + ? screenSizeComboBox.currentIndex + : dialogBox.screenSizeIndex() + + screenSizeComboBox.currentIndex = newIndex + screenSizeComboBox.activated(newIndex) } } } // Screen Size ComboBox diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 9afca814dda..62def1d397e 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -195,6 +195,11 @@ void QdsNewDialog::setScreenSizeIndex(int index) m_qmlScreenSizeIndex = index; } +int QdsNewDialog::screenSizeIndex() const +{ + return m_wizard.screenSizeIndex(); +} + void QdsNewDialog::setTargetQtVersion(int index) { m_wizard.setTargetQtVersionIndex(index); diff --git a/src/plugins/studiowelcome/qdsnewdialog.h b/src/plugins/studiowelcome/qdsnewdialog.h index ede50bc97a7..8e331bd125e 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.h +++ b/src/plugins/studiowelcome/qdsnewdialog.h @@ -66,6 +66,7 @@ public: Q_INVOKABLE QString currentProjectQmlPath() const; Q_INVOKABLE void setScreenSizeIndex(int index); // called when ComboBox item is "activated" + Q_INVOKABLE int screenSizeIndex() const; Q_INVOKABLE void setTargetQtVersion(int index); Q_INVOKABLE QString chooseProjectLocation(); diff --git a/src/plugins/studiowelcome/wizardhandler.cpp b/src/plugins/studiowelcome/wizardhandler.cpp index fce7aa120f9..c8c6c85d12e 100644 --- a/src/plugins/studiowelcome/wizardhandler.cpp +++ b/src/plugins/studiowelcome/wizardhandler.cpp @@ -174,6 +174,15 @@ void WizardHandler::setScreenSizeIndex(int index) cbfield->selectRow(index); } +int WizardHandler::screenSizeIndex() const +{ + auto *field = m_detailsPage->jsonField("ScreenFactor"); + auto *cbfield = dynamic_cast(field); + QTC_ASSERT(cbfield, return -1); + + return cbfield->selectedRow(); +} + void WizardHandler::setTargetQtVersionIndex(int index) { auto *field = m_detailsPage->jsonField("TargetQtVersion"); diff --git a/src/plugins/studiowelcome/wizardhandler.h b/src/plugins/studiowelcome/wizardhandler.h index a828d595f66..ad9424bc441 100644 --- a/src/plugins/studiowelcome/wizardhandler.h +++ b/src/plugins/studiowelcome/wizardhandler.h @@ -50,6 +50,7 @@ public: //TODO: location should not be needed in reset() -- only when creating the project void reset(const ProjectItem &projectInfo, int projectSelection, const Utils::FilePath &location); void setScreenSizeIndex(int index); + int screenSizeIndex() const; void setTargetQtVersionIndex(int index); bool haveTargetQtVersion() const; void setStyleIndex(int index);