1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(profile): add a dialog to indicate profile deletion error

This commit adds an error dialog box that pops up upon profile delete
error to inform users to manually delete files.
This commit is contained in:
initramfs 2016-04-29 13:38:15 +08:00
parent 1dabbca94c
commit 78fd245e4c
No known key found for this signature in database
GPG Key ID: 78B8BDF87E9EF0AF
3 changed files with 19 additions and 4 deletions

View File

@ -483,12 +483,12 @@ bool Profile::isEncrypted(QString name)
return tox_is_data_encrypted(data);
}
void Profile::remove()
bool Profile::remove()
{
if (isRemoved)
{
qWarning() << "Profile " << name << " is already removed!";
return;
return true;
}
isRemoved = true;
@ -509,21 +509,27 @@ void Profile::remove()
QFile historyLegacyUnencrypted {HistoryKeeper::getHistoryPath(name, 0)};
QFile historyLegacyEncrypted {HistoryKeeper::getHistoryPath(name, 1)};
bool isDeleted = true;
if(!profileMain.remove() && profileMain.exists())
{
isDeleted = false;
qWarning() << "Could not remove file " << profileMain.fileName();
}
if(!profileConfig.remove() && profileConfig.exists())
{
isDeleted = false;
qWarning() << "Could not remove file " << profileConfig.fileName();
}
if(!historyLegacyUnencrypted.remove() && historyLegacyUnencrypted.exists())
{
isDeleted = false;
qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName();
}
if(!historyLegacyEncrypted.remove() && historyLegacyEncrypted.exists())
{
isDeleted = false;
qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName();
}
@ -531,10 +537,13 @@ void Profile::remove()
{
if(!history->remove() && QFile::exists(History::getDbPath(name)))
{
isDeleted = false;
qWarning() << "Could not remove file " << History::getDbPath(name);
}
history.release();
}
return isDeleted;
}
bool Profile::rename(QString newName)

View File

@ -78,7 +78,8 @@ public:
/// Removes the profile permanently
/// It is invalid to call loadToxSave or saveToxSave on a deleted profile
/// Updates the profiles vector
void remove();
/// Returns true if the underlying profile files were removed, false otherwise.
bool remove();
/// Tries to rename the profile
bool rename(QString newName);

View File

@ -361,7 +361,12 @@ void ProfileForm::onDeleteClicked()
tr("Are you sure you want to delete this profile?", "deletion confirmation text")))
{
Nexus& nexus = Nexus::getInstance();
nexus.getProfile()->remove();
if(!nexus.getProfile()->remove())
{
GUI::showError(tr("Files could not be deleted!"), tr("Some files could not be deleted, please manually remove them."));
}
nexus.showLogin();
}
}