34 lines
793 B
QML
34 lines
793 B
QML
// Transient messages. Material's own popup, anchored to the bottom.
|
|
import QtQuick
|
|
import QtQuick.Controls.Material
|
|
|
|
Popup {
|
|
id: snackbar
|
|
property string message: ""
|
|
|
|
function show(text) {
|
|
message = text
|
|
open()
|
|
timer.restart()
|
|
}
|
|
|
|
x: Math.round((parent.width - width) / 2)
|
|
y: parent.height - height - 72
|
|
width: Math.min(parent.width - 48, Math.max(260, label.implicitWidth + 48))
|
|
padding: 16
|
|
modal: false
|
|
focus: false
|
|
closePolicy: Popup.NoAutoClose
|
|
Material.elevation: 6
|
|
Material.roundedScale: Material.SmallScale
|
|
|
|
Label {
|
|
id: label
|
|
anchors.fill: parent
|
|
text: snackbar.message
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
|
|
Timer { id: timer; interval: 5000; onTriggered: snackbar.close() }
|
|
}
|