Formatting
This commit is contained in:
parent
dd79920d92
commit
1d7b47ee4c
14 changed files with 267 additions and 254 deletions
|
|
@ -109,7 +109,7 @@ Singleton {
|
|||
property JsonObject bar
|
||||
|
||||
bar: JsonObject {
|
||||
property string position: "top" // Possible values: "top", "bottom"
|
||||
property string position: "top" // Possible values: "top", "bottom"
|
||||
property bool showActiveWindow: true
|
||||
property bool showSystemInfo: false
|
||||
property bool showMedia: false
|
||||
|
|
|
|||
|
|
@ -43,12 +43,10 @@ NLoader {
|
|||
}
|
||||
|
||||
margins {
|
||||
top: (Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top"
|
||||
? Math.floor(Style.barHeight * scaling) : 0
|
||||
bottom: (Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom"
|
||||
? Math.floor(Style.barHeight * scaling) : 0
|
||||
top: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
|
||||
&& Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
|
||||
bottom: (Settings.data.bar.monitors.includes(modelData.name) || (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
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ NLoader {
|
|||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: Style.marginXS * scaling
|
||||
top: Settings.data.bar.position === "top" ? parent.top : undefined
|
||||
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
|
||||
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
|
||||
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
|
||||
top: Settings.data.bar.position === "top" ? parent.top : undefined
|
||||
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
|
||||
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
|
||||
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
|
||||
}
|
||||
|
||||
// Animation properties
|
||||
|
|
|
|||
|
|
@ -254,4 +254,4 @@ PopupWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,10 +91,10 @@ NLoader {
|
|||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: Style.marginXS * scaling
|
||||
top: Settings.data.bar.position === "top" ? parent.top : undefined
|
||||
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
|
||||
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
|
||||
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
|
||||
top: Settings.data.bar.position === "top" ? parent.top : undefined
|
||||
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
|
||||
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
|
||||
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
|
||||
}
|
||||
|
||||
// Animation properties
|
||||
|
|
|
|||
|
|
@ -346,19 +346,19 @@ ColumnLayout {
|
|||
id: matugenCheck
|
||||
command: ["which", "matugen"]
|
||||
running: false
|
||||
|
||||
onExited: function(exitCode) {
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
// Matugen exists, enable it
|
||||
Settings.data.colorSchemes.useWallpaperColors = true
|
||||
ColorSchemeService.changedWallpaper()
|
||||
ToastService.showNotice("Matugen", "Enabled!")
|
||||
} else {
|
||||
// Matugen not found
|
||||
ToastService.showWarning("Matugen", "Not installed!")
|
||||
ToastService.showNotice("Matugen", "Enabled!")
|
||||
} else {
|
||||
// Matugen not found
|
||||
ToastService.showWarning("Matugen", "Not installed!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,69 +8,69 @@ import qs.Services
|
|||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: 0
|
||||
id: root
|
||||
spacing: 0
|
||||
|
||||
ScrollView {
|
||||
id: scrollView
|
||||
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.fillHeight: true
|
||||
padding: Style.marginM * scaling
|
||||
clip: true
|
||||
Layout.preferredHeight: 0
|
||||
}
|
||||
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
||||
ColumnLayout {
|
||||
spacing: Style.marginL * scaling
|
||||
Layout.fillWidth: true
|
||||
|
||||
ColumnLayout {
|
||||
width: scrollView.availableWidth
|
||||
spacing: 0
|
||||
|
||||
Item {
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,19 +348,19 @@ ColumnLayout {
|
|||
id: swwwCheck
|
||||
command: ["which", "swww"]
|
||||
running: false
|
||||
|
||||
onExited: function(exitCode) {
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
// SWWW exists, enable it
|
||||
Settings.data.wallpaper.swww.enabled = true
|
||||
WallpaperService.startSWWWDaemon()
|
||||
ToastService.showNotice("SWWW", "Enabled!")
|
||||
} else {
|
||||
// SWWW not found
|
||||
ToastService.showWarning("SWWW", "Not installed!")
|
||||
ToastService.showNotice("SWWW", "Enabled!")
|
||||
} else {
|
||||
// SWWW not found
|
||||
ToastService.showWarning("SWWW", "Not installed!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ Variants {
|
|||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
|
||||
// Set margins based on bar position
|
||||
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
|
||||
|
||||
|
||||
// Small height when hidden, appropriate height when visible
|
||||
implicitHeight: toast.visible ? toast.height + Style.marginS * scaling : 1
|
||||
|
||||
// Transparent background
|
||||
color: Color.transparent
|
||||
|
||||
// High layer to appear above other panels
|
||||
|
||||
// High layer to appear above other panels
|
||||
//WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||
exclusionMode: PanelWindow.ExclusionMode.Ignore
|
||||
|
|
@ -43,22 +43,20 @@ Variants {
|
|||
NToast {
|
||||
id: toast
|
||||
scaling: root.scaling
|
||||
|
||||
|
||||
// Simple positioning - margins already account for bar
|
||||
targetY: Style.marginS * scaling
|
||||
|
||||
|
||||
// Hidden position based on bar location
|
||||
hiddenY: Settings.data.bar.position === "top"
|
||||
? -toast.height - 20
|
||||
: toast.height + 20
|
||||
|
||||
hiddenY: Settings.data.bar.position === "top" ? -toast.height - 20 : toast.height + 20
|
||||
|
||||
Component.onCompleted: {
|
||||
// Register this toast with the service
|
||||
ToastService.currentToast = toast
|
||||
|
||||
|
||||
// Connect dismissal signal
|
||||
toast.dismissed.connect(ToastService.onToastDismissed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ Singleton {
|
|||
console.warn("BluetoothService: No adapter available")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
adapter.enabled = enabled
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ Singleton {
|
|||
try {
|
||||
const hlToplevels = Hyprland.toplevels.values
|
||||
const windowsList = []
|
||||
|
||||
|
||||
for (var i = 0; i < hlToplevels.length; i++) {
|
||||
const toplevel = hlToplevels[i]
|
||||
windowsList.push({
|
||||
|
|
@ -158,7 +158,7 @@ Singleton {
|
|||
}
|
||||
|
||||
windows = windowsList
|
||||
|
||||
|
||||
// Update focused window index
|
||||
focusedWindowIndex = -1
|
||||
for (var j = 0; j < windowsList.length; j++) {
|
||||
|
|
@ -167,7 +167,7 @@ Singleton {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updateFocusedWindowTitle()
|
||||
activeWindowChanged()
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ Singleton {
|
|||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
//Logger.warn(e)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,177 +6,184 @@ import qs.Commons
|
|||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
|
||||
// Queue of pending toast messages
|
||||
property var messageQueue: []
|
||||
property bool isShowingToast: false
|
||||
|
||||
|
||||
// Reference to the current toast instance (set by ToastManager)
|
||||
property var currentToast: null
|
||||
|
||||
|
||||
// Methods to show different types of messages
|
||||
function showNotice(label, description = "", persistent = false, duration = 3000) {
|
||||
showToast(label, description, "notice", persistent, duration)
|
||||
}
|
||||
|
||||
|
||||
function showWarning(label, description = "", persistent = false, duration = 4000) {
|
||||
showToast(label, description, "warning", persistent, duration)
|
||||
}
|
||||
|
||||
|
||||
// Utility function to check if a command exists and show appropriate toast
|
||||
function checkCommandAndToast(command, successMessage, failMessage, onSuccess = null) {
|
||||
var checkProcess = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: checkProc
|
||||
command: ["which", "${command}"]
|
||||
running: true
|
||||
|
||||
property var onSuccessCallback: null
|
||||
property bool hasFinished: false
|
||||
|
||||
onExited: {
|
||||
if (!hasFinished) {
|
||||
hasFinished = true
|
||||
if (exitCode === 0) {
|
||||
ToastService.showNotice("${successMessage}")
|
||||
if (onSuccessCallback) onSuccessCallback()
|
||||
} else {
|
||||
ToastService.showWarning("${failMessage}")
|
||||
}
|
||||
checkProc.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback collectors to prevent issues
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
`, root)
|
||||
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: checkProc
|
||||
command: ["which", "${command}"]
|
||||
running: true
|
||||
|
||||
property var onSuccessCallback: null
|
||||
property bool hasFinished: false
|
||||
|
||||
onExited: {
|
||||
if (!hasFinished) {
|
||||
hasFinished = true
|
||||
if (exitCode === 0) {
|
||||
ToastService.showNotice("${successMessage}")
|
||||
if (onSuccessCallback) onSuccessCallback()
|
||||
} else {
|
||||
ToastService.showWarning("${failMessage}")
|
||||
}
|
||||
checkProc.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback collectors to prevent issues
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
`, root)
|
||||
|
||||
checkProcess.onSuccessCallback = onSuccess
|
||||
}
|
||||
|
||||
|
||||
// Simple function to show a random toast (useful for testing or fun messages)
|
||||
function showRandomToast() {
|
||||
var messages = [
|
||||
{ type: "notice", text: "Everything is working smoothly!" },
|
||||
{ type: "notice", text: "Noctalia is looking great today!" },
|
||||
{ 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 messages = [{
|
||||
"type": "notice",
|
||||
"text": "Everything is working smoothly!"
|
||||
}, {
|
||||
"type": "notice",
|
||||
"text": "Noctalia is looking great today!"
|
||||
}, {
|
||||
"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)]
|
||||
showToast(randomMessage.text, randomMessage.type)
|
||||
}
|
||||
|
||||
|
||||
// Convenience function for quick notifications
|
||||
function quickNotice(message) {
|
||||
showNotice(message, false, 2000) // Short duration
|
||||
}
|
||||
|
||||
|
||||
function quickWarning(message) {
|
||||
showWarning(message, false, 3000) // Medium duration
|
||||
}
|
||||
|
||||
|
||||
// Generic command runner with toast feedback
|
||||
function runCommandWithToast(command, args, successMessage, failMessage, onSuccess = null) {
|
||||
var fullCommand = [command].concat(args || [])
|
||||
var runProcess = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: runProc
|
||||
command: ${JSON.stringify(fullCommand)}
|
||||
running: true
|
||||
|
||||
property var onSuccessCallback: null
|
||||
property bool hasFinished: false
|
||||
|
||||
onExited: {
|
||||
if (!hasFinished) {
|
||||
hasFinished = true
|
||||
if (exitCode === 0) {
|
||||
ToastService.showNotice("${successMessage}")
|
||||
if (onSuccessCallback) onSuccessCallback()
|
||||
} else {
|
||||
ToastService.showWarning("${failMessage}")
|
||||
}
|
||||
runProc.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
`, root)
|
||||
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: runProc
|
||||
command: ${JSON.stringify(fullCommand)}
|
||||
running: true
|
||||
|
||||
property var onSuccessCallback: null
|
||||
property bool hasFinished: false
|
||||
|
||||
onExited: {
|
||||
if (!hasFinished) {
|
||||
hasFinished = true
|
||||
if (exitCode === 0) {
|
||||
ToastService.showNotice("${successMessage}")
|
||||
if (onSuccessCallback) onSuccessCallback()
|
||||
} else {
|
||||
ToastService.showWarning("${failMessage}")
|
||||
}
|
||||
runProc.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
`, root)
|
||||
|
||||
runProcess.onSuccessCallback = onSuccess
|
||||
}
|
||||
|
||||
|
||||
// Check if a file/directory exists
|
||||
function checkPathAndToast(path, successMessage, failMessage, onSuccess = null) {
|
||||
runCommandWithToast("test", ["-e", path], successMessage, failMessage, onSuccess)
|
||||
}
|
||||
|
||||
|
||||
// Show toast after a delay (useful for delayed feedback)
|
||||
function delayedToast(message, type = "notice", delayMs = 1000) {
|
||||
var timer = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
Timer {
|
||||
interval: ${delayMs}
|
||||
repeat: false
|
||||
running: true
|
||||
onTriggered: {
|
||||
ToastService.showToast("${message}", "${type}")
|
||||
destroy()
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
import QtQuick
|
||||
Timer {
|
||||
interval: ${delayMs}
|
||||
repeat: false
|
||||
running: true
|
||||
onTriggered: {
|
||||
ToastService.showToast("${message}", "${type}")
|
||||
destroy()
|
||||
}
|
||||
}
|
||||
`, root)
|
||||
}
|
||||
|
||||
|
||||
// Generic method to show a toast
|
||||
function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) {
|
||||
var toastData = {
|
||||
label: label,
|
||||
description: description,
|
||||
type: type,
|
||||
persistent: persistent,
|
||||
duration: duration,
|
||||
timestamp: Date.now()
|
||||
"label": label,
|
||||
"description": description,
|
||||
"type": type,
|
||||
"persistent": persistent,
|
||||
"duration": duration,
|
||||
"timestamp": Date.now()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add to queue
|
||||
messageQueue.push(toastData)
|
||||
|
||||
|
||||
// Process queue if not currently showing a toast
|
||||
if (!isShowingToast) {
|
||||
processQueue()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process the message queue
|
||||
function processQueue() {
|
||||
if (messageQueue.length === 0 || !currentToast) {
|
||||
isShowingToast = false
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (isShowingToast) {
|
||||
// Wait for current toast to finish
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var toastData = messageQueue.shift()
|
||||
isShowingToast = true
|
||||
|
||||
|
||||
|
||||
// Configure and show toast
|
||||
currentToast.label = toastData.label
|
||||
currentToast.description = toastData.description
|
||||
|
|
@ -185,32 +192,32 @@ QtObject {
|
|||
currentToast.duration = toastData.duration
|
||||
currentToast.show()
|
||||
}
|
||||
|
||||
|
||||
// Called when a toast is dismissed
|
||||
function onToastDismissed() {
|
||||
|
||||
isShowingToast = false
|
||||
|
||||
|
||||
// Small delay before showing next toast
|
||||
Qt.callLater(function() {
|
||||
Qt.callLater(function () {
|
||||
processQueue()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Clear all pending messages
|
||||
function clearQueue() {
|
||||
|
||||
messageQueue = []
|
||||
}
|
||||
|
||||
|
||||
// Hide current toast
|
||||
function hideCurrentToast() {
|
||||
if (currentToast && isShowingToast) {
|
||||
currentToast.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue