Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the tools applications of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #include "qvfb.h" |
43 | |
44 | #include <QApplication> |
45 | #include <QRegExp> |
46 | #include <QLibraryInfo> |
47 | #include <QLocale> |
48 | #include <QTranslator> |
49 | #include <stdlib.h> |
50 | #include <stdio.h> |
51 | #include <signal.h> |
52 | #ifdef Q_WS_X11 |
53 | #include <QX11Info> |
54 | #endif |
55 | |
56 | QT_BEGIN_NAMESPACE |
57 | |
58 | void fn_quit_qvfb(int) |
59 | { |
60 | // pretend that we have quit normally |
61 | qApp->quit(); |
62 | } |
63 | |
64 | |
65 | void usage( const char *app ) |
66 | { |
67 | printf( "Usage: %s [-width width] [-height height] [-depth depth] [-zoom zoom]" |
68 | "[-mmap] [-nocursor] [-qwsdisplay :id] [-x11display :id] [-skin skindirectory]\n" |
69 | "Supported depths: 1, 4, 8, 12, 15, 16, 18, 24, 32\n", app ); |
70 | } |
71 | int qvfb_protocol = 0; |
72 | |
73 | int runQVfb( int argc, char *argv[] ) |
74 | { |
75 | Q_INIT_RESOURCE(qvfb); |
76 | |
77 | QApplication app( argc, argv ); |
78 | |
79 | QTranslator translator; |
80 | QTranslator qtTranslator; |
81 | QString sysLocale = QLocale::system().name(); |
82 | QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
83 | if (translator.load(QLatin1String("qvfb_") + sysLocale, resourceDir) |
84 | && qtTranslator.load(QLatin1String("qt_") + sysLocale, resourceDir)) { |
85 | app.installTranslator(&translator); |
86 | app.installTranslator(&qtTranslator); |
87 | } |
88 | |
89 | int width = 0; |
90 | int height = 0; |
91 | int depth = -32; // default, but overridable by skin |
92 | bool depthSet = false; |
93 | int rotation = 0; |
94 | bool cursor = true; |
95 | QVFb::DisplayType displayType = QVFb::QWS; |
96 | double zoom = 1.0; |
97 | QString displaySpec( ":0"); |
98 | QString skin; |
99 | |
100 | for ( int i = 1; i < argc; i++ ){ |
101 | QString arg = argv[i]; |
102 | if ( arg == "-width") { |
103 | width = atoi( argv[++i] ); |
104 | } else if ( arg == "-height") { |
105 | height = atoi( argv[++i] ); |
106 | } else if ( arg == "-skin") { |
107 | skin = argv[++i]; |
108 | } else if ( arg == "-depth") { |
109 | depth = atoi( argv[++i] ); |
110 | depthSet = true; |
111 | } else if ( arg == "-nocursor") { |
112 | cursor = false; |
113 | } else if ( arg == "-mmap") { |
114 | qvfb_protocol = 1; |
115 | } else if ( arg == "-zoom") { |
116 | zoom = atof( argv[++i] ); |
117 | } else if ( arg == "-qwsdisplay") { |
118 | displaySpec = argv[++i]; |
119 | displayType = QVFb::QWS; |
120 | #ifdef Q_WS_X11 |
121 | } else if ( arg == "-x11display") { |
122 | displaySpec = argv[++i]; |
123 | displayType = QVFb::X11; |
124 | |
125 | // Usually only the default X11 depth will work with Xnest, |
126 | // so override the default of 32 with the actual X11 depth. |
127 | if (!depthSet) |
128 | depth = -QX11Info::appDepth(); // default, but overridable by skin |
129 | #endif |
130 | } else { |
131 | printf( "Unknown parameter %s\n", arg.toLatin1().constData() ); |
132 | usage( argv[0] ); |
133 | exit(1); |
134 | } |
135 | } |
136 | |
137 | int displayId = 0; |
138 | QRegExp r( ":[0-9]+"); |
139 | int m = r.indexIn( displaySpec, 0 ); |
140 | int len = r.matchedLength(); |
141 | if ( m >= 0 ) { |
142 | displayId = displaySpec.mid( m+1, len-1 ).toInt(); |
143 | } |
144 | QRegExp rotRegExp( "Rot[0-9]+"); |
145 | m = rotRegExp.indexIn( displaySpec, 0 ); |
146 | len = rotRegExp.matchedLength(); |
147 | if ( m >= 0 ) { |
148 | rotation = displaySpec.mid( m+3, len-3 ).toInt(); |
149 | } |
150 | |
151 | signal(SIGINT, fn_quit_qvfb); |
152 | signal(SIGTERM, fn_quit_qvfb); |
153 | |
154 | QVFb mw( displayId, width, height, depth, rotation, skin, displayType ); |
155 | mw.setZoom(zoom); |
156 | //app.setMainWidget( &mw ); |
157 | mw.enableCursor(cursor); |
158 | mw.show(); |
159 | |
160 | return app.exec(); |
161 | } |
162 | |
163 | QT_END_NAMESPACE |
164 | |
165 | int main( int argc, char *argv[] ) |
166 | { |
167 | return QT_PREPEND_NAMESPACE(runQVfb)(argc, argv); |
168 | } |
169 |
Warning: That file was not part of the compilation database. It may have many parsing errors.