Warning, /plasma/plasma-bigscreen/shell/contents/configuration/ContainmentConfiguration.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Window 2.12
0009 import QtQuick.Layouts 1.0
0010 import QtQuick.Controls 2.3 as Controls
0011 import org.kde.plasma.extras 2.0 as PlasmaExtras
0012 import org.kde.plasma.core 2.0 as PlasmaCore
0013 import org.kde.plasma.configuration 2.0
0014 
0015 //for the "simple mode"
0016 import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
0017 import org.kde.kquickcontrolsaddons 2.0 as Addons
0018 import org.kde.kcm 1.1 as KCM
0019 import org.kde.kirigami 2.11 as Kirigami
0020 
0021 AppletConfiguration {
0022     id: root
0023     isContainment: true
0024 
0025     internalDialog.visible: false
0026     internalDialog.width: Math.min(root.height - units.gridUnit * 2, Math.max(internalDialog.implicitWidth, units.gridUnit * 45))
0027     internalDialog.height: Math.min(root.width, Math.max(internalDialog.implicitHeight, units.gridUnit * 29))
0028 
0029     readonly property bool horizontal: false
0030 
0031 //BEGIN model
0032     globalConfigModel: globalContainmentConfigModel
0033 
0034     ConfigModel {
0035         id: globalContainmentConfigModel
0036         ConfigCategory {
0037             name: i18nd("org.kde.plasma.mycroft.bigscreen", "Wallpaper")
0038             icon: "preferences-desktop-wallpaper"
0039             source: "ConfigurationContainmentAppearance.qml"
0040         }
0041     }
0042 //END model
0043 
0044     Controls.Drawer {
0045         id: imageWallpaperDrawer
0046         edge: root.horizontal ? Qt.LeftEdge : Qt.BottomEdge
0047         visible: true
0048         onClosed: {
0049             if (!root.internalDialog.visible) {
0050                 configDialog.close()
0051             }
0052         }
0053         onOpened: {
0054             wallpapersView.forceActiveFocus()
0055         }
0056         implicitWidth: units.gridUnit * 10
0057         implicitHeight: wallpapersView.cellHeight + topPadding + bottomPadding
0058         width: root.horizontal ? implicitWidth : root.width
0059         height: root.horizontal ? root.height : implicitHeight
0060         leftPadding: units.smallSpacing * 2
0061         rightPadding: units.smallSpacing * 2
0062         topPadding: units.smallSpacing * 2
0063         bottomPadding: units.smallSpacing * 2
0064         
0065         Wallpaper.ImageBackend {
0066             id: imageWallpaper
0067         }
0068         background: null
0069 
0070         ListView {
0071             id: wallpapersView
0072             anchors.fill: parent
0073             readonly property real cellWidth: width / Math.floor(width / (units.gridUnit * 12))
0074             readonly property int cellHeight: cellWidth / screenRatio
0075             readonly property real screenRatio: root.Window.window ? root.Window.window.width / root.Window.window.height : 1.6
0076 
0077             orientation: root.horizontal ? ListView.Vertical : ListView.Horizontal
0078             keyNavigationEnabled: true
0079             highlightFollowsCurrentItem: true
0080             highlightMoveDuration: Kirigami.Units.longDuration
0081             snapMode: ListView.SnapToItem
0082             model: imageWallpaper.wallpaperModel
0083             onCountChanged: currentIndex =  Math.min(model.indexOf(configDialog.wallpaperConfiguration["Image"]), model.rowCount()-1)
0084             KeyNavigation.left: headerItem
0085             Keys.onUpPressed: imageWallpaperDrawer.close()
0086             highlightRangeMode: ListView.ApplyRange
0087             
0088             preferredHighlightBegin: cellWidth
0089             preferredHighlightEnd: cellWidth
0090             displayMarginBeginning: cellWidth*2
0091             displayMarginEnd: cellWidth
0092 
0093             header: WallpaperDelegate {
0094                 id: delegate
0095                 width: wallpapersView.cellWidth
0096                 height: wallpapersView.cellHeight
0097 
0098                 readonly property int index: -1
0099                 checked: activeFocus
0100                 highlighted: configDialog.currentWallpaper = "org.kde.slideshow"
0101                 onIsCurrentChanged: {
0102                     if (isCurrent) {
0103                         forceActiveFocus();
0104                         wallpapersView.currentIndex = -1;
0105                     }
0106                 }
0107                 onActiveFocusChanged: {
0108                     if (activeFocus) {
0109                         wallpapersView.currentIndex = -1;
0110                     }
0111                 }
0112                 onClicked: {
0113                     forceActiveFocus();
0114                     configDialog.currentWallpaper = "org.kde.slideshow";
0115                     configDialog.applyWallpaper();
0116                 }
0117                 Keys.onReturnPressed: clicked()
0118 
0119                 contentItem: Image {
0120                     source: Qt.resolvedUrl("SlideshowThumbnail.png")
0121                     fillMode: Image.PreserveAspectCrop
0122                     sourceSize.width: width
0123                     sourceSize.height: height
0124                     Controls.Label {
0125                         anchors {
0126                             bottom: parent.bottom
0127                             horizontalCenter: parent.horizontalCenter
0128                         }
0129                         color: "white"
0130                         text: i18nd("org.kde.plasma.mycroft.bigscreen", "Slideshow")
0131                     }
0132                 }
0133 
0134                 Keys.onRightPressed: {
0135                     print(wallpapersView.itemAt(1, 1))
0136                     wallpapersView.itemAt(1, 1).forceActiveFocus()
0137                     wallpapersView.currentIndex = 0
0138                 }
0139             }
0140     
0141             delegate: WallpaperDelegate {
0142                 id: delegate
0143 
0144                 highlighted: configDialog.wallpaperConfiguration["Image"] == model.path
0145                 onIsCurrentChanged: {
0146                     if (isCurrent) {
0147                         wallpapersView.currentIndex = index;
0148                     }
0149                 }
0150                 
0151                 contentItem: Item {
0152                     Addons.QIconItem {
0153                         anchors.centerIn: parent
0154                         width: units.iconSizes.large
0155                         height: width
0156                         icon: "view-preview"
0157                         visible: !walliePreview.visible
0158                     }
0159 
0160                     Addons.QPixmapItem {
0161                         id: walliePreview
0162                         anchors.fill: parent
0163                         visible: model.screenshot != null
0164                         smooth: true
0165                         pixmap: model.screenshot
0166                         fillMode: Image.PreserveAspectCrop
0167                     }
0168                 }
0169                 onClicked: {
0170                     configDialog.currentWallpaper = "org.kde.image";
0171                     configDialog.wallpaperConfiguration["Image"] = model.path;
0172                     configDialog.applyWallpaper()
0173                 }
0174                 Keys.onReturnPressed: {
0175                     clicked();
0176                 }
0177             }
0178         }
0179     }
0180 }