mirror of
https://github.com/transmission/transmission.git
synced 2025-12-27 05:38:40 +00:00
(trunk, qt) reuse make-dialog's trailing slash fix in the options dialog when setting the download dir
This commit is contained in:
@@ -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() );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user