Changeset 13694


Ignore:
Timestamp:
Dec 27, 2012, 6:22:48 PM (8 years ago)
Author:
jordan
Message:

(trunk, qt) #5194 'Qt: open folder: on single-file torrents opens the file, not directory, except on Windows and Mac' -- fixed with patch from basinilya

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r13692 r13694  
    610610
    611611// Open Folder & select torrent's file or top folder
     612#undef HAVE_OPEN_SELECT
     613#if defined(Q_OS_WIN)
     614# define HAVE_OPEN_SELECT
     615static
    612616void openSelect(const QString& path)
    613617{
    614 #if defined(Q_OS_WIN)
    615618    const QString explorer = "explorer";
    616619        QString param;
     
    619622        param += QDir::toNativeSeparators(path);
    620623        QProcess::startDetached(explorer, QStringList(param));
     624}
    621625#elif defined(Q_OS_MAC)
     626# define HAVE_OPEN_SELECT
     627static
     628void openSelect(const QString& path)
     629{
    622630    QStringList scriptArgs;
    623631        scriptArgs << QLatin1String("-e")
     
    629637                   << QLatin1String("tell application \"Finder\" to activate");
    630638        QProcess::execute("/usr/bin/osascript", scriptArgs);
    631 #elif defined(Q_OS_UNIX)
    632     QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
     639}
    633640#endif
    634 }
    635641
    636642void
     
    643649    const QString firstfile = files.at(0).filename;
    644650    int slashIndex = firstfile.indexOf('/');
    645     if (files.size() == 1)
    646         openSelect( path + "/" + files.at(0).filename );
     651    if (files.size() > 1)
     652    {
     653        path = path + "/" + firstfile.left(slashIndex);
     654    }
     655#ifdef HAVE_OPEN_SELECT
    647656    else {
    648         path = path + "/" + firstfile.left(slashIndex);
    649         openSelect( path );
    650     }
     657        openSelect( path + "/" + firstfile );
     658        return;
     659    }
     660#endif
     661    QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
    651662}
    652663
Note: See TracChangeset for help on using the changeset viewer.