Skip to content

Commit

Permalink
feat: per widget blur override
Browse files Browse the repository at this point in the history
Changed the way blur works, now there are three sort of "layers" of blur

- Panel, the lowest priority
- Widget, if enabled overrides the panel blur
- System tray elements, visible only if the System Tray (the parent) is not blurrred, also overrides panel blur

refs: #74
  • Loading branch information
luisbocanegra committed Oct 1, 2024
1 parent 22c18cb commit e67bae6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
3 changes: 0 additions & 3 deletions package/contents/ui/code/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ function getEffectiveSettings(customSettings, globalSettings) {
}
}
}
if (!effectiveSettings.hasOwnProperty("blurBehind") || !effectiveSettings.blurBehind) {
effectiveSettings.blurBehind = globalSettings.blurBehind;
}
return effectiveSettings
}

Expand Down
6 changes: 2 additions & 4 deletions package/contents/ui/components/FormWidgetSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ ColumnLayout {
}
}
RowLayout {
visible: keyName !== ""
Label {
text: i18n("Blur behind:")
text: i18n("Blur behind (Beta):")
}
CheckBox {
Kirigami.FormData.label: i18n("Blur behind:")
id: blurCheckbox
checked: configLocal.blurBehind
onCheckedChanged: {
Expand All @@ -97,7 +95,7 @@ ColumnLayout {
enabled: isEnabled.checked
}
Kirigami.ContextualHelpButton {
toolTipText: i18n("Draw a custom blur mask behind the custom background(s).\n\nNative panel background must be enabled with opacity of 0 for this to work as intended.")
toolTipText: i18n("Draw a custom blur mask behind the custom background(s).\n\nRequires the C++ plugin to work, check the repository README on GitHub for details.\n\nNative panel background must be enabled with opacity of 0 for this to work as intended.")
}
}
RowLayout {
Expand Down
4 changes: 2 additions & 2 deletions package/contents/ui/configPerWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ KCM.SimpleKCM {
}
Button {
icon.name: "checkmark-symbolic"
text: "Apply"
text: "Rename"
onClicked: {
configOverrides[nameField.text] = configOverrides[overrideName]
delete configOverrides[overrideName]
Expand All @@ -265,7 +265,7 @@ KCM.SimpleKCM {
}
}
Kirigami.ContextualHelpButton {
toolTipText: i18n("Fallback to the global widget settings for disabled options, except for <b>Enable</b>.")
toolTipText: i18n("Fallback to the global widget settings for disabled options, except for <b>Enable</b> and <b>Blur</>.")
}
}
}
Expand Down
65 changes: 45 additions & 20 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ PlasmoidItem {
"touchingWindow": !panelElement ? false : Boolean(panelElement.touchingWindow),
"floating": !panelElement ? false : Boolean(panelElement.floatingness)
}
property var widgetsDoingBlur: ({})
property var trayItemsDoingBlur: ({})

property var anyWidgetDoingBlur: {
return Object.values(widgetsDoingBlur).some(state => state)
}
property var anyTrayItemDoingBlur: {
return Object.values(trayItemsDoingBlur).some(state => state)
}

property var cfg: {
try {
return JSON.parse(plasmoid.configuration.allSettings)
Expand Down Expand Up @@ -243,8 +253,13 @@ PlasmoidItem {
id: rect
property Item target
property int targetIndex
// we need an exra id so we can track the items in tray
property int maskIndex: inTray ? (panelLayoutCount -1 + targetIndex) : targetIndex
// use an exra id so we can track the panel and items in tray separately
property int maskIndex: {
if (isPanel) return 0
else {
return (inTray ? (panelLayoutCount -1 + targetIndex) : targetIndex) +1
}
}
property int itemType
property bool isPanel: itemType === Enums.ItemType.PanelBgItem
property bool isWidget: itemType === Enums.ItemType.WidgetItem
Expand Down Expand Up @@ -296,8 +311,9 @@ PlasmoidItem {
property bool fgShadowEnabled: cfg.shadow.foreground.enabled && cfgEnabled
property var fgShadow: cfg.shadow.foreground
property bool blurBehind: {
return isPanel || (isWidget && !panelBgItem?.blurBehind)
|| (inTray && !panelBgItem?.blurBehind && !trayWidgetBgItem?.blurBehind)
return (isPanel && !anyWidgetDoingBlur && !anyTrayItemDoingBlur)
|| (isWidget)
|| (inTray && !trayWidgetBgItem?.blurBehind)
? cfg.blurBehind
: false
}
Expand Down Expand Up @@ -805,7 +821,7 @@ PlasmoidItem {
}
}
Label {
text: parseInt(position.x)+","+parseInt(position.y)
text: blurBehind+","+anyWidgetDoingBlur //parseInt(position.x)+","+parseInt(position.y)
font.pixelSize: 8
Rectangle {
anchors.fill: parent
Expand Down Expand Up @@ -884,21 +900,30 @@ PlasmoidItem {
updateMask()
}

onBlurBehindChanged: {
if (isWidget) {
widgetsDoingBlur[maskIndex] = blurBehind
anyWidgetDoingBlur = Object.values(widgetsDoingBlur).some(state => state)
} else if (inTray) {
trayItemsDoingBlur[maskIndex] = blurBehind
anyTrayItemDoingBlur = Object.values(trayItemsDoingBlur).some(state => state)
}
updateMask()
}

function updateMask() {
// Qt.callLater(function() {
if (panelColorizer === null || !blurBehind) return
panelColorizer.updatePanelMask(
maskIndex,
borderRec,
rect.corners.topLeftRadius,
rect.corners.topRightRadius,
rect.corners.bottomLeftRadius,
rect.corners.bottomRightRadius,
Qt.point(rect.positionX-moveX, rect.positionY-moveY),
5,
visible
)
// })
if (panelColorizer === null) return
panelColorizer.updatePanelMask(
maskIndex,
borderRec,
rect.corners.topLeftRadius,
rect.corners.topRightRadius,
rect.corners.bottomLeftRadius,
rect.corners.bottomRightRadius,
Qt.point(rect.positionX-moveX, rect.positionY-moveY),
5,
visible && blurBehind
)
}
}

Expand Down Expand Up @@ -968,7 +993,7 @@ PlasmoidItem {
property: "panelMask"
value: blurMask
when: (panelColorizer !== null && blurMask && panelColorizer?.hasRegions
&& (panelBgItem?.blurBehind || widgetSettings?.blurBehind || trayWidgetSettings?.blurBehind)
&& (panelSettings.blurBehind || anyWidgetDoingBlur || anyTrayItemDoingBlur)
)
}

Expand Down

0 comments on commit e67bae6

Please sign in to comment.