Changeset 13264


Ignore:
Timestamp:
Apr 7, 2012, 12:16:14 AM (9 years ago)
Author:
jordan
Message:

(trunk, qt) fix #4824 'Open Folder bug' with a patch from rb07

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r12616 r13264  
    580580}
    581581
     582// Open Folder & select torrent's file or top folder
     583void openSelect(const QString& path)
     584{
     585#if defined(Q_OS_WIN)
     586    const QString explorer = "explorer";
     587        QString param;
     588        if (!QFileInfo(path).isDir())
     589            param = QLatin1String("/select,");
     590        param += QDir::toNativeSeparators(path);
     591        QProcess::startDetached(explorer, QStringList(param));
     592#elif defined(Q_OS_MAC)
     593    QStringList scriptArgs;
     594        scriptArgs << QLatin1String("-e")
     595                   << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
     596                                         .arg(path);
     597        QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
     598        scriptArgs.clear();
     599        scriptArgs << QLatin1String("-e")
     600                   << QLatin1String("tell application \"Finder\" to activate");
     601        QProcess::execute("/usr/bin/osascript", scriptArgs);
     602#elif defined(Q_OS_UNIX)
     603    QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
     604#endif
     605}
     606
    582607void
    583608TrMainWindow :: openFolder( )
     
    586611    const Torrent * tor( myModel.getTorrentFromId( torrentId ) );
    587612    const QString path( tor->getPath( ) );
    588     QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
     613    const FileList files = tor->files();
     614    if (files.size() == 1)
     615        openSelect( path + "/" + files.at(0).filename );
     616    else {
     617        QDir dir( path + "/" + files.at(0).filename );
     618        dir.cdUp();
     619        openSelect( dir.path() );
     620    }
    589621}
    590622
Note: See TracChangeset for help on using the changeset viewer.