From 5c80ce42e017b8961b906dcb0cbf73a5d54562cd Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 5 Feb 2010 19:02:27 +0000 Subject: [PATCH] Cosmetic fix to usage display (--help) Usage display is now localized --- src/main.cpp | 114 ++++++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b585f85ba..affd437a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -73,13 +73,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; } }; @@ -175,13 +175,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; } @@ -216,39 +271,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; }"); @@ -258,20 +281,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;