mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 08:24:22 +00:00
- Edited project file in order not to compile UI classes when DISABLE_GUI is defined
- Added #ifndef directives to main.cpp in order to fix compilation when DISABLE_GUI is defined
This commit is contained in:
parent
0b7ca15c4f
commit
e2aaf5d1de
51
src/main.cpp
51
src/main.cpp
@ -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.");
|
||||||
|
160
src/src.pro
160
src/src.pro
@ -170,28 +170,10 @@ TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
|
|||||||
$$LANG_PATH/qbittorrent_sr.ts
|
$$LANG_PATH/qbittorrent_sr.ts
|
||||||
|
|
||||||
# Source code
|
# Source code
|
||||||
HEADERS += GUI.h \
|
HEADERS += misc.h \
|
||||||
misc.h \
|
|
||||||
options_imp.h \
|
|
||||||
about_imp.h \
|
|
||||||
createtorrent_imp.h \
|
|
||||||
searchlistdelegate.h \
|
|
||||||
proplistdelegate.h \
|
|
||||||
previewselect.h \
|
|
||||||
previewlistdelegate.h \
|
|
||||||
trackerlogin.h \
|
|
||||||
downloadthread.h \
|
downloadthread.h \
|
||||||
downloadfromurldlg.h \
|
|
||||||
torrentadditiondlg.h \
|
|
||||||
bittorrent.h \
|
bittorrent.h \
|
||||||
searchEngine.h \
|
|
||||||
rss.h \
|
|
||||||
rss_imp.h \
|
|
||||||
speedlimitdlg.h \
|
|
||||||
qtorrenthandle.h \
|
qtorrenthandle.h \
|
||||||
engineselectdlg.h \
|
|
||||||
pluginsource.h \
|
|
||||||
qgnomelook.h \
|
|
||||||
httpserver.h \
|
httpserver.h \
|
||||||
httpconnection.h \
|
httpconnection.h \
|
||||||
httprequestparser.h \
|
httprequestparser.h \
|
||||||
@ -199,70 +181,98 @@ HEADERS += GUI.h \
|
|||||||
json.h \
|
json.h \
|
||||||
eventmanager.h \
|
eventmanager.h \
|
||||||
filterparserthread.h \
|
filterparserthread.h \
|
||||||
trackersadditiondlg.h \
|
|
||||||
searchtab.h \
|
|
||||||
console_imp.h \
|
|
||||||
ico.h \
|
|
||||||
stacktrace.h \
|
stacktrace.h \
|
||||||
torrentpersistentdata.h \
|
torrentpersistentdata.h \
|
||||||
feeddownloader.h \
|
|
||||||
feedList.h \
|
|
||||||
supportedengines.h \
|
|
||||||
transferlistwidget.h \
|
|
||||||
transferlistdelegate.h \
|
|
||||||
transferlistfilterswidget.h \
|
|
||||||
propertieswidget.h \
|
|
||||||
torrentfilesmodel.h \
|
|
||||||
filesystemwatcher.h \
|
filesystemwatcher.h \
|
||||||
peerlistwidget.h \
|
preferences.h
|
||||||
peerlistdelegate.h \
|
|
||||||
reverseresolution.h \
|
!contains(DEFINES, DISABLE_GUI) {
|
||||||
preferences.h \
|
FORMS += GUI.h \
|
||||||
geoip.h \
|
feedList.h \
|
||||||
peeraddition.h \
|
supportedengines.h \
|
||||||
deletionconfirmationdlg.h \
|
transferlistwidget.h \
|
||||||
statusbar.h \
|
transferlistdelegate.h \
|
||||||
trackerlist.h \
|
transferlistfilterswidget.h \
|
||||||
downloadedpiecesbar.h \
|
propertieswidget.h \
|
||||||
pieceavailabilitybar.h
|
torrentfilesmodel.h \
|
||||||
FORMS += ui/mainwindow.ui \
|
geoip.h \
|
||||||
ui/options.ui \
|
peeraddition.h \
|
||||||
ui/about.ui \
|
deletionconfirmationdlg.h \
|
||||||
ui/createtorrent.ui \
|
statusbar.h \
|
||||||
ui/preview.ui \
|
trackerlist.h \
|
||||||
ui/login.ui \
|
downloadedpiecesbar.h \
|
||||||
ui/downloadfromurldlg.ui \
|
peerlistwidget.h \
|
||||||
ui/torrentadditiondlg.ui \
|
peerlistdelegate.h \
|
||||||
ui/search.ui \
|
reverseresolution.h \
|
||||||
ui/rss.ui \
|
feeddownloader.h \
|
||||||
ui/bandwidth_limit.ui \
|
trackersadditiondlg.h \
|
||||||
ui/engineselect.ui \
|
searchtab.h \
|
||||||
ui/pluginsource.ui \
|
console_imp.h \
|
||||||
ui/trackersadditiondlg.ui \
|
ico.h \
|
||||||
ui/console.ui \
|
engineselectdlg.h \
|
||||||
ui/feeddownloader.ui \
|
pluginsource.h \
|
||||||
ui/propertieswidget.ui \
|
qgnomelook.h \
|
||||||
ui/peer.ui \
|
searchEngine.h \
|
||||||
ui/confirmdeletiondlg.ui
|
rss.h \
|
||||||
SOURCES += GUI.cpp \
|
rss_imp.h \
|
||||||
main.cpp \
|
speedlimitdlg.h \
|
||||||
options_imp.cpp \
|
options_imp.h \
|
||||||
createtorrent_imp.cpp \
|
about_imp.h \
|
||||||
|
createtorrent_imp.h \
|
||||||
|
searchlistdelegate.h \
|
||||||
|
proplistdelegate.h \
|
||||||
|
previewselect.h \
|
||||||
|
previewlistdelegate.h \
|
||||||
|
downloadfromurldlg.h \
|
||||||
|
torrentadditiondlg.h \
|
||||||
|
trackerlogin.h \
|
||||||
|
pieceavailabilitybar.h
|
||||||
|
}
|
||||||
|
|
||||||
|
!contains(DEFINES, DISABLE_GUI) {
|
||||||
|
FORMS += ui/mainwindow.ui \
|
||||||
|
ui/options.ui \
|
||||||
|
ui/about.ui \
|
||||||
|
ui/createtorrent.ui \
|
||||||
|
ui/preview.ui \
|
||||||
|
ui/login.ui \
|
||||||
|
ui/downloadfromurldlg.ui \
|
||||||
|
ui/torrentadditiondlg.ui \
|
||||||
|
ui/search.ui \
|
||||||
|
ui/rss.ui \
|
||||||
|
ui/bandwidth_limit.ui \
|
||||||
|
ui/engineselect.ui \
|
||||||
|
ui/pluginsource.ui \
|
||||||
|
ui/trackersadditiondlg.ui \
|
||||||
|
ui/console.ui \
|
||||||
|
ui/feeddownloader.ui \
|
||||||
|
ui/propertieswidget.ui \
|
||||||
|
ui/peer.ui \
|
||||||
|
ui/confirmdeletiondlg.ui
|
||||||
|
}
|
||||||
|
SOURCES += main.cpp \
|
||||||
bittorrent.cpp \
|
bittorrent.cpp \
|
||||||
searchengine.cpp \
|
|
||||||
rss_imp.cpp \
|
|
||||||
qtorrenthandle.cpp \
|
qtorrenthandle.cpp \
|
||||||
engineselectdlg.cpp \
|
|
||||||
downloadthread.cpp \
|
downloadthread.cpp \
|
||||||
httpserver.cpp \
|
httpserver.cpp \
|
||||||
httpconnection.cpp \
|
httpconnection.cpp \
|
||||||
httprequestparser.cpp \
|
httprequestparser.cpp \
|
||||||
httpresponsegenerator.cpp \
|
httpresponsegenerator.cpp \
|
||||||
eventmanager.cpp \
|
eventmanager.cpp
|
||||||
searchtab.cpp \
|
|
||||||
ico.cpp \
|
!contains(DEFINES, DISABLE_GUI) {
|
||||||
rss.cpp \
|
SOURCES += GUI.cpp \
|
||||||
transferlistwidget.cpp \
|
options_imp.cpp \
|
||||||
propertieswidget.cpp \
|
createtorrent_imp.cpp \
|
||||||
peerlistwidget.cpp
|
searchengine.cpp \
|
||||||
|
rss_imp.cpp \
|
||||||
|
engineselectdlg.cpp \
|
||||||
|
searchtab.cpp \
|
||||||
|
ico.cpp \
|
||||||
|
rss.cpp \
|
||||||
|
transferlistwidget.cpp \
|
||||||
|
propertieswidget.cpp \
|
||||||
|
peerlistwidget.cpp
|
||||||
|
}
|
||||||
|
|
||||||
DESTDIR = .
|
DESTDIR = .
|
||||||
|
Loading…
x
Reference in New Issue
Block a user