1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-02-08 12:54:27 +00:00

- Added a command line parameter --no-splash to disable splash screen

This commit is contained in:
Christophe Dumez 2009-09-30 18:57:06 +00:00
parent 3dd9ebc61d
commit 148d175ab0
2 changed files with 76 additions and 65 deletions

View File

@ -956,6 +956,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool(); bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
foreach(QString param, params) { foreach(QString param, params) {
param = param.trimmed(); 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)) { 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); BTSession->downloadFromUrl(param);
}else{ }else{

View File

@ -35,27 +35,27 @@
#include <QSplashScreen> #include <QSplashScreen>
#include <QSettings> #include <QSettings>
#ifdef QT_4_4 #ifdef QT_4_4
#include <QLocalSocket> #include <QLocalSocket>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#else #else
#include <QTcpSocket> #include <QTcpSocket>
#include <QHostAddress> #include <QHostAddress>
#endif #endif
#include <QPlastiqueStyle> #include <QPlastiqueStyle>
#include "qgnomelook.h" #include "qgnomelook.h"
#include <QMotifStyle> #include <QMotifStyle>
#include <QCDEStyle> #include <QCDEStyle>
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#include <QWindowsXPStyle> #include <QWindowsXPStyle>
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include <QMacStyle> #include <QMacStyle>
#endif #endif
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
#include <signal.h> #include <signal.h>
#include <execinfo.h> #include <execinfo.h>
#include "stacktrace.h" #include "stacktrace.h"
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@ -66,44 +66,44 @@
QApplication *app; QApplication *app;
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
void sigtermHandler(int) { void sigtermHandler(int) {
qDebug("Catching SIGTERM, exiting cleanly"); qDebug("Catching SIGTERM, exiting cleanly");
app->exit(); app->exit();
} }
void sigsegvHandler(int) { void sigsegvHandler(int) {
std::cerr << "\n\n*************************************************************\n"; std::cerr << "\n\n*************************************************************\n";
std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n"; std::cerr << "Catching SIGSEGV, please report a bug at http://bug.qbittorrent.org\nand provide the following backtrace:\n";
print_stacktrace(); print_stacktrace();
std::raise(SIGINT); std::raise(SIGINT);
std::abort(); std::abort();
} }
#endif #endif
void useStyle(QApplication *app, int style){ void useStyle(QApplication *app, int style){
switch(style) { switch(style) {
case 1: case 1:
app->setStyle(new QPlastiqueStyle()); app->setStyle(new QPlastiqueStyle());
break; break;
case 2: case 2:
app->setStyle(new QGnomeLookStyle()); app->setStyle(new QGnomeLookStyle());
break; break;
case 3: case 3:
app->setStyle(new QMotifStyle()); app->setStyle(new QMotifStyle());
break; break;
case 4: case 4:
app->setStyle(new QCDEStyle()); app->setStyle(new QCDEStyle());
break; break;
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
case 5: case 5:
app->setStyle(new QMacStyle()); app->setStyle(new QMacStyle());
break; break;
#endif #endif
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
case 6: case 6:
app->setStyle(new QWindowsXPStyle()); app->setStyle(new QWindowsXPStyle());
break; break;
#endif #endif
default: default:
if(app->style()->objectName() == "cleanlooks") { if(app->style()->objectName() == "cleanlooks") {
// Force our own cleanlooks style // Force our own cleanlooks style
qDebug("Forcing 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[]){ int main(int argc, char *argv[]){
QFile file; QFile file;
QString locale; QString locale;
bool no_splash = false;
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';
@ -124,10 +125,14 @@ 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";
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] << " --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;
} }
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--no-splash")){
no_splash = true;
}
} }
// Set environment variable // Set environment variable
if(putenv((char*)"QBITTORRENT="VERSION)) { if(putenv((char*)"QBITTORRENT="VERSION)) {
@ -146,44 +151,47 @@ int main(int argc, char *argv[]){
#else #else
int serverPort = settings.value(QString::fromUtf8("uniqueInstancePort"), -1).toInt(); int serverPort = settings.value(QString::fromUtf8("uniqueInstancePort"), -1).toInt();
if(serverPort != -1) { if(serverPort != -1) {
localSocket.connectToHost(QHostAddress::LocalHost, serverPort, QIODevice::WriteOnly); localSocket.connectToHost(QHostAddress::LocalHost, serverPort, QIODevice::WriteOnly);
#endif #endif
if (localSocket.waitForConnected(1000)){ if (localSocket.waitForConnected(1000)){
std::cout << "Another qBittorrent instance is already running...\n"; std::cout << "Another qBittorrent instance is already running...\n";
// Send parameters // Send parameters
if(argc > 1){ if(argc > 1){
QStringList params; QStringList params;
for(int i=1;i<argc;++i){ for(int i=1;i<argc;++i){
params << QString::fromLocal8Bit(argv[i]); params << QString::fromLocal8Bit(argv[i]);
std::cout << argv[i] << '\n'; std::cout << argv[i] << '\n';
} }
QByteArray block = params.join("\n").toLocal8Bit(); QByteArray block = params.join("\n").toLocal8Bit();
std::cout << "writting: " << block.data() << '\n'; std::cout << "writting: " << block.data() << '\n';
std::cout << "size: " << block.size() << '\n'; std::cout << "size: " << block.size() << '\n';
uint val = localSocket.write(block); uint val = localSocket.write(block);
if(localSocket.waitForBytesWritten(5000)){ if(localSocket.waitForBytesWritten(5000)){
std::cout << "written(" <<val<<"): " << block.data() << '\n'; std::cout << "written(" <<val<<"): " << block.data() << '\n';
}else{ }else{
std::cerr << "Writing to the socket timed out\n"; std::cerr << "Writing to the socket timed out\n";
} }
#ifdef QT_4_4 #ifdef QT_4_4
localSocket.disconnectFromServer(); localSocket.disconnectFromServer();
#else #else
localSocket.disconnectFromHost(); localSocket.disconnectFromHost();
#endif #endif
std::cout << "disconnected\n"; std::cout << "disconnected\n";
}
localSocket.close();
return 0;
} }
localSocket.close();
return 0;
}
#ifndef QT_4_4 #ifndef QT_4_4
} }
#endif #endif
app = new QApplication(argc, argv); app = new QApplication(argc, argv);
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 = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png"))); QSplashScreen *splash;
splash->show(); if(!no_splash) {
splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/skin/splash.png")));
splash->show();
}
// 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;
@ -208,8 +216,10 @@ int main(int argc, char *argv[]){
// Remove first argument (program name) // Remove first argument (program name)
torrentCmdLine.removeFirst(); torrentCmdLine.removeFirst();
GUI *window = new GUI(0, torrentCmdLine); GUI *window = new GUI(0, torrentCmdLine);
splash->finish(window); if(!no_splash) {
delete splash; splash->finish(window);
delete splash;
}
int ret = app->exec(); int ret = app->exec();
delete window; delete window;
delete app; delete app;