Browse Source

Accept multiple files at once. Closes #2253

adaptive-webui-19844
buinsky 10 years ago
parent
commit
cb5b0f891c
  1. 38
      src/main.cpp
  2. 2
      src/mainwindow.h

38
src/main.cpp

@ -74,6 +74,20 @@ Q_IMPORT_PLUGIN(qico)
#include "misc.h" #include "misc.h"
#include "preferences.h" #include "preferences.h"
class MessagesCollector : public QObject
{
Q_OBJECT
public slots:
void collectMessage(const QString& message)
{
messages.append(message.split("|", QString::SkipEmptyParts));
}
public:
QStringList messages;
};
#include "main.moc"
#if defined(Q_OS_WIN) && !defined(QBT_HAS_GETCURRENTPID) #if defined(Q_OS_WIN) && !defined(QBT_HAS_GETCURRENTPID)
#error You seem to have updated QtSingleApplication without porting our custom QtSingleApplication::getRunningPid() function. Please see previous version to understate how it works. #error You seem to have updated QtSingleApplication without porting our custom QtSingleApplication::getRunningPid() function. Please see previous version to understate how it works.
#endif #endif
@ -113,6 +127,10 @@ int main(int argc, char *argv[])
// Create Application // Create Application
Application app("qBittorrent-" + misc::getUserIDString(), argc, argv); Application app("qBittorrent-" + misc::getUserIDString(), argc, argv);
MessagesCollector* messagesCollector = new MessagesCollector();
QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
messagesCollector, SLOT(collectMessage(const QString &)));
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
parseCommandLine(showVersion, showUsage, noSplash, torrents); parseCommandLine(showVersion, showUsage, noSplash, torrents);
#else #else
@ -131,9 +149,8 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
// Set environment variable // Set environment variable
if (!qputenv("QBITTORRENT", QByteArray(VERSION))) { if (!qputenv("QBITTORRENT", QByteArray(VERSION)))
std::cerr << "Couldn't set environment variable...\n"; std::cerr << "Couldn't set environment variable...\n";
}
if (!userAgreesWithLegalNotice()) if (!userAgreesWithLegalNotice())
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -141,6 +158,7 @@ int main(int argc, char *argv[])
// Check if qBittorrent is already running for this user // Check if qBittorrent is already running for this user
if (app.isRunning()) { if (app.isRunning()) {
qDebug("qBittorrent is already running for this user."); qDebug("qBittorrent is already running for this user.");
misc::msleep(300);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
DWORD pid = (DWORD)app.getRunningPid(); DWORD pid = (DWORD)app.getRunningPid();
if (pid > 0) { if (pid > 0) {
@ -181,8 +199,12 @@ int main(int argc, char *argv[])
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
MainWindow window(0, torrents); MainWindow window(0, torrents);
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
&window, SLOT(processParams(const QString&))); &window, SLOT(processParams(const QString &)));
QObject::disconnect(&app, SIGNAL(messageReceived(const QString &)),
messagesCollector, SLOT(collectMessage(const QString &)));
window.processParams(messagesCollector->messages);
delete messagesCollector;
app.setActivationWindow(&window); app.setActivationWindow(&window);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
static_cast<QMacApplication*>(&app)->setReadyToProcessEvents(); static_cast<QMacApplication*>(&app)->setReadyToProcessEvents();
@ -190,8 +212,12 @@ int main(int argc, char *argv[])
#else #else
// Load Headless class // Load Headless class
HeadlessLoader loader(torrents); HeadlessLoader loader(torrents);
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), QObject::connect(&app, SIGNAL(messageReceived(const QString &)),
&loader, SLOT(processParams(const QString&))); &loader, SLOT(processParams(const QString &)));
QObject::disconnect(&app, SIGNAL(messageReceived(const QString &)),
messagesCollector, SLOT(collectMessage(const QString &)));
loader.processParams(messagesCollector->messages);
delete messagesCollector;
#endif #endif
int ret = app.exec(); int ret = app.exec();

2
src/mainwindow.h

@ -87,6 +87,7 @@ public slots:
void updateAltSpeedsBtn(bool alternative); void updateAltSpeedsBtn(bool alternative);
void updateNbTorrents(); void updateNbTorrents();
void shutdownCleanUp(); void shutdownCleanUp();
void processParams(const QStringList& params);
protected slots: protected slots:
// GUI related slots // GUI related slots
@ -128,7 +129,6 @@ protected slots:
void updateGUI(); void updateGUI();
void loadPreferences(bool configure_session = true); void loadPreferences(bool configure_session = true);
void processParams(const QString& params); void processParams(const QString& params);
void processParams(const QStringList& params);
void addTorrent(QString path); void addTorrent(QString path);
void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker); void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker);
void processDownloadedFiles(QString path, QString url); void processDownloadedFiles(QString path, QString url);

Loading…
Cancel
Save