Diffstat (limited to 'core/apps/calibrate/calibrate.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/calibrate/calibrate.cpp | 58 |
1 files changed, 27 insertions, 31 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 | |||
@@ -17,47 +17,45 @@ | |||
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 | } |
@@ -159,59 +157,57 @@ bool Calibrate::sanityCheck() | |||
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 ); |