Warning, /plasma/plasma-mobile/shell/contents/configuration/ConfigurationAppletPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003
0004 import QtQuick 2.0
0005
0006 import org.kde.kirigami 2.10 as Kirigami
0007
0008 Kirigami.ScrollablePage {
0009 id: root
0010
0011 title: configItem.name
0012
0013 required property var configItem
0014
0015 signal settingValueChanged()
0016 onSettingValueChanged: saveConfig() // we save config immediately on mobile
0017
0018 function saveConfig() {
0019 for (let key in plasmoid.configuration) {
0020 if (loader.item["cfg_" + key] != undefined) {
0021 plasmoid.configuration[key] = loader.item["cfg_" + key]
0022 }
0023 }
0024
0025 // For ConfigurationContainmentActions.qml
0026 if (loader.item.hasOwnProperty("saveConfig")) {
0027 loader.item.saveConfig()
0028 }
0029 }
0030
0031 implicitHeight: loader.height
0032
0033 padding: Kirigami.Units.largeSpacing
0034 bottomPadding: 0
0035
0036 Loader {
0037 id: loader
0038 width: parent.width
0039 // HACK the height of the loader is based on the implicitHeight of the content.
0040 // Unfortunately not all content items have a sensible implicitHeight.
0041 // If it is zero fall back to the height of its children
0042 // Also make it at least as high as the page itself. Some existing configs assume they fill the whole space
0043 // TODO KF6 clean this up by making all configs based on SimpleKCM/ScrollViewKCM/GridViewKCM
0044 height: Math.max(root.availableHeight, item.implicitHeight ? item.implicitHeight : item.childrenRect.height)
0045
0046 Component.onCompleted: {
0047 const plasmoidConfig = plasmoid.configuration
0048
0049 const props = {}
0050 for (let key in plasmoidConfig) {
0051 props["cfg_" + key] = plasmoid.configuration[key]
0052 }
0053
0054 setSource(configItem.source, props)
0055 }
0056
0057 onLoaded: {
0058 const plasmoidConfig = plasmoid.configuration;
0059
0060 for (let key in plasmoidConfig) {
0061 const changedSignal = item["cfg_" + key + "Changed"]
0062 if (changedSignal) {
0063 changedSignal.connect(root.settingValueChanged)
0064 }
0065 }
0066
0067 const configurationChangedSignal = item.configurationChanged
0068 if (configurationChangedSignal) {
0069 configurationChangedSignal.connect(root.settingValueChanged)
0070 }
0071 }
0072 }
0073 }