2022-12-21 10:22:48 +08:00
|
|
|
import QtQuick 2.0
|
|
|
|
import org.ukui.menu.core 1.0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property bool useStyleTransparent: true
|
|
|
|
property int paletteRole: Palette.Base
|
|
|
|
property int paletteGroup: Palette.Active
|
2023-03-30 16:44:53 +08:00
|
|
|
property int borderColor: Palette.Base
|
2022-12-21 10:22:48 +08:00
|
|
|
property real alpha: 1.0
|
2023-03-30 16:44:53 +08:00
|
|
|
property real borderAlpha: 1.0
|
2022-12-21 10:22:48 +08:00
|
|
|
|
|
|
|
clip: true
|
2023-03-02 13:57:13 +08:00
|
|
|
border.width: 0
|
2022-12-21 10:22:48 +08:00
|
|
|
|
|
|
|
function updateColor() {
|
|
|
|
if (useStyleTransparent) {
|
2023-03-30 16:44:53 +08:00
|
|
|
color = themePalette.paletteColorWithTransparency(paletteRole, paletteGroup)
|
2022-12-21 10:22:48 +08:00
|
|
|
} else {
|
2023-03-30 16:44:53 +08:00
|
|
|
color = themePalette.paletteColorWithCustomTransparency(paletteRole, paletteGroup, alpha)
|
2022-12-21 10:22:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-24 17:47:17 +08:00
|
|
|
function updateBorderColor() {
|
2023-03-30 16:44:53 +08:00
|
|
|
border.color = themePalette.paletteColorWithCustomTransparency(borderColor, Palette.Active, borderAlpha)
|
2023-03-24 17:47:17 +08:00
|
|
|
}
|
|
|
|
|
2022-12-21 10:22:48 +08:00
|
|
|
Component.onCompleted: {
|
|
|
|
updateColor()
|
2023-03-24 17:47:17 +08:00
|
|
|
updateBorderColor()
|
2022-12-21 10:22:48 +08:00
|
|
|
themePalette.styleColorChanged.connect(updateColor)
|
2023-03-24 17:47:17 +08:00
|
|
|
themePalette.styleColorChanged.connect(updateBorderColor)
|
2022-12-21 10:22:48 +08:00
|
|
|
}
|
|
|
|
Component.onDestruction: {
|
|
|
|
themePalette.styleColorChanged.disconnect(updateColor)
|
2023-03-24 17:47:17 +08:00
|
|
|
themePalette.styleColorChanged.disconnect(updateBorderColor)
|
2022-12-21 10:22:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
onUseStyleTransparentChanged: {
|
|
|
|
updateColor()
|
|
|
|
}
|
|
|
|
onPaletteRoleChanged: {
|
|
|
|
updateColor()
|
|
|
|
}
|
|
|
|
onPaletteGroupChanged: {
|
|
|
|
updateColor()
|
|
|
|
}
|
|
|
|
onAlphaChanged: {
|
|
|
|
updateColor()
|
|
|
|
}
|
2023-03-30 16:44:53 +08:00
|
|
|
onBorderAlphaChanged: {
|
|
|
|
updateBorderColor()
|
|
|
|
}
|
|
|
|
onBorderColorChanged: {
|
2023-03-24 17:47:17 +08:00
|
|
|
updateBorderColor()
|
|
|
|
}
|
2022-12-21 10:22:48 +08:00
|
|
|
}
|
|
|
|
|