-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainWithoutBackground.qml
60 lines (50 loc) · 1.29 KB
/
mainWithoutBackground.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
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Window 2.3
import smarty.input 1.0
import "constants.js" as Constants
ApplicationWindow {
id: root
visible: true
flags: Qt.FramelessWindowHint | Qt.WA_TranslucentBackground
x: Screen.width / 4
y: isOnTheTop() ? Screen.height / 4 : Screen.height / 2
width: mainWidget.width + closeButton.width
height: Math.min(Screen.height / 2, mainWidget.getHeight())
color: "#eee"
// color: "#00000000"
MainWidget {
id: mainWidget
// anchors.fill: parent
width: Screen.width / 2
height: parent.height
spacing: 5
}
Button {
x: mainWidget.x + mainWidget.width
y: mainWidget.y
width: Constants.itemHeight
height: Constants.itemHeight
id: closeButton
text: "X"
onClicked: app.close()
}
Behavior on y {
NumberAnimation {
duration: 500
easing.type: Easing.OutBack
}
}
onActiveChanged: {
if (!active)
app.close()
}
property bool _isOnTheTop: false
function isOnTheTop() {
var result = mainWidget.hasItems()
if (result)
_isOnTheTop = true
return _isOnTheTop || result
}
}