-rw-r--r-- | core/apps/calibrate/calibrate.cpp | 62 | ||||
-rw-r--r-- | core/apps/calibrate/calibrate.h | 3 | ||||
-rw-r--r-- | core/apps/calibrate/main.cpp | 4 |
3 files changed, 33 insertions, 36 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp index e079195..5f52bdc 100644 --- a/core/apps/calibrate/calibrate.cpp +++ b/core/apps/calibrate/calibrate.cpp | |||
@@ -1,283 +1,279 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <math.h> | 21 | #include <math.h> |
22 | 22 | ||
23 | #include "calibrate.h" | 23 | #include "calibrate.h" |
24 | 24 | ||
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qapplication.h> | 27 | #include <qapplication.h> |
28 | 28 | ||
29 | //#if defined(Q_WS_QWS) || defined(_WS_QWS_) | 29 | #include <qpixmap.h> |
30 | 30 | #include <qimage.h> | |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwindowsystem_qws.h> | 33 | #include <qwindowsystem_qws.h> |
34 | #include <qgfx_qws.h> | 34 | #include <qgfx_qws.h> |
35 | 35 | ||
36 | 36 | ||
37 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : | 37 | Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : |
38 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) | 38 | QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) |
39 | { | 39 | { |
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | showCross = TRUE; | 41 | showCross = TRUE; |
42 | const int offset = 30; | 42 | const int offset = 30; |
43 | QRect desk = qApp->desktop() ->geometry(); | 43 | QRect desk = qApp->desktop() ->geometry(); |
44 | setGeometry( 0, 0, desk.width(), desk.height() ); | 44 | setGeometry( 0, 0, desk.width(), desk.height() ); |
45 | if ( desk.height() < 250 ) { | 45 | crosshair.convertFromImage( Resource::loadImage("launcher/crosshair") ); |
46 | int w = desk.height() / 3; | 46 | |
47 | logo.convertFromImage( Resource::loadImage( "logo/opielogo" ).smoothScale( w, w ) ); | 47 | splash.convertFromImage( Resource::loadImage("launcher/firstuse").smoothScale( width(), height() ) ); |
48 | } | 48 | setBackgroundPixmap( splash ); |
49 | else { | 49 | |
50 | logo = Resource::loadPixmap( "logo/opielogo" ); | ||
51 | } | ||
52 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); | 50 | cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); |
53 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); | 51 | cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); |
54 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); | 52 | cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); |
55 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); | 53 | cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); |
56 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); | 54 | cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); |
57 | goodcd = cd; | 55 | goodcd = cd; |
58 | reset(); | 56 | reset(); |
59 | 57 | ||
60 | timer = new QTimer( this ); | 58 | timer = new QTimer( this ); |
61 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); | 59 | connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); |
62 | #endif | 60 | #endif |
63 | } | 61 | } |
64 | 62 | ||
65 | Calibrate::~Calibrate() | 63 | Calibrate::~Calibrate() |
66 | { | 64 | { |
67 | store(); | 65 | store(); |
68 | } | 66 | } |
69 | 67 | ||
70 | void Calibrate::show() | 68 | void Calibrate::show() |
71 | { | 69 | { |
72 | #ifdef QWS | 70 | #ifdef QWS |
73 | grabMouse(); | 71 | grabMouse(); |
74 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); | 72 | QWSServer::mouseHandler() ->getCalibration( &goodcd ); |
75 | QWSServer::mouseHandler() ->clearCalibration(); | 73 | QWSServer::mouseHandler() ->clearCalibration(); |
76 | QDialog::show(); | 74 | QDialog::show(); |
77 | #endif | 75 | #endif |
78 | } | 76 | } |
79 | 77 | ||
80 | void Calibrate::store() | 78 | void Calibrate::store() |
81 | { | 79 | { |
82 | #ifdef QWS | 80 | #ifdef QWS |
83 | QWSServer::mouseHandler() ->calibrate( &goodcd ); | 81 | QWSServer::mouseHandler() ->calibrate( &goodcd ); |
84 | #endif | 82 | #endif |
85 | } | 83 | } |
86 | 84 | ||
87 | void Calibrate::hide() | 85 | void Calibrate::hide() |
88 | { | 86 | { |
89 | if ( isVisible ( )) { | 87 | if ( isVisible()) { |
90 | store(); | 88 | store(); |
91 | 89 | ||
92 | // hack - calibrate is a launcher dialog, but treated like a standalone app | 90 | // hack - calibrate is a launcher dialog, but treated like a standalone app |
93 | { | 91 | { |
94 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 92 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
95 | e << QString ( "calibrate" ); | 93 | e << QString ( "calibrate" ); |
96 | } | 94 | } |
97 | } | 95 | } |
98 | QDialog::hide(); | 96 | QDialog::hide(); |
99 | } | 97 | } |
100 | 98 | ||
101 | void Calibrate::reset() | 99 | void Calibrate::reset() |
102 | { | 100 | { |
103 | #ifdef QWS | 101 | #ifdef QWS |
104 | penPos = QPoint(); | 102 | penPos = QPoint(); |
105 | location = QWSPointerCalibrationData::TopLeft; | 103 | location = QWSPointerCalibrationData::TopLeft; |
106 | crossPos = fromDevice( cd.screenPoints[ location ] ); | 104 | crossPos = fromDevice( cd.screenPoints[ location ] ); |
107 | #endif | 105 | #endif |
108 | } | 106 | } |
109 | 107 | ||
110 | QPoint Calibrate::fromDevice( const QPoint &p ) | 108 | QPoint Calibrate::fromDevice( const QPoint &p ) |
111 | { | 109 | { |
112 | #ifdef QWS | 110 | #ifdef QWS |
113 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); | 111 | return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); |
114 | #else | 112 | #else |
115 | return QPoint(); | 113 | return QPoint(); |
116 | #endif | 114 | #endif |
117 | 115 | ||
118 | } | 116 | } |
119 | 117 | ||
120 | bool Calibrate::sanityCheck() | 118 | bool Calibrate::sanityCheck() |
121 | { | 119 | { |
122 | #ifdef QWS | 120 | #ifdef QWS |
123 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; | 121 | QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; |
124 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; | 122 | QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; |
125 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; | 123 | QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; |
126 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; | 124 | QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; |
127 | 125 | ||
128 | // not needed anywhere .. just calculate it, so it's there | 126 | // not needed anywhere .. just calculate it, so it's there |
129 | cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); | 127 | cd.devPoints[QWSPointerCalibrationData::Center] = QRect( tl, br ).normalize().center(); |
130 | 128 | ||
131 | int dlx = QABS( bl. x ( ) - tl. x ( )); | 129 | int dlx = QABS( bl. x ( ) - tl. x ( )); |
132 | int dly = QABS( bl. y ( ) - tl. y ( )); | 130 | int dly = QABS( bl. y ( ) - tl. y ( )); |
133 | int drx = QABS( br. x ( ) - tr. x ( )); | 131 | int drx = QABS( br. x ( ) - tr. x ( )); |
134 | int dry = QABS( br. y ( ) - tr. y ( )); | 132 | int dry = QABS( br. y ( ) - tr. y ( )); |
135 | int dtx = QABS( tr. x ( ) - tl. x ( )); | 133 | int dtx = QABS( tr. x ( ) - tl. x ( )); |
136 | int dty = QABS( tr. y ( ) - tl. y ( )); | 134 | int dty = QABS( tr. y ( ) - tl. y ( )); |
137 | int dbx = QABS( br. x ( ) - bl. x ( )); | 135 | int dbx = QABS( br. x ( ) - bl. x ( )); |
138 | int dby = QABS( br. y ( ) - bl. y ( )); | 136 | int dby = QABS( br. y ( ) - bl. y ( )); |
139 | 137 | ||
140 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides | 138 | int dl = (int) ::sqrt (( dlx * dlx ) + ( dly * dly )); // calculate vector lengths for all sides |
141 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); | 139 | int dr = (int) ::sqrt (( drx * drx ) + ( dry * dry )); |
142 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); | 140 | int dt = (int) ::sqrt (( dtx * dtx ) + ( dty * dty )); |
143 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); | 141 | int db = (int) ::sqrt (( dbx * dbx ) + ( dby * dby )); |
144 | 142 | ||
145 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) | 143 | // Calculate leeway for x/y (we do not care if diff1/diff2 is for x or y here !) |
146 | int diff1 = QABS( dl - dr ); | 144 | int diff1 = QABS( dl - dr ); |
147 | int avg1 = ( dl + dr ) / 2; | 145 | int avg1 = ( dl + dr ) / 2; |
148 | int diff2 = QABS( dt - db ); | 146 | int diff2 = QABS( dt - db ); |
149 | int avg2 = ( dt + db ) / 2; | 147 | int avg2 = ( dt + db ) / 2; |
150 | 148 | ||
151 | // Calculate leeway for "real" vector length against "manhattan" vector length | 149 | // Calculate leeway for "real" vector length against "manhattan" vector length |
152 | // This is a check, if the rect is rotated (other then 0/90/180/270) | 150 | // This is a check, if the rect is rotated (other then 0/90/180/270) |
153 | // It needs to be performed only for the triange (bl, tl, tr) | 151 | // It needs to be performed only for the triange (bl, tl, tr) |
154 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); | 152 | int diff3 = QABS(( dlx + dly + dtx + dty ) - ( dl + dt )); |
155 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; | 153 | int avg3 = (( dlx + dly + dtx + dty ) + ( dl + dt )) / 2; |
156 | 154 | ||
157 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway | 155 | if (( diff1 > ( avg1 / 20 )) || // 5% leeway |
158 | ( diff2 > ( avg2 / 20 )) || | 156 | ( diff2 > ( avg2 / 20 )) || |
159 | ( diff3 > ( avg3 / 20 ))) | 157 | ( diff3 > ( avg3 / 20 ))) |
160 | return false; | 158 | return false; |
161 | else | 159 | else |
162 | return true; | 160 | return true; |
163 | #else | 161 | #else |
164 | return true; | 162 | return true; |
165 | #endif | 163 | #endif |
166 | } | 164 | } |
167 | 165 | ||
168 | void Calibrate::moveCrosshair( QPoint pt ) | 166 | void Calibrate::moveCrosshair( QPoint pt ) |
169 | { | 167 | { |
170 | showCross = FALSE; | 168 | showCross = FALSE; |
171 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 169 | repaint( crossPos.x() - 14, crossPos.y() - 14, 28, 28 ); |
172 | showCross = TRUE; | 170 | showCross = TRUE; |
173 | crossPos = pt; | 171 | crossPos = pt; |
174 | repaint( crossPos.x() - 8, crossPos.y() - 8, 16, 16 ); | 172 | repaint( crossPos.x() - 14, crossPos.y() - 14, 28, 28 ); |
175 | } | 173 | } |
176 | 174 | ||
177 | void Calibrate::paintEvent( QPaintEvent * ) | 175 | void Calibrate::paintEvent( QPaintEvent * ) |
178 | { | 176 | { |
179 | QPainter p( this ); | 177 | QPainter p( this ); |
180 | 178 | int y = height() / 3; | |
181 | int y; | ||
182 | |||
183 | if ( !logo.isNull() ) { | ||
184 | y = height() / 2 - logo.height() - 15; | ||
185 | p.drawPixmap( ( width() - logo.width() ) / 2, y, logo ); | ||
186 | } | ||
187 | |||
188 | y = height() / 2 + 15; | ||
189 | 179 | ||
190 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, | 180 | p.drawText( 0, y + height() / 8, width(), height() - y, AlignHCenter, |
191 | tr( "Touch the crosshairs firmly and\n" | 181 | tr( "Touch the crosshairs firmly and\n" |
192 | "accurately to calibrate your screen." ) ); | 182 | "accurately to calibrate your screen." ) ); |
193 | 183 | ||
194 | QFont f = p.font(); | 184 | if ( !showCross ) return; |
195 | f.setBold( TRUE ); | 185 | |
196 | p.setFont( f ); | 186 | #if 0 |
197 | p.drawText( 0, y, width(), height() - y, AlignHCenter | WordBreak, | 187 | if ( crosshair.isNull() ) { |
198 | tr( "Welcome to Opie" ) ); | 188 | #endif |
199 | 189 | p.setPen( QColor( 0, 0, 155 ) ); | |
200 | if ( showCross ) { | 190 | p.drawEllipse( crossPos.x()-8, crossPos.y()-8, 16, 16 ); |
201 | p.drawRect( crossPos.x() - 1, crossPos.y() - 8, 2, 7 ); | 191 | p.setPen( QColor( 250, 220, 220 ) ); |
202 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 7 ); | 192 | p.drawRoundRect( crossPos.x()-12, crossPos.y()-12, 24, 24, 75, 75 ); |
203 | p.drawRect( crossPos.x() - 8, crossPos.y() - 1, 7, 2 ); | 193 | p.setPen( QColor( 0, 0, 120 ) ); |
204 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 7, 2 ); | 194 | p.drawRect( crossPos.x() - 1, crossPos.y() - 14, 2, 13 ); |
195 | p.drawRect( crossPos.x() - 1, crossPos.y() + 1, 2, 13 ); | ||
196 | p.drawRect( crossPos.x() - 14, crossPos.y() - 1, 13, 2 ); | ||
197 | p.drawRect( crossPos.x() + 1, crossPos.y() - 1, 13, 2 ); | ||
198 | #if 0 | ||
205 | } | 199 | } |
200 | else p.drawPixmap( crossPos.x(), crossPos.y(), crosshair ); | ||
201 | #endif | ||
206 | } | 202 | } |
207 | 203 | ||
208 | void Calibrate::mousePressEvent( QMouseEvent *e ) | 204 | void Calibrate::mousePressEvent( QMouseEvent *e ) |
209 | { | 205 | { |
210 | #ifdef QWS | 206 | #ifdef QWS |
211 | // map to device coordinates | 207 | // map to device coordinates |
212 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); | 208 | QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize( qt_screen->width(), qt_screen->height() ) ); |
213 | if ( penPos.isNull() ) | 209 | if ( penPos.isNull() ) |
214 | penPos = devPos; | 210 | penPos = devPos; |
215 | else | 211 | else |
216 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, | 212 | penPos = QPoint( ( penPos.x() + devPos.x() ) / 2, |
217 | ( penPos.y() + devPos.y() ) / 2 ); | 213 | ( penPos.y() + devPos.y() ) / 2 ); |
218 | #endif | 214 | #endif |
219 | } | 215 | } |
220 | 216 | ||
221 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) | 217 | void Calibrate::mouseReleaseEvent( QMouseEvent * ) |
222 | { | 218 | { |
223 | #ifdef QWS | 219 | #ifdef QWS |
224 | if ( timer->isActive() ) | 220 | if ( timer->isActive() ) |
225 | return ; | 221 | return ; |
226 | 222 | ||
227 | bool doMove = TRUE; | 223 | bool doMove = TRUE; |
228 | 224 | ||
229 | cd.devPoints[ location ] = penPos; | 225 | cd.devPoints[ location ] = penPos; |
230 | if ( location < QWSPointerCalibrationData::TopRight ) { | 226 | if ( location < QWSPointerCalibrationData::TopRight ) { |
231 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); | 227 | location = (QWSPointerCalibrationData::Location) ( int( location ) + 1 ); |
232 | } | 228 | } |
233 | else { | 229 | else { |
234 | if ( sanityCheck() ) { | 230 | if ( sanityCheck() ) { |
235 | reset(); | 231 | reset(); |
236 | goodcd = cd; | 232 | goodcd = cd; |
237 | hide(); | 233 | hide(); |
238 | emit accept(); | 234 | emit accept(); |
239 | doMove = FALSE; | 235 | doMove = FALSE; |
240 | } | 236 | } |
241 | else { | 237 | else { |
242 | location = QWSPointerCalibrationData::TopLeft; | 238 | location = QWSPointerCalibrationData::TopLeft; |
243 | } | 239 | } |
244 | } | 240 | } |
245 | 241 | ||
246 | if ( doMove ) { | 242 | if ( doMove ) { |
247 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 243 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
248 | dx = ( target.x() - crossPos.x() ) / 10; | 244 | dx = ( target.x() - crossPos.x() ) / 10; |
249 | dy = ( target.y() - crossPos.y() ) / 10; | 245 | dy = ( target.y() - crossPos.y() ) / 10; |
250 | timer->start( 30 ); | 246 | timer->start( 30 ); |
251 | } | 247 | } |
252 | #endif | 248 | #endif |
253 | } | 249 | } |
254 | 250 | ||
255 | void Calibrate::timeout() | 251 | void Calibrate::timeout() |
256 | { | 252 | { |
257 | #ifdef QWS | 253 | #ifdef QWS |
258 | QPoint target = fromDevice( cd.screenPoints[ location ] ); | 254 | QPoint target = fromDevice( cd.screenPoints[ location ] ); |
259 | 255 | ||
260 | bool doneX = FALSE; | 256 | bool doneX = FALSE; |
261 | bool doneY = FALSE; | 257 | bool doneY = FALSE; |
262 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); | 258 | QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); |
263 | 259 | ||
264 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { | 260 | if ( QABS( crossPos.x() - target.x() ) <= QABS( dx ) ) { |
265 | newPos.setX( target.x() ); | 261 | newPos.setX( target.x() ); |
266 | doneX = TRUE; | 262 | doneX = TRUE; |
267 | } | 263 | } |
268 | 264 | ||
269 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { | 265 | if ( QABS( crossPos.y() - target.y() ) <= QABS( dy ) ) { |
270 | newPos.setY( target.y() ); | 266 | newPos.setY( target.y() ); |
271 | doneY = TRUE; | 267 | doneY = TRUE; |
272 | } | 268 | } |
273 | 269 | ||
274 | if ( doneX && doneY ) { | 270 | if ( doneX && doneY ) { |
275 | penPos = QPoint(); | 271 | penPos = QPoint(); |
276 | timer->stop(); | 272 | timer->stop(); |
277 | } | 273 | } |
278 | 274 | ||
279 | moveCrosshair( newPos ); | 275 | moveCrosshair( newPos ); |
280 | #endif | 276 | #endif |
281 | } | 277 | } |
282 | 278 | ||
283 | //#endif // _WS_QWS_ | 279 | //#endif // _WS_QWS_ |
diff --git a/core/apps/calibrate/calibrate.h b/core/apps/calibrate/calibrate.h index 06aa0c9..c1b990a 100644 --- a/core/apps/calibrate/calibrate.h +++ b/core/apps/calibrate/calibrate.h | |||
@@ -1,69 +1,70 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qwsmouse_qws.h> | 21 | #include <qwsmouse_qws.h> |
22 | 22 | ||
23 | //#if defined(Q_WS_QWS) || defined(_WS_QWS_) | 23 | //#if defined(Q_WS_QWS) || defined(_WS_QWS_) |
24 | 24 | ||
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | 27 | ||
28 | class QTimer; | 28 | class QTimer; |
29 | 29 | ||
30 | class Calibrate : public QDialog | 30 | class Calibrate : public QDialog |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | Calibrate(QWidget* parent=0, const char * name=0, WFlags=0); | 34 | Calibrate(QWidget* parent=0, const char * name=0, WFlags=0); |
35 | ~Calibrate(); | 35 | ~Calibrate(); |
36 | 36 | ||
37 | void show(); | 37 | void show(); |
38 | void hide(); | 38 | void hide(); |
39 | 39 | ||
40 | private: | 40 | private: |
41 | QPoint fromDevice( const QPoint &p ); | 41 | QPoint fromDevice( const QPoint &p ); |
42 | bool sanityCheck(); | 42 | bool sanityCheck(); |
43 | void moveCrosshair( QPoint pt ); | 43 | void moveCrosshair( QPoint pt ); |
44 | void paintEvent( QPaintEvent * ); | 44 | void paintEvent( QPaintEvent * ); |
45 | void mousePressEvent( QMouseEvent * ); | 45 | void mousePressEvent( QMouseEvent * ); |
46 | void mouseReleaseEvent( QMouseEvent * ); | 46 | void mouseReleaseEvent( QMouseEvent * ); |
47 | 47 | ||
48 | private slots: | 48 | private slots: |
49 | void timeout(); | 49 | void timeout(); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | void store(); | 52 | void store(); |
53 | void reset(); | 53 | void reset(); |
54 | QPixmap logo; | 54 | QPixmap splash; |
55 | QPixmap crosshair; | ||
55 | #ifdef QWS | 56 | #ifdef QWS |
56 | QWSPointerCalibrationData goodcd,cd; | 57 | QWSPointerCalibrationData goodcd,cd; |
57 | QWSPointerCalibrationData::Location location; | 58 | QWSPointerCalibrationData::Location location; |
58 | #endif | 59 | #endif |
59 | QPoint crossPos; | 60 | QPoint crossPos; |
60 | QPoint penPos; | 61 | QPoint penPos; |
61 | QPixmap saveUnder; | 62 | QPixmap saveUnder; |
62 | QTimer *timer; | 63 | QTimer *timer; |
63 | int dx; | 64 | int dx; |
64 | int dy; | 65 | int dy; |
65 | bool showCross; | 66 | bool showCross; |
66 | }; | 67 | }; |
67 | 68 | ||
68 | //#endif // _WS_QWS_ | 69 | //#endif // _WS_QWS_ |
69 | 70 | ||
diff --git a/core/apps/calibrate/main.cpp b/core/apps/calibrate/main.cpp index 0da0fe0..d9d98f5 100644 --- a/core/apps/calibrate/main.cpp +++ b/core/apps/calibrate/main.cpp | |||
@@ -1,46 +1,46 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "calibrate.h" | 21 | #include "calibrate.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #ifdef QWS | 25 | #ifdef QWS |
26 | #include <qwindowsystem_qws.h> | 26 | #include <qwindowsystem_qws.h> |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | int main( int argc, char ** argv ) | 29 | int main( int argc, char ** argv ) |
30 | { | 30 | { |
31 | QPEApplication a( argc, argv ); | 31 | QPEApplication a( argc, argv ); |
32 | int retval = 0; | 32 | int retval = 0; |
33 | 33 | ||
34 | #ifdef QWS | 34 | #if !defined(QT_DEBUG) && defined(QWS) |
35 | if ( QWSServer::mouseHandler() && | 35 | if ( QWSServer::mouseHandler() && |
36 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 36 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { |
37 | #endif | 37 | #endif |
38 | // Make sure calibration widget starts on top. | 38 | // Make sure calibration widget starts on top. |
39 | Calibrate cal; | 39 | Calibrate cal; |
40 | a.setMainWidget(&cal); | 40 | a.setMainWidget(&cal); |
41 | a.showMainWidget(&cal); | 41 | a.showMainWidget(&cal); |
42 | return a.exec(); | 42 | return a.exec(); |
43 | #ifdef QWS | 43 | #if !defined(QT_DEBUG) && defined(QWS) |
44 | } | 44 | } |
45 | #endif | 45 | #endif |
46 | } | 46 | } |