2023-02-23 16:43:38 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
2026-05-05 07:06:46 +00:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
|
|
#include <KConfigGroup>
|
2023-02-23 16:43:38 +00:00
|
|
|
#include <KIO/CommandLauncherJob>
|
|
|
|
|
#include <KNotificationJobUiDelegate>
|
|
|
|
|
#include <KPluginFactory>
|
2026-05-05 07:06:46 +00:00
|
|
|
#include <KSharedConfig>
|
2023-02-23 16:43:38 +00:00
|
|
|
|
2023-03-30 02:40:47 +00:00
|
|
|
#include "start.h"
|
2023-02-23 16:43:38 +00:00
|
|
|
|
2026-05-05 07:06:46 +00:00
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
bool isLegacyNextWallpaperPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
return path == QStringLiteral("Next") || path.startsWith(QStringLiteral("/usr/share/wallpapers/Next/"))
|
|
|
|
|
|| path.startsWith(QStringLiteral("file:///usr/share/wallpapers/Next/"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString shiftWallpaperPackageUrl()
|
|
|
|
|
{
|
|
|
|
|
const QString metadataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("wallpapers/SHIFT/metadata.json"));
|
|
|
|
|
if (metadataPath.isEmpty()) {
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString packageUrl = QUrl::fromLocalFile(QFileInfo(metadataPath).absolutePath()).toString();
|
|
|
|
|
if (!packageUrl.endsWith(QLatin1Char('/'))) {
|
|
|
|
|
packageUrl += QLatin1Char('/');
|
|
|
|
|
}
|
|
|
|
|
return packageUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ensureLockscreenWallpaperDefaults()
|
|
|
|
|
{
|
|
|
|
|
auto config = KSharedConfig::openConfig(QStringLiteral("kscreenlockerrc"));
|
|
|
|
|
auto greeterGroup = config->group(QStringLiteral("Greeter"));
|
|
|
|
|
|
|
|
|
|
const QString wallpaperPlugin = greeterGroup.readEntry(QStringLiteral("WallpaperPlugin"), QString());
|
|
|
|
|
const QString wallpaperPath =
|
|
|
|
|
greeterGroup.group(QStringLiteral("Wallpaper")).group(wallpaperPlugin).group(QStringLiteral("General")).readEntry(QStringLiteral("Image"), QString());
|
|
|
|
|
|
|
|
|
|
const bool wallpaperUnset = wallpaperPlugin.isEmpty() || wallpaperPath.isEmpty();
|
|
|
|
|
const bool wallpaperLegacyNext = wallpaperPlugin == QStringLiteral("org.kde.image") && isLegacyNextWallpaperPath(wallpaperPath);
|
|
|
|
|
if (!wallpaperUnset && !wallpaperLegacyNext) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString defaultWallpaperUrl = shiftWallpaperPackageUrl();
|
|
|
|
|
if (defaultWallpaperUrl.isEmpty()) {
|
|
|
|
|
qWarning() << "Could not locate SHIFT wallpaper package for lockscreen defaults";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
greeterGroup.group(QStringLiteral("Wallpaper"))
|
|
|
|
|
.group(QStringLiteral("org.kde.image"))
|
|
|
|
|
.group(QStringLiteral("General"))
|
|
|
|
|
.writeEntry(QStringLiteral("Image"), defaultWallpaperUrl, KConfigGroup::Notify);
|
|
|
|
|
greeterGroup.writeEntry(QStringLiteral("WallpaperPlugin"), QStringLiteral("org.kde.image"), KConfigGroup::Notify);
|
|
|
|
|
config->sync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 02:35:56 +00:00
|
|
|
K_PLUGIN_FACTORY_WITH_JSON(StartFactory, "kded_plasma_mobile_start.json", registerPlugin<Start>();)
|
|
|
|
|
|
2023-04-01 06:55:07 +00:00
|
|
|
Start::Start(QObject *parent, const QList<QVariant> &)
|
2023-02-23 16:43:38 +00:00
|
|
|
: KDEDModule{parent}
|
|
|
|
|
{
|
2026-05-05 07:06:46 +00:00
|
|
|
ensureLockscreenWallpaperDefaults();
|
|
|
|
|
|
2023-04-01 07:09:57 +00:00
|
|
|
auto *envmanagerJob = new KIO::CommandLauncherJob(QStringLiteral("plasma-mobile-envmanager --apply-settings"), {});
|
|
|
|
|
envmanagerJob->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
|
|
|
|
|
envmanagerJob->setDesktopName(QStringLiteral("org.kde.plasma-mobile-envmanager"));
|
|
|
|
|
envmanagerJob->start();
|
|
|
|
|
|
|
|
|
|
auto *initialstartJob = new KIO::CommandLauncherJob(QStringLiteral("plasma-mobile-initial-start"), {});
|
|
|
|
|
initialstartJob->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
|
|
|
|
|
initialstartJob->setDesktopName(QStringLiteral("org.kde.plasma-mobile-initial-start"));
|
|
|
|
|
initialstartJob->start();
|
2023-02-23 16:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-30 02:40:47 +00:00
|
|
|
#include "start.moc"
|