[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: add status() in roundimage
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Sun Jun 19 16:53:12 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
7e4fe560 by Prince Gupta at 2022-06-19T12:32:30+05:30
qt: add status() in roundimage
- - - - -
0cf50276 by Prince Gupta at 2022-06-19T12:32:30+05:30
qml: expose image loading status in GridItem
- - - - -
6f46ca55 by Prince Gupta at 2022-06-19T12:32:30+05:30
qml: show custom cover while loading image in NetworkGridItem
ref #26990
- - - - -
678b940e by Prince Gupta at 2022-06-19T12:32:30+05:30
qml: show custom cover while loading image in NetworkThumbnailItem
ref #26990
- - - - -
55529886 by Prince Gupta at 2022-06-19T12:32:30+05:30
qml: remove redundant check
- - - - -
7 changed files:
- modules/gui/qt/network/qml/NetworkCustomCover.qml
- modules/gui/qt/network/qml/NetworkGridItem.qml
- modules/gui/qt/network/qml/NetworkThumbnailItem.qml
- modules/gui/qt/widgets/native/roundimage.cpp
- modules/gui/qt/widgets/native/roundimage.hpp
- modules/gui/qt/widgets/qml/GridItem.qml
- modules/gui/qt/widgets/qml/MediaCover.qml
Changes:
=====================================
modules/gui/qt/network/qml/NetworkCustomCover.qml
=====================================
@@ -32,7 +32,6 @@ Item {
id: custom_cover
anchors.centerIn: parent
- visible: !networkModel || !networkModel.artwork || networkModel.artwork.toString() === ""
height: iconSize
sourceSize: Qt.size(width, height)
source: {
=====================================
modules/gui/qt/network/qml/NetworkGridItem.qml
=====================================
@@ -26,7 +26,7 @@ import "qrc:///widgets/" as Widgets
import "qrc:///style/"
Widgets.GridItem {
- id: item
+ id: root
width: VLCStyle.gridItem_network_width
height: VLCStyle.gridItem_network_height
@@ -48,6 +48,7 @@ Widgets.GridItem {
pictureOverlay: NetworkCustomCover {
networkModel: model
iconSize: VLCStyle.icon_normal
+ visible: !root.isImageReady
}
}
=====================================
modules/gui/qt/network/qml/NetworkThumbnailItem.qml
=====================================
@@ -42,11 +42,13 @@ Item {
&& (rowModel.type !== NetworkMediaModel.TYPE_NODE)
&& (rowModel.type !== NetworkMediaModel.TYPE_DIRECTORY)
+ readonly property bool _showCustomCover: (!artworkSource) || (artwork.status != Image.Ready)
+
signal playClicked(int index)
Widgets.ListCoverShadow {
- anchors.fill: artwork.visible ? artwork : background
- source: artwork.visible ? artwork : background
+ anchors.fill: !item._showCustomCover ? artwork : background
+ source: !item._showCustomCover ? artwork : background
}
Rectangle {
@@ -57,7 +59,7 @@ Item {
width: VLCStyle.listAlbumCover_width
height: VLCStyle.listAlbumCover_height
radius: VLCStyle.listAlbumCover_radius
- visible: !artwork.visible
+ visible: item._showCustomCover
NetworkCustomCover {
networkModel: rowModel
@@ -87,7 +89,7 @@ Item {
horizontalAlignment: Image.AlignLeft
verticalAlignment: Image.AlignTop
source: item.artworkSource
- visible: item.artworkSource !== ""
+ visible: !item._showCustomCover
Widgets.PlayCover {
x: Math.round((artwork.paintedWidth - width) / 2)
=====================================
modules/gui/qt/widgets/native/roundimage.cpp
=====================================
@@ -493,6 +493,11 @@ qreal RoundImage::radius() const
return m_radius;
}
+RoundImage::Status RoundImage::status() const
+{
+ return m_status;
+}
+
void RoundImage::setSource(const QUrl& source)
{
if (m_source == source)
@@ -544,12 +549,14 @@ void RoundImage::handleImageRequestFinished()
if (image.isNull())
{
+ setStatus(Status::Error);
qDebug() << "failed to get image, error" << error << source();
return;
}
image.setDevicePixelRatio(m_dpr);
setRoundImage(image);
+ setStatus(Status::Ready);
const qreal scaledWidth = this->width() * m_dpr;
const qreal scaledHeight = this->height() * m_dpr;
@@ -585,6 +592,7 @@ void RoundImage::load()
if (auto image = imageCache.object(key)) // should only by called in mainthread
{
setRoundImage(*image);
+ setStatus(Status::Ready);
return;
}
@@ -606,11 +614,22 @@ void RoundImage::setRoundImage(QImage image)
update();
}
+void RoundImage::setStatus(const RoundImage::Status status)
+{
+ if (status == m_status)
+ return;
+
+ m_status = status;
+ emit statusChanged();
+}
+
void RoundImage::regenerateRoundImage()
{
if (!isComponentComplete() || m_enqueuedGeneration)
return;
+ setStatus(source().isEmpty() ? Status::Null : Status::Loading);
+
// remove old contents
setRoundImage({});
=====================================
modules/gui/qt/widgets/native/roundimage.hpp
=====================================
@@ -40,7 +40,19 @@ class RoundImage : public QQuickItem
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged FINAL)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL)
+
public:
+ enum Status
+ {
+ Null,
+ Ready,
+ Loading,
+ Error
+ };
+
+ Q_ENUM(Status)
+
RoundImage(QQuickItem *parent = nullptr);
~RoundImage();
@@ -48,6 +60,7 @@ public:
QUrl source() const;
qreal radius() const;
+ Status status() const;
public slots:
void setSource(const QUrl& source);
@@ -56,6 +69,7 @@ public slots:
signals:
void sourceChanged(const QUrl&);
void radiusChanged(qreal);
+ void statusChanged();
protected:
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
@@ -67,11 +81,13 @@ private:
void resetImageRequest();
void load();
void setRoundImage(QImage image);
+ void setStatus(const Status status);
void regenerateRoundImage();
QUrl m_source;
qreal m_radius = 0.0;
qreal m_dpr = 1.0; // device pixel ratio
+ Status m_status = Status::Null;
QImage m_roundImage;
bool m_dirty = false;
=====================================
modules/gui/qt/widgets/qml/GridItem.qml
=====================================
@@ -52,6 +52,7 @@ T.Control {
// Aliases
property alias image: picture.source
+ property alias isImageReady: picture.isImageReady
property alias title: titleLabel.text
property alias subtitle: subtitleTxt.text
property alias playCoverBorderWidth: picture.playCoverBorderWidth
=====================================
modules/gui/qt/widgets/qml/MediaCover.qml
=====================================
@@ -40,6 +40,7 @@ Rectangle {
// Aliases
property alias source: image.source
+ property bool isImageReady: image.status == RoundImage.Ready
property alias imageOverlay: overlay.sourceComponent
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ceac3fe9abc3dc3ca16dcbc7ba64373ec617fffd...55529886ebb9c7eea20dc5f8a26ec1cf6184f455
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ceac3fe9abc3dc3ca16dcbc7ba64373ec617fffd...55529886ebb9c7eea20dc5f8a26ec1cf6184f455
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