Warning, /plasma/plasma-mobile/shell/contents/configuration/WallpaperSelector.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org> 0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 2.12 0006 import QtQuick.Layouts 1.0 0007 import QtQuick.Window 2.15 0008 import QtQuick.Controls 2.3 as Controls 0009 import org.kde.plasma.extras 2.0 as PlasmaExtras 0010 import org.kde.plasma.core 2.0 as PlasmaCore 0011 import org.kde.plasma.configuration 2.0 0012 0013 import org.kde.plasma.wallpapers.image 2.0 as Wallpaper 0014 import org.kde.kquickcontrolsaddons 2.0 as Addons 0015 import org.kde.kcm 1.1 as KCM 0016 0017 Controls.Drawer { 0018 id: imageWallpaperDrawer 0019 dragMargin: 0 0020 0021 required property bool horizontal 0022 0023 onClosed: { 0024 if (!root.appComponent.visible) { 0025 configDialog.close() 0026 } 0027 } 0028 onOpened: { 0029 wallpapersView.forceActiveFocus() 0030 } 0031 implicitWidth: PlasmaCore.Units.gridUnit * 10 0032 implicitHeight: PlasmaCore.Units.gridUnit * 8 0033 width: imageWallpaperDrawer.horizontal ? implicitWidth : parent.width 0034 height: imageWallpaperDrawer.horizontal ? parent.height : implicitHeight 0035 0036 Wallpaper.ImageBackend { 0037 id: imageWallpaper 0038 } 0039 0040 background: null 0041 0042 ListView { 0043 id: wallpapersView 0044 anchors.fill: parent 0045 orientation: imageWallpaperDrawer.horizontal ? ListView.Vertical : ListView.Horizontal 0046 keyNavigationEnabled: true 0047 highlightFollowsCurrentItem: true 0048 snapMode: ListView.SnapToItem 0049 model: imageWallpaper.wallpaperModel 0050 onCountChanged: currentIndex = Math.min(model.indexOf(configDialog.wallpaperConfiguration["Image"]), model.rowCount()-1) 0051 headerPositioning: ListView.PullBackHeader 0052 delegate: Controls.ItemDelegate { 0053 width: imageWallpaperDrawer.horizontal ? parent.width : height * (imageWallpaperDrawer.width / imageWallpaperDrawer.Screen.height) 0054 height: imageWallpaperDrawer.horizontal ? width / (imageWallpaperDrawer.Screen.width / imageWallpaperDrawer.Screen.height) : parent.height 0055 padding: wallpapersView.currentIndex === index ? PlasmaCore.Units.gridUnit / 4 : PlasmaCore.Units.gridUnit / 2 0056 leftPadding: padding 0057 topPadding: padding 0058 rightPadding: padding 0059 bottomPadding: padding 0060 Behavior on padding { 0061 NumberAnimation { 0062 duration: PlasmaCore.Units.longDuration 0063 easing.type: Easing.InOutQuad 0064 } 0065 } 0066 0067 property bool isCurrent: configDialog.wallpaperConfiguration["Image"] == model.path 0068 onIsCurrentChanged: { 0069 if (isCurrent) { 0070 wallpapersView.currentIndex = index; 0071 } 0072 } 0073 0074 z: wallpapersView.currentIndex === index ? 2 : 0 0075 contentItem: Item { 0076 PlasmaCore.IconItem { 0077 anchors.centerIn: parent 0078 width: PlasmaCore.Units.iconSizes.large 0079 height: width 0080 source: "view-preview" 0081 visible: !walliePreview.visible 0082 } 0083 0084 Addons.QPixmapItem { 0085 id: walliePreview 0086 visible: model.screenshot != null 0087 anchors.fill: parent 0088 smooth: true 0089 pixmap: model.screenshot 0090 fillMode: Image.PreserveAspectCrop 0091 } 0092 } 0093 onClicked: { 0094 configDialog.currentWallpaper = "org.kde.image"; 0095 configDialog.wallpaperConfiguration["Image"] = model.path; 0096 configDialog.applyWallpaper() 0097 } 0098 Keys.onReturnPressed: { 0099 clicked(); 0100 } 0101 background: Item { 0102 Rectangle { 0103 anchors { 0104 fill: parent 0105 margins: wallpapersView.currentIndex === index ? 0 : PlasmaCore.Units.gridUnit / 4 0106 Behavior on margins { 0107 NumberAnimation { 0108 duration: PlasmaCore.Units.longDuration 0109 easing.type: Easing.InOutQuad 0110 } 0111 } 0112 } 0113 radius: PlasmaCore.Units.gridUnit / 4 0114 } 0115 } 0116 } 0117 } 0118 }