From f0bf6eb8080eb9fa1688135db5e141a9d6a06457 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Tue, 10 Dec 2024 22:28:11 +0100 Subject: [PATCH] improved manual install process --- launcher/mainwindow_moc.cpp | 9 ++++++++- launcher/modManager/cmodlistview_moc.cpp | 5 +++++ launcher/modManager/cmodlistview_moc.h | 2 +- launcher/startGame/StartGameTab.h | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index 47c796903..243aec6a7 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -164,6 +164,10 @@ void MainWindow::switchToStartTab() ui->startGameButton->setEnabled(true); ui->startGameButton->setChecked(true); ui->tabListWidget->setCurrentIndex(TabRows::START); + + auto* startGameTabWidget = qobject_cast(ui->tabListWidget->widget(TabRows::START)); + if(startGameTabWidget) + startGameTabWidget->refreshState(); } void MainWindow::switchToModsTab() @@ -247,6 +251,9 @@ void MainWindow::dropEvent(QDropEvent* event) void MainWindow::manualInstallFile(QString filePath) { + if(filePath.endsWith(".zip", Qt::CaseInsensitive) || filePath.endsWith(".exe", Qt::CaseInsensitive)) + switchToModsTab(); + QString fileName = QFileInfo{filePath}.fileName(); if(filePath.endsWith(".zip", Qt::CaseInsensitive)) getModView()->downloadFile(fileName.toLower() @@ -279,7 +286,7 @@ void MainWindow::manualInstallFile(QString filePath) } } else - getModView()->downloadFile(fileName, QUrl::fromLocalFile(filePath), fileName); + getModView()->installFiles(QStringList{filePath}); } ETranslationStatus MainWindow::getTranslationStatus() diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 4ecd9060a..1dfde0518 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -788,6 +788,8 @@ void CModListView::installFiles(QStringList files) if(!exe.empty()) { + ui->progressWidget->setVisible(true); + ui->pushButton->setEnabled(false); ui->progressBar->setFormat(tr("Installing chronicles")); float prog = 0.0; @@ -807,6 +809,9 @@ void CModListView::installFiles(QStringList files) if(futureExtract.get()) { + hideProgressBar(); + ui->pushButton->setEnabled(true); + ui->progressWidget->setVisible(false); //update modStateModel->reloadLocalState(); modModel->reloadRepositories(); diff --git a/launcher/modManager/cmodlistview_moc.h b/launcher/modManager/cmodlistview_moc.h index c0c589290..cf23a4319 100644 --- a/launcher/modManager/cmodlistview_moc.h +++ b/launcher/modManager/cmodlistview_moc.h @@ -54,7 +54,6 @@ class CModListView : public QWidget void installMods(QStringList archives); void installMaps(QStringList maps); - void installFiles(QStringList mods); QString genChangelogText(const ModState & mod); QString genModInfoText(const ModState & mod); @@ -113,6 +112,7 @@ public: bool isModInstalled(const QString & modName); void downloadFile(QString file, QUrl url, QString description, qint64 sizeBytes = 0); + void installFiles(QStringList mods); public slots: void enableModByName(QString modName); diff --git a/launcher/startGame/StartGameTab.h b/launcher/startGame/StartGameTab.h index 9768600dc..9f165278c 100644 --- a/launcher/startGame/StartGameTab.h +++ b/launcher/startGame/StartGameTab.h @@ -33,8 +33,6 @@ class StartGameTab : public QWidget MainWindow * getMainWindow(); - void refreshState(); - void refreshUpdateStatus(EGameUpdateStatus status); void refreshTranslation(ETranslationStatus status); void refreshMods(); @@ -45,6 +43,8 @@ public: explicit StartGameTab(QWidget * parent = nullptr); ~StartGameTab(); + void refreshState(); + private slots: void on_buttonGameStart_clicked(); void on_buttonOpenChangelog_clicked();