Changeset 14198


Ignore:
Timestamp:
Sep 8, 2013, 7:12:33 PM (8 years ago)
Author:
jordan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/make-dialog.cc

    r14179 r14198  
    4444****
    4545***/
     46
     47namespace
     48{
     49  QString removeTrailingSlash (const QString& path)
     50  {
     51    // QFileDialog may return path ending with slash if that path refers to
     52    // directory. QFileInfo::fileName() applied to such path would then return
     53    // an empty string which is not what we want, so we strip the slash here.
     54
     55    if (!path.endsWith (QDir::separator ()))
     56      return path;
     57
     58    return path.left (path.length () - 1);
     59  }
     60}
    4661
    4762void
     
    187202MakeDialog :: onFileSelected( const QString& filename )
    188203{
    189     myFile = filename;
     204    myFile = removeTrailingSlash (filename);
    190205    myFileButton->setText( QFileInfo(myFile).fileName() );
    191206    onSourceChanged( );
     
    212227MakeDialog :: onFolderSelected( const QString& filename )
    213228{
    214     myFolder = filename;
     229    myFolder = removeTrailingSlash (filename);
    215230    myFolderButton->setText( QFileInfo(myFolder).fileName() );
    216231    onSourceChanged( );
     
    237252MakeDialog :: onDestinationSelected( const QString& filename )
    238253{
    239     myDestination = filename;
     254    myDestination = removeTrailingSlash (filename);
    240255    myDestinationButton->setText( QFileInfo(myDestination).fileName() );
    241256}
Note: See TracChangeset for help on using the changeset viewer.