From 90351c4a57326f85936e48a7063b596ed96d2a96 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 5 Feb 2010 19:06:46 +0000 Subject: [PATCH] BUGFIX: Usage display was improved and localized (--help) --- Changelog | 1 + src/main.cpp | 114 ++++++++++++++++++++++++++++----------------------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/Changelog b/Changelog index d44d2514c..87f1c3cd5 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ * Unreleased - Christophe Dumez - v2.1.4 - BUGFIX: Make sure seeding torrents display a progress of 100% + - BUGFIX: Usage display was improved and localized (--help) * Sun Jan 31 2010 - Christophe Dumez - v2.1.3 - BUGFIX: Fix "Append .!qB extension to complete files" (libtorrent v0.15) diff --git a/src/main.cpp b/src/main.cpp index 90205b5c4..866f6759f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,13 +81,13 @@ class UsageDisplay: public QObject { public: static void displayUsage(char* prg_name) { std::cout << tr("Usage:").toLocal8Bit().data() << std::endl; - std::cout << '\t' << prg_name << "--version: " << tr("displays program version").toLocal8Bit().data() << std::endl; + std::cout << '\t' << prg_name << " --version: " << tr("displays program version").toLocal8Bit().data() << std::endl; #ifndef DISABLE_GUI - std::cout << '\t' << prg_name << "--no-splash: " << tr("disable splash screen").toLocal8Bit().data() << std::endl; + std::cout << '\t' << prg_name << " --no-splash: " << tr("disable splash screen").toLocal8Bit().data() << std::endl; #endif - std::cout << '\t' << prg_name << "--help: " << tr("displays this help message").toLocal8Bit().data() << std::endl; - std::cout << '\t' << prg_name << "--webui-port=x: " << tr("changes the webui port (current: %1)").arg(QString::number(Preferences::getWebUiPort())).toLocal8Bit().data() << std::endl; - std::cout << '\t' << prg_name << tr("[files or urls]: downloads the torrents passed by the user (optional)").toLocal8Bit().data() << std::endl; + std::cout << '\t' << prg_name << " --help: " << tr("displays this help message").toLocal8Bit().data() << std::endl; + std::cout << '\t' << prg_name << " --webui-port=x: " << tr("changes the webui port (current: %1)").arg(QString::number(Preferences::getWebUiPort())).toLocal8Bit().data() << std::endl; + std::cout << '\t' << prg_name << " " << tr("[files or urls]: downloads the torrents passed by the user (optional)").toLocal8Bit().data() << std::endl; } }; @@ -201,13 +201,68 @@ int main(int argc, char *argv[]){ #ifndef DISABLE_GUI bool no_splash = false; #endif + + //Check if there is another instance running + QLocalSocket localSocket; + QString uid = QString::number(getuid()); + localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly); + if (localSocket.waitForConnected(1000)){ + std::cout << "Another qBittorrent instance is already running...\n"; + // Send parameters + if(argc > 1){ + QStringList params; + for(int i=1;iinstallTranslator(&translator); + app->setApplicationName(QString::fromUtf8("qBittorrent")); + + // Check for executable parameters if(argc > 1){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){ std::cout << "qBittorrent " << VERSION << '\n'; + delete app; return 0; } if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--help")){ UsageDisplay::displayUsage(argv[0]); + delete app; return 0; } @@ -242,39 +297,7 @@ int main(int argc, char *argv[]){ if(putenv((char*)"QBITTORRENT="VERSION)) { std::cerr << "Couldn't set environment variable...\n"; } - //Check if there is another instance running - QLocalSocket localSocket; - QString uid = QString::number(getuid()); - localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly); - if (localSocket.waitForConnected(1000)){ - std::cout << "Another qBittorrent instance is already running...\n"; - // Send parameters - if(argc > 1){ - QStringList params; - for(int i=1;isetStyleSheet("QStatusBar::item { border-width: 0; }"); @@ -284,20 +307,7 @@ int main(int argc, char *argv[]){ splash->show(); } #endif - // Open options file to read locale - locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString(); - QTranslator translator; - if(locale.isEmpty()){ - locale = QLocale::system().name(); - settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale); - } - if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){ - qDebug("%s locale recognized, using translation.", (const char*)locale.toLocal8Bit()); - }else{ - qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toLocal8Bit()); - } - app->installTranslator(&translator); - app->setApplicationName(QString::fromUtf8("qBittorrent")); + if(!LegalNotice::userAgreesWithNotice()) { #ifndef DISABLE_GUI delete splash;