|
|
|
@ -47,6 +47,7 @@
@@ -47,6 +47,7 @@
|
|
|
|
|
#include <QByteArray> |
|
|
|
|
#include <QDebug> |
|
|
|
|
#include <QLibraryInfo> |
|
|
|
|
#include <QMetaObject> |
|
|
|
|
#include <QProcess> |
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
@ -324,15 +325,6 @@ void Application::processMessage(const QString &message)
@@ -324,15 +325,6 @@ void Application::processMessage(const QString &message)
|
|
|
|
|
|
|
|
|
|
void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const |
|
|
|
|
{ |
|
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
|
const auto chopPathSep = [](const QString &str) -> QString |
|
|
|
|
{ |
|
|
|
|
if (str.endsWith(u'\\')) |
|
|
|
|
return str.mid(0, (str.length() -1)); |
|
|
|
|
return str; |
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
QString program = Preferences::instance()->getAutoRunProgram().trimmed(); |
|
|
|
|
|
|
|
|
|
for (int i = (program.length() - 2); i >= 0; --i) |
|
|
|
@ -347,18 +339,10 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
@@ -347,18 +339,10 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
|
|
|
|
|
program.replace(i, 2, QString::number(torrent->filesCount())); |
|
|
|
|
break; |
|
|
|
|
case u'D': |
|
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
|
program.replace(i, 2, chopPathSep(torrent->savePath().toString())); |
|
|
|
|
#else |
|
|
|
|
program.replace(i, 2, torrent->savePath().toString()); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case u'F': |
|
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
|
program.replace(i, 2, chopPathSep(torrent->contentPath().toString())); |
|
|
|
|
#else |
|
|
|
|
program.replace(i, 2, torrent->contentPath().toString()); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case u'G': |
|
|
|
|
program.replace(i, 2, torrent->tags().join(u","_qs)); |
|
|
|
@ -379,11 +363,7 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
@@ -379,11 +363,7 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
|
|
|
|
|
program.replace(i, 2, torrent->name()); |
|
|
|
|
break; |
|
|
|
|
case u'R': |
|
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
|
program.replace(i, 2, chopPathSep(torrent->rootPath().toString())); |
|
|
|
|
#else |
|
|
|
|
program.replace(i, 2, torrent->rootPath().toString()); |
|
|
|
|
#endif |
|
|
|
|
break; |
|
|
|
|
case u'T': |
|
|
|
|
program.replace(i, 2, torrent->currentTracker()); |
|
|
|
@ -791,7 +771,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
@@ -791,7 +771,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
|
|
|
|
|
// According to the qt docs we shouldn't call quit() inside a slot.
|
|
|
|
|
// aboutToQuit() is never emitted if the user hits "Cancel" in
|
|
|
|
|
// the above dialog.
|
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit); |
|
|
|
|
QMetaObject::invokeMethod(qApp, &QCoreApplication::quit, Qt::QueuedConnection); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|