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

@ -109,7 +109,7 @@ Singleton {
property JsonObject bar property JsonObject bar
bar: JsonObject { bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom" property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindow: true property bool showActiveWindow: true
property bool showSystemInfo: false property bool showSystemInfo: false
property bool showMedia: false property bool showMedia: false

View file

@ -43,12 +43,10 @@ NLoader {
} }
margins { margins {
top: (Settings.data.bar.monitors.includes(modelData.name) top: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top" && Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
? Math.floor(Style.barHeight * scaling) : 0 bottom: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
bottom: (Settings.data.bar.monitors.includes(modelData.name) && Settings.data.bar.position === "bottom" ? Math.floor(Style.barHeight * scaling) : 0
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom"
? Math.floor(Style.barHeight * scaling) : 0
} }
// Source we want to show only as a ring // Source we want to show only as a ring

View file

@ -76,10 +76,10 @@ NLoader {
anchors { anchors {
right: parent.right right: parent.right
rightMargin: Style.marginXS * scaling rightMargin: Style.marginXS * scaling
top: Settings.data.bar.position === "top" ? parent.top : undefined top: Settings.data.bar.position === "top" ? parent.top : undefined
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
} }
// Animation properties // Animation properties

View file

@ -254,4 +254,4 @@ PopupWindow {
} }
} }
} }
} }

View file

@ -91,10 +91,10 @@ NLoader {
anchors { anchors {
right: parent.right right: parent.right
rightMargin: Style.marginXS * scaling rightMargin: Style.marginXS * scaling
top: Settings.data.bar.position === "top" ? parent.top : undefined top: Settings.data.bar.position === "top" ? parent.top : undefined
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
} }
// Animation properties // Animation properties

View file

@ -346,19 +346,19 @@ ColumnLayout {
id: matugenCheck id: matugenCheck
command: ["which", "matugen"] command: ["which", "matugen"]
running: false running: false
onExited: function(exitCode) { onExited: function (exitCode) {
if (exitCode === 0) { if (exitCode === 0) {
// Matugen exists, enable it // Matugen exists, enable it
Settings.data.colorSchemes.useWallpaperColors = true Settings.data.colorSchemes.useWallpaperColors = true
ColorSchemeService.changedWallpaper() ColorSchemeService.changedWallpaper()
ToastService.showNotice("Matugen", "Enabled!") ToastService.showNotice("Matugen", "Enabled!")
} else { } else {
// Matugen not found // Matugen not found
ToastService.showWarning("Matugen", "Not installed!") ToastService.showWarning("Matugen", "Not installed!")
} }
} }
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }

View file

@ -8,69 +8,69 @@ import qs.Services
import qs.Widgets import qs.Widgets
ColumnLayout { ColumnLayout {
id: root id: root
spacing: 0 spacing: 0
ScrollView { ScrollView {
id: scrollView id: scrollView
Layout.fillWidth: true
Layout.fillHeight: true
padding: Style.marginM * scaling
clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ColumnLayout {
width: scrollView.availableWidth
spacing: 0
Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.preferredHeight: 0
padding: Style.marginM * scaling }
clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ColumnLayout {
ScrollBar.vertical.policy: ScrollBar.AsNeeded spacing: Style.marginL * scaling
Layout.fillWidth: true
ColumnLayout { NText {
width: scrollView.availableWidth text: "Interfaces"
spacing: 0 font.pointSize: Style.fontSizeXXL * scaling
font.weight: Style.fontWeightBold
Item { color: Color.mOnSurface
Layout.fillWidth: true
Layout.preferredHeight: 0
}
ColumnLayout {
spacing: Style.marginL * scaling
Layout.fillWidth: true
NText {
text: "Interfaces"
font.pointSize: Style.fontSizeXXL * scaling
font.weight: Style.fontWeightBold
color: Color.mOnSurface
}
NToggle {
label: "WiFi Enabled"
description: "Enable WiFi connectivity."
checked: Settings.data.network.wifiEnabled
onToggled: checked => {
Settings.data.network.wifiEnabled = checked
NetworkService.setWifiEnabled(checked)
if (checked) {
ToastService.showNotice("WiFi", "Enabled")
} else {
ToastService.showNotice("WiFi", "Disabled")
}
}
}
NToggle {
label: "Bluetooth Enabled"
description: "Enable Bluetooth connectivity."
checked: Settings.data.network.bluetoothEnabled
onToggled: checked => {
Settings.data.network.bluetoothEnabled = checked
BluetoothService.setBluetoothEnabled(checked)
if (checked) {
ToastService.showNotice("Bluetooth", "Enabled")
} else {
ToastService.showNotice("Bluetooth", "Disabled")
}
}
}
}
} }
NToggle {
label: "WiFi Enabled"
description: "Enable WiFi connectivity."
checked: Settings.data.network.wifiEnabled
onToggled: checked => {
Settings.data.network.wifiEnabled = checked
NetworkService.setWifiEnabled(checked)
if (checked) {
ToastService.showNotice("WiFi", "Enabled")
} else {
ToastService.showNotice("WiFi", "Disabled")
}
}
}
NToggle {
label: "Bluetooth Enabled"
description: "Enable Bluetooth connectivity."
checked: Settings.data.network.bluetoothEnabled
onToggled: checked => {
Settings.data.network.bluetoothEnabled = checked
BluetoothService.setBluetoothEnabled(checked)
if (checked) {
ToastService.showNotice("Bluetooth", "Enabled")
} else {
ToastService.showNotice("Bluetooth", "Disabled")
}
}
}
}
} }
}
} }

View file

@ -348,19 +348,19 @@ ColumnLayout {
id: swwwCheck id: swwwCheck
command: ["which", "swww"] command: ["which", "swww"]
running: false running: false
onExited: function(exitCode) { onExited: function (exitCode) {
if (exitCode === 0) { if (exitCode === 0) {
// SWWW exists, enable it // SWWW exists, enable it
Settings.data.wallpaper.swww.enabled = true Settings.data.wallpaper.swww.enabled = true
WallpaperService.startSWWWDaemon() WallpaperService.startSWWWDaemon()
ToastService.showNotice("SWWW", "Enabled!") ToastService.showNotice("SWWW", "Enabled!")
} else { } else {
// SWWW not found // SWWW not found
ToastService.showWarning("SWWW", "Not installed!") ToastService.showWarning("SWWW", "Not installed!")
} }
} }
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }

View file

@ -24,18 +24,18 @@ Variants {
left: true left: true
right: true right: true
} }
// Set margins based on bar position // Set margins based on bar position
margins.top: Settings.data.bar.position === "top" ? (Style.barHeight + Style.marginS) * scaling : 0 margins.top: Settings.data.bar.position === "top" ? (Style.barHeight + Style.marginS) * scaling : 0
margins.bottom: Settings.data.bar.position === "bottom" ? (Style.barHeight + Style.marginS) * scaling : 0 margins.bottom: Settings.data.bar.position === "bottom" ? (Style.barHeight + Style.marginS) * scaling : 0
// Small height when hidden, appropriate height when visible // Small height when hidden, appropriate height when visible
implicitHeight: toast.visible ? toast.height + Style.marginS * scaling : 1 implicitHeight: toast.visible ? toast.height + Style.marginS * scaling : 1
// Transparent background // Transparent background
color: Color.transparent color: Color.transparent
// High layer to appear above other panels // High layer to appear above other panels
//WlrLayershell.layer: WlrLayer.Overlay //WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
exclusionMode: PanelWindow.ExclusionMode.Ignore exclusionMode: PanelWindow.ExclusionMode.Ignore
@ -43,22 +43,20 @@ Variants {
NToast { NToast {
id: toast id: toast
scaling: root.scaling scaling: root.scaling
// Simple positioning - margins already account for bar // Simple positioning - margins already account for bar
targetY: Style.marginS * scaling targetY: Style.marginS * scaling
// Hidden position based on bar location // Hidden position based on bar location
hiddenY: Settings.data.bar.position === "top" hiddenY: Settings.data.bar.position === "top" ? -toast.height - 20 : toast.height + 20
? -toast.height - 20
: toast.height + 20
Component.onCompleted: { Component.onCompleted: {
// Register this toast with the service // Register this toast with the service
ToastService.currentToast = toast ToastService.currentToast = toast
// Connect dismissal signal // Connect dismissal signal
toast.dismissed.connect(ToastService.onToastDismissed) toast.dismissed.connect(ToastService.onToastDismissed)
} }
} }
} }
} }

View file

@ -147,7 +147,7 @@ Singleton {
console.warn("BluetoothService: No adapter available") console.warn("BluetoothService: No adapter available")
return return
} }
adapter.enabled = enabled adapter.enabled = enabled
} }
} }

View file

