Changeset View
Changeset View
Standalone View
Standalone View
wallpapers/image/image.cpp
Show First 20 Lines • Show All 542 Lines • ▼ Show 20 Line(s) | 542 | path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | |||
---|---|---|---|---|---|
543 | QLatin1String("wallpapers/") + url.path(), | 543 | QLatin1String("wallpapers/") + url.path(), | ||
544 | QStandardPaths::LocateDirectory); | 544 | QStandardPaths::LocateDirectory); | ||
545 | } | 545 | } | ||
546 | 546 | | |||
547 | if (path.isEmpty()) { | 547 | if (path.isEmpty()) { | ||
548 | return; | 548 | return; | ||
549 | } | 549 | } | ||
550 | } else { | 550 | } else { | ||
551 | QString wallpaperPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("wallpapers/") + url.path(); | 551 | QDir wallpaperDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/wallpapers/"); | ||
552 | const QString wallpaperPath = wallpaperDir.absoluteFilePath(url.fileName()); | ||||
553 | | ||||
554 | if (wallpaperDir.mkpath(wallpaperDir.absolutePath()) && !url.fileName().isEmpty()) { | ||||
mart: this is for first run when ~/.local/share/wallpapers isn't there yet? | |||||
This is to check if the directory is available before copying, otherwise FileCopyJob would fail. trmdi: This is to check if the directory is available before copying, otherwise FileCopyJob would fail. | |||||
555 | KIO::FileCopyJob *job = KIO::file_copy(url, QUrl::fromLocalFile(wallpaperPath), -1, KIO::HideProgressInfo | KIO::Overwrite); | ||||
mart: I would prefer it to ask before owerwriting | |||||
trmdi: Do I need to modify this or just land it now? | |||||
552 | 556 | | |||
553 | if (!wallpaperPath.isEmpty()) { | | |||
554 | KIO::FileCopyJob *job = KIO::file_copy(url, QUrl(wallpaperPath), -1, KIO::HideProgressInfo); | | |||
555 | if (setAsCurrent) { | 557 | if (setAsCurrent) { | ||
556 | connect(job, &KJob::result, this, &Image::setWallpaperRetrieved); | 558 | connect(job, &KJob::result, this, &Image::setWallpaperRetrieved); | ||
557 | } else { | 559 | } else { | ||
558 | connect(job, &KJob::result, this, &Image::addWallpaperRetrieved); | 560 | connect(job, &KJob::result, this, &Image::addWallpaperRetrieved); | ||
559 | } | 561 | } | ||
560 | } | 562 | } | ||
561 | 563 | | |||
562 | return; | 564 | return; | ||
▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines |
this is for first run when ~/.local/share/wallpapers isn't there yet?