[vlc-commits] [Git][videolan/vlc][master] 4 commits: qml: remove unneeded call in MusicGenres

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Thu Jan 12 09:54:56 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
da7da41d by Fatih Uzunoglu at 2023-01-12T09:41:31+00:00
qml: remove unneeded call in MusicGenres

this fixes a potential crash on load

- - - - -
89fe5f60 by Fatih Uzunoglu at 2023-01-12T09:41:31+00:00
qml: disable replaceEnter & replaceExit transitions in StackViewExt

- - - - -
d9ee0c5d by Fatih Uzunoglu at 2023-01-12T09:41:31+00:00
qt: add hasContent property and mlChanged signal to MLBaseModel

- - - - -
8294dbc3 by Fatih Uzunoglu at 2023-01-12T09:41:31+00:00
qml: don't show EmptyLabelButtons when there is no content

- - - - -


10 changed files:

- modules/gui/qt/medialibrary/mlbasemodel.cpp
- modules/gui/qt/medialibrary/mlbasemodel.hpp
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/widgets/qml/StackViewExt.qml


Changes:

=====================================
modules/gui/qt/medialibrary/mlbasemodel.cpp
=====================================
@@ -39,6 +39,9 @@ MLBaseModel::MLBaseModel(QObject *parent)
         })
 {
     connect( this, &MLBaseModel::resetRequested, this, &MLBaseModel::onResetRequested );
+
+    connect( this, &MLBaseModel::mlChanged, this, &MLBaseModel::hasContentChanged );
+    connect( this, &MLBaseModel::countChanged, this, &MLBaseModel::hasContentChanged );
 }
 
 /* For std::unique_ptr, see Effective Modern C++, Item 22 */
@@ -276,9 +279,14 @@ MediaLib* MLBaseModel::ml() const
 void MLBaseModel::setMl(MediaLib* medialib)
 {
     assert(medialib);
+
+    if (m_mediaLib == medialib)
+        return;
+
     m_mediaLib = medialib;
     if ( m_ml_event_handle == nullptr )
         m_ml_event_handle.reset( m_mediaLib->registerEventListener(onVlcMlEvent, this ) );
+    mlChanged();
 }
 
 const QString& MLBaseModel::searchPattern() const
@@ -615,3 +623,8 @@ MLQueryParams MLBaseModel::BaseLoader::getParams(size_t index, size_t count) con
 {
     return { m_searchPattern.toUtf8(), m_sort, m_sort_desc, index, count };
 }
+
+bool MLBaseModel::hasContent() const
+{
+    return m_mediaLib && (getCount() > 0);
+}


=====================================
modules/gui/qt/medialibrary/mlbasemodel.hpp
=====================================
@@ -46,7 +46,7 @@ class MLBaseModel : public QAbstractListModel
     Q_PROPERTY(MLItemId parentId READ parentId WRITE setParentId NOTIFY parentIdChanged
                RESET unsetParentId FINAL)
 
-    Q_PROPERTY(MediaLib * ml READ ml WRITE setMl FINAL)
+    Q_PROPERTY(MediaLib * ml READ ml WRITE setMl NOTIFY mlChanged FINAL)
 
     Q_PROPERTY(QString searchPattern READ searchPattern WRITE setSearchPattern FINAL)
 
@@ -57,6 +57,8 @@ class MLBaseModel : public QAbstractListModel
 
     Q_PROPERTY(unsigned int count READ getCount NOTIFY countChanged FINAL)
 
+    Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged FINAL)
+
 public:
     explicit MLBaseModel(QObject *parent = nullptr);
 
@@ -81,10 +83,12 @@ public: // Interface
 
 signals:
     void parentIdChanged();
+    void mlChanged();
     void resetRequested();
     void sortOrderChanged();
     void sortCriteriaChanged();
     void countChanged(unsigned int) const;
+    void hasContentChanged();
 
 protected slots:
     void onResetRequested();
@@ -170,6 +174,8 @@ public:
     int rowCount(const QModelIndex &parent = {}) const override;
     virtual unsigned int getCount() const;
 
