2006-09-30 20:02:39 +04:00
/*
* Bittorrent Client using Qt4 and libtorrent .
2007-07-14 18:31:59 +04:00
* Copyright ( C ) 2006 Christophe Dumez
2006-09-30 20:02:39 +04:00
*
2007-07-14 18:31:59 +04:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2006-09-30 20:02:39 +04:00
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2007-07-14 18:31:59 +04:00
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
2009-04-05 21:00:55 +04:00
* In addition , as a special exception , the copyright holders give permission to
* link this program with the OpenSSL project ' s " OpenSSL " library ( or with
* modified versions of it that use the same license as the " OpenSSL " library ) ,
* and distribute the linked executables . You must obey the GNU General Public
* License in all respects for all of the code used other than " OpenSSL " . If you
* modify file ( s ) , you may extend this exception to your version of the file ( s ) ,
* but you are not obligated to do so . If you do not wish to do so , delete this
* exception statement from your version .
*
2007-07-14 18:31:59 +04:00
* Contact : chris @ qbittorrent . org
2006-09-30 20:02:39 +04:00
*/
# include <QLocale>
# include <QTranslator>
# include <QFile>
2011-01-20 19:14:23 +03:00
# include <QLibraryInfo>
2014-07-05 16:44:13 +04:00
# include <QDebug>
2009-12-15 13:56:41 +03:00
2009-12-15 14:08:22 +03:00
# ifndef DISABLE_GUI
2012-12-28 15:40:22 +04:00
# if defined(QBT_STATIC_QT)
# include <QtPlugin>
2014-05-01 23:53:29 +04:00
# if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_IMPORT_PLUGIN ( QICOPlugin )
# else
2012-12-28 15:40:22 +04:00
Q_IMPORT_PLUGIN ( qico )
# endif
2014-05-01 23:53:29 +04:00
# endif
2010-01-09 18:26:20 +03:00
# include <QMessageBox>
2010-01-31 20:30:17 +03:00
# include <QStyleFactory>
2010-03-15 21:10:18 +03:00
# include <QStyle>
2010-01-03 02:03:46 +03:00
# include <QSplashScreen>
2010-11-04 22:31:12 +03:00
# include <QPainter>
# include <QPen>
# include <QFont>
2010-03-04 11:36:23 +03:00
# include <QPushButton>
2010-10-30 18:35:46 +04:00
# include <QTimer>
2010-10-02 00:03:27 +04:00
# include "sessionapplication.h"
2010-11-14 00:15:52 +03:00
# include "mainwindow.h"
2010-01-03 02:03:46 +03:00
# include "ico.h"
2009-12-15 14:08:22 +03:00
# else
2010-06-09 13:48:14 +04:00
# include "qtsinglecoreapplication.h"
2010-01-09 18:26:20 +03:00
# include <iostream>
# include <stdio.h>
2010-01-03 02:03:46 +03:00
# include "headlessloader.h"
2009-12-15 13:56:41 +03:00
# endif
2011-01-22 22:16:17 +03:00
# include "preferences.h"
2013-09-21 11:59:58 +04:00
# if defined(Q_OS_UNIX)
2009-09-30 22:57:06 +04:00
# include <signal.h>
# include <execinfo.h>
# include "stacktrace.h"
2010-03-30 15:35:20 +04:00
# endif
2013-03-03 03:17:04 +04:00
# ifdef STACKTRACE_WIN
2013-01-19 20:16:57 +04:00
# include <signal.h>
# include "stacktrace_win.h"
# include "stacktrace_win_dlg.h"
# endif
2006-09-30 20:02:39 +04:00
# include <stdlib.h>
# include "misc.h"
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
# include "preferences.h"
2008-11-05 01:39:43 +03:00
2013-09-17 16:21:23 +04:00
# 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.
# endif
2014-12-13 19:42:11 +03:00
void displayUsage ( char * prg_name )
{
std : : cout < < qPrintable ( QObject : : tr ( " Usage: " ) ) < < std : : endl ;
std : : cout < < ' \t ' < < prg_name < < " --version: " < < qPrintable ( QObject : : tr ( " displays program version " ) ) < < std : : endl ;
2010-01-03 02:40:57 +03:00
# ifndef DISABLE_GUI
2014-12-13 19:42:11 +03:00
std : : cout < < ' \t ' < < prg_name < < " --no-splash: " < < qPrintable ( QObject : : tr ( " disable splash screen " ) ) < < std : : endl ;
2012-08-18 19:33:51 +04:00
# else
2014-12-13 19:42:11 +03:00
std : : cout < < ' \t ' < < prg_name < < " -d | --daemon: " < < qPrintable ( QObject : : tr ( " run in daemon-mode (background) " ) ) < < std : : endl ;
2010-01-03 02:40:57 +03:00
# endif
2014-12-13 19:42:11 +03:00
std : : cout < < ' \t ' < < prg_name < < " --help: " < < qPrintable ( QObject : : tr ( " displays this help message " ) ) < < std : : endl ;
std : : cout < < ' \t ' < < prg_name < < " --webui-port=x: " < < qPrintable ( QObject : : tr ( " changes the webui port (current: %1) " ) . arg ( QString : : number ( Preferences : : instance ( ) - > getWebUiPort ( ) ) ) ) < < std : : endl ;
std : : cout < < ' \t ' < < prg_name < < " " < < qPrintable ( QObject : : tr ( " [files or urls]: downloads the torrents passed by the user (optional) " ) ) < < std : : endl ;
}
2010-01-09 18:26:20 +03:00
2014-12-13 19:42:11 +03:00
bool userAgreesWithLegalNotice ( )
{
2014-07-05 16:44:13 +04:00
Preferences * const pref = Preferences : : instance ( ) ;
if ( pref - > getAcceptedLegal ( ) ) // Already accepted once
2014-12-13 19:42:11 +03:00
return true ;
2010-01-09 18:26:20 +03:00
# ifdef DISABLE_GUI
2014-12-13 19:42:11 +03:00
std : : cout < < std : : endl < < " *** " < < qPrintable ( QObject : : tr ( " Legal Notice " ) ) < < " *** " < < std : : endl ;
std : : cout < < qPrintable ( QObject : : tr ( " qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility. \n \n No further notices will be issued. " ) ) < < std : : endl < < std : : endl ;
std : : cout < < qPrintable ( QObject : : tr ( " Press %1 key to accept and continue... " ) . arg ( " 'y' " ) ) < < std : : endl ;
2010-01-18 22:20:59 +03:00
char ret = getchar ( ) ; // Read pressed key
2012-02-20 21:30:53 +04:00
if ( ret = = ' y ' | | ret = = ' Y ' ) {
2014-12-13 19:42:11 +03:00
// Save the answer
pref - > setAcceptedLegal ( true ) ;
return true ;
2010-01-18 22:20:59 +03:00
}
2010-01-19 00:28:54 +03:00
return false ;
2010-01-09 18:26:20 +03:00
# else
QMessageBox msgBox ;
2014-12-13 19:42:11 +03:00
msgBox . setText ( QObject : : tr ( " qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility. \n \n No further notices will be issued. " ) ) ;
msgBox . setWindowTitle ( QObject : : tr ( " Legal notice " ) ) ;
msgBox . addButton ( QObject : : tr ( " Cancel " ) , QMessageBox : : RejectRole ) ;
QAbstractButton * agree_button = msgBox . addButton ( QObject : : tr ( " I Agree " ) , QMessageBox : : AcceptRole ) ;
2011-01-22 22:31:06 +03:00
msgBox . show ( ) ; // Need to be shown or to moveToCenter does not work
msgBox . move ( misc : : screenCenter ( & msgBox ) ) ;
2010-01-09 18:26:20 +03:00
msgBox . exec ( ) ;
2012-02-20 21:30:53 +04:00
if ( msgBox . clickedButton ( ) = = agree_button ) {
2014-12-13 19:42:11 +03:00
// Save the answer
pref - > setAcceptedLegal ( true ) ;
return true ;
2010-01-09 18:26:20 +03:00
}
return false ;
# endif
2014-12-13 19:42:11 +03:00
}
2010-01-03 02:40:57 +03:00
2013-09-21 11:59:58 +04:00
# if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
2014-12-13 20:22:35 +03:00
void sigintHandler ( int )
{
signal ( SIGINT , 0 ) ;
qDebug ( " Catching SIGINT, exiting cleanly " ) ;
qApp - > exit ( ) ;
2010-01-03 02:03:46 +03:00
}
2014-12-13 20:22:35 +03:00
void sigtermHandler ( int )
{
signal ( SIGTERM , 0 ) ;
qDebug ( " Catching SIGTERM, exiting cleanly " ) ;
qApp - > exit ( ) ;
2009-09-30 22:57:06 +04:00
}
2014-12-13 20:22:35 +03:00
void sigsegvHandler ( int )
{
signal ( SIGABRT , 0 ) ;
signal ( SIGSEGV , 0 ) ;
2014-09-11 06:44:25 +04:00
# if !defined Q_OS_WIN && !defined Q_OS_HAIKU
2014-12-13 20:22:35 +03:00
std : : cerr < < " \n \n ************************************************************* \n " ;
std : : cerr < < " Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org \n and provide the following backtrace: \n " ;
std : : cerr < < " qBittorrent version: " < < VERSION < < std : : endl ;
print_stacktrace ( ) ;
2013-01-19 20:16:57 +04:00
# else
2013-01-25 22:52:12 +04:00
# ifdef STACKTRACE_WIN
2014-12-13 20:22:35 +03:00
StraceDlg dlg ;
dlg . setStacktraceString ( straceWin : : getBacktrace ( ) ) ;
dlg . exec ( ) ;
2013-01-25 22:52:12 +04:00
# endif
2013-01-19 20:16:57 +04:00
# endif
2014-12-13 20:22:35 +03:00
raise ( SIGSEGV ) ;
2009-09-30 22:57:06 +04:00
}
2014-12-13 20:22:35 +03:00
void sigabrtHandler ( int )
{
signal ( SIGABRT , 0 ) ;
signal ( SIGSEGV , 0 ) ;
2014-09-11 06:44:25 +04:00
# if !defined Q_OS_WIN && !defined Q_OS_HAIKU
2014-12-13 20:22:35 +03:00
std : : cerr < < " \n \n ************************************************************* \n " ;
std : : cerr < < " Catching SIGABRT, please report a bug at http://bug.qbittorrent.org \n and provide the following backtrace: \n " ;
std : : cerr < < " qBittorrent version: " < < VERSION < < std : : endl ;
print_stacktrace ( ) ;
2013-01-19 20:16:57 +04:00
# else
2013-01-25 22:52:12 +04:00
# ifdef STACKTRACE_WIN
2014-12-13 20:22:35 +03:00
StraceDlg dlg ;
dlg . setStacktraceString ( straceWin : : getBacktrace ( ) ) ;
dlg . exec ( ) ;
2013-01-25 22:52:12 +04:00
# endif
2013-01-19 20:16:57 +04:00
# endif
2014-12-13 20:22:35 +03:00
raise ( SIGABRT ) ;
2009-11-15 13:42:03 +03:00
}
2008-12-26 19:23:53 +03:00
# endif
2006-09-30 20:02:39 +04:00
// Main
2014-12-13 20:22:35 +03:00
int main ( int argc , char * argv [ ] )
{
2014-05-13 20:13:22 +04:00
# if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
2014-12-13 20:22:35 +03:00
if ( QSysInfo : : MacintoshVersion > QSysInfo : : MV_10_8 ) {
// fix Mac OS X 10.9 (mavericks) font issue
// https://bugreports.qt-project.org/browse/QTBUG-32789
QFont : : insertSubstitution ( " .Lucida Grande UI " , " Lucida Grande " ) ;
}
2013-11-11 12:38:20 +04:00
# endif
2014-12-13 20:22:35 +03:00
// Create Application
QString uid = misc : : getUserIDString ( ) ;
2010-10-02 00:03:27 +04:00
# ifdef DISABLE_GUI
2014-12-13 20:22:35 +03:00
bool shouldDaemonize = false ;
for ( int i = 1 ; i < argc ; i + + ) {
if ( strcmp ( argv [ i ] , " -d " ) = = 0 | | strcmp ( argv [ i ] , " --daemon " ) = = 0 ) {
shouldDaemonize = true ;
argc - - ;
for ( int j = i ; j < argc ; j + + ) {
argv [ j ] = argv [ j + 1 ] ;
}
i - - ;
}
2012-08-18 19:33:51 +04:00
}
2014-12-13 20:22:35 +03:00
QtSingleCoreApplication app ( " qBittorrent- " + uid , argc , argv ) ;
2010-10-02 00:03:27 +04:00
# else
2014-12-13 20:22:35 +03:00
SessionApplication app ( " qBittorrent- " + uid , argc , argv ) ;
2010-10-02 00:03:27 +04:00
# endif
2010-07-20 21:13:28 +04:00
2014-12-13 20:22:35 +03:00
// Check if qBittorrent is already running for this user
if ( app . isRunning ( ) ) {
qDebug ( " qBittorrent is already running for this user. " ) ;
// Read torrents given on command line
2013-09-17 16:18:01 +04:00
# ifdef Q_OS_WIN
2014-12-13 20:22:35 +03:00
DWORD pid = ( DWORD ) app . getRunningPid ( ) ;
if ( pid > 0 ) {
BOOL b = AllowSetForegroundWindow ( pid ) ;
qDebug ( " AllowSetForegroundWindow() returns %s " , b ? " TRUE " : " FALSE " ) ;
}
2013-09-17 16:18:01 +04:00
# endif
2014-12-13 20:22:35 +03:00
QStringList torrentCmdLine = app . arguments ( ) ;
//Pass program parameters if any
QString message ;
QFileInfo torrentPath ;
for ( int a = 1 ; a < torrentCmdLine . size ( ) ; + + a ) {
if ( torrentCmdLine [ a ] . startsWith ( " -- " ) ) continue ;
torrentPath . setFile ( torrentCmdLine [ a ] ) ;
if ( torrentPath . exists ( ) )
message + = torrentPath . absoluteFilePath ( ) ;
else
message + = torrentCmdLine [ a ] ;
if ( a < argc - 1 )
message + = " | " ;
}
if ( ! message . isEmpty ( ) ) {
qDebug ( " Passing program parameters to running instance... " ) ;
qDebug ( " Message: %s " , qPrintable ( message ) ) ;
app . sendMessage ( message ) ;
}
else { // Raise main window
app . sendMessage ( " qbt://show " ) ;
}
return EXIT_SUCCESS ;
2010-06-09 13:48:14 +04:00
}
2014-12-13 20:22:35 +03:00
srand ( time ( 0 ) ) ;
Preferences * const pref = Preferences : : instance ( ) ;
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
bool no_splash = false ;
2012-08-18 20:11:27 +04:00
# else
2014-12-13 20:22:35 +03:00
if ( shouldDaemonize & & daemon ( 1 , 0 ) ! = 0 ) {
qCritical ( " Something went wrong while daemonizing, exiting... " ) ;
return EXIT_FAILURE ;
}
2009-12-15 13:56:41 +03:00
# endif
2010-02-05 22:02:27 +03:00
2014-12-13 20:22:35 +03:00
// Load translation
QString locale = pref - > getLocale ( ) ;
QTranslator qtTranslator ;
QTranslator translator ;
if ( locale . isEmpty ( ) ) {
locale = QLocale : : system ( ) . name ( ) ;
pref - > setLocale ( locale ) ;
}
if ( qtTranslator . load (
2013-10-05 20:28:26 +04:00
# if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2014-12-13 20:22:35 +03:00
QString : : fromUtf8 ( " qtbase_ " ) + locale , QLibraryInfo : : location ( QLibraryInfo : : TranslationsPath ) ) | |
qtTranslator . load (
2013-10-05 20:28:26 +04:00
# endif
2014-12-13 20:22:35 +03:00
QString : : fromUtf8 ( " qt_ " ) + locale , QLibraryInfo : : location ( QLibraryInfo : : TranslationsPath ) ) ) {
qDebug ( " Qt %s locale recognized, using translation. " , qPrintable ( locale ) ) ;
}
else {
qDebug ( " Qt %s locale unrecognized, using default (en). " , qPrintable ( locale ) ) ;
}
app . installTranslator ( & qtTranslator ) ;
2010-02-05 22:02:27 +03:00
2014-12-13 20:22:35 +03:00
if ( translator . load ( QString : : fromUtf8 ( " :/lang/qbittorrent_ " ) + locale ) ) {
qDebug ( " %s locale recognized, using translation. " , qPrintable ( locale ) ) ;
2006-09-30 20:02:39 +04:00
}
2014-12-13 20:22:35 +03:00
else {
qDebug ( " %s locale unrecognized, using default (en). " , qPrintable ( locale ) ) ;
2006-09-30 20:02:39 +04:00
}
2014-12-13 20:22:35 +03:00
app . installTranslator ( & translator ) ;
2010-01-03 01:20:37 +03:00
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
if ( locale . startsWith ( " ar " ) | | locale . startsWith ( " he " ) ) {
qDebug ( " Right to Left mode " ) ;
app . setLayoutDirection ( Qt : : RightToLeft ) ;
}
else {
app . setLayoutDirection ( Qt : : LeftToRight ) ;
}
2009-12-15 13:56:41 +03:00
# endif
2014-12-13 20:22:35 +03:00
app . setApplicationName ( QString : : fromUtf8 ( " qBittorrent " ) ) ;
// Check for executable parameters
if ( argc > 1 ) {
if ( QString : : fromLocal8Bit ( argv [ 1 ] ) = = QString : : fromUtf8 ( " --version " ) ) {
std : : cout < < " qBittorrent " < < VERSION < < ' \n ' ;
return EXIT_SUCCESS ;
* Replace priority combo boxes by check boxes in Web UI as in Regular UI
* Prepare http server and preferences classes to add new settings to Web UI
* Tabified Program preferences in Web UI since there will be a lot of settings soon
* Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
* Added a command line parameter to change the web ui port
* Fix PeerGuardian .p2b binary filter support
2009-12-28 22:39:47 +03:00
}
2014-12-13 20:22:35 +03:00
if ( QString : : fromLocal8Bit ( argv [ 1 ] ) = = QString : : fromUtf8 ( " --help " ) ) {
displayUsage ( argv [ 0 ] ) ;
return EXIT_SUCCESS ;
}
for ( int i = 1 ; i < argc ; + + i ) {
2010-01-03 01:20:37 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
if ( QString : : fromLocal8Bit ( argv [ i ] ) = = QString : : fromUtf8 ( " --no-splash " ) ) {
no_splash = true ;
}
else {
2010-01-03 01:20:37 +03:00
# endif
2014-12-13 20:22:35 +03:00
if ( QString : : fromLocal8Bit ( argv [ i ] ) . startsWith ( " --webui-port= " ) ) {
QStringList parts = QString : : fromLocal8Bit ( argv [ i ] ) . split ( " = " ) ;
if ( parts . size ( ) = = 2 ) {
bool ok = false ;
int new_port = parts . last ( ) . toInt ( & ok ) ;
if ( ok & & new_port > 0 & & new_port < = 65535 ) {
Preferences : : instance ( ) - > setWebUiPort ( new_port ) ;
}
}
}
# ifndef DISABLE_GUI
}
# endif
}
2009-09-30 22:57:06 +04:00
}
2010-01-03 01:20:37 +03:00
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
if ( pref - > isSlashScreenDisabled ( ) ) {
no_splash = true ;
}
QSplashScreen * splash = 0 ;
if ( ! no_splash ) {
QPixmap splash_img ( " :/Icons/skin/splash.png " ) ;
QPainter painter ( & splash_img ) ;
QString version = VERSION ;
painter . setPen ( QPen ( Qt : : white ) ) ;
painter . setFont ( QFont ( " Arial " , 22 , QFont : : Black ) ) ;
painter . drawText ( 224 - painter . fontMetrics ( ) . width ( version ) , 270 , version ) ;
splash = new QSplashScreen ( splash_img , Qt : : WindowStaysOnTopHint ) ;
QTimer : : singleShot ( 1500 , splash , SLOT ( deleteLater ( ) ) ) ;
splash - > show ( ) ;
app . processEvents ( ) ;
}
2009-12-15 13:56:41 +03:00
# endif
2014-12-13 20:22:35 +03:00
// Set environment variable
if ( ! qputenv ( " QBITTORRENT " , QByteArray ( VERSION ) ) ) {
std : : cerr < < " Couldn't set environment variable... \n " ;
}
2010-02-05 22:02:27 +03:00
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
app . setStyleSheet ( " QStatusBar::item { border-width: 0; } " ) ;
2009-12-15 13:56:41 +03:00
# endif
2010-02-05 22:02:27 +03:00
2014-12-13 20:22:35 +03:00
if ( ! userAgreesWithLegalNotice ( ) ) {
return EXIT_SUCCESS ;
}
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
app . setQuitOnLastWindowClosed ( false ) ;
2009-12-15 13:56:41 +03:00
# endif
2014-12-13 20:22:35 +03:00
2013-09-21 11:59:58 +04:00
# if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
2014-12-13 20:22:35 +03:00
signal ( SIGABRT , sigabrtHandler ) ;
signal ( SIGTERM , sigtermHandler ) ;
signal ( SIGINT , sigintHandler ) ;
signal ( SIGSEGV , sigsegvHandler ) ;
2009-01-18 18:12:38 +03:00
# endif
2014-12-13 20:22:35 +03:00
// Read torrents given on command line
QStringList torrents ;
QStringList appArguments = app . arguments ( ) ;
for ( int i = 1 ; i < appArguments . size ( ) ; + + i ) {
if ( ! appArguments [ i ] . startsWith ( " -- " ) ) {
qDebug ( ) < < " Command line argument: " < < appArguments [ i ] ;
torrents < < appArguments [ i ] ;
}
2013-01-19 18:38:34 +04:00
}
2011-01-10 20:33:53 +03:00
2009-12-15 13:56:41 +03:00
# ifndef DISABLE_GUI
2014-12-13 20:22:35 +03:00
MainWindow window ( 0 , torrents ) ;
QObject : : connect ( & app , SIGNAL ( messageReceived ( const QString & ) ) ,
& window , SLOT ( processParams ( const QString & ) ) ) ;
app . setActivationWindow ( & window ) ;
2013-09-21 11:59:58 +04:00
# ifdef Q_OS_MAC
2014-12-13 20:22:35 +03:00
static_cast < QMacApplication * > ( & app ) - > setReadyToProcessEvents ( ) ;
2013-09-21 11:59:58 +04:00
# endif // Q_OS_MAC
2009-12-15 13:56:41 +03:00
# else
2014-12-13 20:22:35 +03:00
// Load Headless class
HeadlessLoader loader ( torrents ) ;
QObject : : connect ( & app , SIGNAL ( messageReceived ( const QString & ) ) ,
& loader , SLOT ( processParams ( const QString & ) ) ) ;
2009-12-15 13:56:41 +03:00
# endif
2010-01-03 02:03:46 +03:00
2014-12-13 20:22:35 +03:00
int ret = app . exec ( ) ;
qDebug ( " Application has exited " ) ;
return ret ;
2010-07-21 14:40:46 +04:00
}