Formatting

This commit is contained in:
quadbyte 2025-08-19 13:31:13 -04:00
parent dd79920d92
commit 1d7b47ee4c
14 changed files with 267 additions and 254 deletions

View file

@ -7,29 +7,29 @@ import qs.Widgets
Item {
id: root
property string label: ""
property string description: ""
property string type: "notice" // "notice", "warning"
property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide
property bool persistent: false // If true, requires manual dismiss
property real scaling: 1.0 // Will be set by parent
// Animation properties
property real targetY: 0
property real hiddenY: -height - 20
signal dismissed()
signal dismissed
width: Math.min(500 * scaling, parent.width * 0.8)
height: Math.max(60 * scaling, contentLayout.implicitHeight + Style.marginL * 2 * scaling)
// Position at top center of parent
anchors.horizontalCenter: parent.horizontalCenter
y: hiddenY
z: 1000 // High z-index to appear above everything
function show() {
visible = true
showAnimation.start()
@ -37,18 +37,18 @@ Item {
autoHideTimer.start()
}
}
function hide() {
hideAnimation.start()
}
// Auto-hide timer
Timer {
id: autoHideTimer
interval: root.duration
onTriggered: hide()
}
// Show animation
PropertyAnimation {
id: showAnimation
@ -58,7 +58,7 @@ Item {
duration: Style.animationNormal
easing.type: Easing.OutCubic
}
// Hide animation
PropertyAnimation {
id: hideAnimation
@ -72,26 +72,29 @@ Item {
root.dismissed()
}
}
// Main toast container
Rectangle {
id: container
anchors.fill: parent
radius: Style.radiusL * scaling
// Clean surface background
color: Color.mSurface
// Simple colored border all around
border.color: {
switch (root.type) {
case "warning": return Color.mError
case "notice": return Color.mPrimary
default: return Color.mOutline
case "warning":
return Color.mError
case "notice":
return Color.mPrimary
default:
return Color.mOutline
}
}
border.width: Math.max(2, Style.borderM * scaling)
// Drop shadow effect
layer.enabled: true
layer.effect: MultiEffect {
@ -100,43 +103,49 @@ Item {
shadowBlur: 20 * scaling
shadowVerticalOffset: 4 * scaling
}
RowLayout {
id: contentLayout
anchors.fill: parent
anchors.margins: Style.marginM * scaling
spacing: Style.marginS * scaling
// Icon
NIcon {
id: icon
text: {
switch (root.type) {
case "warning": return "warning"
case "notice": return "info"
default: return "info"
case "warning":
return "warning"
case "notice":
return "info"
default:
return "info"
}
}
color: {
switch (root.type) {
case "warning": return Color.mError
case "notice": return Color.mPrimary
default: return Color.mPrimary
case "warning":
return Color.mError
case "notice":
return Color.mPrimary
default:
return Color.mPrimary
}
}
font.pointSize: Style.fontSizeXXL * 1.5 * scaling // 150% size to cover two lines
Layout.alignment: Qt.AlignVCenter
}
// Label and description
Column {
id: textColumn
spacing: Style.marginXXS * scaling
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
NText {
id: labelText
text: root.label
@ -147,7 +156,7 @@ Item {
width: parent.width
visible: text.length > 0
}
NText {
id: descriptionText
text: root.description
@ -158,23 +167,23 @@ Item {
visible: text.length > 0
}
}
// Close button (only if persistent or manual dismiss needed)
NIconButton {
id: closeButton
icon: "close"
visible: root.persistent || root.duration === 0
color: Color.mOnSurface
fontPointSize: Style.fontSize * scaling
sizeMultiplier: 0.8
Layout.alignment: Qt.AlignTop
onClicked: hide()
}
}
// Click to dismiss (if not persistent)
MouseArea {
anchors.fill: parent
@ -183,9 +192,9 @@ Item {
cursorShape: Qt.PointingHandCursor
}
}
// Initial state
Component.onCompleted: {
visible = false
}
}
}