-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomSnackbar.qml
More file actions
65 lines (50 loc) · 1.18 KB
/
CustomSnackbar.qml
File metadata and controls
65 lines (50 loc) · 1.18 KB
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
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Popup {
id: root
property alias message: snackbarMessage.text
// Public function to show
function show() {
open();
}
// Behavior
closePolicy: Popup.NoAutoClose
// Appearance
padding: 10
width: Math.min(parent.width * 0.9, 800)
// Positioning
x: (parent.width - width) / 2
y: parent.height - height - 20
background: Rectangle {
color: "#333"
radius: 4
}
contentItem: RowLayout {
spacing: 10
Label {
id: snackbarMessage
Layout.fillWidth: true
color: "white"
wrapMode: Text.WordWrap
}
Button {
Layout.alignment: Qt.AlignVCenter
text: "Dismiss"
background: Rectangle {
border.color: "white"
border.width: 1
color: "transparent"
radius: 4
}
onClicked: root.close()
}
}
onClosed: hideTimer.stop()
onOpened: hideTimer.start()
Timer {
id: hideTimer
interval: 3000
onTriggered: root.close()
}
}