Browse Source

Simplify main() logic.

Add Application class.
Put application initialization code to Application class.
Place some code into separate functions.
adaptive-webui-19844
Vladimir Golovnev (Glassez) 10 years ago
parent
commit
ede6715e72
  1. 101
      src/application.cpp
  2. 59
      src/application.h
  3. 419
      src/main.cpp
  4. 8
      src/src.pro

101
src/application.cpp

@ -0,0 +1,101 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include <QDebug>
#include <QFileInfo>
#include <QLocale>
#include <QLibraryInfo>
#include <QSysInfo>
#include "application.h"
#include "preferences.h"
Application::Application(const QString &id, int &argc, char **argv)
#ifndef DISABLE_GUI
: SessionApplication(id, argc, argv)
#else
: QtSingleCoreApplication(id, argc, argv)
#endif
{
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
// fix Mac OS X 10.9 (mavericks) font issue
// https://bugreports.qt-project.org/browse/QTBUG-32789
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
}
#endif
setApplicationName("qBittorrent");
initializeTranslation();
#ifndef DISABLE_GUI
setStyleSheet("QStatusBar::item { border-width: 0; }");
setQuitOnLastWindowClosed(false);
#endif
}
void Application::initializeTranslation()
{
Preferences* const pref = Preferences::instance();
// Load translation
QString locale = pref->getLocale();
if (locale.isEmpty()) {
locale = QLocale::system().name();
pref->setLocale(locale);
}
if (qtTranslator_.load(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
qtTranslator_.load(
#endif
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&qtTranslator_);
if (translator_.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&translator_);
#ifndef DISABLE_GUI
if (locale.startsWith("ar") || locale.startsWith("he")) {
qDebug("Right to Left mode");
setLayoutDirection(Qt::RightToLeft);
}
else {
setLayoutDirection(Qt::LeftToRight);
}
#endif
}

59
src/application.h

@ -0,0 +1,59 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef APPLICATION_H
#define APPLICATION_H
#include <QStringList>
#include <QTranslator>
#ifndef DISABLE_GUI
#include "sessionapplication.h"
#else
#include "qtsinglecoreapplication.h"
#endif
class Application
#ifndef DISABLE_GUI
: public SessionApplication
#else
: public QtSingleCoreApplication
#endif
{
public:
Application(const QString &id, int &argc, char **argv);
private:
QTranslator qtTranslator_;
QTranslator translator_;
void initializeTranslation();
};
#endif // APPLICATION_H

419
src/main.cpp

@ -1,5 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -28,52 +29,46 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include <QLocale>
#include <QTranslator>
#include <QFile>
#include <QLibraryInfo>
#include <QDebug> #include <QDebug>
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#if defined(QBT_STATIC_QT) #include <QFont>
#include <QMessageBox>
#include <QPainter>
#include <QPen>
#include <QPushButton>
#include <QSplashScreen>
#include <QStyle>
#include <QStyleFactory>
#ifdef QBT_STATIC_QT
#include <QtPlugin> #include <QtPlugin>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_IMPORT_PLUGIN(QICOPlugin) Q_IMPORT_PLUGIN(QICOPlugin)
#else #else
Q_IMPORT_PLUGIN(qico) Q_IMPORT_PLUGIN(qico)
#endif #endif
#endif #endif // QBT_STATIC_QT
#include <QMessageBox>
#include <QStyleFactory>
#include <QStyle>
#include <QSplashScreen>
#include <QPainter>
#include <QPen>
#include <QFont>
#include <QPushButton>
#include <QTimer>
#include "sessionapplication.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ico.h" #include "ico.h"
#else #else // DISABLE_GUI
#include "qtsinglecoreapplication.h"
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include "headlessloader.h" #include "headlessloader.h"
#endif #endif // DISABLE_GUI
#include "preferences.h" #include "application.h"
#if defined(Q_OS_UNIX)
#ifdef Q_OS_UNIX
#include <signal.h> #include <signal.h>
#include <execinfo.h> #include <execinfo.h>
#include "stacktrace.h" #include "stacktrace.h"
#endif #endif // Q_OS_UNIX
#ifdef STACKTRACE_WIN #ifdef STACKTRACE_WIN
#include <signal.h> #include <signal.h>
#include "stacktrace_win.h" #include "stacktrace_win.h"
#include "stacktrace_win_dlg.h" #include "stacktrace_win_dlg.h"
#endif #endif //STACKTRACE_WIN
#include <stdlib.h> #include <stdlib.h>
#include "misc.h" #include "misc.h"
@ -83,54 +78,6 @@ Q_IMPORT_PLUGIN(qico)
#error You seem to have updated QtSingleApplication without porting our custom QtSingleApplication::getRunningPid() function. Please see previous version to understate how it works. #error You seem to have updated QtSingleApplication without porting our custom QtSingleApplication::getRunningPid() function. Please see previous version to understate how it works.
#endif #endif
void displayUsage(char* prg_name)
{
std::cout << qPrintable(QObject::tr("Usage:")) << std::endl;
std::cout << '\t' << prg_name << " --version: " << qPrintable(QObject::tr("displays program version")) << std::endl;
#ifndef DISABLE_GUI
std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(QObject::tr("disable splash screen")) << std::endl;
#else
std::cout << '\t' << prg_name << " -d | --daemon: " << qPrintable(QObject::tr("run in daemon-mode (background)")) << std::endl;
#endif
std::cout << '\t' << prg_name << " --help: " << qPrintable(QObject::tr("displays this help message")) << std::endl;
std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(QObject::tr("changes the webui port (current: %1)").arg(QString::number(Preferences::instance()->getWebUiPort()))) << std::endl;
std::cout << '\t' << prg_name << " " << qPrintable(QObject::tr("[files or urls]: downloads the torrents passed by the user (optional)")) << std::endl;
}
bool userAgreesWithLegalNotice()
{
Preferences* const pref = Preferences::instance();
if (pref->getAcceptedLegal()) // Already accepted once
return true;
#ifdef DISABLE_GUI
std::cout << std::endl << "*** " << qPrintable(QObject::tr("Legal Notice")) << " ***" << std::endl;
std::cout << qPrintable(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")) << std::endl << std::endl;
std::cout << qPrintable(QObject::tr("Press %1 key to accept and continue...").arg("'y'")) << std::endl;
char ret = getchar(); // Read pressed key
if (ret == 'y' || ret == 'Y') {
// Save the answer
pref->setAcceptedLegal(true);
return true;
}
return false;
#else
QMessageBox msgBox;
msgBox.setText(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued."));
msgBox.setWindowTitle(QObject::tr("Legal notice"));
msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(misc::screenCenter(&msgBox));
msgBox.exec();
if (msgBox.clickedButton() == agree_button) {
// Save the answer
pref->setAcceptedLegal(true);
return true;
}
return false;
#endif
}
#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN) #if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
void sigintHandler(int) void sigintHandler(int)
{ {
@ -185,199 +132,211 @@ void sigabrtHandler(int)
} }
#endif #endif
// Main #ifndef DISABLE_GUI
int main(int argc, char *argv[]) void showSplashScreen()
{ {
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI) QPixmap splash_img(":/Icons/skin/splash.png");
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) { QPainter painter(&splash_img);
// fix Mac OS X 10.9 (mavericks) font issue QString version = VERSION;
// https://bugreports.qt-project.org/browse/QTBUG-32789 painter.setPen(QPen(Qt::white));
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); painter.setFont(QFont("Arial", 22, QFont::Black));
} painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
QSplashScreen *splash = new QSplashScreen(splash_img, Qt::WindowStaysOnTopHint);
QTimer::singleShot(1500, splash, SLOT(deleteLater()));
splash->show();
qApp->processEvents();
}
#endif #endif
// Create Application void displayVersion()
QString uid = misc::getUserIDString(); {
#ifdef DISABLE_GUI std::cout << qPrintable(qApp->applicationName()) << " " << VERSION << std::endl;
bool shouldDaemonize = false; }
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--daemon") == 0) { void displayUsage(const char *prg_name)
shouldDaemonize = true; {
argc--; std::cout << qPrintable(QObject::tr("Usage:")) << std::endl;
for (int j = i; j < argc; j++) { std::cout << '\t' << prg_name << " --version: " << qPrintable(QObject::tr("displays program version")) << std::endl;
argv[j] = argv[j + 1]; #ifndef DISABLE_GUI
} std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(QObject::tr("disable splash screen")) << std::endl;
i--;
}
}
QtSingleCoreApplication app("qBittorrent-"+uid, argc, argv);
#else #else
SessionApplication app("qBittorrent-"+uid, argc, argv); std::cout << '\t' << prg_name << " -d | --daemon: " << qPrintable(QObject::tr("run in daemon-mode (background)")) << std::endl;
#endif #endif
std::cout << '\t' << prg_name << " --help: " << qPrintable(QObject::tr("displays this help message")) << std::endl;
std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(QObject::tr("changes the webui port (current: %1)").arg(QString::number(Preferences::instance()->getWebUiPort()))) << std::endl;
std::cout << '\t' << prg_name << " " << qPrintable(QObject::tr("[files or urls]: downloads the torrents passed by the user (optional)")) << std::endl;
}
// Check if qBittorrent is already running for this user void parseCommandLine(
if (app.isRunning()) { bool& showVersion, bool& showUsage,
qDebug("qBittorrent is already running for this user."); #ifndef DISABLE_GUI
// Read torrents given on command line bool& noSplash,
#ifdef Q_OS_WIN #else
DWORD pid = (DWORD)app.getRunningPid(); bool& shouldDaemonize,
if (pid > 0) {
BOOL b = AllowSetForegroundWindow(pid);
qDebug("AllowSetForegroundWindow() returns %s", b ? "TRUE" : "FALSE");
}
#endif #endif
QStringList torrentCmdLine = app.arguments(); QStringList& torrents
//Pass program parameters if any )
QString message; {
QFileInfo torrentPath; // Default values
for (int a = 1; a < torrentCmdLine.size(); ++a) { showVersion = false;
if (torrentCmdLine[a].startsWith("--")) continue; showUsage = false;
#ifndef DISABLE_GUI
torrentPath.setFile(torrentCmdLine[a]); noSplash = Preferences::instance()->isSlashScreenDisabled();
if (torrentPath.exists()) #else
message += torrentPath.absoluteFilePath(); shouldDaemonize = false;
else #endif
message += torrentCmdLine[a]; torrents.clear();
if (a < argc-1) QStringList appArguments = qApp->arguments();
message += "|";
}
if (!message.isEmpty()) { for (int i = 1; i < appArguments.size(); ++i) {
qDebug("Passing program parameters to running instance..."); QString& arg = appArguments[i];
qDebug("Message: %s", qPrintable(message));
app.sendMessage(message); if (arg == "--version") {
showVersion = true;
} }
else { // Raise main window else if (arg == "--usage") {
app.sendMessage("qbt://show"); showUsage = true;
}
else if (arg.startsWith("--webui-port=")) {
QStringList parts = arg.split("=");
if (parts.size() == 2) {
bool ok = false;
int new_port = parts.last().toInt(&ok);
if (ok && (new_port > 0) && (new_port <= 65535))
Preferences::instance()->setWebUiPort(new_port);
}
} }
return EXIT_SUCCESS;
}
srand(time(0));
Preferences* const pref = Preferences::instance();
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
bool no_splash = false; else if (arg == "--no-splash") {
noSplash = true;
}
#else #else
if (shouldDaemonize && daemon(1, 0) != 0) { else if ((arg == "-d") || (arg == "--daemon")) {
qCritical("Something went wrong while daemonizing, exiting..."); shouldDaemonize = true;
return EXIT_FAILURE; }
}
#endif #endif
else if (!arg.startsWith("--")) {
QFileInfo torrentPath;
torrentPath.setFile(arg);
// Load translation if (torrentPath.exists())
QString locale = pref->getLocale(); torrents += torrentPath.absoluteFilePath();
QTranslator qtTranslator; else
QTranslator translator; torrents += arg;
if (locale.isEmpty()) { }
locale = QLocale::system().name();
pref->setLocale(locale);
}
if (qtTranslator.load(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
qtTranslator.load(
#endif
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(locale));
} }
app.installTranslator(&qtTranslator); }
if (translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) { bool userAgreesWithLegalNotice()
qDebug("%s locale recognized, using translation.", qPrintable(locale)); {
} Preferences* const pref = Preferences::instance();
else { if (pref->getAcceptedLegal()) // Already accepted once
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale)); return true;
}
app.installTranslator(&translator);
#ifndef DISABLE_GUI #ifdef DISABLE_GUI
if (locale.startsWith("ar") || locale.startsWith("he")) { std::cout << std::endl << "*** " << qPrintable(QObject::tr("Legal Notice")) << " ***" << std::endl;
qDebug("Right to Left mode"); std::cout << qPrintable(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued.")) << std::endl << std::endl;
app.setLayoutDirection(Qt::RightToLeft); std::cout << qPrintable(QObject::tr("Press %1 key to accept and continue...").arg("'y'")) << std::endl;
char ret = getchar(); // Read pressed key
if (ret == 'y' || ret == 'Y') {
// Save the answer
pref->setAcceptedLegal(true);
return true;
} }
else { #else
app.setLayoutDirection(Qt::LeftToRight); QMessageBox msgBox;
msgBox.setText(QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.\n\nNo further notices will be issued."));
msgBox.setWindowTitle(QObject::tr("Legal notice"));
msgBox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
QAbstractButton *agree_button = msgBox.addButton(QObject::tr("I Agree"), QMessageBox::AcceptRole);
msgBox.show(); // Need to be shown or to moveToCenter does not work
msgBox.move(misc::screenCenter(&msgBox));
msgBox.exec();
if (msgBox.clickedButton() == agree_button) {
// Save the answer
pref->setAcceptedLegal(true);
return true;
} }
#endif #endif
app.setApplicationName(QString::fromUtf8("qBittorrent")); return false;
}
// Check for executable parameters
if (argc > 1) {
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--version")) {
std::cout << "qBittorrent " << VERSION << '\n';
return EXIT_SUCCESS;
}
if (QString::fromLocal8Bit(argv[1]) == QString::fromUtf8("--help")) {
displayUsage(argv[0]);
return EXIT_SUCCESS;
}
for (int i = 1; i < argc; ++i) { // Main
int main(int argc, char *argv[])
{
// We must save it here because QApplication constructor may change it
bool isOneArg = (argc == 2);
bool showVersion;
bool showUsage;
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
if (QString::fromLocal8Bit(argv[i]) == QString::fromUtf8("--no-splash")) { bool noSplash;
no_splash = true; #else
} bool shouldDaemonize;
else {
#endif #endif
if (QString::fromLocal8Bit(argv[i]).startsWith("--webui-port=")) { QStringList torrents;
QStringList parts = QString::fromLocal8Bit(argv[i]).split("=");
if (parts.size() == 2) { // Create Application
bool ok = false; Application app("qBittorrent-" + misc::getUserIDString(), argc, argv);
int new_port = parts.last().toInt(&ok);
if (ok && new_port > 0 && new_port <= 65535) {
Preferences::instance()->setWebUiPort(new_port);
}
}
}
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
} parseCommandLine(showVersion, showUsage, noSplash, torrents);
#else
parseCommandLine(showVersion, showUsage, shouldDaemonize, torrents);
#endif #endif
}
}
#ifndef DISABLE_GUI if (showVersion)
if (pref->isSlashScreenDisabled()) { displayVersion();
no_splash = true;
}
QSplashScreen *splash = 0; if (showUsage)
if (!no_splash) { displayUsage(argv[0]);
QPixmap splash_img(":/Icons/skin/splash.png");
QPainter painter(&splash_img); // If only one parameter is present and it is "--version"
QString version = VERSION; // or "--help", program exits after printing appropriate message.
painter.setPen(QPen(Qt::white)); if (isOneArg && (showVersion || showUsage))
painter.setFont(QFont("Arial", 22, QFont::Black)); return EXIT_SUCCESS;
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
splash = new QSplashScreen(splash_img, Qt::WindowStaysOnTopHint);
QTimer::singleShot(1500, splash, SLOT(deleteLater()));
splash->show();
app.processEvents();
}
#endif
// Set environment variable // Set environment variable
if (!qputenv("QBITTORRENT", QByteArray(VERSION))) { if (!qputenv("QBITTORRENT", QByteArray(VERSION))) {
std::cerr << "Couldn't set environment variable...\n"; std::cerr << "Couldn't set environment variable...\n";
} }
#ifndef DISABLE_GUI if (!userAgreesWithLegalNotice())
app.setStyleSheet("QStatusBar::item { border-width: 0; }"); return EXIT_SUCCESS;
// Check if qBittorrent is already running for this user
if (app.isRunning()) {
qDebug("qBittorrent is already running for this user.");
#ifdef Q_OS_WIN
DWORD pid = (DWORD)app.getRunningPid();
if (pid > 0) {
BOOL b = AllowSetForegroundWindow(pid);
qDebug("AllowSetForegroundWindow() returns %s", b ? "TRUE" : "FALSE");
}
#endif #endif
if (!torrents.isEmpty()) {
QString message = torrents.join("|");
qDebug("Passing program parameters to running instance...");
qDebug("Message: %s", qPrintable(message));
app.sendMessage(message);
}
else { // Raise main window
app.sendMessage("qbt://show");
}
if (!userAgreesWithLegalNotice()) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#ifndef DISABLE_GUI srand(time(0));
app.setQuitOnLastWindowClosed(false); #ifdef DISABLE_GUI
if (shouldDaemonize && (daemon(1, 0) != 0)) {
qCritical("Something went wrong while daemonizing, exiting...");
return EXIT_FAILURE;
}
#else
if (!noSplash)
showSplashScreen();
#endif #endif
#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN) #if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
@ -387,16 +346,6 @@ int main(int argc, char *argv[])
signal(SIGSEGV, sigsegvHandler); signal(SIGSEGV, sigsegvHandler);
#endif #endif
// Read torrents given on command line
QStringList torrents;
QStringList appArguments = app.arguments();
for (int i = 1; i < appArguments.size(); ++i) {
if (!appArguments[i].startsWith("--")) {
qDebug() << "Command line argument:" << appArguments[i];
torrents << appArguments[i];
}
}
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
MainWindow window(0, torrents); MainWindow window(0, torrents);
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), QObject::connect(&app, SIGNAL(messageReceived(const QString&)),

8
src/src.pro

@ -4,7 +4,7 @@ CONFIG += qt thread
# Windows specific configuration # Windows specific configuration
win32 { win32 {
include(../winconf.pri) include(../winconf.pri)
} }
# Mac specific configuration # Mac specific configuration
@ -109,7 +109,8 @@ HEADERS += misc.h \
scannedfoldersmodel.h \ scannedfoldersmodel.h \
qinisettings.h \ qinisettings.h \
smtp.h \ smtp.h \
dnsupdater.h dnsupdater.h \
application.h
SOURCES += main.cpp \ SOURCES += main.cpp \
downloadthread.cpp \ downloadthread.cpp \
@ -118,7 +119,8 @@ SOURCES += main.cpp \
misc.cpp \ misc.cpp \
fs_utils.cpp \ fs_utils.cpp \
smtp.cpp \ smtp.cpp \
dnsupdater.cpp dnsupdater.cpp \
application.cpp
nox { nox {
HEADERS += headlessloader.h HEADERS += headlessloader.h

Loading…
Cancel
Save