diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 5972252..1cf4840 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -92,7 +92,7 @@ Variants { // Top section (left widgets) Column { - spacing: Style.marginS * root.scaling + spacing: Style.marginXXS * root.scaling anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: Style.marginM * root.scaling @@ -118,7 +118,7 @@ Variants { // Center section (center widgets) Column { - spacing: Style.marginS * root.scaling + spacing: Style.marginXXS * root.scaling anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter width: parent.width @@ -143,7 +143,7 @@ Variants { // Bottom section (right widgets) Column { - spacing: Style.marginS * root.scaling + spacing: Style.marginXS * root.scaling anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.bottomMargin: Style.marginM * root.scaling diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index cdb8c44..e49bdf7 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -52,7 +52,7 @@ Item { readonly property real minWidth: Math.max(1, screen.width * 0.06) readonly property real maxWidth: minWidth * 2 - implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) + implicitHeight: Math.round(Style.capsuleHeight * scaling) implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling) function getTitle() { @@ -66,21 +66,6 @@ Item { visible: getTitle() !== "" - function calculatedVerticalHeight() { - // Base height for the background rectangle - let total = Math.round(Style.capsuleHeight * scaling) - - // Add padding for the container margins - total += Style.marginM * scaling * 2 // Top and bottom margins - - // Add space for icon if shown - if (showIcon) { - total += Style.fontSizeL * scaling * 1.2 + Style.marginS * scaling - } - - return total - } - function calculatedHorizontalWidth() { let total = Style.marginM * 2 * scaling // internal padding diff --git a/Modules/Bar/Widgets/Clock.qml b/Modules/Bar/Widgets/Clock.qml index b39dade..b01b69f 100644 --- a/Modules/Bar/Widgets/Clock.qml +++ b/Modules/Bar/Widgets/Clock.qml @@ -33,12 +33,23 @@ Rectangle { readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat - + // Use compact mode for vertical bars readonly property bool useCompactMode: barPosition === "left" || barPosition === "right" implicitWidth: useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling) implicitHeight: useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling) + + // React to bar position changes + Connections { + target: BarService + function onBarPositionChanged(newPosition) { + root.barPosition = newPosition + // Force re-evaluation of implicitWidth and implicitHeight + root.implicitWidth = Qt.binding(() => useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)) + root.implicitHeight = Qt.binding(() => useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling)) + } + } radius: Math.round(Style.radiusS * scaling) color: Color.mSurfaceVariant @@ -64,18 +75,20 @@ Rectangle { if (useCompactMode) { // Compact mode: time section (first 2 lines) switch (index) { - case 0: // Hours - if (use12h) { - const hours = now.getHours() - const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours) - return displayHours.toString().padStart(2, '0') - } else { - return now.getHours().toString().padStart(2, '0') - } - case 1: // Minutes - return now.getMinutes().toString().padStart(2, '0') - default: - return "" + case 0: + // Hours + if (use12h) { + const hours = now.getHours() + const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours) + return displayHours.toString().padStart(2, '0') + } else { + return now.getHours().toString().padStart(2, '0') + } + case 1: + // Minutes + return now.getMinutes().toString().padStart(2, '0') + default: + return "" } } else { // Normal mode: single line with time @@ -152,12 +165,14 @@ Rectangle { if (useCompactMode) { // Compact mode: date section (last 2 lines) switch (index) { - case 0: // Day - return now.getDate().toString().padStart(2, '0') - case 1: // Month - return (now.getMonth() + 1).toString().padStart(2, '0') - default: - return "" + case 0: + // Day + return now.getDate().toString().padStart(2, '0') + case 1: + // Month + return (now.getMonth() + 1).toString().padStart(2, '0') + default: + return "" } } return "" diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index 9f97017..3d809e1 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -58,10 +58,6 @@ Item { return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "") } - function calculatedVerticalHeight() { - return Math.round(Style.baseWidgetSize * 0.8 * scaling) - } - function calculatedHorizontalWidth() { let total = Style.marginM * 2 * scaling // internal padding if (showAlbumArt) { @@ -74,7 +70,7 @@ Item { return total } - implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) + implicitHeight: Math.round(Style.capsuleHeight * scaling) implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (rowLayout.implicitWidth + Style.marginM * 2 * scaling) visible: MediaService.currentPlayer !== null && MediaService.canPlay diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index f9d8956..a2ed205 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -51,7 +51,7 @@ Item { readonly property bool showNetworkStats: (widgetSettings.showNetworkStats !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage - implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) + implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.capsuleHeight * scaling) implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginL * 2 * scaling) function calculatedVerticalHeight() { diff --git a/Services/BarService.qml b/Services/BarService.qml index ec89662..1a05419 100644 --- a/Services/BarService.qml +++ b/Services/BarService.qml @@ -7,8 +7,8 @@ import qs.Commons Singleton { id: root - // Bar position property - property string position: Settings.data.bar.position + // Bar position property - initialize safely + property string position: "top" // Signal emitted when bar position changes signal barPositionChanged(string newPosition) @@ -17,7 +17,7 @@ Singleton { Connections { target: Settings function onDataChanged() { - if (Settings.data.bar.position !== root.position) { + if (Settings.data && Settings.data.bar && Settings.data.bar.position !== root.position) { root.position = Settings.data.bar.position root.barPositionChanged(root.position) } @@ -31,6 +31,15 @@ Singleton { // Function to change bar position function setPosition(newPosition) { - Settings.data.bar.position = newPosition + if (Settings.data && Settings.data.bar) { + Settings.data.bar.position = newPosition + } + } + + // Initialize position after component is completed + Component.onCompleted: { + if (Settings.data && Settings.data.bar) { + position = Settings.data.bar.position + } } }