mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
use argstream::usage() in the help message box
This commit is contained in:
parent
8564a22bef
commit
4f56c7dd2f
@ -29,6 +29,7 @@ CrashStackTrace gCrashStackTrace;
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <rshare.h>
|
#include <rshare.h>
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
@ -209,18 +210,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
Q_INIT_RESOURCE(images);
|
Q_INIT_RESOURCE(images);
|
||||||
Q_INIT_RESOURCE(icons);
|
Q_INIT_RESOURCE(icons);
|
||||||
|
|
||||||
// Loop through all command-line args/values to get help wanted before RsInit exit.
|
// This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase
|
||||||
for (int i = 0; i < args.size(); ++i) {
|
|
||||||
QString arg;
|
|
||||||
/* Get the argument name and set a blank value */
|
|
||||||
arg = args.at(i);
|
|
||||||
if ((arg.toLower() == "-h") || (arg.toLower() == "--help")) {
|
|
||||||
QApplication dummyApp (argc, argv); // needed for QMessageBox
|
|
||||||
Rshare::showUsageMessageBox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase
|
|
||||||
//
|
//
|
||||||
RsControl::earlyInitNotificationSystem() ;
|
RsControl::earlyInitNotificationSystem() ;
|
||||||
|
|
||||||
@ -233,28 +223,57 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||||||
RsConfigOptions conf;
|
RsConfigOptions conf;
|
||||||
|
|
||||||
argstream as(argc,argv);
|
argstream as(argc,argv);
|
||||||
as >> option('s',"stderr" ,conf.outStderr ,"output to stderr instead of log file." )
|
as >> option('s',"stderr" ,conf.outStderr ,"output to stderr instead of log file " )
|
||||||
>> option('u',"udp" ,conf.udpListenerOnly,"Only listen to UDP." )
|
>> option('u',"udp" ,conf.udpListenerOnly,"Only listen to UDP " )
|
||||||
>> parameter('c',"base-dir" ,conf.optBaseDir ,"directory", "Set base directory." ,false)
|
>> parameter('c',"base-dir" ,conf.optBaseDir ,"directory", "Set base directory " ,false)
|
||||||
>> parameter('l',"log-file" ,conf.logfname ,"logfile" ,"Set Log filename." ,false)
|
>> parameter('l',"log-file" ,conf.logfname ,"logfile" ,"Set Log filename " ,false)
|
||||||
>> parameter('d',"debug-level" ,conf.debugLevel ,"level" ,"Set debug level." ,false)
|
>> parameter('d',"debug-level" ,conf.debugLevel ,"level" ,"Set debug level " ,false)
|
||||||
>> parameter('i',"ip-address" ,conf.forcedInetAddress,"nnn.nnn.nnn.nnn", "Force IP address to use (if cannot be detected)." ,false)
|
>> parameter('i',"ip-address" ,conf.forcedInetAddress,"nnn.nnn.nnn.nnn", "Force IP address " ,false)
|
||||||
>> parameter('p',"port" ,conf.forcedPort ,"port" ,"Set listenning port to use." ,false)
|
>> parameter('p',"port" ,conf.forcedPort ,"port" ,"Set listenning port " ,false)
|
||||||
>> parameter('o',"opmode" ,conf.opModeStr ,"opmode" ,"Set Operating mode (Full, NoTurtle, Gaming, Minimal)." ,false)
|
>> parameter('o',"opmode" ,conf.opModeStr ,"opmode" ,"Set mode (Full, NoTurtle, Gaming, Minimal) " ,false)
|
||||||
>> parameter('t',"opmode" ,conf.userSuppliedTorExecutable,"tor" ,"supply full tor eecutable path." ,false);
|
>> parameter('t',"opmode" ,conf.userSuppliedTorExecutable,"tor" ,"supply full tor executable path " ,false);
|
||||||
#ifdef RS_JSONAPI
|
#ifdef RS_JSONAPI
|
||||||
as >> parameter('J', "jsonApiPort", conf.jsonApiPort, "jsonApiPort", "Enable JSON API on the specified port", false )
|
as >> parameter('J', "jsonApiPort", conf.jsonApiPort, "jsonApiPort", "Enable JSON API on the specified port", false )
|
||||||
>> parameter('P', "jsonApiBindAddress", conf.jsonApiBindAddress, "jsonApiBindAddress", "JSON API Bind Address.", false);
|
>> parameter('P', "jsonApiBindAddress", conf.jsonApiBindAddress, "jsonApiBindAddress", "JSON API Bind Address ", false);
|
||||||
#endif // ifdef RS_JSONAPI
|
#endif // ifdef RS_JSONAPI
|
||||||
|
|
||||||
#ifdef LOCALNET_TESTING
|
#ifdef LOCALNET_TESTING
|
||||||
as >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false);
|
as >> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction " ,false);
|
||||||
#endif // ifdef LOCALNET_TESTING
|
#endif // ifdef LOCALNET_TESTING
|
||||||
|
|
||||||
#ifdef RS_AUTOLOGIN
|
#ifdef RS_AUTOLOGIN
|
||||||
as >> option('a',"auto-login" ,conf.autoLogin ,"AutoLogin (Windows Only) + StartMinimised");
|
as >> option('a',"auto-login" ,conf.autoLogin ,"AutoLogin (Windows Only) + StartMinimised");
|
||||||
#endif // ifdef RS_AUTOLOGIN
|
#endif // ifdef RS_AUTOLOGIN
|
||||||
|
as >> help('h',"help",QObject::tr("Display this help").toStdString().c_str());
|
||||||
|
|
||||||
|
if(as.helpRequested())
|
||||||
|
{
|
||||||
|
RsInfo() << "\n" <<
|
||||||
|
"+================================================================+\n"
|
||||||
|
"| o---o o |\n"
|
||||||
|
"| \\ / - Retroshare GUI - / \\ |\n"
|
||||||
|
"| o o---o |\n"
|
||||||
|
"+================================================================+"
|
||||||
|
<< std::endl ;
|
||||||
|
|
||||||
|
std::cerr << as.usage(true) << std::endl;
|
||||||
|
|
||||||
|
QApplication dummyApp (argc, argv); // needed for QMessageBox
|
||||||
|
QMessageBox box;
|
||||||
|
QString text = QString::fromUtf8(as.usage(true,false).c_str());
|
||||||
|
QFont font("Courier New",10,50,false);
|
||||||
|
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
||||||
|
font.setStyle(QFont::StyleNormal);
|
||||||
|
font.setBold(true);
|
||||||
|
box.setFont(font);
|
||||||
|
box.setInformativeText(text);
|
||||||
|
box.setWindowTitle(QObject::tr("Retroshare commandline arguments"));
|
||||||
|
|
||||||
|
// now compute the size of text and set the size of the box. For the record, this doesn't work...
|
||||||
|
box.setBaseSize( QSize(QFontMetricsF(font).width(text),QFontMetricsF(font).height()*text.count('\n')) );
|
||||||
|
box.exec();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
conf.main_executable_path = argv[0];
|
conf.main_executable_path = argv[0];
|
||||||
|
|
||||||
int initResult = RsInit::InitRetroShare(conf);
|
int initResult = RsInit::InitRetroShare(conf);
|
||||||
|
Loading…
Reference in New Issue
Block a user