MediaMini: add fixed width option

This commit is contained in:
Sakari
2025-10-17 15:28:32 +08:00
parent 8e5e003f8a
commit 19bfeb2a40
9 changed files with 40 additions and 0 deletions
+6
View File
@@ -40,6 +40,7 @@ Item {
// Maximum widget width with user settings support
readonly property real maxWidth: (widgetSettings.maxWidth !== undefined) ? widgetSettings.maxWidth : Math.max(widgetMetadata.maxWidth, screen.width * 0.06)
readonly property bool useFixedWidth: (widgetSettings.useFixedWidth !== undefined) ? widgetSettings.useFixedWidth : widgetMetadata.useFixedWidth
readonly property bool hasActivePlayer: MediaService.currentPlayer !== null
readonly property string placeholderText: I18n.tr("bar.widget-settings.media-mini.no-active-player")
@@ -111,6 +112,11 @@ Item {
// Dynamic width: adapt to content but respect maximum width setting
readonly property real dynamicWidth: {
// If using fixed width mode, always use maxWidth
if (useFixedWidth) {
return maxWidth
}
// Otherwise, adapt to content
if (!hasActivePlayer) {
return maxWidth
}
@@ -20,6 +20,7 @@ ColumnLayout {
property string valueVisualizerType: widgetData.visualizerType || widgetMetadata.visualizerType
property string valueScrollingMode: widgetData.scrollingMode || widgetMetadata.scrollingMode
property int valueMaxWidth: widgetData.maxWidth !== undefined ? widgetData.maxWidth : widgetMetadata.maxWidth
property bool valueUseFixedWidth: widgetData.useFixedWidth !== undefined ? widgetData.useFixedWidth : widgetMetadata.useFixedWidth
Component.onCompleted: {
if (widgetData && widgetData.hideMode !== undefined) {
@@ -35,6 +36,7 @@ ColumnLayout {
settings.visualizerType = valueVisualizerType
settings.scrollingMode = valueScrollingMode
settings.maxWidth = parseInt(widthInput.text) || widgetMetadata.maxWidth
settings.useFixedWidth = valueUseFixedWidth
return settings
}
@@ -98,6 +100,13 @@ ColumnLayout {
text: valueMaxWidth
}
NToggle {
label: I18n.tr("bar.widget-settings.media-mini.use-fixed-width.label")
description: I18n.tr("bar.widget-settings.media-mini.use-fixed-width.description")
checked: valueUseFixedWidth
onToggled: checked => valueUseFixedWidth = checked
}
NComboBox {
label: I18n.tr("bar.widget-settings.media-mini.scrolling-mode.label")
description: I18n.tr("bar.widget-settings.media-mini.scrolling-mode.description")