shift-shell/shell/contents/configuration/private/ConfigurationAppletPage.qml
Devin Lin a39401100f shell: Rework configuration implementation
This reworks the implementation of the applet/containment configuration
so that it is more optimized for the mobile experience and fixes lateral
navigation (between categories).

Changes:
- Always show a list of category modules (switching from the navigation
  tab bar) in order to support more modules at once
- Split the wallpaper and containment switching view into two modules
- Add a close button at the top
- Add an animation when the window opens and closes
- Refactor the code so that it is clear which files are imported by the
  shell, and which are implementation details
2025-10-05 09:47:35 -04:00

82 lines
2.4 KiB
QML

// SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick 2.0
import org.kde.plasma.plasmoid
import org.kde.kirigami 2.10 as Kirigami
Kirigami.Page {
id: root
required property var configItem
signal settingValueChanged()
onSettingValueChanged: saveConfig() // we save config immediately on mobile
title: configItem.name
topPadding: 0
leftPadding: 0
rightPadding: 0
bottomPadding: 0
function saveConfig() {
for (let key in Plasmoid.configuration) {
if (loader.item["cfg_" + key] != undefined) {
Plasmoid.configuration[key] = loader.item["cfg_" + key]
}
}
// For ConfigurationContainmentActions.qml
if (loader.item.hasOwnProperty("saveConfig")) {
loader.item.saveConfig()
}
}
data: [
Loader {
id: loader
Component.onCompleted: {
const plasmoidConfig = Plasmoid.configuration
const props = {}
for (let key in plasmoidConfig) {
props["cfg_" + key] = Plasmoid.configuration[key]
}
// Inject configurable config values
setSource(configItem.source, props)
}
onLoaded: {
item.parent = root.contentItem;
item.anchors.fill = root.contentItem;
const plasmoidConfig = Plasmoid.configuration;
for (let key in plasmoidConfig) {
const changedSignal = item["cfg_" + key + "Changed"]
if (changedSignal) {
changedSignal.connect(root.settingValueChanged)
}
}
const configurationChangedSignal = item.configurationChanged
if (configurationChangedSignal) {
configurationChangedSignal.connect(root.settingValueChanged)
}
var unsavedChangesChangedSignal = item.unsavedChangesChanged
if (unsavedChangesChangedSignal) {
unsavedChangesChangedSignal.connect( () => {
if (item.unsavedChanges) {
root.settingValueChanged()
}
})
}
}
}
]
}