Fix: QDS New Project dialog shows incorrect items in the screen size combobox

The index in the backend wizard's combobox was not loaded when
initializing the QML combobox.

Task-number: QDS-5523
Change-Id: I48583ff1ca85f840e9b7314a4e0ed734364c326a
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Samuel Ghinet
2021-11-18 11:54:49 +02:00
parent 8368b4ed64
commit c2a4bebad4
5 changed files with 28 additions and 8 deletions

View File

@@ -192,25 +192,29 @@ Item {
SC.ComboBox { // Screen Size ComboBox SC.ComboBox { // Screen Size ComboBox
id: screenSizeComboBox id: screenSizeComboBox
actionIndicatorVisible: false actionIndicatorVisible: false
currentIndex: 1 currentIndex: -1
model: screenSizeModel model: screenSizeModel
textRole: "display" textRole: "display"
width: parent.width width: parent.width
font.pixelSize: DialogValues.defaultPixelSize font.pixelSize: DialogValues.defaultPixelSize
onActivated: (index) => { onActivated: (index) => {
// NOTE: item 0 is activated when the screenSizeModel is reset dialogBox.setScreenSizeIndex(index);
dialogBox.setScreenSizeIndex(index);
var r = screenSizeModel.screenSizes(index); var size = screenSizeModel.screenSizes(index);
widthField.realValue = r.width; widthField.realValue = size.width;
heightField.realValue = r.height; heightField.realValue = size.height;
} }
Connections { Connections {
target: screenSizeModel target: screenSizeModel
function onModelReset() { function onModelReset() {
screenSizeComboBox.activated(screenSizeComboBox.currentIndex) var newIndex = screenSizeComboBox.currentIndex > -1
? screenSizeComboBox.currentIndex
: dialogBox.screenSizeIndex()
screenSizeComboBox.currentIndex = newIndex
screenSizeComboBox.activated(newIndex)
} }
} }
} // Screen Size ComboBox } // Screen Size ComboBox

View File

@@ -195,6 +195,11 @@ void QdsNewDialog::setScreenSizeIndex(int index)
m_qmlScreenSizeIndex = index; m_qmlScreenSizeIndex = index;
} }
int QdsNewDialog::screenSizeIndex() const
{
return m_wizard.screenSizeIndex();
}
void QdsNewDialog::setTargetQtVersion(int index) void QdsNewDialog::setTargetQtVersion(int index)
{ {
m_wizard.setTargetQtVersionIndex(index); m_wizard.setTargetQtVersionIndex(index);

View File

@@ -66,6 +66,7 @@ public:
Q_INVOKABLE QString currentProjectQmlPath() const; Q_INVOKABLE QString currentProjectQmlPath() const;
Q_INVOKABLE void setScreenSizeIndex(int index); // called when ComboBox item is "activated" 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 void setTargetQtVersion(int index);
Q_INVOKABLE QString chooseProjectLocation(); Q_INVOKABLE QString chooseProjectLocation();

View File

@@ -174,6 +174,15 @@ void WizardHandler::setScreenSizeIndex(int index)
cbfield->selectRow(index); cbfield->selectRow(index);
} }
int WizardHandler::screenSizeIndex() const
{
auto *field = m_detailsPage->jsonField("ScreenFactor");
auto *cbfield = dynamic_cast<ProjectExplorer::ComboBoxField *>(field);
QTC_ASSERT(cbfield, return -1);
return cbfield->selectedRow();
}
void WizardHandler::setTargetQtVersionIndex(int index) void WizardHandler::setTargetQtVersionIndex(int index)
{ {
auto *field = m_detailsPage->jsonField("TargetQtVersion"); auto *field = m_detailsPage->jsonField("TargetQtVersion");

View File

@@ -50,6 +50,7 @@ public:
//TODO: location should not be needed in reset() -- only when creating the project //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 reset(const ProjectItem &projectInfo, int projectSelection, const Utils::FilePath &location);
void setScreenSizeIndex(int index); void setScreenSizeIndex(int index);
int screenSizeIndex() const;
void setTargetQtVersionIndex(int index); void setTargetQtVersionIndex(int index);
bool haveTargetQtVersion() const; bool haveTargetQtVersion() const;
void setStyleIndex(int index); void setStyleIndex(int index);