mirror of
https://github.com/transmission/transmission
synced 2024-12-23 16:24:02 +00:00
(trunk, qt) fix #4824 'Open Folder bug' with a patch from rb07
This commit is contained in:
parent
00919e932d
commit
001813c364
1 changed files with 33 additions and 1 deletions
|
@ -579,13 +579,45 @@ TrMainWindow :: setLocation( )
|
|||
d->show( );
|
||||
}
|
||||
|
||||
// Open Folder & select torrent's file or top folder
|
||||
void openSelect(const QString& path)
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString explorer = "explorer";
|
||||
QString param;
|
||||
if (!QFileInfo(path).isDir())
|
||||
param = QLatin1String("/select,");
|
||||
param += QDir::toNativeSeparators(path);
|
||||
QProcess::startDetached(explorer, QStringList(param));
|
||||
#elif defined(Q_OS_MAC)
|
||||
QStringList scriptArgs;
|
||||
scriptArgs << QLatin1String("-e")
|
||||
<< QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
||||
.arg(path);
|
||||
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
|
||||
scriptArgs.clear();
|
||||
scriptArgs << QLatin1String("-e")
|
||||
<< QLatin1String("tell application \"Finder\" to activate");
|
||||
QProcess::execute("/usr/bin/osascript", scriptArgs);
|
||||
#elif defined(Q_OS_UNIX)
|
||||
QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
TrMainWindow :: openFolder( )
|
||||
{
|
||||
const int torrentId( *getSelectedTorrents().begin() );
|
||||
const Torrent * tor( myModel.getTorrentFromId( torrentId ) );
|
||||
const QString path( tor->getPath( ) );
|
||||
QDesktopServices :: openUrl( QUrl::fromLocalFile( path ) );
|
||||
const FileList files = tor->files();
|
||||
if (files.size() == 1)
|
||||
openSelect( path + "/" + files.at(0).filename );
|
||||
else {
|
||||
QDir dir( path + "/" + files.at(0).filename );
|
||||
dir.cdUp();
|
||||
openSelect( dir.path() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue