aboutsummaryrefslogtreecommitdiffstats
path: root/demo/main.cpp
blob: e0651d955941655429c3e5fd6fa2d4dd403f076e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * @file   main.cpp
 * @brief  Entry point for the QtXpl2 demo application.
 */
#include "Xpl2Client.h"

#include <QCommandLineParser>
#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QtQml/QQmlExtensionPlugin>
Q_IMPORT_QML_PLUGIN (Xpl2Plugin)

int
main (int argc, char *argv[])
{
  qSetMessagePattern ("Demo       [%{time HH:mm:ss.zzz}] %{message}");

  QGuiApplication app (argc, argv);

  QCommandLineParser parser;
  parser.addOption ({ "wire-debug", "Log raw wire TX/RX to dev log" });
  parser.addOption ({ "printheads",
                      "Number of simulated printheads (default 10)", "N",
                      "10" });
  parser.addHelpOption ();
  parser.process (app);

  if (parser.isSet ("wire-debug"))
    Xpl2Client::enableWireDebug ();

  int phCount = qBound (1, parser.value ("printheads").toInt (), 99);

  QQmlApplicationEngine engine;
  engine.setInitialProperties ({ { "demoPhCount", phCount } });
  QObject::connect (
      &engine, &QQmlApplicationEngine::objectCreationFailed, &app,
      [] () { QCoreApplication::exit (1); }, Qt::QueuedConnection);

  engine.loadFromModule ("QtXpl2Demo", "Main");
  return app.exec ();
}