Warning, /plasma/plasma-mobile/components/wallpaperimageplugin/qml/WallpaperPluginConfigLoader.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0002 // SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de>
0003 // SPDX-FileCopyrightText: 2019 David Redondo <kde@david-redondo.de>
0004 // SPDX-FileCopyrightText: 2023 Méven Car <meven@kde.org>
0005 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
0006 // SPDX-License-Identifier: LGPL-2.0-or-later
0007
0008 import QtQuick
0009 import QtQuick.Controls as QQC2
0010 import org.kde.plasma.private.mobileshell.wallpaperimageplugin as WallpaperImagePlugin
0011
0012 QQC2.StackView {
0013 id: root
0014
0015 property string wallpaperPlugin
0016 property string wallpaperPluginSource
0017 property var wallpaperPluginConfig
0018 property var wallpaperPluginModel
0019
0020 property var configDialog: QtObject {
0021 property string currentWallpaper: root.wallpaperPlugin
0022 }
0023
0024 function onConfigurationChanged() {
0025 for (var key in root.wallpaperPluginConfig) {
0026 const cfgKey = "cfg_" + key;
0027 if (root.currentItem[cfgKey] !== undefined) {
0028 root.wallpaperPluginConfig[key] = root.currentItem[cfgKey]
0029 }
0030 }
0031 }
0032
0033 onWallpaperPluginSourceChanged: {
0034 loadSourceFile();
0035 }
0036
0037 onWallpaperPluginConfigChanged: {
0038 onWallpaperConfigurationChanged();
0039 }
0040
0041 function onWallpaperConfigurationChanged() {
0042 let wallpaperConfig = root.wallpaperPluginConfig
0043 if (!wallpaperConfig || !root.currentItem) {
0044 return;
0045 }
0046 wallpaperConfig.keys().forEach(key => {
0047 const cfgKey = "cfg_" + key;
0048 if (cfgKey in root.currentItem) {
0049
0050 var changedSignal = root.currentItem[cfgKey + "Changed"]
0051 if (changedSignal) {
0052 changedSignal.disconnect(root.onConfigurationChanged);
0053 }
0054 root.currentItem[cfgKey] = wallpaperConfig[key];
0055
0056 changedSignal = root.currentItem[cfgKey + "Changed"]
0057 if (changedSignal) {
0058 changedSignal.connect(root.onConfigurationChanged)
0059 }
0060 }
0061 })
0062 }
0063
0064 function loadSourceFile() {
0065 let wallpaperConfig = root.wallpaperPluginConfig;
0066 let wallpaperPluginSource = root.wallpaperPluginSource;
0067
0068 // BUG 407619: wallpaperConfig can be null before calling `ContainmentItem::loadWallpaper()`
0069 if (wallpaperConfig && wallpaperPluginSource) {
0070 var props = {
0071 "configDialog": root.configDialog,
0072 "wallpaperConfiguration": wallpaperConfig
0073 };
0074
0075 wallpaperConfig.keys().forEach(key => {
0076 // Preview is not part of the config, only of the WallpaperObject
0077 if (!key.startsWith("Preview")) {
0078 props["cfg_" + key] = wallpaperConfig[key];
0079 }
0080 });
0081
0082 var newItem = replace(Qt.resolvedUrl(wallpaperPluginSource), props)
0083
0084 wallpaperConfig.keys().forEach(key => {
0085 const cfgKey = "cfg_" + key;
0086 if (cfgKey in root.currentItem) {
0087 var changedSignal = root.currentItem[cfgKey + "Changed"]
0088 if (changedSignal) {
0089 changedSignal.connect(root.onConfigurationChanged)
0090 }
0091 }
0092 });
0093
0094 const configurationChangedSignal = newItem.configurationChanged
0095 if (configurationChangedSignal) {
0096 configurationChangedSignal.connect(root.onConfigurationChanged)
0097 }
0098 } else {
0099 replace(emptyConfig)
0100 }
0101 }
0102
0103 Item {
0104 id: emptyConfig
0105 }
0106 }