+    bool hasContent() const;
+
 private:
     void onCacheDataChanged(int first, int last);
     void onCacheBeginInsertRows(int first, int last);


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -298,7 +298,7 @@ FocusScope {
 
     EmptyLabelButton {
         anchors.fill: parent
-        visible: albumModelId.count === 0
+        visible: albumModelId.hasContent && albumModelId.count === 0
         focus: visible
         text: I18n.qtr("No albums found\nPlease try adding sources, by going to the Browse tab")
         Navigation.parentItem: root


=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -243,8 +243,8 @@ FocusScope {
 
     EmptyLabelButton {
         anchors.fill: parent
-        visible: artistModel.count === 0
-        focus: artistModel.count === 0
+        visible: artistModel.hasContent && artistModel.count === 0
+        focus: visible
         text: I18n.qtr("No artists found\nPlease try adding sources, by going to the Browse tab")
         Navigation.parentItem: root
         cover: VLCStyle.noArtArtistCover


=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -215,7 +215,7 @@ FocusScope {
 
     EmptyLabelButton {
         anchors.fill: parent
-        visible: artistModel.count === 0
+        visible: artistModel.hasContent && artistModel.count === 0
         focus: visible
         text: I18n.qtr("No artists found\nPlease try adding sources, by going to the Browse tab")
         Navigation.parentItem: root


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -44,8 +44,6 @@ FocusScope {
 
     onInitialIndexChanged:  resetFocus()
 
-    Component.onCompleted: loadView()
-
     function loadView() {
         if (MainCtx.gridView) {
             view.replace(gridComponent)
@@ -313,8 +311,8 @@ FocusScope {
 
     EmptyLabelButton {
         anchors.fill: parent
-        visible: genreModel.count === 0
-        focus: genreModel.count === 0
+        visible: genreModel.hasContent && genreModel.count === 0
+        focus: visible
         text: I18n.qtr("No genres found\nPlease try adding sources, by going to the Browse tab")
         Navigation.parentItem: root
         cover: VLCStyle.noArtAlbumCover


=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -67,8 +67,8 @@ FocusScope {
 
     EmptyLabelButton {
         anchors.fill: parent
-        visible: tracklistdisplay_id.model.count === 0
-        focus: tracklistdisplay_id.model.count === 0
+        visible: tracklistdisplay_id.model.hasContent && tracklistdisplay_id.model.count === 0
+        focus: visible
         text: I18n.qtr("No tracks found\nPlease try adding sources, by going to the Browse tab")
         Navigation.parentItem: root
         cover: VLCStyle.noArtAlbumCover


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -215,7 +215,7 @@ FocusScope {
     EmptyLabelButton {
         anchors.fill: parent
 
-        visible: (model.count === 0)
+        visible: model.hasContent && (model.count === 0)
 
         focus: visible
 


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -372,7 +372,7 @@ FocusScope {
         coverWidth : VLCStyle.dp(182, VLCStyle.scale)
         coverHeight: VLCStyle.dp(114, VLCStyle.scale)
 
-        visible: (model.count === 0)
+        visible: model.hasContent && (model.count === 0)
 
         focus: visible
 


=====================================
modules/gui/qt/widgets/qml/StackViewExt.qml
=====================================
@@ -28,25 +28,9 @@ StackView {
 
     property string _currentView: ""
 
-    replaceEnter: Transition {
-        PropertyAnimation {
-            property: "opacity"
-            from: 0.0
-            to: 1.0
-            duration: VLCStyle.duration_long
-            easing.type: Easing.InSine
-        }
-    }
+    replaceEnter: null
 
-    replaceExit: Transition {
-        PropertyAnimation {
-            property: "opacity"
-            from: 1.0
-            to: 0.0
-            duration: VLCStyle.duration_long
-            easing.type: Easing.OutSine
-        }
-    }
+    replaceExit: null
 
     /**
      * viewModel: model with the definition of the available view



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/836be4e3416646e6f38d497a7dfedbbfa906bdb8...8294dbc391cce10c8bb04fe3380bdb9bca556d3e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/836be4e3416646e6f38d497a7dfedbbfa906bdb8...8294dbc391cce10c8bb04fe3380bdb9bca556d3e
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