shell configuration: Port to FormCard

This commit is contained in:
Carl Schwan 2023-09-21 21:05:10 +02:00
parent d8f3146de5
commit a12a106439
No known key found for this signature in database
GPG key ID: 02325448204E452A

View file

@ -12,7 +12,7 @@ import QtQuick.Layouts 1.15
import org.kde.plasma.plasmoid import org.kde.plasma.plasmoid
import org.kde.newstuff 1.62 as NewStuff import org.kde.newstuff 1.62 as NewStuff
import org.kde.kirigami 2.19 as Kirigami import org.kde.kirigami 2.19 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1.0 as FormCard
ColumnLayout { ColumnLayout {
id: root id: root
@ -55,89 +55,83 @@ ColumnLayout {
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Layout.fillWidth: true Layout.fillWidth: true
MobileForm.FormCard { FormCard.FormHeader {
Layout.fillWidth: true title: i18n("General")
}
contentItem: ColumnLayout { FormCard.FormCard {
spacing: 0 FormCard.FormComboBoxDelegate {
id: layoutSelectComboBox
enabled: !Plasmoid.immutable
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Homescreen Layout")
description: i18n("The homescreen layout to use.")
visible: model.count > 1 // only show if there are multiple plugins
MobileForm.FormCardHeader { model: configDialog.containmentPluginsConfigModel
title: i18n("General") textRole: "name"
valueRole: "pluginName"
currentIndex: determineCurrentIndex()
onCurrentIndexChanged: {
root.containmentPlugin = configDialog.containmentPluginsConfigModel.get(currentIndex).pluginName;
} }
MobileForm.FormComboBoxDelegate { function determineCurrentIndex() {
id: layoutSelectComboBox for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) {
enabled: !Plasmoid.immutable var data = configDialog.containmentPluginsConfigModel.get(i);
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Homescreen Layout") if (configDialog.containmentPlugin === data.pluginName) {
description: i18n("The homescreen layout to use.") return i;
visible: model.count > 1 // only show if there are multiple plugins
model: configDialog.containmentPluginsConfigModel
textRole: "name"
valueRole: "pluginName"
currentIndex: determineCurrentIndex()
onCurrentIndexChanged: {
root.containmentPlugin = configDialog.containmentPluginsConfigModel.get(currentIndex).pluginName;
}
function determineCurrentIndex() {
for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) {
var data = configDialog.containmentPluginsConfigModel.get(i);
if (configDialog.containmentPlugin === data.pluginName) {
return i;
}
} }
return -1;
} }
return -1;
}
}
FormCard.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox }
FormCard.FormComboBoxDelegate {
id: wallpaperPluginSelectComboBox
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin")
description: i18n("The wallpaper plugin to use.")
model: configDialog.wallpaperConfigModel
textRole: "name"
valueRole: "pluginName"
currentIndex: determineCurrentIndex()
onCurrentIndexChanged: {
var model = configDialog.wallpaperConfigModel.get(currentIndex);
root.currentWallpaper = model.pluginName;
configDialog.currentWallpaper = model.pluginName;
main.sourceFile = model.source;
root.configurationChanged();
} }
MobileForm.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox } function determineCurrentIndex() {
for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
MobileForm.FormComboBoxDelegate { var data = configDialog.wallpaperConfigModel.get(i);
id: wallpaperPluginSelectComboBox if (configDialog.currentWallpaper === data.pluginName) {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin") return i;
description: i18n("The wallpaper plugin to use.")
model: configDialog.wallpaperConfigModel
textRole: "name"
valueRole: "pluginName"
currentIndex: determineCurrentIndex()
onCurrentIndexChanged: {
var model = configDialog.wallpaperConfigModel.get(currentIndex);
root.currentWallpaper = model.pluginName;
configDialog.currentWallpaper = model.pluginName;
main.sourceFile = model.source;
root.configurationChanged();
}
function determineCurrentIndex() {
for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
var data = configDialog.wallpaperConfigModel.get(i);
if (configDialog.currentWallpaper === data.pluginName) {
return i;
}
} }
return -1;
} }
return -1;
} }
}
MobileForm.FormDelegateSeparator { above: wallpaperPluginSelectComboBox } FormCard.FormDelegateSeparator { above: wallpaperPluginSelectComboBox }
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
id: wallpaperPluginButton id: wallpaperPluginButton
Layout.fillWidth: true Layout.fillWidth: true
background: Item {} background: null
contentItem: RowLayout { contentItem: RowLayout {
QQC2.Label { QQC2.Label {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("Wallpaper Plugins") text: i18n("Wallpaper Plugins")
} }
NewStuff.Button { NewStuff.Button {
configFile: "wallpaperplugin.knsrc" configFile: "wallpaperplugin.knsrc"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…") text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
}
} }
} }
} }