Compare commits

..

1 Commits

Author SHA1 Message Date
vkamn
7d6d461d7b fix: fixed country selection on errors 2026-08-11 10:49:52 +08:00
3 changed files with 14 additions and 22 deletions

View File

@@ -59,6 +59,11 @@ void ApiCountryModel::updateModel(const QJsonArray &countries, const QString &cu
{
beginResetModel();
const int previousIndex = m_currentIndex;
if (!currentCountryCode.isEmpty()) {
m_currentIndex = -1;
}
m_countries.clear();
for (int i = 0; i < countries.size(); i++) {
CountryInfo countryInfo;
@@ -67,14 +72,17 @@ void ApiCountryModel::updateModel(const QJsonArray &countries, const QString &cu
countryInfo.countryName = countryObject.value(apiDefs::key::serverCountryName).toString();
countryInfo.countryCode = countryObject.value(apiDefs::key::serverCountryCode).toString();
if (countryInfo.countryCode == currentCountryCode) {
if (!currentCountryCode.isEmpty() && countryInfo.countryCode == currentCountryCode) {
m_currentIndex = i;
emit currentIndexChanged(m_currentIndex);
}
m_countries.push_back(countryInfo);
}
endResetModel();
if (m_currentIndex != previousIndex) {
emit currentIndexChanged(m_currentIndex);
}
}
void ApiCountryModel::updateIssuedConfigsInfo(const QJsonArray &issuedConfigs)

View File

@@ -57,7 +57,7 @@ private:
QVector<CountryInfo> m_countries;
QHash<QString, IssuedConfigInfo> m_issuedConfigs;
int m_currentIndex;
int m_currentIndex = -1;
};
#endif // APICOUNTRYMODEL_H

View File

@@ -95,10 +95,6 @@ PageType {
currentIndex: ApiCountryModel.currentIndex
ButtonGroup {
id: containersRadioButtonGroup
}
header: ColumnLayout {
width: menuContent.width
@@ -197,12 +193,10 @@ PageType {
text: countryName
ButtonGroup.group: containersRadioButtonGroup
imageSource: "qrc:/images/controls/download.svg"
checkable: false
checked: index === ApiCountryModel.currentIndex
checkable: !ConnectionController.isConnected
onClicked: {
if (ConnectionController.isConnectionInProgress) {
@@ -217,18 +211,8 @@ PageType {
root.selectConnectionCountry(index, countryCode, countryName)
}
Keys.onEnterPressed: {
if (checkable) {
checked = true
}
containerRadioButton.clicked()
}
Keys.onReturnPressed: {
if (checkable) {
checked = true
}
containerRadioButton.clicked()
}
Keys.onEnterPressed: containerRadioButton.clicked()
Keys.onReturnPressed: containerRadioButton.clicked()
}
Image {