-
Notifications
You must be signed in to change notification settings - Fork 3
/
Popup.qml
executable file
·66 lines (57 loc) · 1.46 KB
/
Popup.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
import QtQuick 2.0
import Sailfish.Silica 1.0
MouseArea {
id: popup
anchors.top: parent.top
width: parent.width
height: message.paintedHeight + (Theme.paddingLarge * 2)
property alias title: message.text
property alias timeout: hideTimer.interval
property alias background: bg.color
visible: opacity > 0
opacity: 0.0
Behavior on opacity {
FadeAnimation {}
}
Rectangle {
id: bg
anchors.fill: parent
}
Timer {
id: hideTimer
triggeredOnStart: false
repeat: false
interval: 5000
onTriggered: popup.hide()
}
function hide() {
if (hideTimer.running)
hideTimer.stop()
popup.opacity = 0.0
}
function show() {
popup.opacity = 1.0
hideTimer.restart()
}
function notify(text, color) {
popup.title = text
if (color && (typeof(color) != "undefined"))
bg.color = color
else
bg.color = Theme.rgba(Theme.secondaryHighlightColor, 0.9)
show()
}
Label {
id: message
anchors.verticalCenter: popup.verticalCenter
font.pixelSize: 32
anchors.left: parent.left
anchors.leftMargin: Theme.paddingLarge
anchors.right: parent.right
anchors.rightMargin: Theme.paddingLarge
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
wrapMode: Text.Wrap
}
onClicked: hide()
}