Commit ae807524 authored by Peng Liu's avatar Peng Liu
Browse files

Added notification messages informing users of the success or failure of...

Added notification messages informing users of the success or failure of clearing downloaded images.
parent 67400538
...@@ -168,18 +168,24 @@ void GeneralSettingsPage::clearDownloadedPicsButtonClicked() ...@@ -168,18 +168,24 @@ void GeneralSettingsPage::clearDownloadedPicsButtonClicked()
{ {
QString picsPath = settingsCache->getPicsPath() + "/downloadedPics/"; QString picsPath = settingsCache->getPicsPath() + "/downloadedPics/";
QStringList dirs = QDir(picsPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot); QStringList dirs = QDir(picsPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
bool outerSuccessRemove = true;
for (int i = 0; i < dirs.length(); i ++) { for (int i = 0; i < dirs.length(); i ++) {
QString currentPath = picsPath + dirs.at(i) + "/"; QString currentPath = picsPath + dirs.at(i) + "/";
QStringList files = QDir(currentPath).entryList(QDir::Files); QStringList files = QDir(currentPath).entryList(QDir::Files);
bool failRemove = false; bool innerSuccessRemove = true;
for (int j = 0; j < files.length(); j ++) for (int j = 0; j < files.length(); j ++)
if (!QDir(currentPath).remove(files.at(j))) { if (!QDir(currentPath).remove(files.at(j))) {
qDebug() << "Failed to remove " + currentPath.toUtf8() + files.at(j).toUtf8(); 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)); 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() void GeneralSettingsPage::cardDatabasePathButtonClicked()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment