|
@@ -441,9 +441,10 @@ void CModListView::selectMod(const QModelIndex & index)
|
|
|
Helper::enableScrollBySwiping(ui->modInfoBrowser);
|
|
|
Helper::enableScrollBySwiping(ui->changelogBrowser);
|
|
|
|
|
|
- QStringList notInstalledDependencies = this->getModsToInstall(modName);
|
|
|
- QStringList unavailableDependencies = this->findUnavailableMods(notInstalledDependencies);
|
|
|
+ QStringList notInstalledDependencies = getModsToInstall(modName);
|
|
|
+ QStringList unavailableDependencies = findUnavailableMods(notInstalledDependencies);
|
|
|
bool translationMismatch = mod.isTranslation() && CGeneralTextHandler::getPreferredLanguage() != mod.getBaseLanguage().toStdString();
|
|
|
+ bool modIsBeingDownloaded = enqueuedModDownloads.contains(mod.getID());
|
|
|
|
|
|
ui->disableButton->setVisible(modStateModel->isModInstalled(mod.getID()) && modStateModel->isModEnabled(mod.getID()));
|
|
|
ui->enableButton->setVisible(modStateModel->isModInstalled(mod.getID()) && !modStateModel->isModEnabled(mod.getID()));
|
|
@@ -454,9 +455,9 @@ void CModListView::selectMod(const QModelIndex & index)
|
|
|
// Block buttons if action is not allowed at this time
|
|
|
ui->disableButton->setEnabled(true);
|
|
|
ui->enableButton->setEnabled(notInstalledDependencies.empty() && !translationMismatch);
|
|
|
- ui->installButton->setEnabled(unavailableDependencies.empty());
|
|
|
+ ui->installButton->setEnabled(unavailableDependencies.empty() && !modIsBeingDownloaded);
|
|
|
ui->uninstallButton->setEnabled(true);
|
|
|
- ui->updateButton->setEnabled(unavailableDependencies.empty());
|
|
|
+ ui->updateButton->setEnabled(unavailableDependencies.empty() && !modIsBeingDownloaded);
|
|
|
|
|
|
loadScreenshots();
|
|
|
}
|
|
@@ -544,9 +545,6 @@ QStringList CModListView::getModsToInstall(QString mod)
|
|
|
candidates.pop_back();
|
|
|
processed.push_back(potentialToInstall);
|
|
|
|
|
|
- if (modStateModel->isModExists(potentialToInstall) && modStateModel->isModInstalled(potentialToInstall))
|
|
|
- continue;
|
|
|
-
|
|
|
if (modStateModel->isSubmod(potentialToInstall))
|
|
|
{
|
|
|
QString topParent = modStateModel->getTopParent(potentialToInstall);
|
|
@@ -560,7 +558,8 @@ QStringList CModListView::getModsToInstall(QString mod)
|
|
|
potentialToInstall = modStateModel->getTopParent(potentialToInstall);
|
|
|
}
|
|
|
|
|
|
- result.push_back(potentialToInstall);
|
|
|
+ if (modStateModel->isModExists(potentialToInstall) && !modStateModel->isModInstalled(potentialToInstall))
|
|
|
+ result.push_back(potentialToInstall);
|
|
|
|
|
|
if (modStateModel->isModExists(potentialToInstall))
|
|
|
{
|
|
@@ -580,6 +579,8 @@ void CModListView::on_updateButton_clicked()
|
|
|
{
|
|
|
QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
|
|
|
doUpdateMod(modName);
|
|
|
+
|
|
|
+ ui->updateButton->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
void CModListView::doUpdateMod(const QString & modName)
|
|
@@ -587,14 +588,14 @@ void CModListView::doUpdateMod(const QString & modName)
|
|
|
auto targetMod = modStateModel->getMod(modName);
|
|
|
|
|
|
if(targetMod.isUpdateAvailable())
|
|
|
- downloadFile(modName + ".zip", targetMod.getDownloadUrl(), modName, targetMod.getDownloadSizeBytes());
|
|
|
+ downloadMod(targetMod);
|
|
|
|
|
|
for(const auto & name : getModsToInstall(modName))
|
|
|
{
|
|
|
auto mod = modStateModel->getMod(name);
|
|
|
// update required mod, install missing (can be new dependency)
|
|
|
if(mod.isUpdateAvailable() || !mod.isInstalled())
|
|
|
- downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
|
|
|
+ downloadMod(mod);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -617,14 +618,18 @@ void CModListView::on_installButton_clicked()
|
|
|
{
|
|
|
QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();
|
|
|
|
|
|
- for(const auto & name : getModsToInstall(modName))
|
|
|
- {
|
|
|
- auto mod = modStateModel->getMod(name);
|
|
|
- if(mod.isAvailable())
|
|
|
- downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
|
|
|
- else if(!modStateModel->isModEnabled(name))
|
|
|
- enableModByName(name);
|
|
|
- }
|
|
|
+ doInstallMod(modName);
|
|
|
+
|
|
|
+ ui->installButton->setEnabled(false);
|
|
|
+}
|
|
|
+
|
|
|
+void CModListView::downloadMod(const ModState & mod)
|
|
|
+{
|
|
|
+ if (enqueuedModDownloads.contains(mod.getID()))
|
|
|
+ return;
|
|
|
+
|
|
|
+ enqueuedModDownloads.push_back(mod.getID());
|
|
|
+ downloadFile(mod.getID() + ".zip", mod.getDownloadUrl(), mod.getName(), mod.getDownloadSizeBytes());
|
|
|
}
|
|
|
|
|
|
void CModListView::downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes)
|
|
@@ -697,6 +702,7 @@ void CModListView::downloadFinished(QStringList savedFiles, QStringList failedFi
|
|
|
doInstallFiles = true;
|
|
|
}
|
|
|
|
|
|
+ enqueuedModDownloads.clear();
|
|
|
dlManager->deleteLater();
|
|
|
dlManager = nullptr;
|
|
|
|
|
@@ -796,6 +802,7 @@ void CModListView::installFiles(QStringList files)
|
|
|
{
|
|
|
ChroniclesExtractor ce(this, [&prog](float progress) { prog = progress; });
|
|
|
ce.installChronicles(exe);
|
|
|
+ enableModByName("chronicles");
|
|
|
return true;
|
|
|
});
|
|
|
|
|
@@ -959,11 +966,13 @@ void CModListView::on_screenshotsList_clicked(const QModelIndex & index)
|
|
|
|
|
|
void CModListView::doInstallMod(const QString & modName)
|
|
|
{
|
|
|
- for(const auto & name : modStateModel->getMod(modName).getDependencies())
|
|
|
+ for(const auto & name : getModsToInstall(modName))
|
|
|
{
|
|
|
auto mod = modStateModel->getMod(name);
|
|
|
- if(!mod.isInstalled())
|
|
|
- downloadFile(name + ".zip", mod.getDownloadUrl(), name, mod.getDownloadSizeBytes());
|
|
|
+ if(mod.isAvailable())
|
|
|
+ downloadMod(mod);
|
|
|
+ else if(!modStateModel->isModEnabled(name))
|
|
|
+ enableModByName(name);
|
|
|
}
|
|
|
}
|
|
|
|