import QtQuick 2.12 import org.ukui.menu.core 1.0 Rectangle { property bool useStyleTransparent: true property int paletteRole: Palette.Base property int paletteGroup: Palette.Active property int borderColor: Palette.Base property real alpha: 1.0 property real borderAlpha: 1.0 clip: true border.width: 0 function updateColor() { if (useStyleTransparent) { color = themePalette.paletteColorWithTransparency(paletteRole, paletteGroup) } else { color = themePalette.paletteColorWithCustomTransparency(paletteRole, paletteGroup, alpha) } } function updateBorderColor() { border.color = themePalette.paletteColorWithCustomTransparency(borderColor, Palette.Active, borderAlpha) } Component.onCompleted: { updateColor() updateBorderColor() themePalette.styleColorChanged.connect(updateColor) themePalette.styleColorChanged.connect(updateBorderColor) } Component.onDestruction: { themePalette.styleColorChanged.disconnect(updateColor) themePalette.styleColorChanged.disconnect(updateBorderColor) } onUseStyleTransparentChanged: { updateColor() } onPaletteRoleChanged: { updateColor() } onPaletteGroupChanged: { updateColor() } onAlphaChanged: { updateColor() } onBorderAlphaChanged: { updateBorderColor() } onBorderColorChanged: { updateBorderColor() } }