-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserView.qml
105 lines (86 loc) · 3.08 KB
/
UserView.qml
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
/*
* Copyright (C) 2021 CutefishOS.
*
* Author: Reion Wong <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12 as QQC2
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import Cutefish.Accounts 1.0 as Accounts
import Cutefish.System 1.0 as System
import FishUI 1.0 as FishUI
ListView {
id: control
clip: true
height: 80 + FishUI.Units.largeSpacing * 2
orientation: ListView.Horizontal
highlightRangeMode: ListView.StrictlyEnforceRange
preferredHighlightBegin: width / 2 - userItemSize / 2
preferredHighlightEnd: preferredHighlightBegin
spacing: FishUI.Units.largeSpacing * 2
property int userItemSize: 60
delegate: Item {
id: _item
width: 60
height: ListView.view.height
opacity: control.currentIndex === index ? 1.0 : 0.3
scale: control.currentIndex === index ? 1.0 : 0.9
property string displayName: model.realName || model.name
property string userName: model.name
MouseArea {
id: _itemMouseArea
anchors.fill: parent
onClicked: control.currentIndex = index
}
ColumnLayout {
anchors.fill: parent
spacing: FishUI.Units.smallSpacing * 1.5
Image {
id: userIcon
property int iconSize: 60
Layout.preferredHeight: iconSize
Layout.preferredWidth: iconSize
sourceSize: String(model.icon).indexOf("/usr/share/sddm/faces/") > 0 ? Qt.size(iconSize, iconSize) : undefined
source: model.icon
Layout.alignment: Qt.AlignHCenter
smooth: true
scale: _itemMouseArea.pressed ? 0.9 : 1.0
Behavior on scale {
NumberAnimation {
duration: 100
}
}
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: userIcon.width
height: userIcon.height
Rectangle {
anchors.fill: parent
radius: parent.height / 2
}
}
}
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: _item.displayName
}
}
}
}