aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2023-01-08 12:33:10 -0300
committerflow <flowlnlnln@gmail.com>2023-01-13 16:23:09 -0300
commitc294c2d1df57c3d599fdea65bab9bb97b1fd699f (patch)
treed07f642bb138494d6f2eda2b2d22cabfc72a8055 /launcher
parentbd36f8e220fb3019b0a9588b21ed1cbce5afbf93 (diff)
downloadPrismLauncher-c294c2d1df57c3d599fdea65bab9bb97b1fd699f.tar.gz
PrismLauncher-c294c2d1df57c3d599fdea65bab9bb97b1fd699f.tar.bz2
PrismLauncher-c294c2d1df57c3d599fdea65bab9bb97b1fd699f.zip
refactor(RD): allow setting custom folder target for downloaded resources
Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher')
-rw-r--r--launcher/ResourceDownloadTask.cpp12
-rw-r--r--launcher/ResourceDownloadTask.h3
-rw-r--r--launcher/modplatform/ModIndex.h1
-rw-r--r--launcher/ui/dialogs/ResourceDownloadDialog.cpp3
-rw-r--r--launcher/ui/dialogs/ReviewMessageBox.cpp16
-rw-r--r--launcher/ui/dialogs/ReviewMessageBox.h3
6 files changed, 33 insertions, 5 deletions
diff --git a/launcher/ResourceDownloadTask.cpp b/launcher/ResourceDownloadTask.cpp
index 687eaf51..8c9dae6f 100644
--- a/launcher/ResourceDownloadTask.cpp
+++ b/launcher/ResourceDownloadTask.cpp
@@ -40,7 +40,17 @@ ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack pack,
m_filesNetJob.reset(new NetJob(tr("Resource download"), APPLICATION->network()));
m_filesNetJob->setStatus(tr("Downloading resource:\n%1").arg(m_pack_version.downloadUrl));
- m_filesNetJob->addNetAction(Net::Download::makeFile(m_pack_version.downloadUrl, m_pack_model->dir().absoluteFilePath(getFilename())));
+ QDir dir { m_pack_model->dir() };
+ {
+ // FIXME: Make this more generic. May require adding additional info to IndexedVersion,
+ // or adquiring a reference to the base instance.
+ if (!m_pack_version.custom_target_folder.isEmpty()) {
+ dir.cdUp();
+ dir.cd(m_pack_version.custom_target_folder);
+ }
+ }
+
+ m_filesNetJob->addNetAction(Net::Download::makeFile(m_pack_version.downloadUrl, dir.absoluteFilePath(getFilename())));
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &ResourceDownloadTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &ResourceDownloadTask::downloadProgressChanged);
connect(m_filesNetJob.get(), &NetJob::failed, this, &ResourceDownloadTask::downloadFailed);
diff --git a/launcher/ResourceDownloadTask.h b/launcher/ResourceDownloadTask.h
index 275ddbe1..5ce39d69 100644
--- a/launcher/ResourceDownloadTask.h
+++ b/launcher/ResourceDownloadTask.h
@@ -32,6 +32,7 @@ class ResourceDownloadTask : public SequentialTask {
public:
explicit ResourceDownloadTask(ModPlatform::IndexedPack pack, ModPlatform::IndexedVersion version, const std::shared_ptr<ResourceFolderModel> packs, bool is_indexed = true);
const QString& getFilename() const { return m_pack_version.fileName; }
+ const QString& getCustomPath() const { return m_pack_version.custom_target_folder; }
const QVariant& getVersionID() const { return m_pack_version.fileId; }
private:
@@ -43,9 +44,7 @@ private:
LocalModUpdateTask::Ptr m_update_task;
void downloadProgressChanged(qint64 current, qint64 total);
-
void downloadFailed(QString reason);
-
void downloadSucceeded();
std::tuple<QString, QString> to_delete {"", ""};
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index cd40a6ba..b1f8050d 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -68,6 +68,7 @@ struct IndexedVersion {
// For internal use, not provided by APIs
bool is_currently_selected = false;
+ QString custom_target_folder;
};
struct ExtraPackData {
diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp
index 147373c9..b9367c16 100644
--- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp
+++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp
@@ -118,7 +118,8 @@ void ResourceDownloadDialog::confirm()
confirm_dialog->retranslateUi(resourcesString());
for (auto& task : keys) {
- confirm_dialog->appendResource({ task, m_selected.find(task).value()->getFilename() });
+ auto selected = m_selected.constFind(task).value();
+ confirm_dialog->appendResource({ task, selected->getFilename(), selected->getCustomPath() });
}
if (confirm_dialog->exec()) {
diff --git a/launcher/ui/dialogs/ReviewMessageBox.cpp b/launcher/ui/dialogs/ReviewMessageBox.cpp
index 9c638d1f..7b2df278 100644
--- a/launcher/ui/dialogs/ReviewMessageBox.cpp
+++ b/launcher/ui/dialogs/ReviewMessageBox.cpp
@@ -1,6 +1,8 @@
#include "ReviewMessageBox.h"
#include "ui_ReviewMessageBox.h"
+#include "Application.h"
+
#include <QPushButton>
ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon)
@@ -11,6 +13,10 @@ ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QStrin
auto back_button = ui->buttonBox->button(QDialogButtonBox::Cancel);
back_button->setText(tr("Back"));
+ ui->modTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
+ ui->modTreeWidget->header()->setStretchLastSection(false);
+ ui->modTreeWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
+
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ReviewMessageBox::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ReviewMessageBox::reject);
}
@@ -36,6 +42,16 @@ void ReviewMessageBox::appendResource(ResourceInformation&& info)
itemTop->insertChildren(0, { filenameItem });
+ if (!info.custom_file_path.isEmpty()) {
+ auto customPathItem = new QTreeWidgetItem(itemTop);
+ customPathItem->setText(0, tr("This download will be placed in: %1").arg(info.custom_file_path));
+
+ itemTop->insertChildren(1, { customPathItem });
+
+ itemTop->setIcon(1, QIcon(APPLICATION->getThemedIcon("status-yellow")));
+ itemTop->setToolTip(1, tr("This file will be downloaded to a folder location different from the default, possibly due to its loader requiring it."));
+ }
+
ui->modTreeWidget->addTopLevelItem(itemTop);
}
diff --git a/launcher/ui/dialogs/ReviewMessageBox.h b/launcher/ui/dialogs/ReviewMessageBox.h
index 7ee0d65d..5ec2bc23 100644
--- a/launcher/ui/dialogs/ReviewMessageBox.h
+++ b/launcher/ui/dialogs/ReviewMessageBox.h
@@ -12,9 +12,10 @@ class ReviewMessageBox : public QDialog {
public:
static auto create(QWidget* parent, QString&& title, QString&& icon = "") -> ReviewMessageBox*;
- using ResourceInformation = struct {
+ using ResourceInformation = struct res_info {
QString name;
QString filename;
+ QString custom_file_path {};
};
void appendResource(ResourceInformation&& info);