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
@ -54,91 +54,85 @@ ColumnLayout {
spacing: 0 spacing: 0
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 {
spacing: 0 FormCard.FormCard {
FormCard.FormComboBoxDelegate {
MobileForm.FormCardHeader { id: layoutSelectComboBox
title: i18n("General") 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
model: configDialog.containmentPluginsConfigModel
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;
} }
}
MobileForm.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox }
FormCard.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox }
MobileForm.FormComboBoxDelegate {
id: wallpaperPluginSelectComboBox FormCard.FormComboBoxDelegate {
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin") id: wallpaperPluginSelectComboBox
description: i18n("The wallpaper plugin to use.") text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin")
description: i18n("The wallpaper plugin to use.")
model: configDialog.wallpaperConfigModel
textRole: "name" model: configDialog.wallpaperConfigModel
valueRole: "pluginName" textRole: "name"
currentIndex: determineCurrentIndex() valueRole: "pluginName"
onCurrentIndexChanged: { currentIndex: determineCurrentIndex()
var model = configDialog.wallpaperConfigModel.get(currentIndex); onCurrentIndexChanged: {
root.currentWallpaper = model.pluginName; var model = configDialog.wallpaperConfigModel.get(currentIndex);
configDialog.currentWallpaper = model.pluginName; root.currentWallpaper = model.pluginName;
main.sourceFile = model.source; configDialog.currentWallpaper = model.pluginName;
root.configurationChanged(); 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;
}
} }
MobileForm.FormDelegateSeparator { above: wallpaperPluginSelectComboBox } function determineCurrentIndex() {
for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
MobileForm.AbstractFormDelegate { var data = configDialog.wallpaperConfigModel.get(i);
id: wallpaperPluginButton if (configDialog.currentWallpaper === data.pluginName) {
Layout.fillWidth: true return i;
background: Item {}
contentItem: RowLayout {
QQC2.Label {
Layout.fillWidth: true
text: i18n("Wallpaper Plugins")
}
NewStuff.Button {
configFile: "wallpaperplugin.knsrc"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
} }
} }
return -1;
}
}
FormCard.FormDelegateSeparator { above: wallpaperPluginSelectComboBox }
FormCard.AbstractFormDelegate {
id: wallpaperPluginButton
Layout.fillWidth: true
background: null
contentItem: RowLayout {
QQC2.Label {
Layout.fillWidth: true
text: i18n("Wallpaper Plugins")
}
NewStuff.Button {
configFile: "wallpaperplugin.knsrc"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
}
} }
} }
} }
@ -167,7 +161,7 @@ ColumnLayout {
Layout.fillHeight: switchContainmentWarning.visible Layout.fillHeight: switchContainmentWarning.visible
visible: switchContainmentWarning.visible visible: switchContainmentWarning.visible
} }
Item { Item {
id: emptyConfig id: emptyConfig
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
@ -182,7 +176,7 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
visible: !switchContainmentWarning.visible visible: !switchContainmentWarning.visible
// Bug 360862: if wallpaper has no config, sourceFile will be "" // Bug 360862: if wallpaper has no config, sourceFile will be ""
// so we wouldn't load emptyConfig and break all over the place // so we wouldn't load emptyConfig and break all over the place
// hence set it to some random value initially // hence set it to some random value initially