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.newstuff 1.62 as NewStuff
0013 import org.kde.kirigami 2.19 as Kirigami
0014 import org.kde.plasma.core 2.0 as PlasmaCore
0015 import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
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         MobileForm.FormCard {
0059             Layout.fillWidth: true
0060             
0061             contentItem: ColumnLayout {
0062                 spacing: 0
0063                 
0064                 MobileForm.FormCardHeader {
0065                     title: i18n("General")
0066                 }
0067                 
0068                 MobileForm.FormComboBoxDelegate {
0069                     id: layoutSelectComboBox
0070                     enabled: !plasmoid.immutable
0071                     text: i18nd("plasma_shell_org.kde.plasma.desktop", "Homescreen Layout")
0072                     description: i18n("The homescreen layout to use.")
0073                     visible: model.count > 1 // only show if there are multiple plugins
0074                     
0075                     model: configDialog.containmentPluginsConfigModel
0076                     textRole: "name"
0077                     valueRole: "pluginName"
0078                     currentIndex: determineCurrentIndex()
0079                     onCurrentIndexChanged: {
0080                         root.containmentPlugin = configDialog.containmentPluginsConfigModel.get(currentIndex).pluginName;
0081                     }
0082                     
0083                     function determineCurrentIndex() {
0084                         for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) {
0085                             var data = configDialog.containmentPluginsConfigModel.get(i);
0086                             if (configDialog.containmentPlugin === data.pluginName) {
0087                                 return i;
0088                             }
0089                         }
0090                         return -1;
0091                     }
0092                 }
0093                 
0094                 MobileForm.FormDelegateSeparator { above: layoutSelectComboBox; below: wallpaperPluginSelectComboBox }
0095                 
0096                 MobileForm.FormComboBoxDelegate {
0097                     id: wallpaperPluginSelectComboBox
0098                     text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Plugin")
0099                     description: i18n("The wallpaper plugin to use.")
0100                     
0101                     model: configDialog.wallpaperConfigModel
0102                     textRole: "name"
0103                     valueRole: "pluginName"
0104                     currentIndex: determineCurrentIndex()
0105                     onCurrentIndexChanged: {
0106                         var model = configDialog.wallpaperConfigModel.get(currentIndex);
0107                         root.currentWallpaper = model.pluginName;
0108                         configDialog.currentWallpaper = model.pluginName;
0109                         main.sourceFile = model.source;
0110                         root.configurationChanged();
0111                     }
0112                     
0113                     function determineCurrentIndex() {
0114                         for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
0115                             var data = configDialog.wallpaperConfigModel.get(i);
0116                             if (configDialog.currentWallpaper === data.pluginName) {
0117                                 return i;
0118                             }
0119                         }
0120                         return -1;
0121                     }
0122                 }
0123                 
0124                 MobileForm.FormDelegateSeparator { above: wallpaperPluginSelectComboBox }
0125                 
0126                 MobileForm.AbstractFormDelegate {
0127                     id: wallpaperPluginButton
0128                     Layout.fillWidth: true
0129                     background: Item {}
0130                     
0131                     contentItem: RowLayout {
0132                         QQC2.Label {
0133                             Layout.fillWidth: true
0134                             text: i18n("Wallpaper Plugins")
0135                         }
0136                         
0137                         NewStuff.Button {
0138                             configFile: "wallpaperplugin.knsrc"
0139                             text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
0140                         }
0141                     }
0142                 }
0143             }
0144         }
0145     }
0146 
0147     ColumnLayout {
0148         id: switchContainmentWarning
0149         Layout.alignment: Qt.AlignTop
0150         Layout.fillWidth: true
0151         visible: configDialog.containmentPlugin !== root.containmentPlugin
0152         QQC2.Label {
0153             Layout.fillWidth: true
0154             text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes must be applied before other changes can be made")
0155             wrapMode: Text.Wrap
0156             horizontalAlignment: Text.AlignHCenter
0157         }
0158         QQC2.Button {
0159             Layout.alignment: Qt.AlignHCenter
0160             text: i18nd("plasma_shell_org.kde.plasma.desktop", "Apply now")
0161             onClicked: saveConfig()
0162         }
0163     }
0164 
0165     Item {
0166         Layout.alignment: Qt.AlignTop
0167         Layout.fillHeight: switchContainmentWarning.visible
0168         visible: switchContainmentWarning.visible
0169     }
0170     
0171     Item {
0172         id: emptyConfig
0173         Layout.alignment: Qt.AlignTop
0174     }
0175 
0176     QQC2.StackView {
0177         id: main
0178 
0179         Layout.alignment: Qt.AlignTop
0180         Layout.fillHeight: true
0181         Layout.maximumHeight: root.height - generalConfig.height - 70 // HACK: wallpaper configs seem to go over the provisioned height
0182         Layout.fillWidth: true
0183 
0184         visible: !switchContainmentWarning.visible
0185         
0186         // Bug 360862: if wallpaper has no config, sourceFile will be ""
0187         // so we wouldn't load emptyConfig and break all over the place
0188         // hence set it to some random value initially
0189         property string sourceFile: "tbd"
0190         onSourceFileChanged: {
0191             if (sourceFile) {
0192                 var props = {}
0193 
0194                 var wallpaperConfig = configDialog.wallpaperConfiguration
0195                 for (var key in wallpaperConfig) {
0196                     props["cfg_" + key] = wallpaperConfig[key]
0197                 }
0198 
0199                 var newItem = replace(Qt.resolvedUrl(sourceFile), props)
0200 
0201                 for (var key in wallpaperConfig) {
0202                     var changedSignal = newItem["cfg_" + key + "Changed"]
0203                     if (changedSignal) {
0204                         changedSignal.connect(root.configurationChanged)
0205                     }
0206                 }
0207             } else {
0208                 replace(emptyConfig)
0209             }
0210         }
0211     }
0212 }
0213