Warning, /plasma/plasma-mobile/shell/contents/configuration/ConfigurationContainmentAppearance.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0003 *
0004 * SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import org.kde.plasma.configuration 2.0
0009 import QtQuick.Controls 2.15 as QQC2
0010 import QtQuick.Layouts 1.15
0011
0012 import org.kde.plasma.plasmoid
0013 import org.kde.newstuff 1.62 as NewStuff
0014 import org.kde.kirigami 2.19 as Kirigami
0015 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0016
0017 ColumnLayout {
0018 id: root
0019 spacing: 0
0020
0021 property string currentWallpaper: ""
0022 property string containmentPlugin: configDialog.containmentPlugin
0023 signal configurationChanged
0024
0025 //BEGIN functions
0026 function saveConfig() {
0027 if (main.currentItem.saveConfig) {
0028 main.currentItem.saveConfig()
0029 }
0030 for (var key in configDialog.wallpaperConfiguration) {
0031 if (main.currentItem["cfg_"+key] !== undefined) {
0032 configDialog.wallpaperConfiguration[key] = main.currentItem["cfg_"+key]
0033 }
0034 }
0035 configDialog.currentWallpaper = root.currentWallpaper;
0036 configDialog.applyWallpaper()
0037 configDialog.containmentPlugin = root.containmentPlugin
0038 }
0039 //END functions
0040
0041 Kirigami.InlineMessage {
0042 Layout.alignment: Qt.AlignTop
0043 visible: Plasmoid.immutable || animating
0044 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes have been restricted by the system administrator")
0045 showCloseButton: true
0046 Layout.fillWidth: true
0047 Layout.leftMargin: Kirigami.Units.smallSpacing
0048 Layout.rightMargin: Kirigami.Units.smallSpacing
0049 Layout.bottomMargin: Kirigami.Units.smallSpacing * 2 // we need this because ColumnLayout's spacing is 0
0050 }
0051
0052 ColumnLayout {
0053 id: generalConfig
0054 spacing: 0
0055 Layout.alignment: Qt.AlignTop
0056 Layout.fillWidth: true
0057
0058 FormCard.FormHeader {
0059 title: i18n("General")
0060 }
0061
0062 FormCard.FormCard {
0063 FormCard.FormComboBoxDelegate {
0064 id: layoutSelectComboBox
0065 enabled: !Plasmoid.immutable
0066 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Homescreen Layout")
0067 description: i18n("The homescreen layout to use.")
0068 visible: model.count > 1 // only show if there are multiple plugins
0069
0070 model: configDialog.containmentPluginsConfigModel
0071 textRole: "name"
0072 valueRole: "pluginName"
0073 currentIndex: determineCurrentIndex()
0074 onCurrentIndexChanged: {
0075 root.containmentPlugin = configDialog.containmentPluginsConfigModel.get(currentIndex).pluginName;
0076 }
0077
0078 function determineCurrentIndex() {
0079 for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) {
0080 var data = configDialog.containmentPluginsConfigModel.get(i);
0081 if (configDialog.containmentPlugin === data.pluginName) {
0082 return i;
0083 }
0084 }
0085 return -1;
0086 }
0087 }
0088
0089 FormCard.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox }
0090
0091 FormCard.FormComboBoxDelegate {
0092 id: wallpaperPluginSelectComboBox
0093 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin")
0094 description: i18n("The wallpaper plugin to use.")
0095
0096 model: configDialog.wallpaperConfigModel
0097 textRole: "name"
0098 valueRole: "pluginName"
0099 currentIndex: determineCurrentIndex()
0100 onCurrentIndexChanged: {
0101 var model = configDialog.wallpaperConfigModel.get(currentIndex);
0102 root.currentWallpaper = model.pluginName;
0103 configDialog.currentWallpaper = model.pluginName;
0104 main.sourceFile = model.source;
0105 root.configurationChanged();
0106 }
0107
0108 function determineCurrentIndex() {
0109 for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
0110 var data = configDialog.wallpaperConfigModel.get(i);
0111 if (configDialog.currentWallpaper === data.pluginName) {
0112 return i;
0113 }
0114 }
0115 return -1;
0116 }
0117 }
0118
0119 FormCard.FormDelegateSeparator { above: wallpaperPluginSelectComboBox }
0120
0121 FormCard.AbstractFormDelegate {
0122 id: wallpaperPluginButton
0123 Layout.fillWidth: true
0124 background: null
0125
0126 contentItem: RowLayout {
0127 QQC2.Label {
0128 Layout.fillWidth: true
0129 text: i18n("Wallpaper Plugins")
0130 }
0131
0132 NewStuff.Button {
0133 configFile: "wallpaperplugin.knsrc"
0134 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
0135 }
0136 }
0137 }
0138 }
0139 }
0140
0141 ColumnLayout {
0142 id: switchContainmentWarning
0143 Layout.alignment: Qt.AlignTop
0144 Layout.fillWidth: true
0145 visible: configDialog.containmentPlugin !== root.containmentPlugin
0146 QQC2.Label {
0147 Layout.fillWidth: true
0148 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes must be applied before other changes can be made")
0149 wrapMode: Text.Wrap
0150 horizontalAlignment: Text.AlignHCenter
0151 }
0152 QQC2.Button {
0153 Layout.alignment: Qt.AlignHCenter
0154 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Apply now")
0155 onClicked: saveConfig()
0156 }
0157 }
0158
0159 Item {
0160 Layout.alignment: Qt.AlignTop
0161 Layout.fillHeight: switchContainmentWarning.visible
0162 visible: switchContainmentWarning.visible
0163 }
0164
0165 Item {
0166 id: emptyConfig
0167 Layout.alignment: Qt.AlignTop
0168 }
0169
0170 QQC2.StackView {
0171 id: main
0172
0173 Layout.alignment: Qt.AlignTop
0174 Layout.fillHeight: true
0175 Layout.maximumHeight: root.height - generalConfig.height - 70 // HACK: wallpaper configs seem to go over the provisioned height
0176 Layout.fillWidth: true
0177
0178 visible: !switchContainmentWarning.visible
0179
0180 // Bug 360862: if wallpaper has no config, sourceFile will be ""
0181 // so we wouldn't load emptyConfig and break all over the place
0182 // hence set it to some random value initially
0183 property string sourceFile: "tbd"
0184 onSourceFileChanged: {
0185 var wallpaperConfig = configDialog.wallpaperConfiguration;
0186
0187 if (wallpaperConfig && sourceFile) {
0188 var props = {
0189 'configDialog': configDialog
0190 }
0191
0192 for (var key in wallpaperConfig) {
0193 props["cfg_" + key] = wallpaperConfig[key]
0194 }
0195
0196 var newItem = replace(Qt.resolvedUrl(sourceFile), props)
0197
0198 for (var key in wallpaperConfig) {
0199 var changedSignal = newItem["cfg_" + key + "Changed"]
0200 if (changedSignal) {
0201 changedSignal.connect(root.configurationChanged)
0202 }
0203 }
0204 } else {
0205 replace(emptyConfig)
0206 }
0207 }
0208 }
0209 }
0210