Commit 8b183e77 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[kcms/autostart] Automatically rename file if destination exists

If a script with the same name exists KIO would prompt the user to enter a new file name. Given that the filename in the autostart folder is an implementation detail that the user does not care about we can skip the prompt and apply a new name directly.

The displayed name is not affected since that is the source name that remains unaffected
parent fbf1590c
...@@ -347,6 +347,7 @@ void AutostartModel::addScript(const QUrl &url, AutostartModel::AutostartEntrySo ...@@ -347,6 +347,7 @@ void AutostartModel::addScript(const QUrl &url, AutostartModel::AutostartEntrySo
QUrl destinationScript = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + folder + fileName); QUrl destinationScript = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + folder + fileName);
KIO::CopyJob *job = KIO::link(url, destinationScript, KIO::HideProgressInfo); KIO::CopyJob *job = KIO::link(url, destinationScript, KIO::HideProgressInfo);
job->setAutoRename(true);
connect(job, &KIO::CopyJob::renamed, this, [&destinationScript](KIO::Job *job, const QUrl &from, const QUrl &to) { connect(job, &KIO::CopyJob::renamed, this, [&destinationScript](KIO::Job *job, const QUrl &from, const QUrl &to) {
Q_UNUSED(job) Q_UNUSED(job)
......
Markdown is supported
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