|
|
@ -32,21 +32,27 @@ |
|
|
|
#include <QLocale> |
|
|
|
#include <QLocale> |
|
|
|
#include <QTranslator> |
|
|
|
#include <QTranslator> |
|
|
|
#include <QFile> |
|
|
|
#include <QFile> |
|
|
|
#include <QSplashScreen> |
|
|
|
|
|
|
|
|
|
|
|
#ifndef DIABLE_GUI |
|
|
|
|
|
|
|
#include <QSplashScreen> |
|
|
|
|
|
|
|
#include <QPlastiqueStyle> |
|
|
|
|
|
|
|
#include "qgnomelook.h" |
|
|
|
|
|
|
|
#include <QMotifStyle> |
|
|
|
|
|
|
|
#include <QCDEStyle> |
|
|
|
|
|
|
|
#ifdef Q_WS_WIN |
|
|
|
|
|
|
|
#include <QWindowsXPStyle> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef Q_WS_MAC |
|
|
|
|
|
|
|
#include <QMacStyle> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#include "GUI.h" |
|
|
|
|
|
|
|
#include "ico.h" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <QSettings> |
|
|
|
#include <QSettings> |
|
|
|
#include <QLocalSocket> |
|
|
|
#include <QLocalSocket> |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/types.h> |
|
|
|
#include <QPlastiqueStyle> |
|
|
|
|
|
|
|
#include "qgnomelook.h" |
|
|
|
|
|
|
|
#include <QMotifStyle> |
|
|
|
|
|
|
|
#include <QCDEStyle> |
|
|
|
|
|
|
|
#ifdef Q_WS_WIN |
|
|
|
|
|
|
|
#include <QWindowsXPStyle> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef Q_WS_MAC |
|
|
|
|
|
|
|
#include <QMacStyle> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef Q_WS_WIN |
|
|
|
#ifndef Q_WS_WIN |
|
|
|
#include <signal.h> |
|
|
|
#include <signal.h> |
|
|
|
#include <execinfo.h> |
|
|
|
#include <execinfo.h> |
|
|
@ -54,9 +60,7 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include "GUI.h" |
|
|
|
|
|
|
|
#include "misc.h" |
|
|
|
#include "misc.h" |
|
|
|
#include "ico.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QApplication *app; |
|
|
|
QApplication *app; |
|
|
|
|
|
|
|
|
|
|
@ -81,6 +85,7 @@ void sigabrtHandler(int) { |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
void useStyle(QApplication *app, int style){ |
|
|
|
void useStyle(QApplication *app, int style){ |
|
|
|
switch(style) { |
|
|
|
switch(style) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
@ -113,13 +118,16 @@ void useStyle(QApplication *app, int style){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Main
|
|
|
|
// Main
|
|
|
|
int main(int argc, char *argv[]){ |
|
|
|
int main(int argc, char *argv[]){ |
|
|
|
QFile file; |
|
|
|
QFile file; |
|
|
|
QString locale; |
|
|
|
QString locale; |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
bool no_splash = false; |
|
|
|
bool no_splash = false; |
|
|
|
|
|
|
|
#endif |
|
|
|
if(argc > 1){ |
|
|
|
if(argc > 1){ |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){ |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){ |
|
|
|
std::cout << "qBittorrent " << VERSION << '\n'; |
|
|
|
std::cout << "qBittorrent " << VERSION << '\n'; |
|
|
@ -128,18 +136,24 @@ int main(int argc, char *argv[]){ |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--help")){ |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--help")){ |
|
|
|
std::cout << "Usage: \n"; |
|
|
|
std::cout << "Usage: \n"; |
|
|
|
std::cout << '\t' << argv[0] << " --version : displays program version\n"; |
|
|
|
std::cout << '\t' << argv[0] << " --version : displays program version\n"; |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
std::cout << '\t' << argv[0] << " --no-splash : disable splash screen\n"; |
|
|
|
std::cout << '\t' << argv[0] << " --no-splash : disable splash screen\n"; |
|
|
|
|
|
|
|
#endif |
|
|
|
std::cout << '\t' << argv[0] << " --help : displays this help message\n"; |
|
|
|
std::cout << '\t' << argv[0] << " --help : displays this help message\n"; |
|
|
|
std::cout << '\t' << argv[0] << " [files or urls] : starts program and download given parameters (optional)\n"; |
|
|
|
std::cout << '\t' << argv[0] << " [files or urls] : starts program and download given parameters (optional)\n"; |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--no-splash")){ |
|
|
|
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--no-splash")){ |
|
|
|
no_splash = true; |
|
|
|
no_splash = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
if(settings.value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool()) { |
|
|
|
if(settings.value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool()) { |
|
|
|
no_splash = true; |
|
|
|
no_splash = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
// Set environment variable
|
|
|
|
// Set environment variable
|
|
|
|
if(putenv((char*)"QBITTORRENT="VERSION)) { |
|
|
|
if(putenv((char*)"QBITTORRENT="VERSION)) { |
|
|
|
std::cerr << "Couldn't set environment variable...\n"; |
|
|
|
std::cerr << "Couldn't set environment variable...\n"; |
|
|
@ -173,6 +187,7 @@ int main(int argc, char *argv[]){ |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
app = new QApplication(argc, argv); |
|
|
|
app = new QApplication(argc, argv); |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
useStyle(app, settings.value("Preferences/General/Style", 0).toInt()); |
|
|
|
useStyle(app, settings.value("Preferences/General/Style", 0).toInt()); |
|
|
|
app->setStyleSheet("QStatusBar::item { border-width: 0; }"); |
|
|
|
app->setStyleSheet("QStatusBar::item { border-width: 0; }"); |
|
|
|
QSplashScreen *splash = 0; |
|
|
|
QSplashScreen *splash = 0; |
|
|
@ -180,6 +195,7 @@ int main(int argc, char *argv[]){ |
|
|
|
splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png"))); |
|
|
|
splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png"))); |
|
|
|
splash->show(); |
|
|
|
splash->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
// Open options file to read locale
|
|
|
|
// Open options file to read locale
|
|
|
|
locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString(); |
|
|
|
locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString(); |
|
|
|
QTranslator translator; |
|
|
|
QTranslator translator; |
|
|
@ -194,7 +210,9 @@ int main(int argc, char *argv[]){ |
|
|
|
} |
|
|
|
} |
|
|
|
app->installTranslator(&translator); |
|
|
|
app->installTranslator(&translator); |
|
|
|
app->setApplicationName(QString::fromUtf8("qBittorrent")); |
|
|
|
app->setApplicationName(QString::fromUtf8("qBittorrent")); |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
app->setQuitOnLastWindowClosed(false); |
|
|
|
app->setQuitOnLastWindowClosed(false); |
|
|
|
|
|
|
|
#endif |
|
|
|
#ifndef Q_WS_WIN |
|
|
|
#ifndef Q_WS_WIN |
|
|
|
signal(SIGABRT, sigabrtHandler); |
|
|
|
signal(SIGABRT, sigabrtHandler); |
|
|
|
signal(SIGTERM, sigtermHandler); |
|
|
|
signal(SIGTERM, sigtermHandler); |
|
|
@ -204,14 +222,21 @@ int main(int argc, char *argv[]){ |
|
|
|
QStringList torrentCmdLine = app->arguments(); |
|
|
|
QStringList torrentCmdLine = app->arguments(); |
|
|
|
// Remove first argument (program name)
|
|
|
|
// Remove first argument (program name)
|
|
|
|
torrentCmdLine.removeFirst(); |
|
|
|
torrentCmdLine.removeFirst(); |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
GUI *window = new GUI(0, torrentCmdLine); |
|
|
|
GUI *window = new GUI(0, torrentCmdLine); |
|
|
|
if(!no_splash) { |
|
|
|
if(!no_splash) { |
|
|
|
splash->finish(window); |
|
|
|
splash->finish(window); |
|
|
|
delete splash; |
|
|
|
delete splash; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
// Load Headless class
|
|
|
|
|
|
|
|
// TODO: by Frederic Lassabe
|
|
|
|
|
|
|
|
#endif |
|
|
|
int ret = app->exec(); |
|
|
|
int ret = app->exec(); |
|
|
|
|
|
|
|
#ifndef DISABLE_GUI |
|
|
|
delete window; |
|
|
|
delete window; |
|
|
|
qDebug("GUI was deleted!"); |
|
|
|
qDebug("GUI was deleted!"); |
|
|
|
|
|
|
|
#endif |
|
|
|
qDebug("Deleting app..."); |
|
|
|
qDebug("Deleting app..."); |
|
|
|
delete app; |
|
|
|
delete app; |
|
|
|
qDebug("App was deleted! All good."); |
|
|
|
qDebug("App was deleted! All good."); |
|
|
|