From 148d175ab010cb4d51a32561b651737ba34349d4 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 30 Sep 2009 18:57:06 +0000 Subject: [PATCH] - Added a command line parameter --no-splash to disable splash screen --- src/GUI.cpp | 1 + src/main.cpp | 140 +++++++++++++++++++++++++++------------------------ 2 files changed, 76 insertions(+), 65 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index 5f9a0321b..da541499d 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -956,6 +956,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool(); foreach(QString param, params) { param = param.trimmed(); + if(param.startsWith("--")) continue; if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) { BTSession->downloadFromUrl(param); }else{ diff --git a/src/main.cpp b/src/main.cpp index 5378c4f1f..89d8cd61f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,27 +35,27 @@ #include #include #ifdef QT_4_4 - #include - #include - #include +#include +#include +#include #else - #include - #include +#include +#include #endif #include #include "qgnomelook.h" #include #include #ifdef Q_WS_WIN - #include +#include #endif #ifdef Q_WS_MAC - #include +#include #endif #ifndef Q_WS_WIN - #include - #include - #include "stacktrace.h" +#include +#include +#include "stacktrace.h" #endif #include @@ -66,44 +66,44 @@ QApplication *app; #ifndef Q_WS_WIN - void sigtermHandler(int) { - qDebug("Catching SIGTERM, exiting cleanly"); - app->exit(); - } - void sigsegvHandler(int) { - std::cerr << "\n\n*************************************************************\n"; - std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n"; - print_stacktrace(); - std::raise(SIGINT); - std::abort(); - } +void sigtermHandler(int) { + qDebug("Catching SIGTERM, exiting cleanly"); + app->exit(); +} +void sigsegvHandler(int) { + std::cerr << "\n\n*************************************************************\n"; + std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n"; + print_stacktrace(); + std::raise(SIGINT); + std::abort(); +} #endif void useStyle(QApplication *app, int style){ switch(style) { - case 1: - app->setStyle(new QPlastiqueStyle()); - break; - case 2: - app->setStyle(new QGnomeLookStyle()); - break; - case 3: - app->setStyle(new QMotifStyle()); - break; - case 4: - app->setStyle(new QCDEStyle()); - break; + case 1: + app->setStyle(new QPlastiqueStyle()); + break; + case 2: + app->setStyle(new QGnomeLookStyle()); + break; + case 3: + app->setStyle(new QMotifStyle()); + break; + case 4: + app->setStyle(new QCDEStyle()); + break; #ifdef Q_WS_MAC - case 5: + case 5: app->setStyle(new QMacStyle()); break; #endif #ifdef Q_WS_WIN - case 6: + case 6: app->setStyle(new QWindowsXPStyle()); break; #endif - default: + default: if(app->style()->objectName() == "cleanlooks") { // Force our own cleanlooks style qDebug("Forcing our own cleanlooks style"); @@ -116,6 +116,7 @@ void useStyle(QApplication *app, int style){ int main(int argc, char *argv[]){ QFile file; QString locale; + bool no_splash = false; if(argc > 1){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){ std::cout << "qBittorrent " << VERSION << '\n'; @@ -124,10 +125,14 @@ 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"; + std::cout << '\t' << argv[0] << " --no-splash : disable splash screen\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"; return 0; } + if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--no-splash")){ + no_splash = true; + } } // Set environment variable if(putenv((char*)"QBITTORRENT="VERSION)) { @@ -146,44 +151,47 @@ int main(int argc, char *argv[]){ #else int serverPort = settings.value(QString::fromUtf8("uniqueInstancePort"), -1).toInt(); if(serverPort != -1) { - localSocket.connectToHost(QHostAddress::LocalHost, serverPort, QIODevice::WriteOnly); + localSocket.connectToHost(QHostAddress::LocalHost, serverPort, QIODevice::WriteOnly); #endif - if (localSocket.waitForConnected(1000)){ - std::cout << "Another qBittorrent instance is already running...\n"; - // Send parameters - if(argc > 1){ - QStringList params; - for(int i=1;i 1){ + QStringList params; + for(int i=1;isetStyleSheet("QStatusBar::item { border-width: 0; }"); - QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png"))); - splash->show(); + QSplashScreen *splash; + if(!no_splash) { + splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png"))); + splash->show(); + } // Open options file to read locale locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString(); QTranslator translator; @@ -208,8 +216,10 @@ int main(int argc, char *argv[]){ // Remove first argument (program name) torrentCmdLine.removeFirst(); GUI *window = new GUI(0, torrentCmdLine); - splash->finish(window); - delete splash; + if(!no_splash) { + splash->finish(window); + delete splash; + } int ret = app->exec(); delete window; delete app;