(trunk, qt) reuse make-dialog's trailing slash fix in the options dialog when setting the download dir

This commit is contained in:
Jordan Lee
2013-09-08 19:59:47 +00:00
parent 36cc115c7b
commit e0acd2dcc3
4 changed files with 15 additions and 19 deletions

View File

@@ -39,26 +39,12 @@
#include "hig.h"
#include "make-dialog.h"
#include "session.h"
#include "utils.h"
/***
****
***/
namespace
{
QString removeTrailingSlash (const QString& path)
{
// QFileDialog may return path ending with slash if that path refers to
// directory. QFileInfo::fileName() applied to such path would then return
// an empty string which is not what we want, so we strip the slash here.
if (!path.endsWith (QDir::separator ()))
return path;
return path.left (path.length () - 1);
}
}
void
MakeDialog :: onNewDialogDestroyed( QObject * o )
{
@@ -201,7 +187,7 @@ MakeDialog :: onFileSelected( const QStringList& list )
void
MakeDialog :: onFileSelected( const QString& filename )
{
myFile = removeTrailingSlash (filename);
myFile = Utils::removeTrailingDirSeparator (filename);
myFileButton->setText( QFileInfo(myFile).fileName() );
onSourceChanged( );
}
@@ -226,7 +212,7 @@ MakeDialog :: onFolderSelected( const QStringList& list )
void
MakeDialog :: onFolderSelected( const QString& filename )
{
myFolder = removeTrailingSlash (filename);
myFolder = Utils::removeTrailingDirSeparator (filename);
myFolderButton->setText( QFileInfo(myFolder).fileName() );
onSourceChanged( );
}
@@ -251,7 +237,7 @@ MakeDialog :: onDestinationSelected( const QStringList& list )
void
MakeDialog :: onDestinationSelected( const QString& filename )
{
myDestination = removeTrailingSlash (filename);
myDestination = Utils::removeTrailingDirSeparator (filename);
myDestinationButton->setText( QFileInfo(myDestination).fileName() );
}