[vlc-commits] [Git][videolan/vlc][master] 5 commits: qml: set ready count at appropriate time in `DragItem`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Apr 27 14:12:17 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8417e217 by Fatih Uzunoglu at 2025-04-27T13:54:16+00:00
qml: set ready count at appropriate time in `DragItem`
- - - - -
24ab921c by Fatih Uzunoglu at 2025-04-27T13:54:16+00:00
qml: expose shader status in `ImageExt`
- - - - -
bb1957d6 by Fatih Uzunoglu at 2025-04-27T13:54:16+00:00
qml: consider shader status in `DragItem` and handle the counter better
- - - - -
e862c5af by Fatih Uzunoglu at 2025-04-27T13:54:16+00:00
qml: leverage `ImageExt` for background coloring and outlining in `DragItem`
The extra rectangles are useless because `ImageExt` can already do what they
are doing.
- - - - -
1e9f677c by Fatih Uzunoglu at 2025-04-27T13:54:16+00:00
qml: disable asynchronous in `DragItem` image as a Qt bug workaround
- - - - -
2 changed files:
- modules/gui/qt/widgets/qml/DragItem.qml
- modules/gui/qt/widgets/qml/ImageExt.qml
Changes:
=====================================
modules/gui/qt/widgets/qml/DragItem.qml
=====================================
@@ -426,12 +426,15 @@ Item {
Repeater {
id: coverRepeater
- model: dragItem._covers
+ readonly property var _model: dragItem._covers
- property int notReadyCount: count
+ property int notReadyCount
- onModelChanged: {
- notReadyCount = count
+ on_ModelChanged: {
+ // Repeater signals model and count change after it reloads the items.
+ // So we need to adjust the ready count before that:
+ notReadyCount = _model.length
+ model = _model
}
onNotReadyCountChanged: {
@@ -450,53 +453,67 @@ Item {
width: dragItem.coverSize
height: dragItem.coverSize
- Rectangle {
- id: bg
-
- radius: coverRepeater.count > 1 ? dragItem.coverSize : 0.0
- anchors.fill: parent
- color: theme.bg.primary
-
- DefaultShadow {
- anchors.centerIn: parent
-
- sourceItem: bg
- }
- }
-
Widgets.ImageExt {
id: artworkCover
anchors.centerIn: parent
width: coverSize
height: coverSize
- radius: bg.radius
+ radius: coverRepeater.count > 1 ? dragItem.coverSize : 0.0
source: modelData.artwork ?? ""
sourceSize: dragItem.imageSourceSize ?? Qt.size(width * eDPR, height * eDPR)
+ backgroundColor: theme.bg.primary
+ borderWidth: VLCStyle.dp(1, VLCStyle.scale)
+ borderColor: theme.border
fillMode: Image.PreserveAspectCrop
+ // FIXME: Qt bug, asynchronous + texture provider + custom shader does not work properly with `grabToImage()`:
+ asynchronous: false
+
readonly property real eDPR: MainCtx.effectiveDevicePixelRatio(Window.window)
+ property bool _triggerReadiness: false
- onStatusChanged: {
- if (status === Image.Ready)
+ on_TriggerReadinessChanged: {
+ // If it was already true (readiness already signalled), do not decrease the counter.
+ // This handler is only called when the property changes.
+ if (_triggerReadiness) {
coverRepeater.notReadyCount -= 1
- else if (status === Image.Error) {
+ }
+ }
+
+ readonly property var _combinedStatus: [status, shaderStatus]
+
+ on_CombinedStatusChanged: {
+ // Qt `ShaderEffect` documentation states:
+ // > When runtime compilation is not in use and the shader properties
+ // > refer to files with bytecode, the status is always Compiled.
+ // However this is not correct, the status is reported to be "uncompiled" initially.
+ // And sometimes the status remains "uncompiled" even when the shader is in use, for
+ // that reason I only care about `ShaderEffect.Error` here and not `Compiled`.
+
+ if (shaderStatus === ShaderEffect.Error) {
+ _triggerReadiness = true // Not much to do in this case, shader could not be loaded.
+ return
+ }
+
+ if (status === Image.Error) {
const fallbackSource = modelData.fallback ?? defaultCover
- if (source === fallbackSource)
- coverRepeater.notReadyCount -= 1
- else
+ if (source === fallbackSource) {
+ _triggerReadiness = true // Not much to do in this case either, fallback image could not be loaded.
+ } else {
source = fallbackSource
+ }
+ } else if (status === Image.Ready /* && shaderStatus === ShaderEffect.Compiled */) {
+ // FIXME: When Qt starts to report `ShaderEffect.Compiled` properly, start using it.
+ _triggerReadiness = true // Only in this case the image is loaded and shown.
}
}
- }
- Rectangle {
- // for cover border
- color: "transparent"
- border.width: VLCStyle.dp(1, VLCStyle.scale)
- border.color: theme.border
- anchors.fill: parent
- radius: bg.radius
+ DefaultShadow {
+ anchors.centerIn: parent
+
+ sourceItem: parent
+ }
}
}
}
=====================================
modules/gui/qt/widgets/qml/ImageExt.qml
=====================================
@@ -51,6 +51,7 @@ Item {
property alias sourceSize: image.sourceSize
property alias sourceClipRect: image.sourceClipRect
property alias status: image.status
+ property alias shaderStatus: shaderEffect.status
property alias cache: image.cache
// Padding represents how much the content is shrunk. For now this is a readonly property.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/968534864a2ce22fa44442d0dfb69fd2bd4298eb...1e9f677c17d564088032b3ffa2f70f640da2ea37
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/968534864a2ce22fa44442d0dfb69fd2bd4298eb...1e9f677c17d564088032b3ffa2f70f640da2ea37
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list