|
|
@ -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: |
|
|
|