More fixes
This commit is contained in:
parent
004836fc8f
commit
8c815146e6
6 changed files with 53 additions and 48 deletions
|
|
@ -92,7 +92,7 @@ Variants {
|
||||||
|
|
||||||
// Top section (left widgets)
|
// Top section (left widgets)
|
||||||
Column {
|
Column {
|
||||||
spacing: Style.marginS * root.scaling
|
spacing: Style.marginXXS * root.scaling
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: Style.marginM * root.scaling
|
anchors.topMargin: Style.marginM * root.scaling
|
||||||
|
|
@ -118,7 +118,7 @@ Variants {
|
||||||
|
|
||||||
// Center section (center widgets)
|
// Center section (center widgets)
|
||||||
Column {
|
Column {
|
||||||
spacing: Style.marginS * root.scaling
|
spacing: Style.marginXXS * root.scaling
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
@ -143,7 +143,7 @@ Variants {
|
||||||
|
|
||||||
// Bottom section (right widgets)
|
// Bottom section (right widgets)
|
||||||
Column {
|
Column {
|
||||||
spacing: Style.marginS * root.scaling
|
spacing: Style.marginXS * root.scaling
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: Style.marginM * root.scaling
|
anchors.bottomMargin: Style.marginM * root.scaling
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ Item {
|
||||||
readonly property real minWidth: Math.max(1, screen.width * 0.06)
|
readonly property real minWidth: Math.max(1, screen.width * 0.06)
|
||||||
readonly property real maxWidth: minWidth * 2
|
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)
|
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
|
||||||
|
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
|
|
@ -66,21 +66,6 @@ Item {
|
||||||
|
|
||||||
visible: getTitle() !== ""
|
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() {
|
function calculatedHorizontalWidth() {
|
||||||
let total = Style.marginM * 2 * scaling // internal padding
|
let total = Style.marginM * 2 * scaling // internal padding
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,23 @@ Rectangle {
|
||||||
readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock
|
readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock
|
||||||
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
||||||
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
||||||
|
|
||||||
// Use compact mode for vertical bars
|
// Use compact mode for vertical bars
|
||||||
readonly property bool useCompactMode: barPosition === "left" || barPosition === "right"
|
readonly property bool useCompactMode: barPosition === "left" || barPosition === "right"
|
||||||
|
|
||||||
implicitWidth: useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
|
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)
|
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)
|
radius: Math.round(Style.radiusS * scaling)
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
|
|
||||||
|
|
@ -64,18 +75,20 @@ Rectangle {
|
||||||
if (useCompactMode) {
|
if (useCompactMode) {
|
||||||
// Compact mode: time section (first 2 lines)
|
// Compact mode: time section (first 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // Hours
|
case 0:
|
||||||
if (use12h) {
|
// Hours
|
||||||
const hours = now.getHours()
|
if (use12h) {
|
||||||
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
const hours = now.getHours()
|
||||||
return displayHours.toString().padStart(2, '0')
|
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
||||||
} else {
|
return displayHours.toString().padStart(2, '0')
|
||||||
return now.getHours().toString().padStart(2, '0')
|
} else {
|
||||||
}
|
return now.getHours().toString().padStart(2, '0')
|
||||||
case 1: // Minutes
|
}
|
||||||
return now.getMinutes().toString().padStart(2, '0')
|
case 1:
|
||||||
default:
|
// Minutes
|
||||||
return ""
|
return now.getMinutes().toString().padStart(2, '0')
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Normal mode: single line with time
|
// Normal mode: single line with time
|
||||||
|
|
@ -152,12 +165,14 @@ Rectangle {
|
||||||
if (useCompactMode) {
|
if (useCompactMode) {
|
||||||
// Compact mode: date section (last 2 lines)
|
// Compact mode: date section (last 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // Day
|
case 0:
|
||||||
return now.getDate().toString().padStart(2, '0')
|
// Day
|
||||||
case 1: // Month
|
return now.getDate().toString().padStart(2, '0')
|
||||||
return (now.getMonth() + 1).toString().padStart(2, '0')
|
case 1:
|
||||||
default:
|
// Month
|
||||||
return ""
|
return (now.getMonth() + 1).toString().padStart(2, '0')
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,6 @@ Item {
|
||||||
return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "")
|
return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "")
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculatedVerticalHeight() {
|
|
||||||
return Math.round(Style.baseWidgetSize * 0.8 * scaling)
|
|
||||||
}
|
|
||||||
|
|
||||||
function calculatedHorizontalWidth() {
|
function calculatedHorizontalWidth() {
|
||||||
let total = Style.marginM * 2 * scaling // internal padding
|
let total = Style.marginM * 2 * scaling // internal padding
|
||||||
if (showAlbumArt) {
|
if (showAlbumArt) {
|
||||||
|
|
@ -74,7 +70,7 @@ Item {
|
||||||
return total
|
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)
|
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (rowLayout.implicitWidth + Style.marginM * 2 * scaling)
|
||||||
|
|
||||||
visible: MediaService.currentPlayer !== null && MediaService.canPlay
|
visible: MediaService.currentPlayer !== null && MediaService.canPlay
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ Item {
|
||||||
readonly property bool showNetworkStats: (widgetSettings.showNetworkStats !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats
|
readonly property bool showNetworkStats: (widgetSettings.showNetworkStats !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats
|
||||||
readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage
|
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)
|
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginL * 2 * scaling)
|
||||||
|
|
||||||
function calculatedVerticalHeight() {
|
function calculatedVerticalHeight() {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import qs.Commons
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Bar position property
|
// Bar position property - initialize safely
|
||||||
property string position: Settings.data.bar.position
|
property string position: "top"
|
||||||
|
|
||||||
// Signal emitted when bar position changes
|
// Signal emitted when bar position changes
|
||||||
signal barPositionChanged(string newPosition)
|
signal barPositionChanged(string newPosition)
|
||||||
|
|
@ -17,7 +17,7 @@ Singleton {
|
||||||
Connections {
|
Connections {
|
||||||
target: Settings
|
target: Settings
|
||||||
function onDataChanged() {
|
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.position = Settings.data.bar.position
|
||||||
root.barPositionChanged(root.position)
|
root.barPositionChanged(root.position)
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +31,15 @@ Singleton {
|
||||||
|
|
||||||
// Function to change bar position
|
// Function to change bar position
|
||||||
function setPosition(newPosition) {
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue