Browse Source

Fix torrent loading on Mac OS X (closes #1011229)

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
80359f3e5e
  1. 2
      src/Info.plist
  2. 3
      src/main.cpp
  3. 15
      src/qmacapplication.cpp
  4. 5
      src/qmacapplication.h

2
src/Info.plist

@ -52,6 +52,8 @@
<string>qbittorrent</string> <string>qbittorrent</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.qbittorrent</string> <string>org.qbittorrent</string>
<key>NSAppleScriptEnabled</key>
<string>YES</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2006-2012 Christophe Dumez</string> <string>Copyright © 2006-2012 Christophe Dumez</string>
<key>UTExportedTypeDeclarations</key> <key>UTExportedTypeDeclarations</key>

3
src/main.cpp

@ -307,6 +307,9 @@ int main(int argc, char *argv[]) {
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
&window, SLOT(processParams(const QString&))); &window, SLOT(processParams(const QString&)));
app.setActivationWindow(&window); app.setActivationWindow(&window);
#ifdef Q_WS_MAC
static_cast<QMacApplication*>(&app)->setReadyToProcessEvents();
#endif // Q_WS_MAC
#else #else
// Load Headless class // Load Headless class
HeadlessLoader loader(torrentCmdLine); HeadlessLoader loader(torrentCmdLine);

15
src/qmacapplication.cpp

@ -34,11 +34,21 @@
#include "qmacapplication.h" #include "qmacapplication.h"
QMacApplication::QMacApplication(QString appid, int &argc, char** argv) : QMacApplication::QMacApplication(QString appid, int &argc, char** argv) :
QtSingleApplication(appid, argc, argv) QtSingleApplication(appid, argc, argv),
m_readyToProcessEvents(false)
{ {
qDebug("Constructing a QMacApplication to receive file open events"); qDebug("Constructing a QMacApplication to receive file open events");
} }
void QMacApplication::setReadyToProcessEvents()
{
m_readyToProcessEvents = true;
if (!m_torrentsQueue.isEmpty()) {
emit newFileOpenMacEvent(m_torrentsQueue.join("|"));
m_torrentsQueue.clear();
}
}
bool QMacApplication::event(QEvent * ev) { bool QMacApplication::event(QEvent * ev) {
switch (ev->type()) { switch (ev->type()) {
case QEvent::FileOpen: case QEvent::FileOpen:
@ -49,7 +59,10 @@ bool QMacApplication::event(QEvent * ev) {
path = static_cast<QFileOpenEvent *>(ev)->url().toString(); path = static_cast<QFileOpenEvent *>(ev)->url().toString();
} }
qDebug("Received a mac file open event: %s", qPrintable(path)); qDebug("Received a mac file open event: %s", qPrintable(path));
if (m_readyToProcessEvents)
emit newFileOpenMacEvent(path); emit newFileOpenMacEvent(path);
else
m_torrentsQueue.append(path);
return true; return true;
} }
default: default:

5
src/qmacapplication.h

@ -31,12 +31,14 @@
#define QMACAPPLICATION_H #define QMACAPPLICATION_H
#include "qtsingleapplication.h" #include "qtsingleapplication.h"
#include <QStringList>
class QMacApplication : public QtSingleApplication class QMacApplication : public QtSingleApplication
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QMacApplication(QString appid, int &argc, char** argv); explicit QMacApplication(QString appid, int &argc, char** argv);
void setReadyToProcessEvents();
signals: signals:
void newFileOpenMacEvent(const QString &path); void newFileOpenMacEvent(const QString &path);
@ -44,6 +46,9 @@ signals:
protected: protected:
bool event(QEvent *); bool event(QEvent *);
private:
bool m_readyToProcessEvents;
QStringList m_torrentsQueue;
}; };
#endif // QMACAPPLICATION_H #endif // QMACAPPLICATION_H

Loading…
Cancel
Save