-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathToast.qml
66 lines (50 loc) · 1.45 KB
/
Toast.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
//----------------------------------------------------------------
// Toast/Popup with specified timeout to show/stay on screen.
//
// 1. It can be a toast with image only.
// 2. It can be a toast with text only.
// 3. It can be a toast with both image and text.
//----------------------------------------------------------------
Rectangle {
id: toast
property alias text: msg.text
property alias fontSize: msg.font.pixelSize
property alias textColor: msg.color
property alias imgSrc: img.source
// time for toast to stay
property int timeout: 2000
color: "blue"
radius: 8
border.color: "#666666"
border.width: 4
width: 320
height: 240
anchors.centerIn: parent
z: 1000
//----------------------------------------------------------------
// initially toast will not be visible
// once its visible, timer will start running
// and once timer has triggered, it will hide the toast again
//----------------------------------------------------------------
visible: false
Column {
anchors.centerIn: parent
spacing: 10
Image {
id: img
x: parent.width/2 - width/2
}
Text {
id: msg
}
}
Timer {
id: timer
interval: timeout
repeat: false
running: toast.visible
triggeredOnStart: false
onTriggered: toast.visible = false;
}
}//toast