Add in-app version information

This commit is contained in:
lupoDharkael
2017-07-28 21:23:25 +02:00
parent bd4b5b0def
commit 1c56baa00f
2 changed files with 18 additions and 4 deletions

View File

@@ -27,6 +27,8 @@
#include <QDir>
int main(int argc, char *argv[]) {
qApp->setApplicationVersion(static_cast<QString>(APP_VERSION));
QTranslator translator;
translator.load(QLocale::system().language(),
"Internationalization", "_", "/usr/share/flameshot/translations/");
@@ -52,7 +54,12 @@ int main(int argc, char *argv[]) {
app.setApplicationName("flameshot");
app.setOrganizationName("Dharkael");
// CLI parsing
QCommandLineParser parser;
QCommandLineOption versionOption(QStringList() << "v" << "version",
"Show version information");
parser.addOption(versionOption);
parser.addHelpOption();
parser.setApplicationDescription(
"Powerfull yet simple to use screenshot software.");
@@ -64,17 +71,22 @@ int main(int argc, char *argv[]) {
"mode [mode_options]");
parser.parse(app.arguments());
// show app version
if (parser.isSet("version")) {
qInfo().noquote() << "Flameshot" << qApp->applicationVersion()
<< "\nCompiled with Qt" << QT_VERSION_STR;
return 0;
}
const QStringList args = parser.positionalArguments();
const QString command = args.isEmpty() ? QString() : args.first();
QCommandLineOption pathOption(QStringList() << "p" << "path",
"Path where the capture will be saved",
"pathVal");
"Path where the capture will be saved", "");
QCommandLineOption clipboardOption({{"c", "clipboard"},
"Save the capture to the clipboard"});
QCommandLineOption delayOption(QStringList() << "d" << "delay",
"Delay time in milliseconds",
"pathVal");
"Delay time in milliseconds", "0");
// parse commands
if (command == "full") {
parser.clearPositionalArguments();
parser.addPositionalArgument(