[vlc-commits] [Git][videolan/vlc][master] 7 commits: qt: make `m_transactionPending` a property in MLPlaylistListmodel

Steve Lhomme (@robUx4) gitlab at videolan.org
Sun May 19 06:08:24 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
64c4c817 by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qt: make `m_transactionPending` a property in MLPlaylistListmodel

- - - - -
16102d09 by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qt: make `m_transactionPending` a property in MLPlaylistModel

- - - - -
34c999e0 by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qml: do not accept drop event in PlaylistMedia when `m_transactionPending` is set

- - - - -
3bd2b082 by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qml: do not accept drop event in PlaylistMediaList when `m_transactionPending` is set

- - - - -
198eeaf9 by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qml: introduce ProgressIndicator

A convenient control, designed to be
used as a progress indicator.

Contains a text alongside a busy
indicator, with round rectangular
semi-translucent background.

- - - - -
c799a60e by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qml: use ProgressIndicator in PlaylistMediaList

- - - - -
743369dd by Fatih Uzunoglu at 2024-05-19T05:48:15+00:00
qml: use ProgressIndicator in PlaylistMediaDisplay

- - - - -


10 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistlistmodel.hpp
- modules/gui/qt/medialibrary/mlplaylistmodel.cpp
- modules/gui/qt/medialibrary/mlplaylistmodel.hpp
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/qml.qrc
- + modules/gui/qt/widgets/qml/ProgressIndicator.qml


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -1128,7 +1128,8 @@ libqt_plugin_la_QML = \
 	widgets/qml/FadingEdgeForListView.qml \
 	widgets/qml/PopupIconToolButton.qml \
         widgets/qml/PartialEffect.qml \
-        widgets/qml/ViewHeader.qml
+        widgets/qml/ViewHeader.qml \
+        widgets/qml/ProgressIndicator.qml
 
 
 # Shaders:


