2022-03-13 20:20:18 +05:30
|
|
|
#include "ReviewMessageBox.h"
|
|
|
|
#include "ui_ReviewMessageBox.h"
|
|
|
|
|
2023-01-08 21:03:10 +05:30
|
|
|
#include "Application.h"
|
|
|
|
|
2022-06-17 06:52:14 +05:30
|
|
|
#include <QPushButton>
|
|
|
|
|
2022-03-13 20:20:18 +05:30
|
|
|
ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon)
|
|
|
|
: QDialog(parent), ui(new Ui::ReviewMessageBox)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2022-04-22 21:50:31 +05:30
|
|
|
|
2022-06-17 06:52:14 +05:30
|
|
|
auto back_button = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
back_button->setText(tr("Back"));
|
|
|
|
|
2023-01-08 21:03:10 +05:30
|
|
|
ui->modTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
|
|
ui->modTreeWidget->header()->setStretchLastSection(false);
|
|
|
|
ui->modTreeWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
|
2022-04-22 21:50:31 +05:30
|
|
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ReviewMessageBox::accept);
|
|
|
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ReviewMessageBox::reject);
|
2022-03-13 20:20:18 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
ReviewMessageBox::~ReviewMessageBox()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ReviewMessageBox::create(QWidget* parent, QString&& title, QString&& icon) -> ReviewMessageBox*
|
|
|
|
{
|
|
|
|
return new ReviewMessageBox(parent, title, icon);
|
|
|
|
}
|
|
|
|
|
2022-11-25 17:53:46 +05:30
|
|
|
void ReviewMessageBox::appendResource(ResourceInformation&& info)
|
2022-03-13 20:20:18 +05:30
|
|
|
{
|
|
|
|
auto itemTop = new QTreeWidgetItem(ui->modTreeWidget);
|
2022-04-22 21:50:31 +05:30
|
|
|
itemTop->setCheckState(0, Qt::CheckState::Checked);
|
|
|
|
itemTop->setText(0, info.name);
|
2022-03-13 20:20:18 +05:30
|
|
|
|
|
|
|
auto filenameItem = new QTreeWidgetItem(itemTop);
|
2022-04-22 21:50:31 +05:30
|
|
|
filenameItem->setText(0, tr("Filename: %1").arg(info.filename));
|
2022-03-13 20:20:18 +05:30
|
|
|
|
|
|
|
itemTop->insertChildren(0, { filenameItem });
|
|
|
|
|
2023-01-08 21:03:10 +05:30
|
|
|
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."));
|
|
|
|
}
|
|
|
|
|
2022-03-13 20:20:18 +05:30
|
|
|
ui->modTreeWidget->addTopLevelItem(itemTop);
|
|
|
|
}
|
2022-04-22 21:50:31 +05:30
|
|
|
|
2022-11-25 17:53:46 +05:30
|
|
|
auto ReviewMessageBox::deselectedResources() -> QStringList
|
2022-04-22 21:50:31 +05:30
|
|
|
{
|
|
|
|
QStringList list;
|
|
|
|
|
|
|
|
auto* item = ui->modTreeWidget->topLevelItem(0);
|
|
|
|
|
2022-06-11 01:10:39 +05:30
|
|
|
for (int i = 1; item != nullptr; ++i) {
|
2022-04-22 21:50:31 +05:30
|
|
|
if (item->checkState(0) == Qt::CheckState::Unchecked) {
|
|
|
|
list.append(item->text(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
item = ui->modTreeWidget->topLevelItem(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2023-01-08 20:58:55 +05:30
|
|
|
|
|
|
|
void ReviewMessageBox::retranslateUi(QString resources_name)
|
|
|
|
{
|
|
|
|
setWindowTitle(tr("Confirm %1 selection").arg(resources_name));
|
|
|
|
|
|
|
|
ui->explainLabel->setText(tr("You're about to download the following %1:").arg(resources_name));
|
|
|
|
ui->onlyCheckedLabel->setText(tr("Only %1 with a check will be downloaded!").arg(resources_name));
|
|
|
|
}
|