Do not ask users if they want to overwrite saved file twice

Summary: Qt file dialog already asks if user want the file to be overwritten.

Test Plan:
1. Open a message with some link.
2. Right-click on the link and choose "Save link as..."
3. Save the file.
4. Repeat step 2, click "OK".
5. Confirm the file to be overwritten from Qt dialog.
6. Without this patch, a new KMail dialog should appear with another proposal to overwrite the file.

Reviewers: #kde_pim, mlaurent

Reviewed By: #kde_pim, mlaurent

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D28377
wilder
Yuri Chornoivan 6 years ago
parent 0249f747a0
commit 28ab73bcf2
  1. 17
      src/kmcommands.cpp

@ -530,23 +530,6 @@ KMCommand::Result KMUrlSaveCommand::execute()
KRecentDirs::add(recentDirClass, saveUrl.path());
}
bool fileExists = false;
if (saveUrl.isLocalFile()) {
fileExists = QFile::exists(saveUrl.toLocalFile());
} else {
auto job = KIO::stat(saveUrl, KIO::StatJob::DestinationSide, 0);
KJobWidgets::setWindow(job, parentWidget());
fileExists = job->exec();
}
if (fileExists) {
if (KMessageBox::warningContinueCancel(nullptr,
xi18nc("@info", "File <filename>%1</filename> exists.<nl/>Do you want to replace it?",
saveUrl.toDisplayString()), i18n("Save to File"), KGuiItem(i18n("&Replace")))
!= KMessageBox::Continue) {
return Canceled;
}
}
KIO::Job *job = KIO::file_copy(mUrl, saveUrl, -1, KIO::Overwrite);
connect(job, &KIO::Job::result, this, &KMUrlSaveCommand::slotUrlSaveResult);
setEmitsCompletedItself(true);

Loading…
Cancel
Save