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