Added mod reinstall dialog

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-11-25 00:18:10 +02:00
parent 7f6027498e
commit 1a0fd5f993
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318
11 changed files with 165 additions and 8 deletions

View file

@ -120,6 +120,8 @@ void ModPage::updateVersionList()
auto current_pack = getCurrentPack();
if (!current_pack)
return;
auto installedVersion = m_model->getInstalledPackVersion(current_pack);
auto installedIndex = -1;
for (int i = 0; i < current_pack->versions.size(); i++) {
auto version = current_pack->versions[i];
bool valid = false;
@ -129,13 +131,19 @@ void ModPage::updateVersionList()
break;
}
}
QString flag;
if (installedIndex == -1 && installedVersion.isValid() && installedVersion == version.fileId) {
flag = tr("[installed]");
installedIndex = i;
}
// Only add the version if it's valid or using the 'Any' filter, but never if the version is opted out
if ((valid || m_filter->versions.empty()) && !optedOut(version)) {
auto release_type = version.version_type.isValid() ? QString(" [%1]").arg(version.version_type.toString()) : "";
m_ui->versionSelectionBox->addItem(QString("%1%2").arg(version.version, release_type), QVariant(i));
m_ui->versionSelectionBox->addItem(QString("%1%2%3").arg(version.version, release_type, flag), QVariant(i));
}
}
if (installedIndex != -1)
m_ui->versionSelectionBox->setCurrentIndex(installedIndex);
if (m_ui->versionSelectionBox->count() == 0) {
m_ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1));
m_ui->resourceSelectionButton->setText(tr("Cannot select invalid version :("));