- 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:
Christophe Dumez 2009-12-15 10:56:41 +00:00
parent 0b7ca15c4f
commit e2aaf5d1de
2 changed files with 123 additions and 88 deletions

View file

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

View file

@ -170,28 +170,10 @@ TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
$$LANG_PATH/qbittorrent_sr.ts
# Source code
HEADERS += GUI.h \
misc.h \
options_imp.h \
about_imp.h \
createtorrent_imp.h \
searchlistdelegate.h \
proplistdelegate.h \
previewselect.h \
previewlistdelegate.h \
trackerlogin.h \
HEADERS += misc.h \
downloadthread.h \
downloadfromurldlg.h \
torrentadditiondlg.h \
bittorrent.h \
searchEngine.h \
rss.h \
rss_imp.h \
speedlimitdlg.h \
qtorrenthandle.h \
engineselectdlg.h \
pluginsource.h \
qgnomelook.h \
httpserver.h \
httpconnection.h \
httprequestparser.h \
@ -199,70 +181,98 @@ HEADERS += GUI.h \
json.h \
eventmanager.h \
filterparserthread.h \
trackersadditiondlg.h \
searchtab.h \
console_imp.h \
ico.h \
stacktrace.h \
torrentpersistentdata.h \
feeddownloader.h \
feedList.h \
supportedengines.h \
transferlistwidget.h \
transferlistdelegate.h \
transferlistfilterswidget.h \
propertieswidget.h \
torrentfilesmodel.h \
filesystemwatcher.h \
peerlistwidget.h \
peerlistdelegate.h \
reverseresolution.h \
preferences.h \
geoip.h \
peeraddition.h \
deletionconfirmationdlg.h \
statusbar.h \
trackerlist.h \
downloadedpiecesbar.h \
pieceavailabilitybar.h
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 += GUI.cpp \
main.cpp \
options_imp.cpp \
createtorrent_imp.cpp \
preferences.h
!contains(DEFINES, DISABLE_GUI) {
FORMS += GUI.h \
feedList.h \
supportedengines.h \
transferlistwidget.h \
transferlistdelegate.h \
transferlistfilterswidget.h \
propertieswidget.h \
torrentfilesmodel.h \
geoip.h \
peeraddition.h \
deletionconfirmationdlg.h \
statusbar.h \
trackerlist.h \
downloadedpiecesbar.h \
peerlistwidget.h \
peerlistdelegate.h \
reverseresolution.h \
feeddownloader.h \
trackersadditiondlg.h \
searchtab.h \
console_imp.h \
ico.h \
engineselectdlg.h \
pluginsource.h \
qgnomelook.h \
searchEngine.h \
rss.h \
rss_imp.h \
speedlimitdlg.h \
options_imp.h \
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 \
searchengine.cpp \
rss_imp.cpp \
qtorrenthandle.cpp \
engineselectdlg.cpp \
downloadthread.cpp \
httpserver.cpp \
httpconnection.cpp \
httprequestparser.cpp \
httpresponsegenerator.cpp \
eventmanager.cpp \
searchtab.cpp \
ico.cpp \
rss.cpp \
transferlistwidget.cpp \
propertieswidget.cpp \
peerlistwidget.cpp
eventmanager.cpp
!contains(DEFINES, DISABLE_GUI) {
SOURCES += GUI.cpp \
options_imp.cpp \
createtorrent_imp.cpp \
searchengine.cpp \
rss_imp.cpp \
engineselectdlg.cpp \
searchtab.cpp \
ico.cpp \
rss.cpp \
transferlistwidget.cpp \
propertieswidget.cpp \
peerlistwidget.cpp
}
DESTDIR = .