blob: ae9c3566bdb6209e21e7de80acd35bfb129409ae (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/****************************************************************************
**
** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved.
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "qml.h"
#include "qmlviewer.h"
#include <QWidget>
#include <QDir>
#include <QApplication>
#include <QTranslator>
#include <QDebug>
void usage()
{
qWarning("Usage: qmlviewer [options] <filename>");
qWarning(" ");
qWarning(" options:");
qWarning(" -v, -version ............................. display version");
qWarning(" -frameless ............................... run with no window frame");
qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame");
qWarning(" -recordfile <output> ..................... set video recording file");
qWarning(" - ImageMagick 'convert' for GIF)");
qWarning(" - png file for raw frames");
qWarning(" - 'ffmpeg' for other formats");
qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode");
qWarning(" -recordperiod <milliseconds> ............. set time between recording frames");
qWarning(" -record arg .............................. add a recording process argument");
qWarning(" -autorecord [from-]<tomilliseconds> ...... set recording to start and stop");
qWarning(" -devicekeys .............................. use numeric keys (see F1)");
qWarning(" -cache ................................... disk cache remote content");
qWarning(" -recordtest <directory> .................. record an autotest");
qWarning(" -runtest <directory> ..................... run a previously recorded test");
qWarning(" -translation <translationfile> ........... set the language to run in");
qWarning(" -L <directory> ........................... prepend to the library search path");
qWarning(" ");
qWarning(" Press F1 for interactive help");
exit(1);
}
int main(int argc, char ** argv)
{
//### default to using raster graphics backend for now
bool gsSpecified = false;
for (int i = 0; i < argc; ++i) {
QString arg = argv[i];
if (arg == "-graphicssystem") {
gsSpecified = true;
break;
}
}
if (!gsSpecified)
QApplication::setGraphicsSystem("raster");
QApplication app(argc, argv);
app.setApplicationName("viewer");
bool frameless = false;
QString fileName;
int period = 0;
int autorecord_from = 0;
int autorecord_to = 0;
QString dither = "none";
QString recordfile;
QStringList recordargs;
QStringList libraries;
QString skin;
bool devkeys = false;
bool cache = false;
QString translationFile;
for (int i = 1; i < argc; ++i) {
QString arg = argv[i];
if (arg == "-frameless") {
frameless = true;
} else if (arg == "-skin") {
skin = QString(argv[++i]);
} else if (arg == "-cache") {
cache = true;
} else if (arg == "-recordperiod") {
period = QString(argv[++i]).toInt();
} else if (arg == "-recordfile") {
recordfile = QString(argv[++i]);
} else if (arg == "-record") {
recordargs << QString(argv[++i]);
} else if (arg == "-recorddither") {
dither = QString(argv[++i]);
} else if (arg == "-autorecord") {
QString range = QString(argv[++i]);
int dash = range.indexOf('-');
if (dash > 0)
autorecord_from = range.left(dash).toInt();
autorecord_to = range.mid(dash+1).toInt();
} else if (arg == "-devicekeys") {
devkeys = true;
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR);
return 0;
} else if (arg == "-translation") {
if(i + 1 >= argc)
usage();
translationFile = argv[i + 1];
++i;
} else if (arg == "-L") {
libraries << QString(argv[++i]);
} else if (arg[0] != '-') {
fileName = arg;
} else if (1 || arg == "-help") {
usage();
}
}
QTranslator qmlTranslator;
if (!translationFile.isEmpty()) {
qmlTranslator.load(translationFile);
app.installTranslator(&qmlTranslator);
}
QmlViewer viewer(0, frameless ? Qt::FramelessWindowHint : Qt::Widget);
foreach (QString lib, libraries)
viewer.addLibraryPath(lib);
viewer.setCacheEnabled(cache);
viewer.setRecordFile(recordfile);
if (period>0)
viewer.setRecordPeriod(period);
if (autorecord_to)
viewer.setAutoRecord(autorecord_from,autorecord_to);
if (!skin.isEmpty() && QDir(skin).exists())
viewer.setSkin(skin);
if (devkeys)
viewer.setDeviceKeys(true);
viewer.setRecordDither(dither);
viewer.setRecordArgs(recordargs);
if (!fileName.isEmpty()) {
viewer.openQml(fileName);
viewer.show();
} else {
viewer.show();
viewer.open();
}
return app.exec();
}
|