refactor(RD): allow setting custom folder target for downloaded resources
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
		@@ -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()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user