[vlc-commits] qt: display user friendly paths in convert dialog
Pierre Lamot
git at videolan.org
Fri Jan 19 18:27:54 CET 2018
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Jan 19 18:10:24 2018 +0100| [8ac8ea35793fb3dd62e4635e81f3496da8d1f310] | committer: Jean-Baptiste Kempf
qt: display user friendly paths in convert dialog
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8ac8ea35793fb3dd62e4635e81f3496da8d1f310
---
modules/gui/qt/dialogs/convert.cpp | 20 ++++++++++++--------
modules/gui/qt/dialogs/convert.hpp | 1 +
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/modules/gui/qt/dialogs/convert.cpp b/modules/gui/qt/dialogs/convert.cpp
index 052cdeb55c..8a87518fa9 100644
--- a/modules/gui/qt/dialogs/convert.cpp
+++ b/modules/gui/qt/dialogs/convert.cpp
@@ -37,6 +37,9 @@
#include <QFileDialog>
#include <QCheckBox>
+#define urlToDisplayString(filestr) toNativeSeparators(QUrl(filestr).toDisplayString(\
+ QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments ))
+
ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
const QStringList& inputMRLs )
: QVLCDialog( parent, _p_intf ),
@@ -155,11 +158,11 @@ void ConvertDialog::fileBrowse()
{
QString fileExtension = ( ! profile->isEnabled() ) ? ".*" : "." + profile->getMux();
- QUrl fileName = QFileDialog::getSaveFileUrl( this, qtr( "Save file..." ),
+ outgoingMRL = QFileDialog::getSaveFileUrl( this, qtr( "Save file..." ),
p_intf->p_sys->filepath,
QString( "%1 (*%2);;%3 (*.*)" ).arg( qtr( "Containers" ) )
.arg( fileExtension ).arg( qtr("All") ), 0, QFileDialog::DontConfirmOverwrite );
- fileLine->setText( fileName.toEncoded() );
+ fileLine->setText( urlToDisplayString( outgoingMRL ) );
setDestinationFileExtension();
}
@@ -199,7 +202,7 @@ void ConvertDialog::close()
// Only one file, use the destination provided
if(singleFileSelected)
{
- newFileName = QUrl(fileLine->text()).toLocalFile();
+ newFileName = outgoingMRL.toLocalFile();
}
// Multiple, use the convention.
@@ -245,13 +248,14 @@ void ConvertDialog::close()
void ConvertDialog::setDestinationFileExtension()
{
- if( !fileLine->text().isEmpty() && profile->isEnabled() )
+ if( !outgoingMRL.isEmpty() && profile->isEnabled() )
{
- QString newFileExtension = "." + profile->getMux();
- if( fileLine->text().lastIndexOf( "." ) == -1 )
+ QString filepath = outgoingMRL.path(QUrl::FullyEncoded);
+ if( filepath.lastIndexOf( "." ) == -1 )
{
- QString newFileName = fileLine->text().append( newFileExtension );
- fileLine->setText( toNativeSeparators( newFileName ) );
+ QString newFileExtension = "." + profile->getMux();
+ outgoingMRL.setPath(filepath + newFileExtension);
+ fileLine->setText( urlToDisplayString( outgoingMRL ) );
}
}
}
diff --git a/modules/gui/qt/dialogs/convert.hpp b/modules/gui/qt/dialogs/convert.hpp
index 56ad469621..bfa9c9cadd 100644
--- a/modules/gui/qt/dialogs/convert.hpp
+++ b/modules/gui/qt/dialogs/convert.hpp
@@ -51,6 +51,7 @@ private:
const QStringList *incomingMRLs;
const bool singleFileSelected;
+ QUrl outgoingMRL;
QStringList mrls;
private slots:
More information about the vlc-commits
mailing list