From ae807524972342baaa243de852b3b33323dc871a Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Thu, 7 Aug 2014 14:00:59 -0400 Subject: [PATCH] Added notification messages informing users of the success or failure of clearing downloaded images. --- cockatrice/src/dlg_settings.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 9e94b084..ed88e36d 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -168,18 +168,24 @@ void GeneralSettingsPage::clearDownloadedPicsButtonClicked() { QString picsPath = settingsCache->getPicsPath() + "/downloadedPics/"; QStringList dirs = QDir(picsPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + bool outerSuccessRemove = true; for (int i = 0; i < dirs.length(); i ++) { QString currentPath = picsPath + dirs.at(i) + "/"; QStringList files = QDir(currentPath).entryList(QDir::Files); - bool failRemove = false; + bool innerSuccessRemove = true; for (int j = 0; j < files.length(); j ++) if (!QDir(currentPath).remove(files.at(j))) { qDebug() << "Failed to remove " + currentPath.toUtf8() + files.at(j).toUtf8(); - failRemove = true; + outerSuccessRemove = false; + innerSuccessRemove = false; } - if (!failRemove) + if (innerSuccessRemove) QDir(picsPath).rmdir(dirs.at(i)); } + if (outerSuccessRemove) + QMessageBox::information(this, tr("Success"), tr("Downloaded card images have been cleared.")); + else + QMessageBox::critical(this, tr("Error"), tr("One or more downloaded card images could not be cleared.")); } void GeneralSettingsPage::cardDatabasePathButtonClicked()