-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSkel.qml
217 lines (187 loc) · 7.62 KB
/
Skel.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
* Copyright 2019 Romain V. <contact@rokin.in> - <https://github.com/Rokin05>
*
* 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
* (at your option) 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 Library General Public
* License along with this program; if not, see <https://www.gnu.org/licenses>.
*/
import QtQuick 2.8
import "components"
import "components/style" as Style
Style.Background {
id: control
property alias menu: taskbar.data
property alias free: freespace.data
property alias taskbar: taskbar // Hook for Full-view button switch.
property string position: config['menu.default.position'] // left, right.
property string defaultSize: config['menu.default.size'] // mini, icon, tiny, half.
property real taskbarMaxSize: 600
property real miniSize // "max size" of each states.
property real iconSize
property real tinySize
property real halfSize
property real fullSize
property string menuState: updateMenuState() // get the current menu state (mini, icon, tiny, half).
readonly property bool isMini: root.menuState == "mini"
readonly property bool isIcon: root.menuState == "icon"
readonly property bool isTiny: root.menuState == "tiny"
readonly property bool isHalf: root.menuState == "half"
readonly property bool isFull: root.menuState == "full"
readonly property bool isRight: position == "right"
readonly property bool isMirror: isRight ? true : false
readonly property real taskbarSize: taskbar.width
readonly property real gripSize: config['menu/border.size']
property real mousePosY
Component.onCompleted: initSize()
Text {
anchors.fill: parent; z: 999; color: "red"
visible: false
text: (
" TaskbarSize : "+ taskbar.width +
"\n ● state : "+menuState+
"\n ● mini : "+miniSize+" - "+isMini+
"\n ● icon : "+iconSize+" - "+isIcon+
"\n ● tiny : "+tinySize+" - "+isTiny+
"\n ● half : "+halfSize+" - "+isHalf+
"\n ● full : "+fullSize+" - "+isFull+
"\n - screensaver : "+screensaver.chrono+
"\n - Mouse.Y : "+mousePosY)
}
Row {
anchors.fill: parent ; spacing: 0
LayoutMirroring.enabled: control.isMirror
Item {
id: taskbar
width: getDefaultSize()
anchors.top: parent.top
anchors.bottom: parent.bottom
Connections {
target: login
onUserSelected: if (isIcon) taskbar.width = tinySize
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: screensaver.chrono = 0
//onPositionChanged: screensaver.chrono = 0
onDoubleClicked: if (!isFull) taskbar.width = miniSize
//onEntered:
//onExited:
//onReleased:
onPositionChanged: {
screensaver.chrono = 0;
mousePosY = mouse.y;
}
}
Style.MenuBorder {
id: border
z: 100
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
LayoutMirroring.enabled: control.isMirror
visible: !control.isFull
menuState: control.menuState // shared with skel.
isPressed: borderArea.pressed // Share borderArea event with MenuBorderStyle.
isMouse: borderArea.containsMouse // Share borderArea event with MenuBorderStyle.
MouseArea {
id: borderArea
hoverEnabled: true
anchors.fill: parent
drag.target: parent; drag.axis: Drag.XAxis
onMouseXChanged: if (drag.active) control.updateLayout(mouseX)
onReleased: if (drag.active) control.mirrorLayout(mouseX)
onEntered: if (isMini) taskbar.width = iconSize
}
}
Style.MenuBackground { anchors.fill: parent; LayoutMirroring.enabled: control.isMirror }
// <MENU STUFF GO HERE YEAAAH>
}
Item {
id: freespace
width: control.width - taskbar.width
anchors.top: parent.top
anchors.bottom: parent.bottom
MouseArea {
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onClicked: screensaver.chrono = 0
//onPositionChanged: screensaver.chrono = 0
onDoubleClicked: if (isMini) taskbar.width = iconSize
onPositionChanged: {
screensaver.chrono = 0;
mousePosY = mouse.y;
}
}
// <FREE STUFF GO HERE YEAAAH>
}
}
function updateMenuState() {
// Update menuState property.
var w = taskbar.width;
if (w == fullSize) return "full";
if (w >= fullSize && w < iconSize) return "mini";
if (w == iconSize) return "icon";
if (w >= iconSize && w < halfSize) return "tiny";
return "half";
}
function initSize() {
var facesize = parseInt(config['userlist/icon.size']);
var bordersize = parseInt(config['userlist/frame.spacing']);
var textfield = parseInt(config["textfield/width"]);
var nbrVisibleUser = 3; //userModel.count
// this is purely cosmetic and can be safe remove.
var gripMargin = 36;
// Update property values.
fullSize = 0;
miniSize = gripSize;
iconSize = facesize + (bordersize*2);
tinySize = iconSize + textfield + login.miniloginSize;
halfSize = iconSize * nbrVisibleUser;
// Adjust with gripSize & margins
iconSize += gripSize;
tinySize += gripMargin;
if (halfSize <= tinySize) { halfSize = tinySize + 1; }
}
function getDefaultSize() {
if (defaultSize == "mini") return miniSize;
if (defaultSize == "icon") return iconSize;
if (defaultSize == "tiny") return tinySize;
if (defaultSize == "half") return halfSize;
if (defaultSize == "halfmax") return taskbarMaxSize; // Alternative.
if (defaultSize == "full") return 0;
return iconSize;
}
function updateLayout(mousex) {
var pos = taskbar.width;
isRight
? pos -= mousex
: pos += mousex
if (pos <= (miniSize + 20)) { pos = miniSize } else { if (pos < iconSize) pos = iconSize }
if (pos > taskbarMaxSize) pos = taskbarMaxSize;
taskbar.width = pos;
if (pos > iconSize && pos < taskbarMaxSize && isRight) taskbar.x += mousex;
}
function mirrorLayout(mousex) {
var drop = width - taskbar.width;
isRight
? drop += mousex
: drop -= mousex
if (drop < 300) {
position = isRight ? "left" : "right";
if (drop < iconSize) drop = iconSize;
if (drop > taskbarMaxSize) drop = taskbarMaxSize;
taskbar.width = drop;
}
}
}