Skip to content

Commit 10c3aa4

Browse files
committed
fix: use even spacing to avoid gaps if unified widgets feature is used
closes: #122
1 parent 2aee2d2 commit 10c3aa4

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

package/contents/ui/code/utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,8 @@ function clearOldWidgetConfig(config) {
490490
function getWidgetConfigIdx(id, name, config) {
491491
// console.log("getWidgetConfigIdx()")
492492
return config.findIndex((item) => item.id == id && item.name == name)
493+
}
494+
495+
function makeEven(n) {
496+
return n - n % 2
493497
}

package/contents/ui/components/FormWidgetSettings.qml

+23-11
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,30 @@ ColumnLayout {
209209
twinFormLayouts: parentLayout
210210
Layout.fillWidth: true
211211

212-
SpinBox {
212+
RowLayout {
213213
Kirigami.FormData.label: i18n("Spacing:")
214-
id: spacingCheckbox
215-
value: configLocal.spacing || 0
216-
from: 0
217-
to: 999
218-
visible: keyName === "widgets" && currentTab === 1
219-
enabled: visible
220-
onValueModified: {
221-
if (!enabled) return
222-
configLocal.spacing = value
223-
updateConfig()
214+
SpinBox {
215+
id: spacingCheckbox
216+
value: configLocal.spacing || 0
217+
from: 0
218+
to: 999
219+
visible: keyName === "widgets" && currentTab === 1
220+
enabled: visible
221+
onValueModified: {
222+
if (!enabled) return
223+
configLocal.spacing = value
224+
updateConfig()
225+
}
226+
}
227+
228+
Button {
229+
visible: spacingCheckbox.value % 2 !== 0 && spacingCheckbox.visible
230+
icon.name: "dialog-warning-symbolic"
231+
ToolTip.text: i18n("<strong>Odd</strong> values are automatically converted to <strong>evens</strong> if <strong>Unified Background</strong> feature is used.")
232+
highlighted: true
233+
hoverEnabled: true
234+
ToolTip.visible: hovered
235+
224236
}
225237
}
226238
}

package/contents/ui/configUnifiedBackground.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ KCM.SimpleKCM {
108108
Kirigami.FormLayout {
109109
Kirigami.InlineMessage {
110110
Layout.fillWidth: true
111-
text: i18n("Select start and end of unified background areas, widgets between <b>Start</b> and <b>End</b> must be left Disabled.")
111+
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.")
112112
visible: true
113113
type: Kirigami.MessageType.Information
114114
}

package/contents/ui/main.qml

+13-6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ PlasmoidItem {
119119
}
120120
}
121121
property var widgetSettings: cfg.widgets
122+
property var widgetsSpacing: {
123+
if (true) {
124+
return Utils.makeEven(widgetSettings?.spacing ?? 4)
125+
} else {
126+
return widgetSettings?.spacing ?? 4
127+
}
128+
}
122129
property var panelSettings: cfg.panel
123130
property var stockPanelSettings: cfg.stockPanelSettings
124131
property var trayWidgetSettings: cfg.trayWidgets
@@ -507,10 +514,10 @@ PlasmoidItem {
507514
anchors.centerIn: (isTray || isTrayArrow) ? parent : undefined
508515
anchors.fill: (isPanel ||isTray || isTrayArrow) ? parent : undefined
509516

510-
property int extraLSpacing: ((unifyBgType === 2 || unifyBgType === 3) && horizontal ? widgetSettings.spacing : 0) / 2
511-
property int extraRSpacing: ((unifyBgType === 1 || unifyBgType === 2) && horizontal ? widgetSettings.spacing : 0) / 2
512-
property int extraTSpacing: ((unifyBgType === 2 || unifyBgType === 3) && !horizontal ? widgetSettings.spacing : 0) / 2
513-
property int extraBSpacing: ((unifyBgType === 1 || unifyBgType === 2) && !horizontal ? widgetSettings.spacing : 0) / 2
517+
property int extraLSpacing: ((unifyBgType === 2 || unifyBgType === 3) && horizontal ? widgetsSpacing : 0) / 2
518+
property int extraRSpacing: ((unifyBgType === 1 || unifyBgType === 2) && horizontal ? widgetsSpacing : 0) / 2
519+
property int extraTSpacing: ((unifyBgType === 2 || unifyBgType === 3) && !horizontal ? widgetsSpacing : 0) / 2
520+
property int extraBSpacing: ((unifyBgType === 1 || unifyBgType === 2) && !horizontal ? widgetsSpacing : 0) / 2
514521

515522
property int marginLeft: (marginEnabled ? cfg.margin.side.left : 0)
516523
+ extraLSpacing
@@ -1074,14 +1081,14 @@ PlasmoidItem {
10741081
Binding {
10751082
target: panelLayout
10761083
property: "columnSpacing"
1077-
value: widgetSettings.spacing
1084+
value: widgetsSpacing
10781085
when: !editMode
10791086
}
10801087

10811088
Binding {
10821089
target: panelLayout
10831090
property: "rowSpacing"
1084-
value: widgetSettings.spacing
1091+
value: widgetsSpacing
10851092
when: !editMode
10861093
}
10871094

0 commit comments

Comments
 (0)