Spracherkennung für: .qml vermutete Sprache: Abap {ABAP[66] Delphi[52] CS[36]} [Methode: maximale Elemente, drei Dimensionen]
/*****************************************************************************
* Copyright (C) 2020 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* ( at your option ) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import QtQuick
import QtQuick.
Window
import VLC.MainInterface
import VLC.Widgets
as Widgets
import VLC.Style
Item {
id: root
// Properties
property real playIconSize: VLCStyle.play_cover_normal
property bool playCoverShowPlay: implicitPlayCoverShowPlay
property bool implicitPlayCoverShowPlay: false
readonly
property real effectiveRadius: fallbackImage.visible ? fallbackImage.effectiv
eRadius
: (image.visible ? image.effectiveRadius
: 0.0)
readonly property real eDPR: MainCtx.effectiveDevicePixelRatio(Window.window)
// Aliases
property alias radius: image.radius
property alias radiusTopRight: image.radiusTopRight
property alias radiusTopLeft: image.radiusTopLeft
property alias radiusBottomRight: image.radiusBottomRight
property alias radiusBottomLeft: image.radiusBottomLeft
property alias color: image.backgroundColor
property url source
property alias cacheImage: image.cache
property bool _loadTimeout: false
property string fallbackImageSource
property alias imageOverlay: overlay.sourceComponent
readonly property bool playCoverVisible: (_playCoverItem && _playCoverItem.visible)
required property int pictureWidth
required property int pictureHeight
readonly property real padding: fallbackImage.visible ? fallbackImage.padding : image.padding
readonly property real paintedWidth: fallbackImage.visible ? fallbackImage.paintedWidth : image.paintedWidth
readonly property real paintedHeight: fallbackImage.visible ? fallbackImage.paintedHeight : image.paintedHeight
property alias fillMode: image.fillMode
readonly property Item textureProvider: fallbackImage.visible ? fallbackImage.textureProviderItem : image.textureProviderItem
// Signals
signal playIconClicked(var point)
// Settings
height: VLCStyle.listAlbumCover_height
width: VLCStyle.listAlbumCover_width
Accessible.role: Accessible.Graphic
Accessible.name: qsTr("Media cover")
// If this type is used within a reusable delegate, connect `ItemView::reused()` to this function.
function reinitialize() {
root._loadTimeout = false
fallbackImage.source = Qt.binding(() => { return fallbackImage.defaultSource })
image.source = Qt.binding(() => { return image.defaultSource })
}
// If this type is used within a reusable delegate, connect `ItemView::pooled()` to this function.
// NOTE: This does not override `QQuickItem::releaseResources()`.
function releaseResources() {
fallbackImage.source = ""
image.source = ""
}
// Children
//delay placeholder showing up
Timer {
id: timer
interval: VLCStyle.duration_long
onTriggered: root._loadTimeout = true
}
Widgets.ImageExt {
id: image
anchors.fill: parent
source: defaultSource
sourceSize: Qt.size(root.pictureWidth * root.eDPR,
root.pictureHeight * root.eDPR)
readonly property url defaultSource: root.source
onStatusChanged: {
if (status === Image.Loading) {
root._loadTimeout = false
timer.start()
} else {
timer.stop()
}
}
}
Widgets.ImageExt {
id: fallbackImage
anchors.fill: parent
radius: root.radius
radiusTopRight: root.radiusTopRight
radiusTopLeft: root.radiusTopLeft
radiusBottomRight: root.radiusBottomRight
radiusBottomLeft: root.radiusBottomLeft
backgroundColor: root.color
fillMode: root.fillMode
visible: image.source.toString() === "" //RoundImage.source is a QUrl
|| image.status === Image.Error
|| (image.status === Image.Loading && root._loadTimeout)
// we only keep this image till there is no main image
// try to release the resources otherwise
source: defaultSource
readonly property url defaultSource: visible ? root.fallbackImageSource : ""
sourceSize: Qt.size(root.pictureWidth * root.eDPR,
root.pictureHeight * root.eDPR)
cache: true
}
Loader {
id: overlay
anchors.centerIn: parent
anchors.alignWhenCentered: true
width: root.paintedWidth
height: root.paintedHeight
}
Component {
id: playCoverComponent
Widgets.PlayCover {
anchors.centerIn: parent
width: playIconSize
visible: (opacity > 0.0 || root.playCoverShowPlay)
opacity: 0.0
Behavior on opacity {
NumberAnimation {
duration: VLCStyle.duration_short
easing.type: Easing.InOutSine
}
}
Component.onCompleted: {
tapped.connect(root.playIconClicked)
opacity = Qt.binding(() => { return (root.playCoverShowPlay ? 1.0 : 0.0) })
}
}
}
property Widgets.PlayCover _playCoverItem
property var _playCoverItemIncubator
onPlayCoverShowPlayChanged: {
// NOTE: We are lazy loading the component when this gets visible and it stays loaded.
// We could consider unloading it when visible goes to false.
if (playCoverShowPlay && !_playCoverItem && !_playCoverItemIncubator) {
// https://doc.qt.io/qt-6/qqmlincubator.html#details
const incubator = playCoverComponent.incubateObject(root, {}, 1 /* QQmlIncubator::AsynchronousIfNested */)
_playCoverItemIncubator = incubator
// https://doc.qt.io/qt-6/qml-qtqml-component.html#incubateObject-method
if (incubator.status !== Component.Ready) {
incubator.onStatusChanged = function(status) {
if (status === Component.Ready) {
root._playCoverItem = incubator.object
// Incubator should be garbage collected, we don't need it anymore:
root._playCoverItemIncubator = null
}
}
} else {
root._playCoverItem = incubator.object
// Incubator should be garbage collected, we don't need it anymore:
root._playCoverItemIncubator = null
}
}
}
}
[Dauer der Verarbeitung: 0.3 Sekunden, vorverarbeitet 2026-10-24]