-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathScreenItem.qml
More file actions
149 lines (144 loc) · 4.41 KB
/
ScreenItem.qml
File metadata and controls
149 lines (144 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.0
import QtQuick.Effects
import org.deepin.dtk 1.0 as D
import org.deepin.dcc 1.0
Item {
id: root
property var screen
property real translationX: 100
property real translationY: 100
property real scale: 0.1
property real radius: 8
property bool selected: false
property real offset: (imgRepeater.count - 1) * 6
signal pressed
signal positionChanged
signal released
signal updatePosition
// Home screen icon responsive sizing constants
readonly property int homeIconMaxSize: 24
readonly property real homeIconSizeRatio: 0.25
readonly property int homeIconMinMargin: 4
readonly property real homeIconMarginRatio: 0.04
// Home screen icon responsive sizing
readonly property int homeIconSize: Math.min(homeIconMaxSize, Math.round(root.width * homeIconSizeRatio))
readonly property int homeIconMargin: Math.max(homeIconMinMargin, Math.round(root.width * homeIconMarginRatio))
focus: true
Repeater {
id: imgRepeater
model: screen.screenItems.length
delegate: Image {
id: image
x: offset - index * 6
y: offset - index * 6
z: 1 - (0.01 * index)
width: root.width - offset
height: root.height - offset
opacity: index != 0 ? 0.8 : 1
source: "image://DccImage/" + screen.wallpaper
mipmap: true
fillMode: Image.PreserveAspectCrop
asynchronous: true
layer.enabled: true
layer.effect: MultiEffect {
maskEnabled: true
maskSource: imageMask
antialiasing: true
maskThresholdMin: 0.5
maskSpreadAtMin: 1.0
}
Item {
id: imageMask
anchors.fill: parent
layer.enabled: true
visible: false
Rectangle {
anchors.fill: parent
anchors.margins: 0.5
radius: root.radius
}
}
Rectangle {
anchors.fill: parent
radius: root.radius
color: "transparent"
opacity: (index === 0 && root.selected) ? 0.7 : 0.2
border.color: (index === 0 && root.selected) ? this.palette.window : "#000000"
border.width: 2
smooth: true
}
}
}
DccLabel {
x: offset
y: offset
z: 2
width: root.width - offset
height: root.height - offset
padding: root.radius + 5
text: screen.name
elide: Text.ElideMiddle
color: "white"
layer.enabled: true
layer.effect: MultiEffect {
shadowEnabled: true
shadowBlur: 0.01
shadowColor: Qt.rgba(0.0, 0.0, 0.0, 0.7)
shadowVerticalOffset: 1
}
}
D.DciIcon {
z: 2
visible: screen && dccData.primaryScreen && (screen.name === dccData.primaryScreen.name)
name: "home_screen"
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.bottomMargin: root.homeIconMargin
anchors.rightMargin: root.homeIconMargin
sourceSize: Qt.size(root.homeIconSize, root.homeIconSize)
}
Loader {
x: offset
y: offset
z: 2
width: root.width - offset
height: root.height - offset
active: root.selected
visible: root.selected
sourceComponent: Rectangle {
anchors.fill: parent
radius: root.radius + 1
color: "transparent"
border.color: this.palette.highlight
border.width: 2
smooth: true
}
}
MouseArea {
z: 2
anchors.fill: parent
drag.target: parent
onPressed: root.pressed()
onPositionChanged: root.positionChanged()
onReleased: root.released()
}
Component.onCompleted: updatePosition()
Connections {
target: screen
function onXChanged() {
updatePosition()
}
function onYChanged() {
updatePosition()
}
function onWidthChanged() {
updatePosition()
}
function onHeightChanged() {
updatePosition()
}
}
}