Added notification messages informing users of the success or failure of clearing downloaded images.
This commit is contained in:
parent
674005383b
commit
ae80752497
1 changed files with 9 additions and 3 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue