Clean and default settings in desktop widgets

This commit is contained in:
Thibault Martin
2026-02-27 20:11:11 +01:00
parent 4f106a7627
commit eaa467c0dd
9 changed files with 82 additions and 56 deletions
+7 -4
View File
@@ -251,28 +251,31 @@
"desktop": {
"Clock": {
"showBackground": true,
"roundedCorners": true,
"clockStyle": "digital",
"clockColor": "none",
"useCustomFont": false,
"customFont": "",
"format": "HH:mm\\nd MMMM yyyy"
},
"MediaPlayer": {
"showBackground": true,
"roundedCorners": true,
"visualizerType": "linear",
"hideMode": "visible",
"showButtons": true,
"showAlbumArt": true,
"showVisualizer": true,
"roundedCorners": true
"showVisualizer": true
},
"Weather": {
"showBackground": true
"showBackground": true,
"roundedCorners": true
},
"SystemStat": {
"showBackground": true,
"roundedCorners": true,
"statType": "CPU",
"diskPath": "/",
"roundedCorners": true,
"layout": "bottom"
}
}
@@ -21,8 +21,9 @@ Item {
readonly property bool isDragging: internal.isDragging
readonly property bool isScaling: internal.isScaling
property bool showBackground: (widgetData && widgetData.showBackground !== undefined) ? widgetData.showBackground : true
property bool roundedCorners: (widgetData && widgetData.roundedCorners !== undefined) ? widgetData.roundedCorners : true
// All Desktop widgets have these settings, but fallback just in case
property bool showBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : (widgetMetadata?.showBackground ?? true)
property bool roundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : (widgetMetadata?.roundedCorners ?? true)
property real widgetScale: 1.0
property real minScale: 0.5
@@ -14,12 +14,12 @@ DraggableDesktopWidget {
readonly property color clockTextColor: Color.resolveColorKey(clockColor)
readonly property real fontSize: Math.round(Style.fontSizeXXXL * 2.5 * widgetScale)
readonly property real widgetOpacity: (widgetData && widgetData.opacity !== undefined) ? widgetData.opacity : 1.0
readonly property string clockStyle: (widgetData && widgetData.clockStyle !== undefined) ? widgetData.clockStyle : (widgetMetadata.clockStyle !== undefined ? widgetMetadata.clockStyle : "digital")
readonly property string clockColor: (widgetData && widgetData.clockColor !== undefined) ? widgetData.clockColor : (widgetMetadata.clockColor !== undefined ? widgetMetadata.clockColor : "none")
readonly property bool useCustomFont: (widgetData && widgetData.useCustomFont !== undefined) ? widgetData.useCustomFont : (widgetMetadata.useCustomFont !== undefined ? widgetMetadata.useCustomFont : false)
readonly property string customFont: (widgetData && widgetData.customFont !== undefined) ? widgetData.customFont : ""
readonly property string format: (widgetData && widgetData.format !== undefined) ? widgetData.format : (widgetMetadata.format !== undefined ? widgetMetadata.format : "HH:mm\\nd MMMM yyyy")
readonly property real widgetOpacity: widgetData.opacity !== undefined ? widgetData.opacity : 1.0
readonly property string clockStyle: widgetData.clockStyle !== undefined ? widgetData.clockStyle : widgetMetadata.clockStyle
readonly property string clockColor: widgetData.clockColor !== undefined ? widgetData.clockColor : widgetMetadata.clockColor
readonly property bool useCustomFont: widgetData.useCustomFont !== undefined ? widgetData.useCustomFont : widgetMetadata.useCustomFont
readonly property string customFont: widgetData.customFont !== undefined ? widgetData.customFont : widgetMetadata.customFont
readonly property string format: widgetData.format !== undefined ? widgetData.format : widgetMetadata.format
readonly property real contentPadding: Math.round((clockStyle === "minimal" ? Style.marginL : Style.marginXL) * widgetScale)
implicitWidth: contentLoader.item ? Math.round((contentLoader.item.implicitWidth || contentLoader.item.width || 0) + contentPadding * 2) : 0
@@ -20,15 +20,15 @@ ColumnLayout {
QtObject {
id: _settings
property string icon: (widgetData && widgetData.icon !== undefined) ? widgetData.icon : (widgetMetadata && widgetMetadata.icon ? widgetMetadata.icon : "")
property string onClicked: (widgetData && widgetData.onClicked !== undefined) ? widgetData.onClicked : (widgetMetadata && widgetMetadata.onClicked ? widgetMetadata.onClicked : "")
property string onRightClicked: (widgetData && widgetData.onRightClicked !== undefined) ? widgetData.onRightClicked : (widgetMetadata && widgetMetadata.onRightClicked ? widgetMetadata.onRightClicked : "")
property string onMiddleClicked: (widgetData && widgetData.onMiddleClicked !== undefined) ? widgetData.onMiddleClicked : (widgetMetadata && widgetMetadata.onMiddleClicked ? widgetMetadata.onMiddleClicked : "")
property string icon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
property string onClicked: widgetData.onClicked !== undefined ? widgetData.onClicked : widgetMetadata.onClicked
property string onRightClicked: widgetData.onRightClicked !== undefined ? widgetData.onRightClicked : widgetMetadata.onRightClicked
property string onMiddleClicked: widgetData.onMiddleClicked !== undefined ? widgetData.onMiddleClicked : widgetMetadata.onMiddleClicked
property ListModel _stateChecksListModel: ListModel {}
property string stateChecksJson: "[]"
property string generalTooltipText: (widgetData && widgetData.generalTooltipText !== undefined) ? widgetData.generalTooltipText : (widgetMetadata && widgetMetadata.generalTooltipText ? widgetMetadata.generalTooltipText : "")
property bool enableOnStateLogic: (widgetData && widgetData.enableOnStateLogic !== undefined) ? widgetData.enableOnStateLogic : (widgetMetadata && widgetMetadata.enableOnStateLogic !== undefined ? widgetMetadata.enableOnStateLogic : false)
property bool showExecTooltip: (widgetData && widgetData.showExecTooltip !== undefined) ? widgetData.showExecTooltip : (widgetMetadata && widgetMetadata.showExecTooltip !== undefined ? widgetMetadata.showExecTooltip : true)
property string generalTooltipText: widgetData.generalTooltipText !== undefined ? widgetData.generalTooltipText : widgetMetadata.generalTooltipText
property bool enableOnStateLogic: widgetData.enableOnStateLogic !== undefined ? widgetData.enableOnStateLogic : widgetMetadata.enableOnStateLogic
property bool showExecTooltip: widgetData.showExecTooltip !== undefined ? widgetData.showExecTooltip : widgetMetadata.showExecTooltip
function populateStateChecks() {
try {
@@ -143,6 +143,7 @@ ColumnLayout {
_settings.generalTooltipText = text;
saveSettings();
}
defaultValue: widgetMetadata.generalTooltipText
}
NToggle {
@@ -154,6 +155,7 @@ ColumnLayout {
_settings.showExecTooltip = checked;
saveSettings();
}
defaultValue: widgetMetadata.showExecTooltip
}
NTextInput {
@@ -166,6 +168,7 @@ ColumnLayout {
_settings.onClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onClicked
}
NTextInput {
@@ -178,6 +181,7 @@ ColumnLayout {
_settings.onRightClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onRightClicked
}
NTextInput {
@@ -190,6 +194,7 @@ ColumnLayout {
_settings.onMiddleClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onMiddleClicked
}
NDivider {}
@@ -204,6 +209,7 @@ ColumnLayout {
_settings.enableOnStateLogic = checked;
saveSettings();
}
defaultValue: widgetMetadata.enableOnStateLogic
}
ColumnLayout {
@@ -16,11 +16,11 @@ ColumnLayout {
signal settingsChanged(var settings)
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : true
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
property string valueClockStyle: widgetData.clockStyle !== undefined ? widgetData.clockStyle : widgetMetadata.clockStyle
property string valueClockColor: widgetData.clockColor !== undefined ? widgetData.clockColor : widgetMetadata.clockColor
property bool valueUseCustomFont: widgetData.useCustomFont !== undefined ? widgetData.useCustomFont : widgetMetadata.useCustomFont
property string valueCustomFont: widgetData.customFont !== undefined ? widgetData.customFont : ""
property string valueCustomFont: widgetData.customFont !== undefined ? widgetData.customFont : widgetMetadata.custonFont
property string valueFormat: widgetData.format !== undefined ? widgetData.format : widgetMetadata.format
// Track the currently focused input field
@@ -97,39 +97,18 @@ ColumnLayout {
valueClockStyle = key;
saveSettings();
}
defaultValue: widgetMetadata.clockStyle
}
NComboBox {
NColorChoice {
label: I18n.tr("common.select-color")
description: I18n.tr("common.select-color-description")
model: [
{
"name": I18n.tr("common.none"),
"key": "none"
},
{
"key": "primary",
"name": I18n.tr("common.primary")
},
{
"key": "secondary",
"name": I18n.tr("common.secondary")
},
{
"key": "tertiary",
"name": I18n.tr("common.tertiary")
},
{
"key": "error",
"name": I18n.tr("common.error")
}
]
currentKey: valueClockColor
onSelected: key => {
valueClockColor = key;
saveSettings();
}
minimumWidth: 200
defaultValue: widgetMetadata.clockColor
}
NToggle {
@@ -141,6 +120,7 @@ ColumnLayout {
valueUseCustomFont = checked;
saveSettings();
}
defaultValue: widgetMetadata.useCustomFont
}
NSearchableComboBox {
@@ -158,6 +138,8 @@ ColumnLayout {
valueCustomFont = key;
saveSettings();
}
enabled: valueClockStyle === "minimal"
defaultValue: Settings.data.ui.fontDefault
}
NDivider {
@@ -203,6 +185,7 @@ ColumnLayout {
});
}
}
defaultValue: widgetMetadata.format
}
}
@@ -290,6 +273,7 @@ ColumnLayout {
valueShowBackground = checked;
saveSettings();
}
defaultValue: widgetMetadata.showBackground
}
NToggle {
@@ -302,5 +286,6 @@ ColumnLayout {
valueRoundedCorners = checked;
saveSettings();
}
defaultValue: widgetMetadata.roundedCorners
}
}
@@ -14,12 +14,12 @@ ColumnLayout {
signal settingsChanged(var settings)
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
property string valueVisualizerType: (widgetData.visualizerType && widgetData.visualizerType !== "") ? widgetData.visualizerType : (widgetMetadata.visualizerType || "linear")
property string valueVisualizerType: widgetData.visualizerType ? widgetData.visualizerType : widgetMetadata.visualizerType
property string valueHideMode: widgetData.hideMode !== undefined ? widgetData.hideMode : widgetMetadata.hideMode
property bool valueShowButtons: widgetData.showButtons !== undefined ? widgetData.showButtons : (widgetMetadata.showButtons !== undefined ? widgetMetadata.showButtons : true)
property bool valueShowAlbumArt: widgetData.showAlbumArt !== undefined ? widgetData.showAlbumArt : (widgetMetadata.showAlbumArt !== undefined ? widgetMetadata.showAlbumArt : true)
property bool valueShowVisualizer: widgetData.showVisualizer !== undefined ? widgetData.showVisualizer : (widgetMetadata.showVisualizer !== undefined ? widgetMetadata.showVisualizer : true)
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : (widgetMetadata.roundedCorners !== undefined ? widgetMetadata.roundedCorners : true)
property bool valueShowButtons: widgetData.showButtons !== undefined ? widgetData.showButtons : widgetMetadata.showButtons
property bool valueShowAlbumArt: widgetData.showAlbumArt !== undefined ? widgetData.showAlbumArt : widgetMetadata.showAlbumArt
property bool valueShowVisualizer: widgetData.showVisualizer !== undefined ? widgetData.showVisualizer : widgetMetadata.showVisualizer
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
function saveSettings() {
var settings = Object.assign({}, widgetData || {});
@@ -42,6 +42,7 @@ ColumnLayout {
valueShowBackground = checked;
saveSettings();
}
defaultValue: widgetMetadata.showBackground
}
NToggle {
@@ -53,6 +54,7 @@ ColumnLayout {
valueRoundedCorners = checked;
saveSettings();
}
defaultValue: widgetMetadata.roundedCorners
}
NToggle {
@@ -64,6 +66,7 @@ ColumnLayout {
valueShowAlbumArt = checked;
saveSettings();
}
defaultValue: widgetMetadata.showAlbumArt
}
NToggle {
@@ -75,6 +78,7 @@ ColumnLayout {
valueShowVisualizer = checked;
saveSettings();
}
defaultValue: widgetMetadata.showVisualizer
}
NToggle {
@@ -86,6 +90,7 @@ ColumnLayout {
valueShowButtons = checked;
saveSettings();
}
defaultValue: widgetMetadata.showButtons
}
NComboBox {
@@ -112,6 +117,7 @@ ColumnLayout {
valueVisualizerType = key;
saveSettings();
}
defaultValue: widgetMetadata.visualizerType
}
NComboBox {
@@ -137,5 +143,6 @@ ColumnLayout {
valueHideMode = key;
saveSettings();
}
defaultValue: widgetMetadata.hideMode
}
}
@@ -18,8 +18,8 @@ ColumnLayout {
property string valueStatType: widgetData.statType !== undefined ? widgetData.statType : widgetMetadata.statType
property string valueDiskPath: widgetData.diskPath !== undefined ? widgetData.diskPath : widgetMetadata.diskPath
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : (widgetMetadata.roundedCorners !== undefined ? widgetMetadata.roundedCorners : true)
property string valueLayout: widgetData.layout !== undefined ? widgetData.layout : (widgetMetadata.layout !== undefined ? widgetMetadata.layout : "side")
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
property string valueLayout: widgetData.layout !== undefined ? widgetData.layout : widgetMetadata.layout
function saveSettings() {
var settings = Object.assign({}, widgetData || {});
@@ -67,6 +67,7 @@ ColumnLayout {
valueStatType = key;
saveSettings();
}
defaultValue: widgetMetadata.statType
}
NComboBox {
@@ -86,6 +87,7 @@ ColumnLayout {
valueDiskPath = key;
saveSettings();
}
defaultValue: widgetMetadata.diskPath
}
NDivider {
@@ -101,6 +103,7 @@ ColumnLayout {
valueShowBackground = checked;
saveSettings();
}
defaultValue: widgetMetadata.showBackground
}
NToggle {
@@ -113,6 +116,7 @@ ColumnLayout {
valueRoundedCorners = checked;
saveSettings();
}
defaultValue: widgetMetadata.roundedCorners
}
NDivider {
@@ -139,5 +143,6 @@ ColumnLayout {
valueLayout = key;
saveSettings();
}
defaultValue: widgetMetadata.layout
}
}
@@ -14,10 +14,12 @@ ColumnLayout {
signal settingsChanged(var settings)
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
function saveSettings() {
var settings = Object.assign({}, widgetData || {});
settings.showBackground = valueShowBackground;
settings.roundedCorners = valueRoundedCorners;
settingsChanged(settings);
}
@@ -30,5 +32,19 @@ ColumnLayout {
valueShowBackground = checked;
saveSettings();
}
defaultValue: widgetMetadata.showBackground
}
NToggle {
Layout.fillWidth: true
visible: valueShowBackground
label: I18n.tr("panels.desktop-widgets.clock-rounded-corners-label")
description: I18n.tr("panels.desktop-widgets.clock-rounded-corners-description")
checked: valueRoundedCorners
onToggled: checked => {
valueRoundedCorners = checked;
saveSettings();
}
defaultValue: widgetMetadata.roundedCorners
}
}
+7 -4
View File
@@ -55,28 +55,31 @@ Singleton {
property var widgetMetadata: ({
"Clock": {
"showBackground": true,
"roundedCorners": true,
"clockStyle": "digital",
"clockColor": "none",
"useCustomFont": false,
"customFont": "",
"format": "HH:mm\\nd MMMM yyyy"
},
"MediaPlayer": {
"showBackground": true,
"roundedCorners": true,
"visualizerType": "linear",
"hideMode": "visible",
"showButtons": true,
"showAlbumArt": true,
"showVisualizer": true,
"roundedCorners": true
"showVisualizer": true
},
"Weather": {
"showBackground": true
"showBackground": true,
"roundedCorners": true
},
"SystemStat": {
"showBackground": true,
"roundedCorners": true,
"statType": "CPU",
"diskPath": "/",
"roundedCorners": true,
"layout": "bottom"
}
})