diff --git a/package/contents/config/config.qml b/package/contents/config/config.qml index 0288da2..ecd2728 100644 --- a/package/contents/config/config.qml +++ b/package/contents/config/config.qml @@ -21,12 +21,6 @@ ConfigModel { source: "configNewTray.qml" } - ConfigCategory { - name: i18n("Test") - icon: "preferences" - source: "colorCompTest.qml" - } - ConfigCategory { name: i18n("General") icon: "preferences" diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index 6e0488a..e050d0e 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -487,7 +487,7 @@ - {"panel":{"blurBehind":true,"backgroundColor":{"lightnessValue":0.1,"saturationValue":0.05,"alpha":1,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#013eff","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"foregroundColor":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#fc0000","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":0,"enabled":false},"radius":{"topLeft":8,"topRight":8,"bottomRight":8,"bottomLeft":8},"margins":{"right":4,"left":4,"top":4,"bottom":4},"border":{"customSides":false,"custom":{"widths":{"left":0,"bottom":2,"right":3,"top":2},"margins":[],"radius":0},"width":1,"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.2,"systemColor":"highlightColor","systemColorSet":"View","type":0,"custom":"#ff6c06","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.15,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"size":8,"xOffset":0,"yOffset":0},"enabled":true},"widgets":{"blurBehind":false,"backgroundColor":{"lightnessValue":0.2,"saturationValue":0.6,"alpha":1,"type":0,"custom":"#00004b","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColorSet":"View","systemColor":"backgroundColor","enabled":true},"foregroundColor":{"lightnessValue":0.85,"saturationValue":0.75,"alpha":1,"systemColor":"highlightColor","systemColorSet":"Header","type":0,"custom":"#ff9a00","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"radius":{"topLeft":8,"topRight":8,"bottomRight":8,"bottomLeft":8},"margins":{"right":0,"left":0,"top":4,"bottom":4},"border":{"customSides":false,"custom":{"widths":{"left":0,"bottom":3,"right":0,"top":0},"margins":[],"radius":0},"width":0,"color":{"lightnessValue":0.35,"saturationValue":0.05,"alpha":1,"systemColorSet":"View","type":0,"custom":"#eeff71","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColor":"backgroundColor","enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColor":"backgroundColor","enabled":true},"size":5,"xOffset":0,"yOffset":0},"enabled":true},"trayWidgets":{"blurBehind":false,"backgroundColor":{"lightnessValue":0.1,"saturationValue":0.75,"alpha":1,"systemColor":"highlightColor","systemColorSet":"Window","type":0,"custom":"#0023f8","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"foregroundColor":{"lightnessValue":0.2,"saturationValue":0.7,"alpha":1,"systemColor":"highlightColor","systemColorSet":"View","type":0,"custom":"#feff76","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"radius":{"topLeft":5,"topRight":5,"bottomRight":5,"bottomLeft":5},"margins":{"right":2,"left":2,"top":4,"bottom":4},"border":{"customSides":true,"custom":{"widths":{"left":0,"bottom":2,"right":0,"top":0},"margins":[],"radius":0},"width":0,"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.4,"systemColor":"backgroundColor","systemColorSet":"Window","type":0,"custom":"#04ff0c","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColor":"textColor","systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":0,"enabled":true},"size":5,"xOffset":0,"yOffset":0},"enabled":true},"nativePanelBackground":{"enabled":true,"opacity":1}} + {"panel":{"blurBehind":true,"backgroundColor":{"lightnessValue":0.1,"saturationValue":0.05,"alpha":1,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#013eff","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"foregroundColor":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#fc0000","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":0,"enabled":false},"radius":{"topLeft":8,"topRight":8,"bottomRight":8,"bottomLeft":8},"margins":{"right":4,"left":4,"top":4,"bottom":4},"border":{"customSides":false,"custom":{"widths":{"left":0,"bottom":2,"right":3,"top":2},"margins":[],"radius":0},"width":1,"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.2,"systemColor":"highlightColor","systemColorSet":"View","type":0,"custom":"#ff6c06","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.15,"systemColor":"backgroundColor","systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"size":8,"xOffset":0,"yOffset":0},"enabled":true},"widgets":{"blurBehind":false,"backgroundColor":{"lightnessValue":0.2,"saturationValue":0.6,"alpha":1,"type":0,"custom":"#00004b","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColorSet":"View","systemColor":"backgroundColor","enabled":true},"foregroundColor":{"lightnessValue":0.85,"saturationValue":0.75,"alpha":1,"systemColor":"highlightColor","systemColorSet":"Header","type":0,"custom":"#ff9a00","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"radius":{"topLeft":8,"topRight":8,"bottomRight":8,"bottomLeft":8},"margins":{"right":0,"left":0,"top":4,"bottom":4},"border":{"customSides":false,"custom":{"widths":{"left":0,"bottom":3,"right":0,"top":0},"margins":[],"radius":0},"width":0,"color":{"lightnessValue":0.35,"saturationValue":0.05,"alpha":1,"systemColorSet":"View","type":0,"custom":"#eeff71","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColor":"backgroundColor","enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"systemColor":"backgroundColor","enabled":true},"size":5,"xOffset":0,"yOffset":0},"enabled":true},"trayWidgets":{"blurBehind":false,"backgroundColor":{"lightnessValue":0.1,"saturationValue":0.75,"alpha":1,"systemColor":"highlightColor","systemColorSet":"Window","type":0,"custom":"#0023f8","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"foregroundColor":{"lightnessValue":0.2,"saturationValue":0.7,"alpha":1,"systemColor":"highlightColor","systemColorSet":"View","type":0,"custom":"#feff76","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":true,"lightnessEnabled":true,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true},"radius":{"topLeft":5,"topRight":5,"bottomRight":5,"bottomLeft":5},"margins":{"right":2,"left":2,"top":4,"bottom":4},"border":{"customSides":true,"custom":{"widths":{"left":0,"bottom":2,"right":0,"top":0},"margins":[],"radius":0},"width":0,"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":0.4,"systemColor":"backgroundColor","systemColorSet":"Window","type":0,"custom":"#04ff0c","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":1,"enabled":true}},"shadow":{"color":{"lightnessValue":0.05,"saturationValue":0.05,"alpha":1,"systemColor":"textColor","systemColorSet":"View","type":0,"custom":"#282828","list":["#ED8796","#A6DA95","#EED49F","#8AADF4","#F5BDE6","#8BD5CA","#f5a97f"],"followColor":0,"saturationEnabled":false,"lightnessEnabled":false,"animation":{"enabled":false,"interval":3000,"smoothing":800},"sourceType":0,"enabled":true},"size":5,"xOffset":0,"yOffset":0},"enabled":true},"nativePanelBackground":{"enabled":true,"opacity":1}, "forceForegroundColor":{}} diff --git a/package/contents/ui/code/utils.js b/package/contents/ui/code/utils.js index a4c472a..f224d5f 100644 --- a/package/contents/ui/code/utils.js +++ b/package/contents/ui/code/utils.js @@ -19,6 +19,19 @@ function isBgManaged(item) { return managed } +function isEffectManaged(item) { + let managed = false + if (item?.children) { + for (let i in item.children) { + const child = item.children[i]; + if (!child?.luisbocanegraPanelColorizerEffectManaged) continue + managed = true + } + } + // console.error(item, "managed:", managed); + return managed +} + function findTrayGridView(item) { if (!item?.children) return null if (item instanceof GridView) { diff --git a/package/contents/ui/components/FormWidgetSettings.qml b/package/contents/ui/components/FormWidgetSettings.qml index dd75064..a570ae5 100644 --- a/package/contents/ui/components/FormWidgetSettings.qml +++ b/package/contents/ui/components/FormWidgetSettings.qml @@ -79,7 +79,6 @@ ColumnLayout { onCheckedChanged: { configLocal.blurBehind = checked if (checked) { - nativePanelBackgroundCheckbox.checked = true } updateConfig() } diff --git a/package/contents/ui/components/WidgetCardCheck.qml b/package/contents/ui/components/WidgetCardCheck.qml new file mode 100644 index 0000000..c792e41 --- /dev/null +++ b/package/contents/ui/components/WidgetCardCheck.qml @@ -0,0 +1,51 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import org.kde.kirigami as Kirigami + +Kirigami.AbstractCard { + id: root + property var widget + signal updateWidget(mask: bool, effect: bool) + checked: maskCheckbox.checked || effectCheckbox.checked + + contentItem: RowLayout { + Kirigami.Icon { + width: Kirigami.Units.gridUnit + height: width + source: widget.icon + } + ColumnLayout { + Label { + text: widget.title + } + Label { + text: widget.name + opacity: 0.6 + } + } + Item { + Layout.fillWidth: true + } + Button { + id: maskCheckbox + text: i18n("Mask") + checkable: true + checked: widget.method.mask ?? false + icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" + onCheckedChanged: { + updateWidget(maskCheckbox.checked, effectCheckbox.checked) + } + } + Button { + id: effectCheckbox + text: i18n("Effect") + checkable: true + checked: widget.method.multiEffect ?? false + icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic" + onCheckedChanged: { + updateWidget(maskCheckbox.checked, effectCheckbox.checked) + } + } + } +} diff --git a/package/contents/ui/configForeground.qml b/package/contents/ui/configForeground.qml index 27ba6dd..f94e573 100644 --- a/package/contents/ui/configForeground.qml +++ b/package/contents/ui/configForeground.qml @@ -5,81 +5,39 @@ import org.kde.kcmutils as KCM import org.kde.kirigami as Kirigami import org.kde.plasma.plasmoid import "components" as Components +import "code/utils.js" as Utils KCM.SimpleKCM { id:root property bool cfg_isEnabled - property bool cfg_fgColorEnabled: fgColorEnabled.checked - property int cfg_fgMode: plasmoid.configuration.fgMode - property int cfg_fgColorMode: plasmoid.configuration.fgColorMode - property alias cfg_fgColorModeTheme: fgColorModeTheme.currentIndex - property alias cfg_fgColorModeThemeVariant: fgColorModeThemeVariant.currentIndex - property string cfg_fgSingleColor: fgSingleColor.color - property string cfg_fgCustomColors: fgCustomColors.text - - property int cfg_fgRainbowInterval: fgRainbowInterval.value - property bool widgetBgEnabled: plasmoid.configuration.widgetBgEnabled - - property real cfg_fgOpacity: parseFloat(fgOpacity.text) - property string cfg_forceRecolor: "" - - property bool cfg_fgContrastFixEnabled: fgContrastFixEnabled.checked - property bool cfg_fgSaturationEnabled: fgSaturationEnabled.checked - property real cfg_fgSaturation: fgSaturation.text - property real cfg_fgLightness: fgLightness.text - property string cfg_panelWidgets - property bool clearing: false + property string cfg_allSettings + property var config: JSON.parse(cfg_allSettings) + property var forceFgConfig + property bool loaded: false - property bool cfg_fgShadowEnabled: fgShadowEnabled.checked - property string cfg_fgShadowColor: fgShadowColor.color - property int cfg_fgShadowX: fgShadowX.value - property int cfg_fgShadowY: fgShadowY.value - property int cfg_fgShadowRadius: fgShadowRadius.value - property bool cfg_fixCustomBadges: fixCustomBadgesCheckbox.checked - - ListModel { - id: fgCustomColorsModel - } - - Connections { - target: fgCustomColorsModel - onCountChanged: { - if (clearing) return - console.log("model count changed:", fgCustomColorsModel.count); - updateString() - } - } - - function initModel() { - clearing = true - fgCustomColorsModel.clear() - const colors = cfg_fgCustomColors.split(" ") - for (let i in colors) { - fgCustomColorsModel.append({"color": colors[i]}) - } - clearing = false - } - - function getRandomColor() { - const h = Math.random() - const s = Math.random() - const l = Math.random() - const a = 1.0 - console.log(h,s,l); - return Qt.hsla(h,s,l,a) + Component.onCompleted: { + forceFgConfig = config.forceForegroundColor + console.error(JSON.stringify(forceFgConfig, null, null)) + initWidgets() + updateWidgetsModel() } - function updateString() { - console.log("updateString()"); - let colors_list = [] - for (let i = 0; i < fgCustomColorsModel.count; i++) { - let c = fgCustomColorsModel.get(i).color - console.log(c); - colors_list.push(c) + function updateConfig() { + for (let i = 0; i < widgetsModel.count; i++) { + const widget = widgetsModel.get(i) + const name = widget.name + const method = widget.method + console.error(name, method.mask, method.multiEffect) + if (method.mask || method.multiEffect) { + forceFgConfig[name] = {"method": widget.method} + } else { + delete forceFgConfig[widget.name] + } } - cfg_fgCustomColors = colors_list.join(" ") + config.forceForegroundColor = forceFgConfig + cfg_allSettings = JSON.stringify(config, null, null) } ListModel { @@ -93,43 +51,20 @@ KCM.SimpleKCM { const name = widget.name const title = widget.title const icon = widget.icon - widgetsModel.append({"name": name, "title": title, "icon": icon, "enabled": false}) + widgetsModel.append({ "name": name, "title": title, "icon": icon, "method": { "mask":false, "multiEffect": false }} ) } } function updateWidgetsModel(){ - let widgeList = [] - const forceRecolorList = cfg_forceRecolor.trim().split("|") - console.log(forceRecolorList.join(" ")); - for (let i = 0; i < widgetsModel.count; i++) { - let widget = widgetsModel.get(i) - if (forceRecolorList.includes(widget.name)) { - widgetsModel.set(i, {"enabled": true}) - } - } - } - - function updateWidgetsString(){ - console.log("UPDATING STRING"); - console.log("current:", cfg_forceRecolor); - var currentWidgets = new Set(cfg_forceRecolor.trim().split("|")) - for (let i = 0; i < widgetsModel.count; i++) { const widget = widgetsModel.get(i) - if (widget.enabled) { - currentWidgets.add(widget.name) - } else { - currentWidgets.delete(widget.name) + const name = widget.name + if (name in forceFgConfig) { + let cfg = forceFgConfig[name] + widgetsModel.set(i, {"method": cfg.method}) } } - cfg_forceRecolor = Array.from(currentWidgets).join("|") - console.log("new:", cfg_forceRecolor) - } - - Component.onCompleted: { - initModel() - initWidgets() - updateWidgetsModel() + loaded = true } header: RowLayout { @@ -143,8 +78,6 @@ KCM.SimpleKCM { } CheckBox { id: fgColorEnabled - checked: cfg_fgColorEnabled - onCheckedChanged: cfg_fgColorEnabled = checked } } Item { @@ -156,7 +89,7 @@ KCM.SimpleKCM { text: i18n("Last preset loaded:") } Label { - text: plasmoid.configuration.lastPreset || "None" + text: "None" font.weight: Font.DemiBold } } @@ -165,556 +98,48 @@ KCM.SimpleKCM { ColumnLayout { Kirigami.FormLayout { - enabled: cfg_fgColorEnabled - visible: cfg_isEnabled - Kirigami.Separator { - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Color mode") - } - - RadioButton { - text: i18n("Static") - id: staticColorMode - ButtonGroup.group: animationModeGroup - property int index: 0 - checked: plasmoid.configuration.fgMode === index - } - RadioButton { - text: i18n("Interval") - id: animatedColorMode - ButtonGroup.group: animationModeGroup - property int index: 1 - checked: plasmoid.configuration.fgMode === index - } - - ButtonGroup { - id: animationModeGroup - onCheckedButtonChanged: { - if (checkedButton) { - cfg_fgMode = checkedButton.index - - // ensure valid option is checked as single and accent are - // disabled in animated mode - if (animatedColorMode.checked && cfg_fgMode <= 1) { - listColorRadio.checked = true - } - } - } - } - - - SpinBox { - Kirigami.FormData.label: i18n("Interval (ms):") - id: fgRainbowInterval - from: 0 - to: 30000 - stepSize: 100 - value: cfg_fgRainbowInterval - onValueModified: { - cfg_fgRainbowInterval = value - } - enabled: animatedColorMode.checked - } - - Kirigami.Separator { - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Colors") - } - - // RowLayout { - RadioButton { - id: fgSingleColorRadio - Kirigami.FormData.label: i18n("Source:") - text: i18n("Custom") - ButtonGroup.group: colorModeGroup - property int index: 0 - checked: plasmoid.configuration.fgColorMode === index - enabled: !animatedColorMode.checked - } - // } - // RowLayout { - RadioButton { - text: i18n("System") - id: accentColorRadio - ButtonGroup.group: colorModeGroup - property int index: 1 - checked: plasmoid.configuration.fgColorMode === index - enabled: !animatedColorMode.checked - } + // enabled: cfg_fgColorEnabled + // visible: cfg_isEnabled + + // CheckBox { + // Kirigami.FormData.label: i18n("Fix custom badges:") + // id: fixCustomBadgesCheckbox + // checked: cfg_fixCustomBadges + // onCheckedChanged: cfg_fixCustomBadges = checked // } - RadioButton { - id: followBgColorRadio - ButtonGroup.group: colorModeGroup - property int index: 4 - checked: plasmoid.configuration.fgColorMode === index - enabled: !animatedColorMode.checked && widgetBgEnabled - text: !widgetBgEnabled ? i18n("Widget background is disabled") : i18n("Widget background") - } - RadioButton { - id: listColorRadio - text: i18n("Custom list") - ButtonGroup.group: colorModeGroup - property int index: 2 - checked: plasmoid.configuration.fgColorMode === index - // visible: !staticColorMode.checked - } - RadioButton { - id: randomColorRadio - text: i18n("Random") - ButtonGroup.group: colorModeGroup - property int index: 3 - checked: plasmoid.configuration.fgColorMode === index - // visible: !staticColorMode.checked - } - - ButtonGroup { - id: colorModeGroup - onCheckedButtonChanged: { - if (checkedButton) { - cfg_fgColorMode = checkedButton.index - } - } - } - - Components.ColorButton { - id: fgSingleColor - showAlphaChannel: false - dialogTitle: i18n("Text/icons") - color: cfg_fgSingleColor - visible: fgSingleColorRadio.checked - onAccepted: { - cfg_fgSingleColor = color - } - } - - ComboBox { - id: fgColorModeTheme - Kirigami.FormData.label: i18n("Color:") - model: [ - i18n("Text"), - i18n("Disabled Text"), - i18n("Highlighted Text"), - i18n("Active Text"), - i18n("Link"), - i18n("Visited Link"), - i18n("Negative Text"), - i18n("Neutral Text"), - i18n("Positive Text"), - i18n("Background"), - i18n("Highlight"), - i18n("Active Background"), - i18n("Link Background"), - i18n("Visited Link Background"), - i18n("Negative Background"), - i18n("Neutral Background"), - i18n("Positive Background"), - i18n("Alternate Background"), - i18n("Focus"), - i18n("Hover") - ] - visible: accentColorRadio.checked - } - - ComboBox { - id: fgColorModeThemeVariant - Kirigami.FormData.label: i18n("Color set:") - model: [i18n("View"), i18n("Window"), i18n("Button"), i18n("Selection"), i18n("Tooltip"), i18n("Complementary"), i18n("Header")] - visible: accentColorRadio.checked - } - - GroupBox { - visible: listColorRadio.checked - ColumnLayout { - Layout.alignment: Qt.AlignTop - Repeater { - id: fgCustomColorsRepeater - model: fgCustomColorsModel - delegate : RowLayout { - TextMetrics { - id: metrics - text: (model.length + 1).toString() - } - - Label { - text: (index + 1).toString() + "." - Layout.preferredWidth: metrics.width - } - - TextMetrics { - id: colorMetrics - text: "#FFFFFF" - } - - TextArea { - text: modelData - font.capitalization: Font.AllUppercase - Kirigami.SpellCheck.enabled: false - Layout.preferredWidth: colorMetrics.width * 1.4 - } - - Components.ColorButton { - showAlphaChannel: false - dialogTitle: i18n("Widget background") + "("+index+")" - color: modelData - showCurentColor: false - onAccepted: (color) => { - fgCustomColorsModel.set(index, {"color": color.toString()}) - updateString() - } - } - - Button { - icon.name: "randomize-symbolic" - onClicked: { - fgCustomColorsModel.set(index, {"color": getRandomColor().toString() }) - updateString() - } - } - - Button { - // text: "up" - icon.name: "arrow-up" - enabled: index>0 - onClicked: { - let prevIndex = index-1 - let prev = fgCustomColorsModel.get(prevIndex).color - fgCustomColorsModel.set(prevIndex, fgCustomColorsModel.get(index)) - fgCustomColorsModel.set(index, {"color":prev}) - updateString() - } - } - - Button { - icon.name: "arrow-down" - // anchors.right: parent.right - enabled: index < fgCustomColorsModel.count - 1 - onClicked: { - let nextIndex = index+1 - let next = fgCustomColorsModel.get(nextIndex).color - fgCustomColorsModel.set(nextIndex, fgCustomColorsModel.get(index)) - fgCustomColorsModel.set(index, {"color":next}) - updateString() - } - } - - Button { - // text: "Remove" - icon.name: "edit-delete-remove" - // anchors.right: parent.right - onClicked: { - fgCustomColorsModel.remove(index) - } - } - - Button { - icon.name: "list-add-symbolic" - onClicked: { - fgCustomColorsModel.insert(index+1, {"color": getRandomColor().toString() }) - } - } - } - } - - RowLayout { - TextArea { - id: fgCustomColors - text: cfg_fgCustomColors - onTextChanged: { - cfg_fgCustomColors = text - } - Layout.preferredWidth: 300 - wrapMode: TextEdit.WordWrap - font.capitalization: Font.AllUppercase - Kirigami.SpellCheck.enabled: false - } - Button { - id: btn - icon.name: "view-refresh-symbolic" - onClicked: initModel() - } - } - } - } - - RowLayout { - Kirigami.FormData.label: i18n("Opacity:") - TextField { - id: fgOpacity - placeholderText: "0-1" - text: parseFloat(cfg_fgOpacity).toFixed(validator.decimals) - Layout.preferredWidth: Kirigami.Units.gridUnit * 4 - - validator: DoubleValidator { - bottom: 0.0 - top: 1.0 - decimals: 2 - notation: DoubleValidator.StandardNotation - } - - onTextChanged: { - const newVal = parseFloat(text) - cfg_fgOpacity = isNaN(newVal) ? 0 : newVal - } - - Components.ValueMouseControl { - height: parent.height - 8 - width: height - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.verticalCenter: parent.verticalCenter - - from: parent.validator.bottom - to: parent.validator.top - decimals: parent.validator.decimals - stepSize: 0.05 - value: cfg_fgOpacity - onValueChanged: { - cfg_fgOpacity = parseFloat(value) - } - } - } - } - - CheckBox { - Kirigami.FormData.label: i18n("Contrast correction:") - id: fgContrastFixEnabled - checked: cfg_fgContrastFixEnabled - onCheckedChanged: cfg_fgContrastFixEnabled = checked - // visible: !randomColorRadio.checked - } - - CheckBox { - Kirigami.FormData.label: i18n("Saturation:") - text: i18n("Enable") - id: fgSaturationEnabled - checked: cfg_fgSaturationEnabled - onCheckedChanged: cfg_fgSaturationEnabled = checked - enabled: fgContrastFixEnabled.checked - } - - RowLayout { - Kirigami.FormData.label: i18n("Saturation:") - TextField { - id: fgSaturation - placeholderText: "0-1" - text: parseFloat(cfg_fgSaturation).toFixed(validator.decimals) - enabled: fgContrastFixEnabled.checked && fgSaturationEnabled.checked - Layout.preferredWidth: Kirigami.Units.gridUnit * 4 - - validator: DoubleValidator { - bottom: 0.0 - top: 1.0 - decimals: 2 - notation: DoubleValidator.StandardNotation - } - - onTextChanged: { - const newVal = parseFloat(text) - cfg_fgSaturation = isNaN(newVal) ? 0 : newVal - } - - Components.ValueMouseControl { - height: parent.height - 8 - width: height - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.verticalCenter: parent.verticalCenter - - from: parent.validator.bottom - to: parent.validator.top - decimals: parent.validator.decimals - stepSize: 0.05 - value: cfg_fgSaturation - onValueChanged: { - cfg_fgSaturation = parseFloat(value) - } - } - } - } - RowLayout { - Kirigami.FormData.label: i18n("Lightness:") - TextField { - id: fgLightness - placeholderText: "0-1" - text: parseFloat(cfg_fgLightness).toFixed(validator.decimals) - enabled: fgContrastFixEnabled.checked - Layout.preferredWidth: Kirigami.Units.gridUnit * 4 - - validator: DoubleValidator { - bottom: 0.0 - top: 1.0 - decimals: 2 - notation: DoubleValidator.StandardNotation - } - - onTextChanged: { - const newVal = parseFloat(text) - cfg_fgLightness = isNaN(newVal) ? 0 : newVal - } - - Components.ValueMouseControl { - height: parent.height - 8 - width: height - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.verticalCenter: parent.verticalCenter - - from: parent.validator.bottom - to: parent.validator.top - decimals: parent.validator.decimals - stepSize: 0.05 - value: cfg_fgLightness - onValueChanged: { - cfg_fgLightness = parseFloat(value) - } - } - } - } - - Kirigami.Separator { - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Shadow") - } - - CheckBox { - Kirigami.FormData.label: i18n("Enabled:") - id: fgShadowEnabled - checked: cfg_fgShadowEnabled - onCheckedChanged: cfg_fgShadowEnabled = checked - enabled: fgColorEnabled.checked - } - - - Components.ColorButton { - id: fgShadowColor - Kirigami.FormData.label: i18n("Color:") - showAlphaChannel: true - dialogTitle: i18n("Panel shadow") - color: cfg_fgShadowColor - enabled: fgColorEnabled.checked && fgShadowEnabled.checked - onAccepted: { - cfg_fgShadowColor = color - } - } - - SpinBox { - Kirigami.FormData.label: i18n("Strength:") - id: fgShadowRadius - value: cfg_fgShadowRadius - from: 0 - to: 99 - enabled: fgColorEnabled.checked && fgShadowEnabled.checked - onValueModified: { - cfg_fgShadowRadius = value - } - } - - SpinBox { - Kirigami.FormData.label: i18n("X offset:") - id: fgShadowX - value: cfg_fgShadowX - from: -99 - to: 99 - enabled: fgColorEnabled.checked && fgShadowEnabled.checked - onValueModified: { - cfg_fgShadowX = value - } - } - - SpinBox { - Kirigami.FormData.label: i18n("Y offset:") - id: fgShadowY - value: cfg_fgShadowY - from: -99 - to: 99 - enabled: fgColorEnabled.checked && fgShadowEnabled.checked - onValueModified: { - cfg_fgShadowY = value - } - } - - Kirigami.Separator { - Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Custom badges") - } - - CheckBox { - Kirigami.FormData.label: i18n("Fix custom badges:") - id: fixCustomBadgesCheckbox - checked: cfg_fixCustomBadges - onCheckedChanged: cfg_fixCustomBadges = checked - } - - Label { - text: i18n("Fix unreadable custom badges (e.g. counters) drawn by some widgets.") - opacity: 0.7 - Layout.maximumWidth: 400 - wrapMode: Text.Wrap - } + // Label { + // text: i18n("Fix unreadable custom badges (e.g. counters) drawn by some widgets.") + // opacity: 0.7 + // Layout.maximumWidth: 400 + // wrapMode: Text.Wrap + // } Kirigami.Separator { Kirigami.FormData.isSection: true - Kirigami.FormData.label: i18n("Force icon color") + Kirigami.FormData.label: i18n("Force Text/Icon color") } Label { - text: i18n("Force icon color to specific widgets. To restore the original color disable and restart Plasma or logout") + text: i18n("Mask: Force Icon colorization.
Effect: Force Icons/Text colorization using post-processing effect.
To restore the original color disable and restart Plasma or logout.") opacity: 0.7 - Layout.maximumWidth: 400 + Layout.maximumWidth: widgetCards.width wrapMode: Text.Wrap } - RowLayout { - Layout.preferredWidth: widgetCards.width - Layout.minimumWidth: 100 - Button { - text: i18n("Restore default rules") - icon.name: "kt-restore-defaults-symbolic" - onClicked: { - cfg_forceRecolor = plasmoid.configuration.forceRecolorDefault - initWidgets() - updateWidgetsModel() - } - Layout.fillWidth: true - } - KCM.ContextualHelpButton { - toolTipText: "From version 0.5.0 partial widget names e.g. weather are no longer allowed.

If forced icon colors are not applied properly you can use this option to restore the default which has the correct format" - } - } - ColumnLayout { id: widgetCards Repeater { model: widgetsModel - delegate: Kirigami.AbstractCard { - contentItem: RowLayout { - Kirigami.Icon { - width: Kirigami.Units.gridUnit - height: width - source: model.icon - } - ColumnLayout { - Label { - text: model.title - } - Label { - text: model.name - opacity: 0.6 - } - } - Item { - Layout.fillWidth: true - } - Button { - checkable: true - checked: model.enabled - icon.name: checked ? "checkmark-symbolic" : "edit-delete-remove-symbolic" - onCheckedChanged: { - widgetsModel.set(index, {"enabled": checked}) - updateWidgetsString() - } - } + delegate: Components.WidgetCardCheck { + widget: model + onUpdateWidget: (maskEnabled, effectEnabled) => { + if (!loaded) return + widgetsModel.set(index, + { + "method":{ "mask": maskEnabled, "multiEffect": effectEnabled} + }) + root.updateConfig() } } } diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 4dba722..e5d58f8 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -42,6 +42,14 @@ PlasmoidItem { property var widgetSettings: cfg.widgets property var panelSettings: cfg.panel property var trayWidgetSettings: cfg.trayWidgets + property var forceRecolorList: cfg.forceForegroundColor + property int forceRecolorCount: Object.keys(forceRecolorList).length + signal recolorNeeded() + + onForceRecolorCountChanged: { + console.error("onForceRecolorCountChanged ->", forceRecolorCount) + recolorNeeded() + } function getColor(colorCfg) { let newColor = "transparent" @@ -76,11 +84,15 @@ PlasmoidItem { return newColor } - function applyFgColor(element, newColor, fgColorCfg, depth) { + function applyFgColor(element, newColor, fgColorCfg, depth, forceMask, forceEffect) { let count = 0; let maxDepth = depth - if (Utils.getWidgetName(element) === "org.kde.plasma.systemtray" && separateTray) return - + let widgetName = Utils.getWidgetName(element) + if (widgetName === "org.kde.plasma.systemtray" && separateTray) return + if (widgetName && widgetName in forceRecolorList) { + forceMask = forceRecolorList[widgetName].method.mask + forceEffect = forceRecolorList[widgetName].method.multiEffect + } for (var i = 0; i < element.visibleChildren.length; i++) { var child = element.visibleChildren[i] if (child.Kirigami?.Theme) { @@ -92,11 +104,17 @@ PlasmoidItem { if (child.color) { child.color = newColor } + if (child.hasOwnProperty("isMask") && forceMask) { + child.isMask = true + } + if (forceEffect && !Utils.isEffectManaged(child)) { + colorEffectComoponent.createObject(child, {"target": child, "effectColor": newColor, "effectSource": child}) + } count++ - repaintDebugComponent.createObject(child) + // repaintDebugComponent.createObject(child) } if (child.visibleChildren?.length ?? 0 > 0) { - const result = applyFgColor(child, newColor, fgColorCfg, depth + 1) + const result = applyFgColor(child, newColor, fgColorCfg, depth + 1, forceMask, forceEffect) count += result.count if (result.depth > maxDepth) { maxDepth = result.depth @@ -116,7 +134,7 @@ PlasmoidItem { anchors.left: parent.left Timer { id: deleteThisTimer - interval: 500 + interval: 100 onTriggered: { speedDebugItem.destroy() } @@ -126,11 +144,30 @@ PlasmoidItem { } } + property Component colorEffectComoponent: MultiEffect { + // a not very effective way to recolor things that can't be recolored + // the usual way + id: effectRect + property bool luisbocanegraPanelColorizerEffectManaged: true + property string effectColor + property Item target + property Item effectSource + height: effectSource.height + width: effectSource.width + colorizationColor: effectColor + source: effectSource + colorization: 1 + autoPaddingEnabled: false + } + property Component backgroundComponent: Kirigami.ShadowedRectangle { id: rect property Item target property int itemType property bool luisbocanegraPanelColorizerBgManaged: true + // mask and color effect do + property bool requiresRefresh: false + property string widgetName: Utils.getWidgetName(target) property var cfg: { return Utils.getItemCfg(itemType, null) //TODO widget name here } @@ -169,9 +206,10 @@ PlasmoidItem { Timer { id: recolorTimer interval: 250 + repeat: requiresRefresh onTriggered: { if (!(rect.itemType === Enums.ItemType.PanelBgItem)) { - const result = applyFgColor(target, fgColor, fgColorCfg, 0) + const result = applyFgColor(target, fgColor, fgColorCfg, 0, false, false) if (result) { itemCount = result.count maxDepth = result.depth @@ -200,10 +238,17 @@ PlasmoidItem { // console.error("FG COLOR CHANGED", fgColor, target) recolorTimer.start() } - + function recolor() { + recolorTimer.start() + } Component.onCompleted: { + main.recolorNeeded.connect(rect.recolor) recolorTimer.start() + if (widgetName && widgetName in forceRecolorList) { + requiresRefresh = true + } } + height: itemType === Enums.ItemType.TrayItem ? target.height : parent.height width: itemType === Enums.ItemType.TrayItem ? target.width : parent.width anchors.centerIn: (itemType === Enums.ItemType.TrayItem || itemType === Enums.ItemType.TrayArrow) ? parent : undefined @@ -557,6 +602,7 @@ PlasmoidItem { onPanelLayoutCountChanged: { if (panelLayoutCount === 0) return + trayInitTimer.restart() showWidgets(panelLayout) updateCurrentWidgets() showPanelBg(panelBg) @@ -570,20 +616,20 @@ PlasmoidItem { Timer { id: trayInitTimer - interval: 5 + interval: 100 onTriggered: { - if (trayGridViewCount === 0) return - if (!trayGridView) return - showTrayAreas(trayGridView) - showTrayAreas(trayGridView.parent) + if (trayGridView && trayGridViewCount !== 0) { + showTrayAreas(trayGridView) + showTrayAreas(trayGridView.parent) + } updateCurrentWidgets() } } function updateCurrentWidgets() { - if (!trayGridView) return panelWidgets = [] panelWidgets = Utils.findWidgets(panelLayout, panelWidgets) + if (!trayGridView) return panelWidgets = Utils.findWidgetsTray(trayGridView, panelWidgets) panelWidgets = Utils.findWidgetsTray(trayGridView.parent, panelWidgets) }