forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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();
|
||||
|
@@ -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<ProjectExplorer::ComboBoxField *>(field);
|
||||
QTC_ASSERT(cbfield, return -1);
|
||||
|
||||
return cbfield->selectedRow();
|
||||
}
|
||||
|
||||
void WizardHandler::setTargetQtVersionIndex(int index)
|
||||
{
|
||||
auto *field = m_detailsPage->jsonField("TargetQtVersion");
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user