Skip to content

Commit

Permalink
feat: color refresh & expanded representation text color fix
Browse files Browse the repository at this point in the history
- Merge current configuration with the default one on launch
- Only change Kirigami.Theme for the children elements as it causes the expanded representations to get these colors otherwise
- Allow configuring a periodic color refresh for widgets that recreate elements so they don't get stuck
- Update configuration structure to allow disabling padding, radius and margin

refs: #69 #70
  • Loading branch information
luisbocanegra committed Sep 23, 2024
1 parent dcfed1c commit b11b66c
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 896 deletions.
931 changes: 185 additions & 746 deletions package/contents/ui/code/globals.js

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions package/contents/ui/code/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,20 @@ function getWidgetName(item) {
if (item.applet?.plasmoid?.pluginName) {
name = item.applet.plasmoid.pluginName
} else {
const modelItem = item.children.find((child) => child.hasOwnProperty("model"))
if (!modelItem) return null
const model = modelItem.model
if (model.itemType === "StatusNotifier") {
name = model.Id
} else if (model.itemType === "Plasmoid") {
const applet = model.applet ?? null
name = applet?.plasmoid.pluginName ?? null
for (let i in item.children) {
if (!(item.children[i].model)) continue
const model = item.children[i].model
if (model.itemType === "StatusNotifier") {
name = model.Id
} else if (model.itemType === "Plasmoid") {
const applet = model.applet ?? null
name = applet?.plasmoid.pluginName ?? null
}
}
}
if (name) {
console.error("@@@@ getWidgetName ->", name)
}
// if (name) {
// console.error("@@@@ getWidgetName ->", name)
// }
return name
}

Expand Down Expand Up @@ -277,3 +278,7 @@ function mergeConfigs(defaultConfig, existingConfig) {
}
return existingConfig
}

