Warning, /plasma/plasma-desktop/desktoppackage/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.3 as QQC2
0010 import QtQuick.Layouts 1.1
0011 import QtQml 2.15
0012
0013 import org.kde.newstuff 1.62 as NewStuff
0014 import org.kde.kirigami 2.20 as Kirigami
0015 import org.kde.kcmutils
0016 import org.kde.plasma.plasmoid 2.0
0017 import org.kde.plasma.configuration 2.0
0018
0019 Item {
0020 id: appearanceRoot
0021 signal configurationChanged
0022
0023 property int formAlignment: wallpaperComboBox.Kirigami.ScenePosition.x - appearanceRoot.Kirigami.ScenePosition.x + Kirigami.Units.smallSpacing
0024 property string currentWallpaper: ""
0025 property string containmentPlugin: ""
0026 property alias parentLayout: parentLayout
0027
0028 function saveConfig() {
0029 if (main.currentItem.saveConfig) {
0030 main.currentItem.saveConfig()
0031 }
0032 configDialog.currentWallpaper = appearanceRoot.currentWallpaper;
0033 for (var key in configDialog.wallpaperConfiguration) {
0034 if (main.currentItem["cfg_"+key] !== undefined) {
0035 configDialog.wallpaperConfiguration[key] = main.currentItem["cfg_"+key]
0036 }
0037 }
0038 configDialog.applyWallpaper()
0039 configDialog.containmentPlugin = appearanceRoot.containmentPlugin
0040 }
0041
0042 ColumnLayout {
0043 width: root.availableWidth
0044 height: Math.max(implicitHeight, root.availableHeight)
0045 spacing: 0 // unless it's 0 there will be an additional gap between two FormLayouts
0046
0047 Component.onCompleted: {
0048 for (var i = 0; i < configDialog.containmentPluginsConfigModel.count; ++i) {
0049 var pluginName = configDialog.containmentPluginsConfigModel.data(configDialog.containmentPluginsConfigModel.index(i, 0), ConfigModel.PluginNameRole);
0050 if (configDialog.containmentPlugin === pluginName) {
0051 pluginComboBox.currentIndex = i
0052 pluginComboBox.activated(i);
0053 break;
0054 }
0055 }
0056
0057 for (var i = 0; i < configDialog.wallpaperConfigModel.count; ++i) {
0058 var pluginName = configDialog.wallpaperConfigModel.data(configDialog.wallpaperConfigModel.index(i, 0), ConfigModel.PluginNameRole);
0059 if (configDialog.currentWallpaper === pluginName) {
0060 wallpaperComboBox.currentIndex = i
0061 wallpaperComboBox.activated(i);
0062 break;
0063 }
0064 }
0065 }
0066
0067 Kirigami.InlineMessage {
0068 visible: Plasmoid.immutable || animating
0069 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes have been restricted by the system administrator")
0070 showCloseButton: true
0071 Layout.fillWidth: true
0072 Layout.leftMargin: Kirigami.Units.smallSpacing
0073 Layout.rightMargin: Kirigami.Units.smallSpacing
0074 Layout.bottomMargin: Kirigami.Units.smallSpacing * 2 // we need this because ColumnLayout's spacing is 0
0075 }
0076
0077 Kirigami.FormLayout {
0078 id: parentLayout // needed for twinFormLayouts to work in wallpaper plugins
0079 twinFormLayouts: main.currentItem.formLayout || []
0080 Layout.fillWidth: true
0081 QQC2.ComboBox {
0082 id: pluginComboBox
0083 Layout.preferredWidth: Math.max(implicitWidth, wallpaperComboBox.implicitWidth)
0084 Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:")
0085 enabled: !Plasmoid.immutable
0086 model: configDialog.containmentPluginsConfigModel
0087 textRole: "name"
0088 onActivated: {
0089 var model = configDialog.containmentPluginsConfigModel.get(currentIndex)
0090 appearanceRoot.containmentPlugin = model.pluginName
0091 appearanceRoot.configurationChanged()
0092 }
0093 }
0094
0095 RowLayout {
0096 Layout.fillWidth: true
0097 enabled: main.currentItem.objectName !== "switchContainmentWarningItem"
0098 Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper type:")
0099
0100 QQC2.ComboBox {
0101 id: wallpaperComboBox
0102 Layout.preferredWidth: Math.max(implicitWidth, pluginComboBox.implicitWidth)
0103 model: configDialog.wallpaperConfigModel
0104 textRole: "name"
0105 onActivated: {
0106 var idx = configDialog.wallpaperConfigModel.index(currentIndex, 0)
0107 var pluginName = configDialog.wallpaperConfigModel.data(idx, ConfigModel.PluginNameRole)
0108 if (appearanceRoot.currentWallpaper === pluginName) {
0109 return;
0110 }
0111 appearanceRoot.currentWallpaper = pluginName
0112 configDialog.currentWallpaper = pluginName
0113 main.sourceFile = configDialog.wallpaperConfigModel.data(idx, ConfigModel.SourceRole)
0114 appearanceRoot.configurationChanged()
0115 }
0116 }
0117 NewStuff.Button {
0118 configFile: "wallpaperplugin.knsrc"
0119 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins…")
0120 visibleWhenDisabled: true // don't hide on disabled
0121 Layout.preferredHeight: wallpaperComboBox.height
0122 }
0123 }
0124 }
0125
0126 Item {
0127 id: emptyConfig
0128 }
0129
0130 QQC2.StackView {
0131 id: main
0132
0133 implicitHeight: main.empty ? 0 : currentItem.implicitHeight
0134
0135 Layout.fillHeight: true;
0136 Layout.fillWidth: true;
0137
0138 // Bug 360862: if wallpaper has no config, sourceFile will be ""
0139 // so we wouldn't load emptyConfig and break all over the place
0140 // hence set it to some random value initially
0141 property string sourceFile: "tbd"
0142
0143 onSourceFileChanged: loadSourceFile()
0144
0145 function loadSourceFile() {
0146 const wallpaperConfig = configDialog.wallpaperConfiguration
0147 // BUG 407619: wallpaperConfig can be null before calling `ContainmentItem::loadWallpaper()`
0148 if (wallpaperConfig && sourceFile) {
0149 var props = {
0150 "configDialog": configDialog
0151 }
0152
0153 for (var key in wallpaperConfig) {
0154 props["cfg_" + key] = wallpaperConfig[key]
0155 }
0156
0157 var newItem = replace(Qt.resolvedUrl(sourceFile), props)
0158
0159 for (var key in wallpaperConfig) {
0160 var changedSignal = newItem["cfg_" + key + "Changed"]
0161 if (changedSignal) {
0162 changedSignal.connect(appearanceRoot.configurationChanged)
0163 }
0164 }
0165
0166 const configurationChangedSignal = newItem.configurationChanged
0167 if (configurationChangedSignal) {
0168 configurationChangedSignal.connect(appearanceRoot.configurationChanged)
0169 }
0170 } else {
0171 replace(emptyConfig)
0172 }
0173 }
0174 }
0175 }
0176
0177 Component {
0178 id: switchContainmentWarning
0179
0180 Item {
0181 objectName: "switchContainmentWarningItem"
0182
0183 Kirigami.PlaceholderMessage {
0184 id: message
0185 width: parent.width - Kirigami.Units.largeSpacing * 8
0186 anchors.centerIn: parent
0187
0188 icon.name: "documentinfo"
0189 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout changes must be applied before other changes can be made")
0190
0191 helpfulAction: QQC2.Action {
0192 icon.name: "dialog-ok-apply"
0193 text: i18nd("plasma_shell_org.kde.plasma.desktop", "Apply Now")
0194 onTriggered: saveConfig()
0195 }
0196 }
0197 }
0198 }
0199
0200 onContainmentPluginChanged: {
0201 if (configDialog.containmentPlugin !== appearanceRoot.containmentPlugin) {
0202 main.push(switchContainmentWarning);
0203 categoriesScroll.enabled = false;
0204 } else if (main.currentItem.objectName === "switchContainmentWarningItem") {
0205 main.pop();
0206 categoriesScroll.enabled = true;
0207 }
0208 }
0209 }