Skip to content

Commit

Permalink
fix: use even spacing to avoid gaps if unified widgets feature is used
Browse files Browse the repository at this point in the history
closes: #122
  • Loading branch information
luisbocanegra committed Jan 8, 2025
1 parent 2aee2d2 commit 10c3aa4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
4 changes: 4 additions & 0 deletions package/contents/ui/code/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,8 @@ function clearOldWidgetConfig(config) {
function getWidgetConfigIdx(id, name, config) {
// console.log("getWidgetConfigIdx()")
return config.findIndex((item) => item.id == id && item.name == name)
}

function makeEven(n) {
return n - n % 2
}
34 changes: 23 additions & 11 deletions package/contents/ui/components/FormWidgetSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,30 @@ ColumnLayout {
twinFormLayouts: parentLayout
Layout.fillWidth: true

SpinBox {
RowLayout {
Kirigami.FormData.label: i18n("Spacing:")
id: spacingCheckbox
value: configLocal.spacing || 0
from: 0
to: 999
visible: keyName === "widgets" && currentTab === 1
enabled: visible
onValueModified: {
if (!enabled) return
configLocal.spacing = value
updateConfig()
SpinBox {
id: spacingCheckbox
value: configLocal.spacing || 0
from: 0
to: 999
visible: keyName === "widgets" && currentTab === 1
enabled: visible
onValueModified: {
if (!enabled) return
configLocal.spacing = value
updateConfig()
}
}

Button {
visible: spacingCheckbox.value % 2 !== 0 && spacingCheckbox.visible
icon.name: "dialog-warning-symbolic"
ToolTip.text: i18n("<strong>Odd</strong> values are automatically converted to <strong>evens</strong> if <strong>Unified Background</strong> feature is used.")
highlighted: true
hoverEnabled: true
ToolTip.visible: hovered

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package/contents/ui/configUnifiedBackground.qml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ KCM.SimpleKCM {
Kirigami.FormLayout {
Kirigami.InlineMessage {
Layout.fillWidth: true
text: i18n("Select start and end of unified background areas, widgets between <b>Start</b> and <b>End</b> must be left Disabled.")
text: i18n("Select start and end of unified background areas, widgets between <b>Start</b> and <b>End</b> must be left <b>disabled</b>. Note: <strong>odd</strong> widget spacing values are automatically converted to <strong>evens</strong> when this feature is used.")
visible: true
type: Kirigami.MessageType.Information
}
Expand Down
19 changes: 13 additions & 6 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ PlasmoidItem {
}
}
property var widgetSettings: cfg.widgets
property var widgetsSpacing: {
if (true) {
return Utils.makeEven(widgetSettings?.spacing ?? 4)
} else {
return widgetSettings?.spacing ?? 4
}
}
property var panelSettings: cfg.panel
property var stockPanelSettings: cfg.stockPanelSettings
property var trayWidgetSettings: cfg.trayWidgets
Expand Down Expand Up @@ -507,10 +514,10 @@ PlasmoidItem {
anchors.centerIn: (isTray || isTrayArrow) ? parent : undefined
anchors.fill: (isPanel ||isTray || isTrayArrow) ? parent : undefined

property int extraLSpacing: ((unifyBgType === 2 || unifyBgType === 3) && horizontal ? widgetSettings.spacing : 0) / 2
property int extraRSpacing: ((unifyBgType === 1 || unifyBgType === 2) && horizontal ? widgetSettings.spacing : 0) / 2
property int extraTSpacing: ((unifyBgType === 2 || unifyBgType === 3) && !horizontal ? widgetSettings.spacing : 0) / 2
property int extraBSpacing: ((unifyBgType === 1 || unifyBgType === 2) && !horizontal ? widgetSettings.spacing : 0) / 2
property int extraLSpacing: ((unifyBgType === 2 || unifyBgType === 3) && horizontal ? widgetsSpacing : 0) / 2
property int extraRSpacing: ((unifyBgType === 1 || unifyBgType === 2) && horizontal ? widgetsSpacing : 0) / 2
property int extraTSpacing: ((unifyBgType === 2 || unifyBgType === 3) && !horizontal ? widgetsSpacing : 0) / 2
property int extraBSpacing: ((unifyBgType === 1 || unifyBgType === 2) && !horizontal ? widgetsSpacing : 0) / 2

property int marginLeft: (marginEnabled ? cfg.margin.side.left : 0)
+ extraLSpacing
Expand Down Expand Up @@ -1074,14 +1081,14 @@ PlasmoidItem {
Binding {
target: panelLayout
property: "columnSpacing"
value: widgetSettings.spacing
value: widgetsSpacing
when: !editMode
}

Binding {
target: panelLayout
property: "rowSpacing"
value: widgetSettings.spacing
value: widgetsSpacing
when: !editMode
}

Expand Down

0 comments on commit 10c3aa4

Please sign in to comment.