- 修复嵌套Object更新的问题
This commit is contained in:
parent
cdb0b509bf
commit
5b22cd2660
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "top.mashiros.widget.ordinalscale",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
|
||||
"title": {
|
||||
"en": "Ordinal Scale Widget Collections",
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user