[vlc-devel] [RFC 79/82] qml: provide a progress bar to indicate medialibrary scan progress

Pierre Lamot pierre at videolabs.io
Fri Feb 1 14:02:23 CET 2019


---
 modules/gui/qt/Makefile.am                   |  1 +
 modules/gui/qt/qml/utils/ScanProgressBar.qml | 54 ++++++++++++++++++++
 modules/gui/qt/vlc.qrc                       |  1 +
 3 files changed, 56 insertions(+)
 create mode 100644 modules/gui/qt/qml/utils/ScanProgressBar.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 9dd1840baa..8c563febed 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -551,6 +551,7 @@ libqt_plugin_la_RES = \
 	gui/qt/qml/utils/SelectableDelegateModel.qml \
 	gui/qt/qml/utils/ComboBoxExt.qml \
 	gui/qt/qml/utils/StackViewExt.qml \
+	gui/qt/qml/utils/ScanProgressBar.qml \
 	gui/qt/qml/menus/CheckableModelSubMenu.qml \
 	gui/qt/qml/menus/AudioMenu.qml \
 	gui/qt/qml/menus/HelpMenu.qml \
diff --git a/modules/gui/qt/qml/utils/ScanProgressBar.qml b/modules/gui/qt/qml/utils/ScanProgressBar.qml
new file mode 100644
index 0000000000..1e1bf1e22f
--- /dev/null
+++ b/modules/gui/qt/qml/utils/ScanProgressBar.qml
@@ -0,0 +1,54 @@
+/*****************************************************************************
+ * Copyright (C) 2019 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 2.11
+import QtQuick.Controls 2.4
+
+import "qrc:///style/"
+
+ProgressBar {
+    property int progressPercent: 0
+    property bool discoveryDone: true
+
+    Connections {
+        target: medialib
+        onProgressUpdated: {
+            progressPercent = percent;
+            if (discoveryDone)
+                progressText_id.text = percent + "%";
+        }
+        onDiscoveryProgress: {
+            progressText_id.text = entryPoint;
+        }
+        onDiscoveryStarted: discoveryDone = false
+        onDiscoveryCompleted: discoveryDone = true
+    }
+
+    visible: (progressPercent < 100) && (progressPercent != 0)
+    id: progressBar_id
+    from: 0
+    to: 100
+    height: progressText_id.height
+    anchors.topMargin: 10
+    anchors.bottomMargin: 10
+    value: progressPercent
+    Text {
+        id: progressText_id
+        color: VLCStyle.colors.text
+        anchors.horizontalCenter: parent.horizontalCenter
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 0a2429d19a..22f9ff7a03 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -178,6 +178,7 @@
         <file alias="MenuExt.qml">qml/utils/MenuExt.qml</file>
         <file alias="MenuItemExt.qml">qml/utils/MenuItemExt.qml</file>
         <file alias="ExpandGridView.qml">qml/utils/ExpandGridView.qml</file>
+        <file alias="ScanProgressBar.qml">qml/utils/ScanProgressBar.qml</file>
     </qresource>
     <qresource prefix="/mediacenter">
         <file alias="MCMusicDisplay.qml">qml/mediacenter/MCMusicDisplay.qml</file>
-- 
2.19.1



More information about the vlc-devel mailing list