@ -145,7 +145,7 @@ Singleton {
try { try {
const hlToplevels = Hyprland.toplevels.values const hlToplevels = Hyprland.toplevels.values
const windowsList = [] const windowsList = []
for (var i = 0; i < hlToplevels.length; i++) { for (var i = 0; i < hlToplevels.length; i++) {
const toplevel = hlToplevels[i] const toplevel = hlToplevels[i]
windowsList.push({ windowsList.push({
@ -158,7 +158,7 @@ Singleton {
} }
windows = windowsList windows = windowsList
// Update focused window index // Update focused window index
focusedWindowIndex = -1 focusedWindowIndex = -1
for (var j = 0; j < windowsList.length; j++) { for (var j = 0; j < windowsList.length; j++) {
@ -167,7 +167,7 @@ Singleton {
break break
} }
} }
updateFocusedWindowTitle() updateFocusedWindowTitle()
activeWindowChanged() activeWindowChanged()
} catch (e) { } catch (e) {

View file

@ -20,6 +20,7 @@ Singleton {
} }
} }
} catch (e) { } catch (e) {
//Logger.warn(e) //Logger.warn(e)
} }

View file

@ -6,177 +6,184 @@ import qs.Commons
QtObject { QtObject {
id: root id: root
// Queue of pending toast messages // Queue of pending toast messages
property var messageQueue: [] property var messageQueue: []
property bool isShowingToast: false property bool isShowingToast: false
// Reference to the current toast instance (set by ToastManager) // Reference to the current toast instance (set by ToastManager)
property var currentToast: null property var currentToast: null
// Methods to show different types of messages // Methods to show different types of messages
function showNotice(label, description = "", persistent = false, duration = 3000) { function showNotice(label, description = "", persistent = false, duration = 3000) {
showToast(label, description, "notice", persistent, duration) showToast(label, description, "notice", persistent, duration)
} }
function showWarning(label, description = "", persistent = false, duration = 4000) { function showWarning(label, description = "", persistent = false, duration = 4000) {
showToast(label, description, "warning", persistent, duration) showToast(label, description, "warning", persistent, duration)
} }
// Utility function to check if a command exists and show appropriate toast // Utility function to check if a command exists and show appropriate toast
function checkCommandAndToast(command, successMessage, failMessage, onSuccess = null) { function checkCommandAndToast(command, successMessage, failMessage, onSuccess = null) {
var checkProcess = Qt.createQmlObject(` var checkProcess = Qt.createQmlObject(`
import QtQuick import QtQuick
import Quickshell.Io import Quickshell.Io
Process { Process {
id: checkProc id: checkProc
command: ["which", "${command}"] command: ["which", "${command}"]
running: true running: true
property var onSuccessCallback: null property var onSuccessCallback: null
property bool hasFinished: false property bool hasFinished: false
onExited: { onExited: {
if (!hasFinished) { if (!hasFinished) {
hasFinished = true hasFinished = true
if (exitCode === 0) { if (exitCode === 0) {
ToastService.showNotice("${successMessage}") ToastService.showNotice("${successMessage}")
if (onSuccessCallback) onSuccessCallback() if (onSuccessCallback) onSuccessCallback()
} else { } else {
ToastService.showWarning("${failMessage}") ToastService.showWarning("${failMessage}")
} }
checkProc.destroy() checkProc.destroy()
} }
} }
// Fallback collectors to prevent issues // Fallback collectors to prevent issues
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }
`, root) `, root)
checkProcess.onSuccessCallback = onSuccess checkProcess.onSuccessCallback = onSuccess
} }
// Simple function to show a random toast (useful for testing or fun messages) // Simple function to show a random toast (useful for testing or fun messages)
function showRandomToast() { function showRandomToast() {
var messages = [ var messages = [{
{ type: "notice", text: "Everything is working smoothly!" }, "type": "notice",
{ type: "notice", text: "Noctalia is looking great today!" }, "text": "Everything is working smoothly!"
{ type: "notice", text: "Your desktop setup is amazing!" }, }, {
{ type: "warning", text: "Don't forget to take a break!" }, "type": "notice",
{ type: "notice", text: "Configuration saved successfully!" }, "text": "Noctalia is looking great today!"
{ type: "warning", text: "Remember to backup your settings!" } }, {
] "type": "notice",
"text": "Your desktop setup is amazing!"
}, {
"type": "warning",
"text": "Don't forget to take a break!"
}, {
"type": "notice",
"text": "Configuration saved successfully!"
}, {
"type": "warning",
"text": "Remember to backup your settings!"
}]
var randomMessage = messages[Math.floor(Math.random() * messages.length)] var randomMessage = messages[Math.floor(Math.random() * messages.length)]
showToast(randomMessage.text, randomMessage.type) showToast(randomMessage.text, randomMessage.type)
} }
// Convenience function for quick notifications // Convenience function for quick notifications
function quickNotice(message) { function quickNotice(message) {
showNotice(message, false, 2000) // Short duration showNotice(message, false, 2000) // Short duration
} }
function quickWarning(message) { function quickWarning(message) {
showWarning(message, false, 3000) // Medium duration showWarning(message, false, 3000) // Medium duration
} }
// Generic command runner with toast feedback // Generic command runner with toast feedback
function runCommandWithToast(command, args, successMessage, failMessage, onSuccess = null) { function runCommandWithToast(command, args, successMessage, failMessage, onSuccess = null) {
var fullCommand = [command].concat(args || []) var fullCommand = [command].concat(args || [])
var runProcess = Qt.createQmlObject(` var runProcess = Qt.createQmlObject(`
import QtQuick import QtQuick
import Quickshell.Io import Quickshell.Io
Process { Process {
id: runProc id: runProc
command: ${JSON.stringify(fullCommand)} command: ${JSON.stringify(fullCommand)}
running: true running: true
property var onSuccessCallback: null property var onSuccessCallback: null
property bool hasFinished: false property bool hasFinished: false
onExited: { onExited: {
if (!hasFinished) { if (!hasFinished) {
hasFinished = true hasFinished = true
if (exitCode === 0) { if (exitCode === 0) {
ToastService.showNotice("${successMessage}") ToastService.showNotice("${successMessage}")
if (onSuccessCallback) onSuccessCallback() if (onSuccessCallback) onSuccessCallback()
} else { } else {
ToastService.showWarning("${failMessage}") ToastService.showWarning("${failMessage}")
} }
runProc.destroy() runProc.destroy()
} }
} }
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }
`, root) `, root)
runProcess.onSuccessCallback = onSuccess runProcess.onSuccessCallback = onSuccess
} }
// Check if a file/directory exists // Check if a file/directory exists
function checkPathAndToast(path, successMessage, failMessage, onSuccess = null) { function checkPathAndToast(path, successMessage, failMessage, onSuccess = null) {
runCommandWithToast("test", ["-e", path], successMessage, failMessage, onSuccess) runCommandWithToast("test", ["-e", path], successMessage, failMessage, onSuccess)
} }
// Show toast after a delay (useful for delayed feedback) // Show toast after a delay (useful for delayed feedback)
function delayedToast(message, type = "notice", delayMs = 1000) { function delayedToast(message, type = "notice", delayMs = 1000) {
var timer = Qt.createQmlObject(` var timer = Qt.createQmlObject(`
import QtQuick import QtQuick
Timer { Timer {
interval: ${delayMs} interval: ${delayMs}
repeat: false repeat: false
running: true running: true
onTriggered: { onTriggered: {
ToastService.showToast("${message}", "${type}") ToastService.showToast("${message}", "${type}")
destroy() destroy()
} }
} }
`, root) `, root)
} }
// Generic method to show a toast // Generic method to show a toast
function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) { function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) {
var toastData = { var toastData = {
label: label, "label": label,
description: description, "description": description,
type: type, "type": type,
persistent: persistent, "persistent": persistent,
duration: duration, "duration": duration,
timestamp: Date.now() "timestamp": Date.now()
} }
// Add to queue // Add to queue
messageQueue.push(toastData) messageQueue.push(toastData)
// Process queue if not currently showing a toast // Process queue if not currently showing a toast
if (!isShowingToast) { if (!isShowingToast) {
processQueue() processQueue()
} }
} }
// Process the message queue // Process the message queue
function processQueue() { function processQueue() {
if (messageQueue.length === 0 || !currentToast) { if (messageQueue.length === 0 || !currentToast) {
isShowingToast = false isShowingToast = false
return return
} }
if (isShowingToast) { if (isShowingToast) {
// Wait for current toast to finish // Wait for current toast to finish
return return
} }
var toastData = messageQueue.shift() var toastData = messageQueue.shift()
isShowingToast = true isShowingToast = true
// Configure and show toast // Configure and show toast
currentToast.label = toastData.label currentToast.label = toastData.label
currentToast.description = toastData.description currentToast.description = toastData.description
@ -185,32 +192,32 @@ QtObject {
currentToast.duration = toastData.duration currentToast.duration = toastData.duration
currentToast.show() currentToast.show()
} }
// Called when a toast is dismissed // Called when a toast is dismissed
function onToastDismissed() { function onToastDismissed() {
isShowingToast = false isShowingToast = false
// Small delay before showing next toast // Small delay before showing next toast
Qt.callLater(function() { Qt.callLater(function () {
processQueue() processQueue()
}) })
} }
// Clear all pending messages // Clear all pending messages
function clearQueue() { function clearQueue() {
messageQueue = [] messageQueue = []
} }
// Hide current toast // Hide current toast
function hideCurrentToast() { function hideCurrentToast() {
if (currentToast && isShowingToast) { if (currentToast && isShowingToast) {
currentToast.hide() currentToast.hide()
} }
} }
Component.onCompleted: { Component.onCompleted: {
} }
} }

View file

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