Warning, /plasma/plasma-mobile/components/mobileshell/qml/homescreen/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-2024 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004
0005 import QtQuick
0006 import QtQuick.Layouts
0007 import QtQuick.Window
0008 import QtQuick.Controls as Controls
0009
0010 import org.kde.kirigami 2.20 as Kirigami
0011 import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
0012 import org.kde.kquickcontrolsaddons 2.0 as Addons
0013 import org.kde.plasma.private.mobileshell.wallpaperimageplugin as WallpaperImagePlugin
0014
0015 Controls.Drawer {
0016 id: imageWallpaperDrawer
0017 dragMargin: 0
0018
0019 required property bool horizontal
0020
0021 onOpened: {
0022 wallpapersView.forceActiveFocus()
0023 }
0024
0025 implicitWidth: Kirigami.Units.gridUnit * 10
0026 implicitHeight: Kirigami.Units.gridUnit * 8
0027 width: imageWallpaperDrawer.horizontal ? implicitWidth : parent.width
0028 height: imageWallpaperDrawer.horizontal ? parent.height : implicitHeight
0029
0030 Wallpaper.ImageBackend {
0031 id: imageWallpaper
0032 }
0033
0034 background: null
0035
0036 ListView {
0037 id: wallpapersView
0038 anchors.fill: parent
0039 anchors.leftMargin: imageWallpaperDrawer.leftMargin
0040 anchors.rightMargin: imageWallpaperDrawer.rightMargin
0041 anchors.bottomMargin: imageWallpaperDrawer.bottomMargin
0042 orientation: imageWallpaperDrawer.horizontal ? ListView.Vertical : ListView.Horizontal
0043 keyNavigationEnabled: true
0044 highlightFollowsCurrentItem: true
0045 snapMode: ListView.SnapToItem
0046 model: imageWallpaper.wallpaperModel
0047 // onCountChanged: currentIndex = Math.min(model.indexOf(configDialog.wallpaperConfiguration["Image"]), model.rowCount()-1)
0048 headerPositioning: ListView.PullBackHeader
0049
0050 delegate: Controls.ItemDelegate {
0051 width: imageWallpaperDrawer.horizontal ? parent.width : height * (imageWallpaperDrawer.width / imageWallpaperDrawer.Screen.height)
0052 height: imageWallpaperDrawer.horizontal ? width / (imageWallpaperDrawer.Screen.width / imageWallpaperDrawer.Screen.height) : parent.height
0053 padding: wallpapersView.currentIndex === index ? Kirigami.Units.gridUnit / 4 : Kirigami.Units.gridUnit / 2
0054 leftPadding: padding
0055 topPadding: padding
0056 rightPadding: padding
0057 bottomPadding: padding
0058 Behavior on padding {
0059 NumberAnimation {
0060 duration: Kirigami.Units.longDuration
0061 easing.type: Easing.InOutQuad
0062 }
0063 }
0064
0065 property bool isCurrent: WallpaperImagePlugin.WallpaperPlugin.homescreenWallpaperPath == model.path
0066 onIsCurrentChanged: {
0067 if (isCurrent) {
0068 wallpapersView.currentIndex = index;
0069 }
0070 }
0071
0072 z: wallpapersView.currentIndex === index ? 2 : 0
0073 contentItem: Item {
0074 Kirigami.Icon {
0075 anchors.centerIn: parent
0076 width: Kirigami.Units.iconSizes.large
0077 height: width
0078 source: "view-preview"
0079 visible: !walliePreview.visible
0080 }
0081
0082 Addons.QPixmapItem {
0083 id: walliePreview
0084 visible: model.screenshot != null
0085 anchors.fill: parent
0086 smooth: true
0087 pixmap: model.screenshot
0088 fillMode: Image.PreserveAspectCrop
0089 }
0090 }
0091 onClicked: {
0092 WallpaperImagePlugin.WallpaperPlugin.setHomescreenWallpaper(model.path);
0093 }
0094 Keys.onReturnPressed: {
0095 clicked();
0096 }
0097 background: Item {
0098 Rectangle {
0099 anchors {
0100 fill: parent
0101 margins: wallpapersView.currentIndex === index ? 0 : Kirigami.Units.gridUnit / 4
0102 Behavior on margins {
0103 NumberAnimation {
0104 duration: Kirigami.Units.longDuration
0105 easing.type: Easing.InOutQuad
0106 }
0107 }
0108 }
0109 radius: Kirigami.Units.gridUnit / 4
0110 }
0111 }
0112 }
0113 }
0114 }