mirror of
https://github.com/logos-storage/logos-storage-app-skeleton.git
synced 2026-06-13 20:09:28 +00:00
Add error toast
This commit is contained in:
parent
340d3f774f
commit
8c6bd2f4ef
97
src/qml/ErrorToast.qml
Normal file
97
src/qml/ErrorToast.qml
Normal file
@ -0,0 +1,97 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Logos.Theme
|
||||
import Logos.Controls
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property alias title: titleText.text
|
||||
property alias message: messageText.text
|
||||
|
||||
function show(t, msg) {
|
||||
root.title = t
|
||||
root.message = msg
|
||||
root.visible = true
|
||||
slideAnim.restart()
|
||||
}
|
||||
|
||||
function hide() {
|
||||
root.visible = false
|
||||
}
|
||||
|
||||
visible: false
|
||||
opacity: 0
|
||||
width: 500
|
||||
radius: Theme.spacing.tiny
|
||||
color: "#1e1e1e"
|
||||
|
||||
implicitHeight: content.implicitHeight + Theme.spacing.medium * 2
|
||||
|
||||
transform: Translate { id: slideTranslate; y: 20 }
|
||||
|
||||
ParallelAnimation {
|
||||
id: slideAnim
|
||||
|
||||
NumberAnimation {
|
||||
target: slideTranslate
|
||||
property: "y"
|
||||
from: 20
|
||||
to: 0
|
||||
duration: 500
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 500
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
margins: Theme.spacing.medium
|
||||
}
|
||||
spacing: Theme.spacing.tiny
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
LogosText {
|
||||
id: titleText
|
||||
Layout.fillWidth: true
|
||||
color: Theme.palette.error
|
||||
font.pixelSize: Theme.typography.primaryText
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
LogosText {
|
||||
text: "✕"
|
||||
color: Theme.palette.textMuted
|
||||
font.pixelSize: Theme.typography.primaryText
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LogosText {
|
||||
id: messageText
|
||||
Layout.fillWidth: true
|
||||
color: Theme.palette.text
|
||||
font.pixelSize: Theme.typography.primaryText
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user