19
19
* Authors: Michael Zanetti <michael.zanetti@canonical.com>
20
20
* Riccardo Padovani <rpadovani@ubuntu.com>
21
21
* David Planella <david.planella@ubuntu.com>
22
* Stefano Verzegnassi <stefano92.100@gmail.com>
24
25
#include <QtGui/QGuiApplication>
45
46
QStringList args = a.arguments();
46
47
if (args.contains("-h") || args.contains("--help")) {
47
qDebug() << "usage: " + args.at(0) + " [-p|--phone] [-t|--tablet] [-h|--help] [-I <path>]";
48
qDebug() << " -p|--phone If running on Desktop, start in a phone sized window.";
49
qDebug() << " -t|--tablet If running on Desktop, start in a tablet sized window.";
48
qDebug() << "usage: " + args.at(0) + " [-h|--help] <path>";
50
49
qDebug() << " -h|--help Print this help.";
51
qDebug() << " -I <path> Give a path for an additional QML import directory. May be used multiple times.";
50
qDebug() << " <path> Path of the document to load.";
55
for (int i = 0; i < args.count(); i++) {
56
if (args.at(i) == "-I" && args.count() > i + 1) {
57
QString addedPath = args.at(i+1);
58
if (addedPath.startsWith('.')) {
59
addedPath = addedPath.right(addedPath.length() - 1);
60
addedPath.prepend(QDir::currentPath());
62
importPathList.append(addedPath);
54
// Check if the path of the document has been specified.
56
for (int i = 1; i < args.count(); i++) {
57
if (args.at(i) != "-h" && args.at(i) != "--h") {
61
view.engine()->rootContext()->setContextProperty("documentPath", docPath);
66
63
if (args.contains(QLatin1String("-testability")) || getenv("QT_LOAD_TESTABILITY")) {
67
64
QLibrary testLib(QLatin1String("qttestability"));
81
view.engine()->rootContext()->setContextProperty("tablet", QVariant(false));
82
view.engine()->rootContext()->setContextProperty("phone", QVariant(false));
83
if (args.contains("-t") || args.contains("--tablet")) {
84
qDebug() << "running in tablet mode";
85
view.engine()->rootContext()->setContextProperty("tablet", QVariant(true));
86
} else if (args.contains("-p") || args.contains("--phone")){
87
qDebug() << "running in phone mode";
88
view.engine()->rootContext()->setContextProperty("phone", QVariant(true));
89
} else if (qgetenv("QT_QPA_PLATFORM") != "ubuntumirclient") {
90
// Default to tablet size on X11
91
view.engine()->rootContext()->setContextProperty("tablet", QVariant(true));
94
78
view.engine()->setImportPathList(importPathList);