function stringify(config) {
return JSON.stringify(config, null, null)
}
20 changes: 10 additions & 10 deletions package/contents/ui/components/FormPadding.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Kirigami.FormLayout {
CheckBox {
Kirigami.FormData.label: i18n("Enabled:")
id: enabledCheckbox
checked: config.paddingEnabled
checked: config.padding.enabled
onCheckedChanged: {
config.paddingEnabled = checked
config.padding.enabled = checked
updateConfig()
}
}
Expand All @@ -44,50 +44,50 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n("Padding:")
SpinBox {
id: topMargin
value: config.padding.top
value: config.padding.side.top
from: 0
to: 99
Layout.row: 0
Layout.column: 1
onValueModified: {
config.padding.top = value
config.padding.side.top = value
updateConfig()
}
}
SpinBox {
id: bottomMargin
value: config.padding.bottom
value: config.padding.side.bottom
from: 0
to: 99
Layout.row: 2
Layout.column: 1
onValueModified: {
config.padding.bottom = value
config.padding.side.bottom = value
updateConfig()
}
}
SpinBox {
id: leftMargin
value: config.padding.left
value: config.padding.side.left
from: 0
to: 99
Layout.row: 1
Layout.column: 0
onValueModified: {
config.padding.left = value
config.padding.side.left = value
updateConfig()
}
}

SpinBox {
id: rightMargin
value: config.padding.right
value: config.padding.side.right
from: 0
to: 99
Layout.row: 1
Layout.column: 2
onValueModified: {
config.padding.right = value
config.padding.side.right = value
updateConfig()
}
}
Expand Down
40 changes: 20 additions & 20 deletions package/contents/ui/components/FormShape.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Kirigami.FormLayout {
CheckBox {
Kirigami.FormData.label: i18n("Enabled:")
id: radiusEnabledCheckbox
checked: config.radiusEnabled
checked: config.radius.enabled
onCheckedChanged: {
config.radiusEnabled = checked
config.radius.enabled = checked
updateConfig()
}
}
Expand All @@ -43,41 +43,41 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n("Radius:")
SpinBox {
id: topLeftRadius
value: config.radius.topLeft
value: config.radius.corner.topLeft
from: 0
to: 99
onValueModified: {
config.radius.topLeft = value
config.radius.corner.topLeft = value
updateConfig()
}
}
SpinBox {
id: topRightRadius
value: config.radius.topRight
value: config.radius.corner.topRight
from: 0
to: 99
onValueModified: {
config.radius.topRight = value
config.radius.corner.topRight = value
updateConfig()
}
}
SpinBox {
id: bottomLeftRadius
value: config.radius.bottomLeft
value: config.radius.corner.bottomLeft
from: 0
to: 99
onValueModified: {
config.radius.bottomLeft = value
config.radius.corner.bottomLeft = value
updateConfig()
}
}
SpinBox {
id: bottomRightRadius
value: config.radius.bottomRight
value: config.radius.corner.bottomRight
from: 0
to: 99
onValueModified: {
config.radius.bottomRight = value
config.radius.corner.bottomRight = value
updateConfig()
}
}
Expand All @@ -91,9 +91,9 @@ Kirigami.FormLayout {
CheckBox {
Kirigami.FormData.label: i18n("Enabled:")
id: marginEnabledCheckbox
checked: config.marginEnabled
checked: config.margin.enabled
onCheckedChanged: {
config.marginEnabled = checked
config.margin.enabled = checked
updateConfig()
}
}
Expand All @@ -104,50 +104,50 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n("Margin:")
SpinBox {
id: topMargin
value: config.margin.top
value: config.margin.side.top
from: 0
to: 99
Layout.row: 0
Layout.column: 1
onValueModified: {
config.margin.top = value
config.margin.side.top = value
updateConfig()
}
}
SpinBox {
id: bottomMargin
value: config.margin.bottom
value: config.margin.side.bottom
from: 0
to: 99
Layout.row: 2
Layout.column: 1
onValueModified: {
config.margin.bottom = value
config.margin.side.bottom = value
updateConfig()
}
}
SpinBox {
id: leftMargin
value: config.margin.left
value: config.margin.side.left
from: 0
to: 99
Layout.row: 1
Layout.column: 0
onValueModified: {
config.margin.left = value
config.margin.side.left = value
updateConfig()
}
}

SpinBox {
id: rightMargin
value: config.margin.right
value: config.margin.side.right
from: 0
to: 99
Layout.row: 1
Layout.column: 2
onValueModified: {
config.margin.right = value
config.margin.side.right = value
updateConfig()
}
}
Expand Down
18 changes: 14 additions & 4 deletions package/contents/ui/components/WidgetCardCheck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.kde.kirigami as Kirigami
Kirigami.AbstractCard {
id: root
property var widget
signal updateWidget(mask: bool, effect: bool)
checked: maskCheckbox.checked || effectCheckbox.checked
signal updateWidget(mask: bool, effect: bool, reload: bool)
checked: maskCheckbox.checked || effectCheckbox.checked || reloadCheckbox.checked

contentItem: RowLayout {
Kirigami.Icon {
Expand Down Expand Up @@ -57,7 +57,7 @@ Kirigami.AbstractCard {
checked: widget.method.mask ?? false
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic"
onCheckedChanged: {
updateWidget(maskCheckbox.checked, effectCheckbox.checked)
updateWidget(maskCheckbox.checked, effectCheckbox.checked, reloadCheckbox.checked)
}
}
Button {
Expand All @@ -67,7 +67,17 @@ Kirigami.AbstractCard {
checked: widget.method.multiEffect ?? false
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic"
onCheckedChanged: {
updateWidget(maskCheckbox.checked, effectCheckbox.checked)
updateWidget(maskCheckbox.checked, effectCheckbox.checked, reloadCheckbox.checked)
}
}
Button {
id: reloadCheckbox
text: i18n("Reload")
checkable: true
checked: widget.reload ?? false
icon.name: checked ? "checkmark-symbolic" : "dialog-close-symbolic"
onCheckedChanged: {
updateWidget(maskCheckbox.checked, effectCheckbox.checked, reloadCheckbox.checked)
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions package/contents/ui/components/WidgetCardConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Kirigami.AbstractCard {
property var configOverrides: []
property var overrideAssociations: {}
property bool showList: false
property string currentGroup: overrideAssociations[widget.name]
property string currentGroup: overrideAssociations[widget.name] || ""

contentItem: ColumnLayout {
RowLayout {
Expand Down Expand Up @@ -104,7 +104,6 @@ Kirigami.AbstractCard {
highlight: Item {}
highlightMoveDuration: 0
highlightResizeDuration: 0
boundsBehavior: Flickable.StopAtBoundsfiltered
}
}
}
Expand Down
Loading

0 comments on commit b11b66c

Please sign in to comment.