mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(toxsave, profileimporter): Added remove
function call before overwrite file
Fix #3558.
This commit is contained in:
parent
a163d18754
commit
58ea0afed1
|
@ -67,10 +67,17 @@ bool handleToxSave(const QString& path)
|
||||||
|
|
||||||
QString profilePath = Settings::getInstance().getSettingsDirPath() + profile + Core::TOX_EXT;
|
QString profilePath = Settings::getInstance().getSettingsDirPath() + profile + Core::TOX_EXT;
|
||||||
|
|
||||||
if (QFileInfo(profilePath).exists() && !GUI::askQuestion(QObject::tr("Profile already exists", "import confirm title"),
|
if (QFileInfo(profilePath).exists())
|
||||||
QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile)))
|
{
|
||||||
|
QString title = QObject::tr("Profile already exists", "import confirm title");
|
||||||
|
QString message = QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile);
|
||||||
|
bool erase = GUI::askQuestion(title, message);
|
||||||
|
if (!erase)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
QFile(profilePath).remove();
|
||||||
|
}
|
||||||
|
|
||||||
QFile::copy(path, profilePath);
|
QFile::copy(path, profilePath);
|
||||||
// no good way to update the ui from here... maybe we need a Widget:refreshUi() function...
|
// no good way to update the ui from here... maybe we need a Widget:refreshUi() function...
|
||||||
// such a thing would simplify other code as well I believe
|
// such a thing would simplify other code as well I believe
|
||||||
|
|
|
@ -61,26 +61,17 @@ bool ProfileImporter::importProfile()
|
||||||
|
|
||||||
if (QFileInfo(profilePath).exists())
|
if (QFileInfo(profilePath).exists())
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton reply;
|
QString title = QObject::tr("Profile already exists", "import confirm title");
|
||||||
reply = QMessageBox::warning( this,
|
QString message = QObject::tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile);
|
||||||
tr("Profile already exists", "import confirm title"),
|
bool erase = GUI::askQuestion(title, message);
|
||||||
tr("A profile named \"%1\" already exists. Do you want to erase it?", "import confirm text").arg(profile),
|
|
||||||
QMessageBox::Yes | QMessageBox::No);
|
|
||||||
|
|
||||||
if (reply == QMessageBox::Yes)
|
if (!erase)
|
||||||
{
|
|
||||||
QFile::copy(path, profilePath);
|
|
||||||
return true; //import successfull
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false; //import canelled
|
return false; //import canelled
|
||||||
}
|
|
||||||
}
|
QFile(profilePath).remove();
|
||||||
else
|
|
||||||
{
|
|
||||||
QFile::copy(path, profilePath);
|
|
||||||
return true; //import successfull
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFile::copy(path, profilePath);
|
||||||
|
return true; //import successfull
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user