Commit 22bf04c4 authored by Pierre Lamot's avatar Pierre Lamot Committed by 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's avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 6b36c463)
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f2b6aa74
......@@ -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 );
}
......
......@@ -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:
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment