diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2017-08-21 09:19:33 +0200 |
---|---|---|
committer | Holger Freyther <holger+qt@freyther.de> | 2017-09-12 06:17:48 +0000 |
commit | 7f17ecb20a42dbf6ad2d994f9521e738b4b97a11 (patch) | |
tree | 8a09551080b0d356fd421cf633cc7c8e1047b0cd /wayland/democompositor | |
parent | 1a80548f586f4e1c0e747276e67fb6da9f213718 (diff) |
democompositor: Make font name, font size and scene configurable
Make it easy to launch another scene. Use the QCommandLineParser
to parse the font name, font size and the qml scene.
Change-Id: Ib2489f81bc6119ff92da01b6f36035d5266bfacf
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'wayland/democompositor')
-rw-r--r-- | wayland/democompositor/main.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/wayland/democompositor/main.cpp b/wayland/democompositor/main.cpp index ac25eaf..2b1279d 100644 --- a/wayland/democompositor/main.cpp +++ b/wayland/democompositor/main.cpp @@ -48,6 +48,8 @@ ** ****************************************************************************/ +#include <QtCore/QCommandLineOption> +#include <QtCore/QCommandLineParser> #include <QtCore/QUrl> #include <QtCore/QDebug> @@ -71,13 +73,38 @@ int main(int argc, char *argv[]) { qputenv("QT_QPA_EGLFS_HIDECURSOR", "1"); QGuiApplication app(argc, argv); + QGuiApplication::setApplicationName("democompositor"); + QGuiApplication::setApplicationVersion("1.0"); - QFont f("Open Sans", 12); + /* Parse options */ + QCommandLineParser parser; + parser.setApplicationDescription("Demo Compositor"); + parser.addHelpOption(); + parser.addVersionOption(); + + QCommandLineOption fontNameOpt(QStringList() << "f" << "font", + QCoreApplication::translate("main", "Default font to use"), + QCoreApplication::translate("main", "Name of the font"), + "Open Sans"); + parser.addOption(fontNameOpt); + QCommandLineOption fontNameSzeOpt(QStringList() << "s" << "size", + QCoreApplication::translate("main", "Default font size to use"), + QCoreApplication::translate("main", "Point size of the font"), + "12"); + parser.addOption(fontNameSzeOpt); + QCommandLineOption qmlUrlOpt(QStringList() << "o" << "open", + QCoreApplication::translate("main", "QML scene to open"), + QCoreApplication::translate("main", "URL"), + "qrc:///qml/main.qml"); + parser.addOption(qmlUrlOpt); + parser.process(app); + + QFont f(parser.value(fontNameOpt), parser.value(fontNameSzeOpt).toInt()); app.setFont(f); qputenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1"); registerTypes(); - QQmlApplicationEngine appEngine(QUrl("qrc:///qml/main.qml")); + QQmlApplicationEngine appEngine(QUrl(parser.value(qmlUrlOpt))); return app.exec(); } |