mirror of
https://github.com/stemoretti/BaseUI.git
synced 2025-07-18 21:14:25 -04:00
Heavy changes
This commit is contained in:
51
qml/PopupToast.qml
Normal file
51
qml/PopupToast.qml
Normal file
@ -0,0 +1,51 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Window
|
||||
|
||||
Popup {
|
||||
id: root
|
||||
|
||||
function start(toastText) {
|
||||
toastLabel.text = toastText
|
||||
if (!toastTimer.running)
|
||||
open()
|
||||
else
|
||||
toastTimer.restart()
|
||||
}
|
||||
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height)
|
||||
|
||||
closePolicy: Popup.CloseOnPressOutside
|
||||
bottomMargin: Screen.primaryOrientation === Qt.LandscapeOrientation ? 24 : 80
|
||||
|
||||
background: Rectangle {
|
||||
color: Style.toastColor
|
||||
radius: 24
|
||||
opacity: Style.toastOpacity
|
||||
}
|
||||
|
||||
onAboutToShow: toastTimer.start()
|
||||
onAboutToHide: toastTimer.stop()
|
||||
|
||||
Timer {
|
||||
id: toastTimer
|
||||
|
||||
interval: 3000
|
||||
repeat: false
|
||||
|
||||
onTriggered: root.close()
|
||||
}
|
||||
|
||||
Label {
|
||||
id: toastLabel
|
||||
|
||||
width: parent.width
|
||||
leftPadding: 16
|
||||
rightPadding: 16
|
||||
font.pixelSize: 16
|
||||
color: "white"
|
||||
wrapMode: Label.WordWrap
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user