=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.cpp
=====================================
@@ -120,7 +120,7 @@ void appendMediaIntoPlaylist(vlc_medialibrary_t* ml, int64_t playlistId, const s
     if (unlikely(m_transactionPending))
         return;
 
-    m_transactionPending = true;
+    setTransactionPending(true);
 
     m_mediaLib->runOnMLThread(this,
     //ML thread
@@ -178,7 +178,7 @@ void appendMediaIntoPlaylist(vlc_medialibrary_t* ml, int64_t playlistId, const s
     if (unlikely(m_transactionPending))
         return false;
 
-    m_transactionPending = true;
+    setTransactionPending(true);
 
     std::vector<MLItemId> itemList;
     for (const QVariant & id : ids)
@@ -342,12 +342,26 @@ std::unique_ptr<MLListCacheLoader> MLPlaylistListModel::createMLLoader() const /
 
 void MLPlaylistListModel::endTransaction()
 {
-    m_transactionPending = false;
-    if (m_resetAfterTransaction)
+    setTransactionPending(false);
+}
+
+void MLPlaylistListModel::setTransactionPending(const bool value)
+{
+    if (m_transactionPending == value)
+        return;
+
+    m_transactionPending = value;
+
+    if (!value)
     {
-        m_resetAfterTransaction = false;
-        emit resetRequested();
+        if (m_resetAfterTransaction)
+        {
+            m_resetAfterTransaction = false;
+            emit resetRequested();
+        }
     }
+
+    emit transactionPendingChanged(value);
 }
 
 QString MLPlaylistListModel::getCover(MLPlaylist * playlist) const


=====================================
modules/gui/qt/medialibrary/mlplaylistlistmodel.hpp
=====================================
@@ -58,6 +58,8 @@ public:
 
     Q_PROPERTY(PlaylistType playlistType READ playlistType WRITE setPlaylistType NOTIFY playlistTypeChanged FINAL)
 
+    Q_PROPERTY(bool transactionPending READ transactionPending NOTIFY transactionPendingChanged FINAL)
+
 public:
     explicit MLPlaylistListModel(QObject * parent = nullptr);
 
@@ -72,6 +74,8 @@ public: // Interface
 
     Q_INVOKABLE MLItemId getItemId(int index) const;
 
+    bool transactionPending() const { return m_transactionPending; };
+
 public: // QAbstractItemModel implementation
     QHash<int, QByteArray> roleNames() const override;
 
@@ -91,6 +95,8 @@ private: // Functions
 
     void endTransaction();
 
+    void setTransactionPending(bool);
+
 private: // MLBaseModel implementation
     void onVlcMlEvent(const MLEvent & event) override;
 
@@ -99,6 +105,7 @@ signals:
     void coverDefaultChanged();
     void coverPrefixChanged ();
     void playlistTypeChanged();
+    void transactionPendingChanged(bool);
 
 public: // Properties
     QSize coverSize() const;


=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.cpp
=====================================
@@ -68,7 +68,7 @@ static const QHash<QByteArray, vlc_ml_sorting_criteria_t> criterias =
 
     QVector<vlc::playlist::Media> medias = vlc::playlist::toMediaList(items);
 
-    m_transactionPending = true;
+    setTransactionPending(true);
 
     m_mediaLib->runOnMLThread(this,
     //ML thread
@@ -227,7 +227,7 @@ void MLPlaylistModel::moveImpl(int64_t playlistId, HighLowRanges&& ranges)
     highLowRanges.lowRangeIt = highLowRanges.lowRanges.size();
     highLowRanges.highRangeIt = 0;
 
-    m_transactionPending = true;
+    setTransactionPending(true);
 
     moveImpl(id, std::move(highLowRanges));
 }
@@ -275,19 +275,32 @@ void MLPlaylistModel::removeImpl(int64_t playlistId, const std::vector<std::pair
     auto rangeList = getSortedRowsRanges(indexes, false);
     assert(rangeList.size() > 0);
 
-    m_transactionPending = true;
+    setTransactionPending(true);
     removeImpl(id, std::move(rangeList), 0);
 }
 
 void MLPlaylistModel::endTransaction()
 {
-    m_transactionPending = false;
-    if (m_resetAfterTransaction)
+    setTransactionPending(false);
+}
+
+void MLPlaylistModel::setTransactionPending(bool value)
+{
+    if (m_transactionPending == value)
+        return;
+
+    m_transactionPending = value;
+
+    if (!value)
     {
-        m_resetAfterTransaction = false;
-        emit resetRequested();
+        if (m_resetAfterTransaction)
+        {
+            m_resetAfterTransaction = false;
+            emit resetRequested();
+        }
     }
 
+    emit transactionPendingChanged();
 }
 
 //-------------------------------------------------------------------------------------------------


=====================================
modules/gui/qt/medialibrary/mlplaylistmodel.hpp
=====================================
@@ -26,6 +26,8 @@ class MLPlaylistModel : public MLBaseModel
 {
     Q_OBJECT
 
+    Q_PROPERTY(bool transactionPending READ transactionPending NOTIFY transactionPendingChanged FINAL)
+
 public:
     enum Role
     {
@@ -55,9 +57,14 @@ public: // Interface
 
     Q_INVOKABLE void remove(const QModelIndexList & indexes);
 
+    bool transactionPending() const { return m_transactionPending; };
+
 public: // QAbstractItemModel implementation
     QHash<int, QByteArray> roleNames() const override;
 
+signals:
+    void transactionPendingChanged();
+
 protected: // MLBaseModel implementation
     QVariant itemRoleData(MLItem *item, int role = Qt::DisplayRole) const override;
 
@@ -95,6 +102,8 @@ private: // Functions
 
     void endTransaction();
 
+    void setTransactionPending(bool);
+
     void generateThumbnail(const MLItemId& itemid) const;
 
     bool m_transactionPending = false;


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -127,6 +127,12 @@ MainInterface.MainTableView {
 
 
     onDropEntered: (delegate, index, drag, before) => {
+        if (!root.model || root.model.transactionPending)
+        {
+            drag.accepted = false
+            return
+        }
+
         root._dropUpdatePosition(drag, index, delegate, before)
     }
 


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -129,6 +129,38 @@ FocusScope {
 
             resetFocus();
         }
+
+        onTransactionPendingChanged: {
+            if (transactionPending)
+                visibilityTimer.start()
+            else {
+                visibilityTimer.stop()
+                progressIndicator.visible = false
+            }
+        }
+    }
+
+    Widgets.ProgressIndicator {
+        id: progressIndicator
+        anchors.bottom: parent.bottom
+        anchors.right: parent.right
+        anchors.margins: VLCStyle.margin_small
+
+        visible: false
+
+        z: 99
+
+        text: qsTr("Processing...")
+
+        Timer {
+            id: visibilityTimer
+
+            interval: VLCStyle.duration_humanMoment
+
+            onTriggered: {
+                progressIndicator.visible = true
+            }
+        }
     }
 
     Widgets.MLDragItem {


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -118,6 +118,15 @@ MainInterface.MainViewLoader {
         coverDefault: root._placeHolder
 
         coverPrefix: (isMusic) ? "playlist-music" : "playlist-video"
+
+        onTransactionPendingChanged: {
+            if (transactionPending)
+                visibilityTimer.start()
+            else {
+                visibilityTimer.stop()
+                progressIndicator.visible = false
+            }
+        }
     }
 
     function _actionAtIndex() {
@@ -139,6 +148,12 @@ MainInterface.MainViewLoader {
     }
 
     function _adjustDragAccepted(drag) {
+        if (!root.model || root.model.transactionPending)
+        {
+            drag.accepted = false
+            return
+        }
+
         if (drag.source !== dragItemPlaylist && Helpers.isValidInstanceOf(drag.source, Widgets.DragItem))
             drag.accepted = true
         else if (drag.hasUrls)
@@ -188,6 +203,29 @@ MainInterface.MainViewLoader {
         }
     }
 
+    Widgets.ProgressIndicator {
+        id: progressIndicator
+        anchors.bottom: parent.bottom
+        anchors.right: parent.right
+        anchors.margins: VLCStyle.margin_small
+
+        visible: false
+
+        z: 99
+
+        text: qsTr("Processing...")
+
+        Timer {
+            id: visibilityTimer
+
+            interval: VLCStyle.duration_humanMoment
+
+            onTriggered: {
+                progressIndicator.visible = true
+            }
+        }
+    }
+
     Widgets.MLDragItem {
         id: dragItemPlaylist
 


=====================================
modules/gui/qt/qml.qrc
=====================================
@@ -99,6 +99,7 @@
         <file alias="PopupIconToolButton.qml">widgets/qml/PopupIconToolButton.qml</file>
         <file alias="PartialEffect.qml">widgets/qml/PartialEffect.qml</file>
         <file alias="ViewHeader.qml">widgets/qml/ViewHeader.qml</file>
+        <file alias="ProgressIndicator.qml">widgets/qml/ProgressIndicator.qml</file>
     </qresource>
     <qresource prefix="/network">
         <file alias="AddressbarButton.qml">network/qml/AddressbarButton.qml</file>


=====================================
modules/gui/qt/widgets/qml/ProgressIndicator.qml
=====================================
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (C) 2024 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.Controls
+
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+
+Control {
+    id: root
+
+    padding: VLCStyle.margin_xxxsmall
+    font.pixelSize: VLCStyle.fontSize_normal
+
+    hoverEnabled: false
+
+    required property string text
+
+    readonly property ColorContext colorContext: ColorContext {
+        id: theme
+        colorSet: ColorContext.Badge
+    }
+
+    background: Rectangle {
+        border.color: theme.border
+        radius: VLCStyle.dp(6, VLCStyle.scale)
+        color: theme.bg.primary
+        opacity: 0.8
+    }
+
+    contentItem: Row {
+        spacing: VLCStyle.margin_xxxsmall
+
+        Text {
+            anchors.verticalCenter: parent.verticalCenter
+            text: root.text
+            font: root.font
+
+            color: theme.fg.primary
+
+            visible: (text.length > 0)
+        }
+
+        BusyIndicator {
+            palette.dark: theme.fg.primary
+
+            anchors.verticalCenter: parent.verticalCenter
+        }
+    }
+}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0346060dd5c80ddb4286d2a9fd25c76aacc2a9c5...743369ddc25aad2fa4fecde0b0616d11df38cacc

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0346060dd5c80ddb4286d2a9fd25c76aacc2a9c5...743369ddc25aad2fa4fecde0b0616d11df38cacc
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