[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt/mlmodel(s): Add the 'isNew' property
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Mon Nov 15 10:25:57 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
30208d91 by Benjamin Arnaud at 2021-11-15T09:18:40+00:00
qt/mlmodel(s): Add the 'isNew' property
- - - - -
dddbaa6d by Benjamin Arnaud at 2021-11-15T09:18:40+00:00
qml/VideoGridItem: Update 'new_indicator' item
- - - - -
19 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/medialibrary/mlgrouplistmodel.cpp
- modules/gui/qt/medialibrary/mlgrouplistmodel.hpp
- modules/gui/qt/medialibrary/mlplaylistmedia.cpp
- modules/gui/qt/medialibrary/mlplaylistmedia.hpp
- modules/gui/qt/medialibrary/mlplaylistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistmodel.hpp
- modules/gui/qt/medialibrary/mlrecentsvideomodel.cpp
- modules/gui/qt/medialibrary/mlvideo.cpp
- modules/gui/qt/medialibrary/mlvideo.hpp
- modules/gui/qt/medialibrary/mlvideomodel.cpp
- modules/gui/qt/medialibrary/mlvideomodel.hpp
- modules/gui/qt/medialibrary/qml/MediaGroupList.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoGridItem.qml
- + modules/gui/qt/pixmaps/new_indicator.svg
- modules/gui/qt/style/VLCStyle.qml
- modules/gui/qt/vlc.qrc
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -573,6 +573,7 @@ libqt_plugin_la_RES = \
gui/qt/pixmaps/play.svg \
gui/qt/pixmaps/play_button.svg \
gui/qt/pixmaps/play_shadow.png \
+ gui/qt/pixmaps/new_indicator.svg \
gui/qt/pixmaps/playlist/add.svg \
gui/qt/pixmaps/playlist/playlist.svg \
gui/qt/pixmaps/playlist/remove.svg \
=====================================
modules/gui/qt/medialibrary/mlgrouplistmodel.cpp
=====================================
@@ -77,6 +77,7 @@ QHash<int, QByteArray> MLGroupListModel::roleNames() const /* override */
{ GROUP_DATE, "date" },
{ GROUP_COUNT, "count" },
// NOTE: Media specific.
+ { GROUP_IS_NEW, "isNew" },
{ GROUP_TITLE, "title" },
{ GROUP_RESOLUTION, "resolution_name" },
{ GROUP_CHANNEL, "channel" },
@@ -154,6 +155,8 @@ QVariant MLGroupListModel::data(const QModelIndex & index, int role) const /* ov
case GROUP_COUNT:
return 1;
// NOTE: Media specific.
+ case GROUP_IS_NEW:
+ return QVariant::fromValue(video->isNew());
case GROUP_TITLE:
return QVariant::fromValue(video->getTitle());
case GROUP_RESOLUTION:
=====================================
modules/gui/qt/medialibrary/mlgrouplistmodel.hpp
=====================================
@@ -42,6 +42,7 @@ public:
GROUP_DATE,
GROUP_COUNT,
// NOTE: Media specific.
+ GROUP_IS_NEW,
GROUP_TITLE,
GROUP_RESOLUTION,
GROUP_CHANNEL,
=====================================
modules/gui/qt/medialibrary/mlplaylistmedia.cpp
=====================================
@@ -106,6 +106,11 @@ MLPlaylistMedia::MLPlaylistMedia(vlc_medialibrary_t * ml, const vlc_ml_media_t *
// Interface
//-------------------------------------------------------------------------------------------------
+bool MLPlaylistMedia::isNew() const
+{
+ return (m_playCount == 1 && m_progress <= 0);
+}
+
QString MLPlaylistMedia::getTitle() const
{
return m_title;
=====================================
modules/gui/qt/medialibrary/mlplaylistmedia.hpp
=====================================
@@ -39,6 +39,8 @@ public:
MLPlaylistMedia(vlc_medialibrary_t * ml, const vlc_ml_media_t * data);
public: // Interface
+ bool isNew() const;
+
QString getTitle() const;
QString getThumbnail();
=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.cpp
=====================================
@@ -173,6 +173,7 @@ QHash<int, QByteArray> MLPlaylistModel::roleNames() const /* override */
return
{
{ MEDIA_ID, "id" },
+ { MEDIA_IS_NEW, "isNew" },
{ MEDIA_TITLE, "title" },
{ MEDIA_THUMBNAIL, "thumbnail" },
{ MEDIA_DURATION, "duration" },
@@ -199,6 +200,8 @@ QVariant MLPlaylistModel::data(const QModelIndex & index, int role) const /* ove
{
case MEDIA_ID:
return QVariant::fromValue(media->getId());
+ case MEDIA_IS_NEW:
+ return QVariant::fromValue(media->isNew());
case MEDIA_TITLE:
return QVariant::fromValue(media->getTitle());
case MEDIA_THUMBNAIL:
=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.hpp
=====================================
@@ -30,6 +30,7 @@ public:
enum Role
{
MEDIA_ID = Qt::UserRole + 1,
+ MEDIA_IS_NEW,
MEDIA_TITLE,
MEDIA_THUMBNAIL,
MEDIA_DURATION,
=====================================
modules/gui/qt/medialibrary/mlrecentsvideomodel.cpp
=====================================
@@ -22,6 +22,7 @@ namespace {
enum Role {
VIDEO_ID = Qt::UserRole + 1,
+ VIDEO_IS_NEW,
VIDEO_TITLE,
VIDEO_THUMBNAIL,
VIDEO_DURATION,
@@ -50,6 +51,8 @@ QVariant MLRecentsVideoModel::data( const QModelIndex& index , int role ) const
{
case VIDEO_ID:
return QVariant::fromValue( video->getId() );
+ case VIDEO_IS_NEW:
+ return QVariant::fromValue( video->isNew() );
case VIDEO_TITLE:
return QVariant::fromValue( video->getTitle() );
case VIDEO_THUMBNAIL:
@@ -79,6 +82,7 @@ QHash<int, QByteArray> MLRecentsVideoModel::roleNames() const
{
return {
{ VIDEO_ID, "id" },
+ { VIDEO_IS_NEW, "isNew" },
{ VIDEO_TITLE, "title" },
{ VIDEO_THUMBNAIL, "thumbnail" },
{ VIDEO_DURATION, "duration" },
=====================================
modules/gui/qt/medialibrary/mlvideo.cpp
=====================================
@@ -163,6 +163,11 @@ void MLVideo::onMlEvent( const vlc_ml_event_t* event )
vlc_ml_event_unregister_from_callback( m_ml, m_ml_event_handle.release() );
}
+bool MLVideo::isNew() const
+{
+ return (m_playCount == 1 && m_progress <= 0);
+}
+
QString MLVideo::getFileName() const
{
return m_fileName;
=====================================
modules/gui/qt/medialibrary/mlvideo.hpp
=====================================
@@ -90,6 +90,7 @@ class MLVideo : public MLItem
public:
MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data);
+ bool isNew() const;
QString getFileName() const;
QString getTitle() const;
QString getThumbnail();
=====================================
modules/gui/qt/medialibrary/mlvideomodel.cpp
=====================================
@@ -52,6 +52,8 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
{
case VIDEO_ID:
return QVariant::fromValue( video->getId() );
+ case VIDEO_IS_NEW:
+ return QVariant::fromValue( video->isNew() );
case VIDEO_FILENAME:
return QVariant::fromValue( video->getFileName() );
case VIDEO_TITLE:
@@ -88,6 +90,7 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
{
return {
{ VIDEO_ID, "id" },
+ { VIDEO_IS_NEW, "isNew" },
{ VIDEO_FILENAME, "fileName" },
{ VIDEO_TITLE, "title" },
{ VIDEO_THUMBNAIL, "thumbnail" },
=====================================
modules/gui/qt/medialibrary/mlvideomodel.hpp
=====================================
@@ -38,6 +38,7 @@ class MLVideoModel : public MLBaseModel
public:
enum Role {
VIDEO_ID = Qt::UserRole + 1,
+ VIDEO_IS_NEW,
VIDEO_FILENAME,
VIDEO_TITLE,
VIDEO_THUMBNAIL,
=====================================
modules/gui/qt/medialibrary/qml/MediaGroupList.qml
=====================================
@@ -285,7 +285,8 @@ FocusScope {
labels: _getLabels(model, i18n.qtr("%1 Videos"))
// NOTE: We don't want to show the indicator for a group.
- showNewIndicator: (model.count === 1)
+ // FIXME: Sometimes MLBaseModel::getDataAt returns {} so we use 'isNew === true'.
+ showNewIndicator: (model.count === 1 && model.isNew === true)
dragItem: dragItemGroup
=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -284,9 +284,6 @@ FocusScope {
labels: (model.count > 1) ? [ i18n.qtr("%1 Tracks").arg(_getCount(model)) ]
: [ i18n.qtr("%1 Track") .arg(_getCount(model)) ]
- // NOTE: We don't want to show the new indicator for a playlist.
- showNewIndicator: false
-
dragItem: dragItemPlaylist
selectedUnderlay : shadows.selected
=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -270,7 +270,11 @@ FocusScope {
&&
gridView.expandIndex !== gridItem.index) ? 0.7 : 1
+ // FIXME: Sometimes MLBaseModel::getDataAt returns {} so we use 'isNew === true'.
+ showNewIndicator: (model.isNew === true)
+
dragItem: root.dragItem
+
unselectedUnderlay: shadows.unselected
selectedUnderlay: shadows.selected
=====================================
modules/gui/qt/medialibrary/qml/VideoGridItem.qml
=====================================
@@ -26,8 +26,7 @@ import "qrc:///style/"
Widgets.GridItem {
id: root
- property bool showNewIndicator: true
- property int newIndicatorMedian: root.highlighted ? VLCStyle.icon_small : VLCStyle.icon_xsmall
+ property alias showNewIndicator: image.visible
property var labels: [
model.resolution_name || "",
@@ -80,29 +79,18 @@ Widgets.GridItem {
}
onPlayClicked: root.play()
-
- Behavior on newIndicatorMedian {
- NumberAnimation {
- duration: VLCStyle.duration_normal
- easing.type: Easing.InOutSine
- }
- }
- Item {
- clip: true
- x: parent.width - width
- y: 0
- width: 2 * root.newIndicatorMedian
- height: 2 * root.newIndicatorMedian
- visible: root.showNewIndicator && model.progress <= 0
-
- Rectangle {
- x: parent.width - root.newIndicatorMedian
- y: - root.newIndicatorMedian
- width: 2 * root.newIndicatorMedian
- height: 2 * root.newIndicatorMedian
- color: VLCStyle.colors.accent
- rotation: 45
- }
+ Image {
+ id: image
+
+ anchors.right: parent.right
+ anchors.top: parent.top
+
+ width: VLCStyle.gridItem_newIndicator
+ height: width
+
+ visible: false
+
+ source: VLCStyle.newIndicator
}
}
=====================================
modules/gui/qt/pixmaps/new_indicator.svg
=====================================
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="8" height="8" viewBox="0 0 8 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <path d="M0,0 L6,0 C7.104569,-2.02906125e-16 8,0.8954305 8,2 L8,8 L8,8 L0,0 Z" fill="#FF610A"/>
+</svg>
=====================================
modules/gui/qt/style/VLCStyle.qml
=====================================
@@ -192,6 +192,8 @@ QtObject {
readonly property int gridItemSelectedBorder: dp(8, scale)
+ readonly property int gridItem_newIndicator: dp(8, scale)
+
readonly property int column_width: dp(114, scale)
readonly property int column_margin_width: dp(32, scale)
@@ -265,6 +267,9 @@ QtObject {
// Play shadow
readonly property url playShadow: "qrc:///play_shadow.png";
+ // New indicator
+ readonly property url newIndicator: "qrc:///new_indicator.svg";
+
// Player controlbar
readonly property int maxControlbarControlHeight: dp(64, scale)
=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -121,6 +121,7 @@
<file alias="theme_daynight.svg">pixmaps/theme_daynight.svg</file>
<file alias="theme_light.svg">pixmaps/theme_light.svg</file>
<file alias="play_shadow.png">pixmaps/play_shadow.png</file>
+ <file alias="new_indicator.svg">pixmaps/new_indicator.svg</file>
</qresource>
<qresource prefix="/prefsmenu">
<file alias="cone_audio_64.png">pixmaps/prefs/spref_cone_Audio_64.png</file>
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6fd238d9c9b7f640cd862b0ebca543ad8fb642e2...dddbaa6deb2457f35ef1fc1d68d1ca3d1f9abd62
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6fd238d9c9b7f640cd862b0ebca543ad8fb642e2...dddbaa6deb2457f35ef1fc1d68d1ca3d1f9abd62
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list