mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #473, added help / version option for core and made help box info type
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a33558987c
commit
4268f9c347
@@ -275,7 +275,7 @@ namespace BlackGui
|
||||
void CGuiUtility::commandLineErrorMessage(const QString &errorMessage, const QCommandLineParser &parser)
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::warning(0, QGuiApplication::applicationDisplayName(), "<html><head/><body><h2>" + errorMessage + "</h2><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
QMessageBox::warning(nullptr, QGuiApplication::applicationDisplayName(), "<html><head/><body><h2>" + errorMessage + "</h2><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
# else
|
||||
fputs(qPrintable(errorMessage), stderr);
|
||||
fputs("\n\n", stderr);
|
||||
@@ -286,7 +286,7 @@ namespace BlackGui
|
||||
void CGuiUtility::commandLineVersionRequested()
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::information(0, QGuiApplication::applicationDisplayName(), QGuiApplication::applicationDisplayName() + ' ' + QCoreApplication::applicationVersion());
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), QGuiApplication::applicationDisplayName() + ' ' + QCoreApplication::applicationVersion());
|
||||
# else
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
# endif
|
||||
@@ -295,7 +295,7 @@ namespace BlackGui
|
||||
void CGuiUtility::commandLineHelpRequested(QCommandLineParser &parser)
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QMessageBox::warning(0, QGuiApplication::applicationDisplayName(), "<html><head/><body><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), "<html><head/><body><pre>" + parser.helpText() + "</pre></body></html>");
|
||||
# else
|
||||
parser.showHelp(); // terminates
|
||||
Q_UNREACHABLE();
|
||||
|
||||
@@ -42,15 +42,22 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, CSwiftCore::
|
||||
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
|
||||
parser.addOption({{"s", "session"}, QCoreApplication::translate("main", "Use session bus.")});
|
||||
parser.addOption({{"y", "system"}, QCoreApplication::translate("main", "Use system bus.")});
|
||||
parser.addOption({{"p", "p2p"}, QCoreApplication::translate("main", "Use P2P bus with <address>."), QCoreApplication::translate("main", "address") });
|
||||
parser.addOption({{"p", "p2p"}, QCoreApplication::translate("main", "Use P2P bus with address.")});
|
||||
parser.addOption({{"m", "minimized"}, QCoreApplication::translate("main", "Start minimized in system tray.")});
|
||||
|
||||
QCommandLineOption helpOption = parser.addHelpOption();
|
||||
QCommandLineOption versionOption = parser.addVersionOption();
|
||||
|
||||
if (!parser.parse(QCoreApplication::arguments()))
|
||||
{
|
||||
*errorMessage = parser.errorText();
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
// help/version
|
||||
if (parser.isSet(helpOption)) { return CommandLineHelpRequested; }
|
||||
if (parser.isSet(versionOption)) { return CommandLineVersionRequested; }
|
||||
|
||||
if (parser.isSet("session"))
|
||||
{
|
||||
if (parser.isSet("system") || parser.isSet("p2p"))
|
||||
@@ -93,11 +100,9 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, CSwiftCore::
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
CGuiUtility::initSwiftGuiApplication(a, "swiftcore", CIcons::swiftNova24());
|
||||
const QString appName("swiftcore");
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("swiftcore");
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.setApplicationDescription(appName);
|
||||
|
||||
CSwiftCore::SetupInfo setup;
|
||||
QString errorMessage;
|
||||
@@ -122,6 +127,7 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
CGuiUtility::initSwiftGuiApplication(a, appName, CIcons::swiftNova24());
|
||||
CSwiftCore w(setup);
|
||||
if (!setup.m_minimzed) { w.show(); }
|
||||
return a.exec();
|
||||
|
||||
Reference in New Issue
Block a user