Warning, /plasma/kwin/src/kcms/decoration/ui/Themes.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 SPDX-FileCopyrightText: 2019 Valerio Pilo <vpilo@coldshock.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 import QtQuick 0008 0009 import org.kde.kcmutils as KCM 0010 import org.kde.kirigami 2.20 as Kirigami 0011 import org.kde.kwin.private.kdecoration as KDecoration 0012 0013 KCM.GridView { 0014 function updateDecoration(item, marginTopLeft, marginBottomRight) { 0015 const mainMargin = Kirigami.Units.largeSpacing; 0016 const shd = item.shadow; 0017 item.anchors.leftMargin = mainMargin + marginTopLeft - (shd ? shd.paddingLeft : 0); 0018 item.anchors.rightMargin = mainMargin + marginBottomRight - (shd ? shd.paddingRight : 0); 0019 item.anchors.topMargin = mainMargin + marginTopLeft - (shd ? shd.paddingTop : 0); 0020 item.anchors.bottomMargin = mainMargin + marginBottomRight - (shd ? shd.paddingBottom : 0); 0021 } 0022 0023 view.model: kcm.themesModel 0024 view.currentIndex: kcm.theme 0025 view.onContentHeightChanged: view.positionViewAtIndex(view.currentIndex, GridView.Visible) 0026 0027 view.implicitCellWidth: Kirigami.Units.gridUnit * 18 0028 0029 framedView: false 0030 0031 view.delegate: KCM.GridDelegate { 0032 id: delegate 0033 text: model.display 0034 0035 thumbnailAvailable: true 0036 thumbnail: Rectangle { 0037 anchors.fill: parent 0038 color: palette.base 0039 clip: true 0040 0041 KDecoration.Bridge { 0042 id: bridgeItem 0043 plugin: model.plugin 0044 theme: model.theme 0045 kcmoduleName: model.kcmoduleName 0046 } 0047 KDecoration.Settings { 0048 id: settingsItem 0049 bridge: bridgeItem.bridge 0050 Component.onCompleted: { 0051 settingsItem.borderSizesIndex = kcm.borderSize; 0052 } 0053 } 0054 KDecoration.Decoration { 0055 id: inactivePreview 0056 bridge: bridgeItem.bridge 0057 settings: settingsItem 0058 anchors.fill: parent 0059 onShadowChanged: updateDecoration(inactivePreview, 0, client.decoration.titleBar.height) 0060 Component.onCompleted: { 0061 client.active = false; 0062 client.caption = model.display; 0063 updateDecoration(inactivePreview, 0, client.decoration.titleBar.height); 0064 } 0065 } 0066 KDecoration.Decoration { 0067 id: activePreview 0068 bridge: bridgeItem.bridge 0069 settings: settingsItem 0070 anchors.fill: parent 0071 onShadowChanged: updateDecoration(activePreview, client.decoration.titleBar.height, 0) 0072 Component.onCompleted: { 0073 client.active = true; 0074 client.caption = model.display; 0075 updateDecoration(activePreview, client.decoration.titleBar.height, 0); 0076 } 0077 } 0078 MouseArea { 0079 anchors.fill: parent 0080 onClicked: delegate.clicked() 0081 onDoubleClicked: delegate.doubleClicked() 0082 } 0083 Connections { 0084 target: kcm 0085 function onBorderSizeChanged() { 0086 settingsItem.borderSizesIndex = kcm.borderSize; 0087 } 0088 } 0089 } 0090 actions: [ 0091 Kirigami.Action { 0092 icon.name: "edit-entry" 0093 tooltip: i18n("Edit %1 Theme", model.display) 0094 enabled: model.configureable 0095 onTriggered: { 0096 kcm.theme = index; 0097 view.currentIndex = index; 0098 bridgeItem.bridge.configure(delegate); 0099 } 0100 } 0101 ] 0102 0103 onClicked: { 0104 kcm.theme = index; 0105 view.currentIndex = index; 0106 } 0107 onDoubleClicked: { 0108 kcm.save(); 0109 } 0110 } 0111 Connections { 0112 target: kcm 0113 function onThemeChanged() { 0114 view.currentIndex = kcm.theme; 0115 } 0116 } 0117 }