shift-shell/shell/contents/configuration/private/ChangeContainmentModule.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

72 lines
2.1 KiB
QML

// SPDX-FileCopyrightText: 2025 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.plasma.configuration
import org.kde.plasma.plasmoid
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
ColumnLayout {
id: root
property string containmentPlugin: configDialog.containmentPlugin
signal configurationChanged // No need to emit, because containment changes apply immediately
//BEGIN functions
function saveConfig() {
configDialog.containmentPlugin = root.containmentPlugin
}
//END functions
FormCard.FormHeader {
title: i18n("Select Homescreen")
}
FormCard.FormCard {
Repeater {
model: configDialog.containmentPluginsConfigModel
delegate: FormCard.FormRadioDelegate {
enabled: !Plasmoid.immutable
text: model.name
checked: configDialog.containmentPlugin === model.pluginName
// Always restore binding
onCheckedChanged: checked = Qt.binding(() => configDialog.containmentPlugin === model.pluginName);
onClicked: {
if (root.containmentPlugin === model.pluginName) {
return;
}
root.containmentPlugin = model.pluginName;
confirmationDialog.name = model.name;
confirmationDialog.open();
}
}
}
}
Kirigami.PromptDialog {
id: confirmationDialog
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
property string name
title: i18n("Change homescreen to %1?", name)
subtitle: i18n("Your current homescreen's settings are saved, and will be restored if you switch back.")
onAccepted: {
root.saveConfig();
close();
}
onRejected: {
root.containmentPlugin = configDialog.containmentPlugin;
}
}
Item { Layout.fillHeight: true }
}