vlc | branch: master | Pierre Lamot <pie...@videolabs.io> | Fri Jan 19 18:10:22 2018 +0100| [6b36c463f13cb3dea55bccbb8482e28fb6227e18] | committer: Jean-Baptiste Kempf
qt: keep files with local file representation and store them as URL in open dialog - fields are now, read only and can be only edited throught the add/browse buttons Signed-off-by: Jean-Baptiste Kempf <j...@videolan.org> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b36c463f13cb3dea55bccbb8482e28fb6227e18 --- modules/gui/qt/components/open_panels.cpp | 40 +++++++++++++++++-------------- modules/gui/qt/components/open_panels.hpp | 2 ++ modules/gui/qt/ui/open_file.ui | 8 +++++-- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/modules/gui/qt/components/open_panels.cpp b/modules/gui/qt/components/open_panels.cpp index 5902c51156..47ec13df10 100644 --- a/modules/gui/qt/components/open_panels.cpp +++ b/modules/gui/qt/components/open_panels.cpp @@ -211,6 +211,7 @@ void FileOpenPanel::dropEvent( QDropEvent *event ) ui.fileListWidg ); item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); + urlList << url; } } updateMRL(); @@ -223,9 +224,14 @@ void FileOpenPanel::browseFile() QStringList files = THEDP->showSimpleOpen( qtr( "Select one or multiple files" ) ); foreach( const QString &file, files ) { - QListWidgetItem *item = - new QListWidgetItem( toNativeSeparators( file ), ui.fileListWidg ); - item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); + QUrl url(file); + urlList << url; + QListWidgetItem *item = nullptr; + item = new QListWidgetItem( + toNativeSeparators( url.toDisplayString(QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments) ), + ui.fileListWidg + ); + item->setFlags( Qt::ItemIsEnabled ); ui.fileListWidg->addItem( item ); savedirpathFromFile( file ); } @@ -240,6 +246,7 @@ void FileOpenPanel::removeFile() { QListWidgetItem *temp = ui.fileListWidg->takeItem( i ); delete temp; + urlList.removeAt( i ); } updateMRL(); @@ -252,15 +259,12 @@ void FileOpenPanel::browseFileSub() QStringList urls = THEDP->showSimpleOpen( qtr("Open subtitle file"), EXT_FILTER_SUBTITLE, p_intf->p_sys->filepath ); - if( urls.isEmpty() ) return; - - // TODO Handle selection of more than one subtitles file - char *path = vlc_uri2path( qtu(urls[0]) ); - if( path == NULL ) + if( urls.isEmpty() ) { return; + } - ui.subInput->setText( qfu(path) ); - free( path ); + subUrl = QUrl(urls[0]); + ui.subInput->setText( subUrl.toDisplayString(QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments) ); updateMRL(); } @@ -272,11 +276,8 @@ void FileOpenPanel::updateMRL() /* File Listing */ if( dialogBox == NULL ) - for( int i = 0; i < ui.fileListWidg->count(); i++ ) - { - if( !ui.fileListWidg->item( i )->text().isEmpty() ) - fileList << toURI(ui.fileListWidg->item( i )->text()); - } + foreach( const QUrl& url, urlList ) + fileList << url.toEncoded(); else { QList<QUrl> urls = dialogBox->selectedUrls(); @@ -285,8 +286,8 @@ void FileOpenPanel::updateMRL() } /* Options */ - if( ui.subGroupBox->isChecked() && !ui.subInput->text().isEmpty() ) { - mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) ); + if( ui.subGroupBox->isChecked() && !subUrl.isEmpty() ) { + mrl.append( " :sub-file=" + colon_escape( subUrl.toEncoded() ) ); } emit methodChanged( "file-caching" ); @@ -299,6 +300,7 @@ void FileOpenPanel::accept() if( dialogBox ) p_intf->p_sys->filepath = dialogBox->directory().absolutePath(); ui.fileListWidg->clear(); + urlList.clear(); } /* Function called by Open Dialog when clicked on cancel */ @@ -306,12 +308,14 @@ void FileOpenPanel::clear() { ui.fileListWidg->clear(); ui.subInput->clear(); + urlList.clear(); + subUrl = QUrl(); } /* Update buttons depending on current selection */ void FileOpenPanel::updateButtons() { - bool b_has_files = ( ui.fileListWidg->count() > 0 ); + bool b_has_files = !urlList.empty(); ui.removeFileButton->setEnabled( b_has_files ); ui.subGroupBox->setEnabled( b_has_files ); } diff --git a/modules/gui/qt/components/open_panels.hpp b/modules/gui/qt/components/open_panels.hpp index d124a25ff6..71a983141d 100644 --- a/modules/gui/qt/components/open_panels.hpp +++ b/modules/gui/qt/components/open_panels.hpp @@ -129,6 +129,8 @@ protected: void dragLeaveEvent( QDragLeaveEvent * ) Q_DECL_OVERRIDE; private: Ui::OpenFile ui; + QList<QUrl> urlList; + QUrl subUrl; //url for subtitle FileOpenBox *dialogBox; void BuildOldPanel(); public slots: diff --git a/modules/gui/qt/ui/open_file.ui b/modules/gui/qt/ui/open_file.ui index 8da3e20ec1..233b61cd47 100644 --- a/modules/gui/qt/ui/open_file.ui +++ b/modules/gui/qt/ui/open_file.ui @@ -40,7 +40,11 @@ </property> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QLineEdit" name="subInput"/> + <widget class="QLineEdit" name="subInput"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> </item> <item> <widget class="QPushButton" name="subBrowseButton"> @@ -95,7 +99,7 @@ <enum>Qt::ScrollBarAlwaysOff</enum> </property> <property name="editTriggers"> - <set>QAbstractItemView::AllEditTriggers</set> + <set>QAbstractItemView::NoEditTriggers</set> </property> <property name="alternatingRowColors"> <bool>true</bool> _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits