diff --git a/src/main.cpp b/src/main.cpp index 6b3c6a386..889d64c30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,11 +21,12 @@ #include "src/widget/toxsave.h" #include "src/autoupdate.h" #include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include #include #include @@ -57,6 +58,15 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); a.setApplicationName("qTox"); a.setOrganizationName("Tox"); + a.setApplicationVersion("\nGit commit: " + QString(GIT_VERSION)); + + // Process arguments + QCommandLineParser parser; + parser.setApplicationDescription("qTox, version: " + QString(GIT_VERSION) + "\nBuilt: " + __TIME__ + " " + __DATE__); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("uri", QObject::tr("Tox URI to parse")); + parser.process(a); Settings::getInstance(); // Build our Settings singleton as soon as QApplication is ready, not before @@ -83,7 +93,7 @@ int main(int argc, char *argv[]) // Windows platform plugins DLL hell fix QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); a.addLibraryPath("platforms"); - + qDebug() << "built on: " << __TIME__ << __DATE__; qDebug() << "commit: " << GIT_VERSION << "\n"; @@ -101,10 +111,9 @@ int main(int argc, char *argv[]) ipc.registerEventHandler(&toxURIEventHandler); ipc.registerEventHandler(&toxSaveEventHandler); - // Process arguments - if (argc >= 2) + if (parser.positionalArguments().size() > 0) { - QString firstParam(argv[1]); + QString firstParam(parser.positionalArguments()[0]); // Tox URIs. If there's already another qTox instance running, we ask it to handle the URI and we exit // Otherwise we start a new qTox instance and process it ourselves if (firstParam.startsWith("tox:"))