[vlc-devel] [PATCH 11/55] qml: fix SortControl background effect rendering
Fatih Uzunoglu
fuzun54 at outlook.com
Thu Jan 7 21:36:24 UTC 2021
---
modules/gui/qt/widgets/qml/SortControl.qml | 64 +++++++++++-----------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/modules/gui/qt/widgets/qml/SortControl.qml b/modules/gui/qt/widgets/qml/SortControl.qml
index f384548900..55c1a1d0b5 100644
--- a/modules/gui/qt/widgets/qml/SortControl.qml
+++ b/modules/gui/qt/widgets/qml/SortControl.qml
@@ -104,8 +104,6 @@ Widgets.NavigableFocusScope {
padding: 1
onOpened: {
- updateBgRect()
-
button.KeyNavigation.down = list
button.highlighted = true
@@ -228,58 +226,60 @@ Widgets.NavigableFocusScope {
}
}
- function updateBgRect() {
- glassEffect.popupGlobalPos = g_root.mapFromItem(root, popup.x, popup.y)
- }
-
background: Rectangle {
border.width: VLCStyle.dp(1)
border.color: colors.accent
- Widgets.FrostedGlassEffect {
- id: glassEffect
- source: g_root
+ Loader {
+ id: effectLoader
anchors.fill: parent
anchors.margins: VLCStyle.dp(1)
- property point popupGlobalPos
- sourceRect: Qt.rect(popupGlobalPos.x, popupGlobalPos.y, glassEffect.width, glassEffect.height)
+ asynchronous: true
- tint: colors.bg
- tintStrength: 0.3
- }
- }
+ Component {
+ id: frostedGlassEffect
- Connections {
- target: g_root
+ Widgets.FrostedGlassEffect {
+ source: g_root
- enabled: popup.visible
+ // since Popup is not an Item, we can not directly map its position
+ // to the source item. Instead, we can use root because popup's
+ // position is relative to its position.
+ // This method unfortunately causes issues when source item is resized.
+ // But in that case, we reload the effectLoader to redraw the effect.
+ property point popupMappedPos: g_root.mapFromItem(root, popup.x, popup.y)
+ sourceRect: Qt.rect(popupMappedPos.x, popupMappedPos.y, width, height)
- onWidthChanged: {
- popup.updateBgRect()
- }
+ tint: colors.bg
+ tintStrength: 0.3
+ }
+ }
- onHeightChanged: {
- popup.updateBgRect()
+ sourceComponent: frostedGlassEffect
+
+ function reload() {
+ if (status != Loader.Ready)
+ return
+
+ sourceComponent = undefined
+ sourceComponent = frostedGlassEffect
+ }
}
}
Connections {
- target: mainInterface
+ target: g_root
enabled: popup.visible
- onIntfScaleFactorChanged: {
- popup.updateBgRect()
+ onWidthChanged: {
+ effectLoader.reload()
}
- }
-
- Connections {
- target: playlistColumn
- onWidthChanged: {
- popup.updateBgRect()
+ onHeightChanged: {
+ effectLoader.reload()
}
}
}
--
2.27.0
More information about the vlc-devel
mailing list