[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: use native separators for showing ml folders

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jul 10 15:24:15 UTC 2022



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


Commits:
bb6f707d by Prince Gupta at 2022-07-10T15:06:19+00:00
qt: use native separators for showing ml folders

- - - - -
99f59dcb by Prince Gupta at 2022-07-10T15:06:19+00:00
qt: fix selection dialog for ml folders

use correct constructor of QUrl

- - - - -


5 changed files:

- modules/gui/qt/dialogs/preferences/simple_preferences.cpp
- modules/gui/qt/medialibrary/mlfoldersmodel.cpp
- modules/gui/qt/medialibrary/mlhelper.cpp
- modules/gui/qt/medialibrary/mlhelper.hpp
- modules/gui/qt/widgets/native/mlfolderseditor.cpp


Changes:

=====================================
modules/gui/qt/dialogs/preferences/simple_preferences.cpp
=====================================
@@ -1644,16 +1644,20 @@ void SPrefsPanel::saveAsso()
 #endif /* _WIN32 */
 
 void SPrefsPanel::MLaddNewFolder() {
-    QUrl newEntryPoint = QFileDialog::getExistingDirectoryUrl( this , qtr("Please choose an entry point folder") ,
-                                             QUrl( QDir::homePath( ) ) );
+    const QUrl homeDirectory = QUrl::fromLocalFile(QDir::homePath());
+    QUrl newEntryPoint = QFileDialog::getExistingDirectoryUrl( this
+                                                              , qtr("Please choose an entry point folder")
+                                                              , homeDirectory );
 
     if(! newEntryPoint.isEmpty() )
         mlFoldersEditor->add( newEntryPoint );
 }
 
 void SPrefsPanel::MLBanFolder( ) {
-    QUrl newEntryPoint = QFileDialog::getExistingDirectoryUrl( this , qtr("Please choose an entry point folder") ,
-                                             QUrl( QDir::homePath( ) ) );
+    const QUrl homeDirectory = QUrl::fromLocalFile(QDir::homePath());
+    QUrl newEntryPoint = QFileDialog::getExistingDirectoryUrl( this
+                                                              , qtr("Please choose an entry point folder")
+                                                              , homeDirectory );
 
     if(! newEntryPoint.isEmpty() )
         mlBannedFoldersEditor->add( newEntryPoint );


=====================================
modules/gui/qt/medialibrary/mlfoldersmodel.cpp
=====================================
@@ -81,7 +81,7 @@ QVariant MLFoldersBaseModel::data( const QModelIndex &index ,
             QUrl url = QUrl::fromUserInput(m_mrls[index.row()].mrl);
             if (!url.isValid())
                 return {};
-            return QVariant::fromValue( url.toDisplayString( QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments ) );
+            return QVariant::fromValue(urlToDisplayString(url));
         }
         default :
             return {};


=====================================
modules/gui/qt/medialibrary/mlhelper.cpp
=====================================
@@ -21,6 +21,8 @@
 // MediaLibrary includes
 #include "mlbasemodel.hpp"
 
+#include <QDir>
+
 QString MsToString( int64_t time , bool doShort )
 {
     if (time < 0)
@@ -51,3 +53,12 @@ QString toValidLocalFile(const char *mrl)
     QUrl url(mrl);
     return url.isLocalFile() ? url.toLocalFile() : QString {};
 }
+
+QString urlToDisplayString(const QUrl &url)
+{
+    const QString displayString = url.toDisplayString(QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments);
+    if (url.isLocalFile())
+        return QDir::toNativeSeparators(displayString);
+
+    return displayString;
+}


=====================================
modules/gui/qt/medialibrary/mlhelper.hpp
=====================================
@@ -32,6 +32,7 @@
 class MLBaseModel;
 class MLItemId;
 class CoverGenerator;
+class QUrl;
 
 template<typename T>
 class MLDeleter
@@ -100,4 +101,6 @@ void thumbnailCopy(const MLListRange<T> &list, O dst, const int max)
 
 QString MsToString( int64_t time, bool doShort = false );
 
+QString urlToDisplayString(const QUrl &url);
+
 #endif // MLHELPER_HPP


=====================================
modules/gui/qt/widgets/native/mlfolderseditor.cpp
=====================================
@@ -26,6 +26,7 @@
 #endif
 
 #include "mlfolderseditor.hpp"
+#include "medialibrary/mlhelper.hpp"
 
 #include <QBoxLayout>
 #include <QHeaderView>
@@ -79,7 +80,7 @@ void MLFoldersEditor::commit()
 
 void MLFoldersEditor::handleOpFailure(int operation, const QUrl &url)
 {
-    const QString entryPoint = url.toDisplayString( QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments );
+    const QString entryPoint = urlToDisplayString(url);
 
     QString msg;
     switch (operation)
@@ -122,7 +123,7 @@ void MLFoldersEditor::newRow(const QUrl &mrl)
     const int row = rowCount();
     setRowCount(row + 1);
 
-    const QString text = mrl.toDisplayString( QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments );
+    const QString text = urlToDisplayString(mrl);
     auto col1 = new QTableWidgetItem( text );
     col1->setData(Qt::UserRole, mrl);
     col1->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/456bed4a6884456500bf6d54b60d2828519f4872...99f59dcbb9e09616ec25e22843f1e411d6224385

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/456bed4a6884456500bf6d54b60d2828519f4872...99f59dcbb9e09616ec25e22843f1e411d6224385
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