diff --git a/package.json b/package.json index a49e9e5..efb0dc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "top.mashiros.widget.ordinalscale", - "version": "1.1.1", + "version": "1.1.2", "title": { "en": "Ordinal Scale Widget Collections", diff --git a/qml/BottomUI.qml b/qml/BottomUI.qml index 5931e40..4c69ca1 100644 --- a/qml/BottomUI.qml +++ b/qml/BottomUI.qml @@ -40,10 +40,6 @@ WidgetTemplate { readonly property real w: widget.width readonly property real r: (w**2+4*h**2)/2/h - onUpdated: { - widget.settings.styles = Object.assign(defaultValues, widget.settings.styles); - } - onConfigsChanged: { line.requestPaint(); triangle.requestPaint(); @@ -127,7 +123,7 @@ WidgetTemplate { anchors.fill: parent header: TitleBar { - text: qsTr("UI Settings") + text: qsTr("Ordinal Scale Bottom UI widget") standardButtons: Dialog.Save | Dialog.Reset diff --git a/qml/TopUI.qml b/qml/TopUI.qml index 2e68046..7053ead 100644 --- a/qml/TopUI.qml +++ b/qml/TopUI.qml @@ -30,10 +30,6 @@ WidgetTemplate { "Text Vertical Offset": 16 } - onUpdated: { - widget.settings.styles = Object.assign(defaultValues, widget.settings.styles); - } - onConfigsChanged: { line.requestPaint(); c0.requestPaint(); @@ -373,7 +369,7 @@ WidgetTemplate { anchors.fill: parent header: TitleBar { - text: qsTr("UI Settings") + text: qsTr("Ordinal Scale Top UI widget") standardButtons: Dialog.Save | Dialog.Reset diff --git a/qml/WeatherWidget.qml b/qml/WeatherWidget.qml index 901674b..5a81e75 100644 --- a/qml/WeatherWidget.qml +++ b/qml/WeatherWidget.qml @@ -52,10 +52,6 @@ WidgetTemplate { } } - onUpdated: { - widget.settings.styles = Object.assign(defaultValues, widget.settings.styles); - } - readonly property var configs: widget.settings.styles readonly property real w: widget.width readonly property real h: 0.46*widget.width @@ -245,7 +241,7 @@ WidgetTemplate { anchors.fill: parent header: TitleBar { - text: qsTr("Settings") + text: qsTr("Ordinal Scale Weather Widget") standardButtons: Dialog.Save | Dialog.Reset diff --git a/qml/WidgetTemplate.qml b/qml/WidgetTemplate.qml index 290b286..8fb82a0 100644 --- a/qml/WidgetTemplate.qml +++ b/qml/WidgetTemplate.qml @@ -14,6 +14,23 @@ T.Widget { signal completed() signal updated() + function updateObject(targetObj, sourceObj) { + for (let prop in sourceObj) { + if (sourceObj.hasOwnProperty(prop) && sourceObj[prop] !== undefined) { + if (typeof sourceObj[prop] === 'object') { + Object.assign(targetObj[prop], sourceObj[prop]); + } else { + targetObj[prop] = sourceObj[prop]; + } + } + } + return targetObj; + } + + onUpdated: { + widget.settings.styles = updateObject(JSON.parse(JSON.stringify(defaultValues)), widget.settings.styles); + } + Component.onCompleted: { if (!widget.settings.styles) { widget.settings.styles = defaultValues;