(trunk, qt) #3606 'Qt client New Torrent from Source Folder is Goofy' -- fixed, mikedld

This commit is contained in:
Jordan Lee 2013-09-08 19:12:33 +00:00
parent e45c4d19d9
commit 0ed8f46e07
1 changed files with 18 additions and 3 deletions

View File

@ -44,6 +44,21 @@
****
***/
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 )
{
@ -186,7 +201,7 @@ MakeDialog :: onFileSelected( const QStringList& list )
void
MakeDialog :: onFileSelected( const QString& filename )
{
myFile = filename;
myFile = removeTrailingSlash (filename);
myFileButton->setText( QFileInfo(myFile).fileName() );
onSourceChanged( );
}
@ -211,7 +226,7 @@ MakeDialog :: onFolderSelected( const QStringList& list )
void
MakeDialog :: onFolderSelected( const QString& filename )
{
myFolder = filename;
myFolder = removeTrailingSlash (filename);
myFolderButton->setText( QFileInfo(myFolder).fileName() );
onSourceChanged( );
}
@ -236,7 +251,7 @@ MakeDialog :: onDestinationSelected( const QStringList& list )
void
MakeDialog :: onDestinationSelected( const QString& filename )
{
myDestination = filename;
myDestination = removeTrailingSlash (filename);
myDestinationButton->setText( QFileInfo(myDestination).fileName() );
}