Skip to content

Commit 7cf87cb

Browse files
committed
fix: target current panel by id when changing stock panel settings
before this change it was possible to target the wrong panel as only location and screen where checked
1 parent 905fa90 commit 7cf87cb

File tree

2 files changed

+25
-73
lines changed

2 files changed

+25
-73
lines changed

package/contents/ui/code/utils.js

+24-52
Original file line numberDiff line numberDiff line change
@@ -417,59 +417,31 @@ function getWidgetRootDir() {
417417
return path.join('/')
418418
}
419419

420-
function getPanelPosition() {
421-
var location
422-
var screen = main.screen
423-
424-
switch (plasmoid.location) {
425-
case PlasmaCore.Types.TopEdge:
426-
location = "top"
427-
break
428-
case PlasmaCore.Types.BottomEdge:
429-
location = "bottom"
430-
break
431-
case PlasmaCore.Types.LeftEdge:
432-
location = "left"
433-
break
434-
case PlasmaCore.Types.RightEdge:
435-
location = "right"
436-
break
437-
}
438-
439-
console.log("location:" + location + " screen:" + screen);
440-
return { "screen": screen, "location": location }
441-
}
442-
443-
function setPanelModeScript(panelPosition, panelSettings) {
420+
function setPanelModeScript(panelId, panelSettings) {
444421
var setPanelModeScript = `
445-
for (var id of panelIds) {
446-
var panel = panelById(id);
447-
if (panel.screen === ${panelPosition.screen} && panel.location === "${panelPosition.location}" ) {
448-
if (${panelSettings.visibility.enabled}) {
449-
panel.hiding = "${panelSettings.visibility.value}"
450-
}
451-
if (${panelSettings.thickness.enabled}) {
452-
panel.height = ${panelSettings.thickness.value}
453-
}
454-
if (${panelSettings.lengthMode.enabled}) {
455-
panel.lengthMode = "${panelSettings.lengthMode.value}"
456-
}
457-
if (${panelSettings.position.enabled}) {
458-
panel.location = "${panelSettings.position.value}"
459-
}
460-
if (${panelSettings.floating.enabled}) {
461-
panel.floating = ${panelSettings.floating.value}
462-
}
463-
if (${panelSettings.alignment.enabled}) {
464-
panel.alignment = "${panelSettings.alignment.value}"
465-
}
466-
if (${panelSettings.opacity.enabled}) {
467-
panel.opacity = "${panelSettings.opacity.value}"
468-
}
469-
break
470-
}
471-
}`
472-
return setPanelModeScript
422+
var panel = panelById(${panelId});
423+
if (${panelSettings.visibility.enabled}) {
424+
panel.hiding = "${panelSettings.visibility.value}"
425+
}
426+
if (${panelSettings.thickness.enabled}) {
427+
panel.height = ${panelSettings.thickness.value}
428+
}
429+
if (${panelSettings.lengthMode.enabled}) {
430+
panel.lengthMode = "${panelSettings.lengthMode.value}"
431+
}
432+
if (${panelSettings.position.enabled}) {
433+
panel.location = "${panelSettings.position.value}"
434+
}
435+
if (${panelSettings.floating.enabled}) {
436+
panel.floating = ${panelSettings.floating.value}
437+
}
438+
if (${panelSettings.alignment.enabled}) {
439+
panel.alignment = "${panelSettings.alignment.value}"
440+
}
441+
if (${panelSettings.opacity.enabled}) {
442+
panel.opacity = "${panelSettings.opacity.value}"
443+
}`;
444+
return setPanelModeScript;
473445
}
474446

475447
function evaluateScript(script) {

package/contents/ui/main.qml

+1-21
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,6 @@ PlasmoidItem {
2525
property int panelLayoutCount: panelLayout?.children?.length || 0
2626
property int trayGridViewCount: trayGridView?.count || 0
2727
property int trayGridViewCountOld: 0
28-
property var panelPrefixes: ["north","south","west","east"]
29-
property var panelPosition: {
30-
var location
31-
var screen = main.screen
32-
switch (plasmoid.location) {
33-
case PlasmaCore.Types.TopEdge:
34-
location = "top"
35-
break
36-
case PlasmaCore.Types.BottomEdge:
37-
location = "bottom"
38-
break
39-
case PlasmaCore.Types.LeftEdge:
40-
location = "left"
41-
break
42-
case PlasmaCore.Types.RightEdge:
43-
location = "right"
44-
break
45-
}
46-
return { "screen": screen, "location": location }
47-
}
4828
property bool horizontal: Plasmoid.formFactor === PlasmaCore.Types.Horizontal
4929
property bool editMode: Plasmoid.containment.corona?.editMode ?? false
5030
property bool onDesktop: plasmoid.location === PlasmaCore.Types.Floating
@@ -158,7 +138,7 @@ PlasmoidItem {
158138
onStockPanelSettingsChanged: {
159139
Qt.callLater(function() {
160140
// console.error(JSON.stringify(stockPanelSettings))
161-
let script = Utils.setPanelModeScript(panelPosition, stockPanelSettings)
141+
let script = Utils.setPanelModeScript(Plasmoid.containment.id, stockPanelSettings)
162142
if (stockPanelSettings.visible.enabled) {
163143
panelView.visible = stockPanelSettings.visible.value
164144
} else {

0 commit comments

Comments
 (0)