import_dialog: UI improvements

1. A warning regarding system data and system archives are added
2. Disable button when nothing is selected
This commit is contained in:
zhupengfei
2019-10-02 16:16:49 +08:00
parent 5d675d605a
commit 58f903f80f
2 changed files with 18 additions and 4 deletions
+15 -4
View File
@@ -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<u64>(storage.bytesAvailable()));
->setEnabled(total_size > 0 && total_size <= static_cast<u64>(storage.bytesAvailable()));
}
void ImportDialog::UpdateItemCheckState(QTreeWidgetItem* item) {
+3
View File
@@ -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;