From 58f903f80f316d02eea45924af0ce51d404930bd Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Wed, 2 Oct 2019 16:16:49 +0800 Subject: [PATCH] import_dialog: UI improvements 1. A warning regarding system data and system archives are added 2. Disable button when nothing is selected --- src/frontend/import_dialog.cpp | 19 +++++++++++++++---- src/frontend/import_dialog.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/frontend/import_dialog.cpp b/src/frontend/import_dialog.cpp index 2aa4522..3cfdf67 100644 --- a/src/frontend/import_dialog.cpp +++ b/src/frontend/import_dialog.cpp @@ -182,10 +182,22 @@ void ImportDialog::InsertSecondLevelItem(std::size_t row, const Core::ContentSpe ui->main->setItemWidget(item, 0, checkBox); connect(checkBox, &QCheckBox::stateChanged, - [this, item, size = content.maximum_size](int state) { + [this, item, size = content.maximum_size, type = content.type, + exists = content.already_exists](int state) { if (state == Qt::Checked) { total_size += size; } else { + if (!warning_shown && !exists && + (type == Core::ContentType::SystemArchive || + type == Core::ContentType::Sysdata)) { + + QMessageBox::warning( + this, tr("Warning"), + tr("System Archive and System Data are important files that may " + "be necessary for your imported games to run.\nIt is highly " + "recommended to import these contents if they do not exist yet.")); + warning_shown = true; + } total_size -= size; } UpdateSizeDisplay(); @@ -278,8 +290,7 @@ void ImportDialog::UpdateSizeDisplay() { LOG_ERROR(Frontend, "Storage {} is not good", user_path); QMessageBox::critical( this, tr("Bad Storage"), - tr("An error occured while trying to get available space for the storage.\nPlease " - "ensure that your SD card is well connected and try again.")); + tr("An error occured while trying to get available space for the storage.")); reject(); } @@ -288,7 +299,7 @@ void ImportDialog::UpdateSizeDisplay() { ui->totalSize->setText(tr("Total Size: %1").arg(ReadableByteSize(total_size))); ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok) - ->setEnabled(total_size <= static_cast(storage.bytesAvailable())); + ->setEnabled(total_size > 0 && total_size <= static_cast(storage.bytesAvailable())); } void ImportDialog::UpdateItemCheckState(QTreeWidgetItem* item) { diff --git a/src/frontend/import_dialog.h b/src/frontend/import_dialog.h index 430cacf..053bdd9 100644 --- a/src/frontend/import_dialog.h +++ b/src/frontend/import_dialog.h @@ -46,6 +46,9 @@ private: // TODO: Is there a more elegant way of doing the same? bool program_trigger = false; + // Whether the System Archive / System Data warning has been shown + bool warning_shown = false; + // TODO: Why this won't work as locals? Core::ContentSpecifier current_content = {}; u64 current_count = 0;