diff --git a/resources/qml/ColorDialog.qml b/resources/qml/ColorDialog.qml index f163211f53..afb7b324a3 100644 --- a/resources/qml/ColorDialog.qml +++ b/resources/qml/ColorDialog.qml @@ -27,11 +27,15 @@ UM.Dialog "#FFFFFF", "#D3D3D3", "#9E9E9E", "#5A5A5A", "#000000", ] - Component.onCompleted: + Component.onCompleted: updateSwatches() + onSwatchColorsChanged: updateSwatches() + + function updateSwatches() { - for (let i = 0; i < base.swatchColors.length; i ++) + swatchColorsModel.clear(); + for (const swatchColor of base.swatchColors) { - swatchColorsModel.append({ swatchColor: base.swatchColors[i] }); + swatchColorsModel.append({ swatchColor }); } } diff --git a/resources/qml/Preferences/Materials/MaterialsView.qml b/resources/qml/Preferences/Materials/MaterialsView.qml index 6d153f5960..97f0ce4de1 100644 --- a/resources/qml/Preferences/Materials/MaterialsView.qml +++ b/resources/qml/Preferences/Materials/MaterialsView.qml @@ -222,7 +222,22 @@ Item id: colorDialog title: catalog.i18nc("@title", "Material color picker") color: properties.color_code - onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color) +// swatchColors: ["#2161AF", "#57AFB2", "#F7B32D", "#E33D4A", "#C088AD"] + onAccepted: { + base.setMetaDataEntry("color_code", properties.color_code, color); + console.log("color_code"); + + const timer = Qt.createQmlObject("import QtQuick 2.0; Timer {}", base); + timer.interval = 10000; + timer.repeat = true; + timer.triggered.connect(function () { + console.log("updating colors"); + colorDialog.swatchColors = ["#2161AF", "#57AFB2", "#F7B32D", "#E33D4A", "#C088AD"]; + }) + + console.log("starting timers"); + timer.start(); + } } }