summaryrefslogtreecommitdiff
path: root/core/apps/calibrate/calibrate.cpp
authorllornkcor <llornkcor>2002-04-18 01:51:16 (UTC)
committer llornkcor <llornkcor>2002-04-18 01:51:16 (UTC)
commit329d0e3182356a3a072ea417f71ce208b10865ce (patch) (unidiff)
tree39e3f956f20f47e725de15cc01160487464d5df4 /core/apps/calibrate/calibrate.cpp
parent025156262b9bcab1e484347fe89657671f8f951f (diff)
downloadopie-329d0e3182356a3a072ea417f71ce208b10865ce.zip
opie-329d0e3182356a3a072ea417f71ce208b10865ce.tar.gz
opie-329d0e3182356a3a072ea417f71ce208b10865ce.tar.bz2
bug fix
Diffstat (limited to 'core/apps/calibrate/calibrate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/calibrate/calibrate.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp
index 8647957..7b60e64 100644
--- a/core/apps/calibrate/calibrate.cpp
+++ b/core/apps/calibrate/calibrate.cpp
@@ -40,10 +40,10 @@ Calibrate::Calibrate(QWidget* parent, const char * name, WFlags wf) :
40 QRect desk = qApp->desktop()->geometry(); 40 QRect desk = qApp->desktop()->geometry();
41 setGeometry( 0, 0, desk.width(), desk.height() ); 41 setGeometry( 0, 0, desk.width(), desk.height() );
42 if ( desk.height() < 250 ) { 42 if ( desk.height() < 250 ) {
43 int w = desk.height()/3; 43 int w = desk.height()/3;
44 logo.convertFromImage(Resource::loadImage("launcher/opielogo").smoothScale(w,w)); 44 logo.convertFromImage(Resource::loadImage("launcher/opielogo").smoothScale(w,w));
45 } else { 45 } else {
46 logo = Resource::loadPixmap( "launcher/launcher/opielogo" ); 46 logo = Resource::loadPixmap( "launcher/opielogo" );
47 } 47 }
48 cd.screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint( offset, offset ); 48 cd.screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint( offset, offset );
49 cd.screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint( offset, qt_screen->deviceHeight() - offset ); 49 cd.screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint( offset, qt_screen->deviceHeight() - offset );
@@ -78,7 +78,7 @@ void Calibrate::store()
78void Calibrate::hide() 78void Calibrate::hide()
79{ 79{
80 if ( isVisible() ) 80 if ( isVisible() )
81 store(); 81 store();
82 QDialog::hide(); 82 QDialog::hide();
83} 83}
84 84
@@ -92,7 +92,7 @@ void Calibrate::reset()
92QPoint Calibrate::fromDevice( const QPoint &p ) 92QPoint Calibrate::fromDevice( const QPoint &p )
93{ 93{
94 return qt_screen->mapFromDevice( p, 94 return qt_screen->mapFromDevice( p,
95 QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()) ); 95 QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()) );
96} 96}
97 97
98bool Calibrate::sanityCheck() 98bool Calibrate::sanityCheck()
@@ -107,14 +107,14 @@ bool Calibrate::sanityCheck()
107 int diff = QABS( vl - vr ); 107 int diff = QABS( vl - vr );
108 int avg = ( vl + vr ) / 2; 108 int avg = ( vl + vr ) / 2;
109 if ( diff > avg / 20 ) // 5% leeway 109 if ( diff > avg / 20 ) // 5% leeway
110 return FALSE; 110 return FALSE;
111 111
112 int ht = QABS( tl.x() - tr.x() ); 112 int ht = QABS( tl.x() - tr.x() );
113 int hb = QABS( br.x() - bl.x() ); 113 int hb = QABS( br.x() - bl.x() );
114 diff = QABS( ht - hb ); 114 diff = QABS( ht - hb );
115 avg = ( ht + hb ) / 2; 115 avg = ( ht + hb ) / 2;
116 if ( diff > avg / 20 ) // 5% leeway 116 if ( diff > avg / 20 ) // 5% leeway
117 return FALSE; 117 return FALSE;
118 118
119 return TRUE; 119 return TRUE;
120} 120}
@@ -144,31 +144,31 @@ void Calibrate::paintEvent( QPaintEvent * )
144 int y; 144 int y;
145 145
146 if ( !logo.isNull() ) { 146 if ( !logo.isNull() ) {
147 y = height() / 2 - logo.height() - 15; 147 y = height() / 2 - logo.height() - 15;
148 p.drawPixmap( (width() - logo.width())/2, y, logo ); 148 p.drawPixmap( (width() - logo.width())/2, y, logo );
149 } 149 }
150 150
151 y = height() / 2 + 15; 151 y = height() / 2 + 15;
152 152
153 p.drawText( 0, y+height()/8, width(), height() - y, AlignHCenter, 153 p.drawText( 0, y+height()/8, width(), height() - y, AlignHCenter,
154 tr("Touch the crosshairs firmly and\n" 154 tr("Touch the crosshairs firmly and\n"
155 "accurately to calibrate your screen.") ); 155 "accurately to calibrate your screen.") );
156 156
157 QFont f = p.font(); f.setBold(TRUE); 157 QFont f = p.font(); f.setBold(TRUE);
158 p.setFont( f ); 158 p.setFont( f );
159 p.drawText( 0, y, width(), height() - y, AlignHCenter|WordBreak, 159 p.drawText( 0, y, width(), height() - y, AlignHCenter|WordBreak,
160 tr("Welcome to Opie") ); 160 tr("Welcome to Opie") );
161 161
162/* 162/*
163 saveUnder = QPixmap::grabWindow( winId(), crossPos.x()-8, crossPos.y()-8, 163 saveUnder = QPixmap::grabWindow( winId(), crossPos.x()-8, crossPos.y()-8,
164 16, 16 ); 164 16, 16 );
165 moveCrosshair( crossPos ); 165 moveCrosshair( crossPos );
166*/ 166*/
167 if ( showCross ) { 167 if ( showCross ) {
168 p.drawRect( crossPos.x()-1, crossPos.y()-8, 2, 7 ); 168 p.drawRect( crossPos.x()-1, crossPos.y()-8, 2, 7 );
169 p.drawRect( crossPos.x()-1, crossPos.y()+1, 2, 7 ); 169 p.drawRect( crossPos.x()-1, crossPos.y()+1, 2, 7 );
170 p.drawRect( crossPos.x()-8, crossPos.y()-1, 7, 2 ); 170 p.drawRect( crossPos.x()-8, crossPos.y()-1, 7, 2 );
171 p.drawRect( crossPos.x()+1, crossPos.y()-1, 7, 2 ); 171 p.drawRect( crossPos.x()+1, crossPos.y()-1, 7, 2 );
172 } 172 }
173} 173}
174 174
@@ -176,41 +176,41 @@ void Calibrate::mousePressEvent( QMouseEvent *e )
176{ 176{
177 // map to device coordinates 177 // map to device coordinates
178 QPoint devPos = qt_screen->mapToDevice( e->pos(), 178 QPoint devPos = qt_screen->mapToDevice( e->pos(),
179 QSize(qt_screen->width(), qt_screen->height()) ); 179 QSize(qt_screen->width(), qt_screen->height()) );
180 if ( penPos.isNull() ) 180 if ( penPos.isNull() )
181 penPos = devPos; 181 penPos = devPos;
182 else 182 else
183 penPos = QPoint( (penPos.x() + devPos.x())/2, 183 penPos = QPoint( (penPos.x() + devPos.x())/2,
184 (penPos.y() + devPos.y())/2 ); 184 (penPos.y() + devPos.y())/2 );
185} 185}
186 186
187void Calibrate::mouseReleaseEvent( QMouseEvent * ) 187void Calibrate::mouseReleaseEvent( QMouseEvent * )
188{ 188{
189 if ( timer->isActive() ) 189 if ( timer->isActive() )
190 return; 190 return;
191 191
192 bool doMove = TRUE; 192 bool doMove = TRUE;
193 193
194 cd.devPoints[location] = penPos; 194 cd.devPoints[location] = penPos;
195 if ( location < QWSPointerCalibrationData::LastLocation ) { 195 if ( location < QWSPointerCalibrationData::LastLocation ) {
196 location = (QWSPointerCalibrationData::Location)((int)location + 1); 196 location = (QWSPointerCalibrationData::Location)((int)location + 1);
197 } else { 197 } else {
198 if ( sanityCheck() ) { 198 if ( sanityCheck() ) {
199 reset(); 199 reset();
200 goodcd = cd; 200 goodcd = cd;
201 hide(); 201 hide();
202 emit accept(); 202 emit accept();
203 doMove = FALSE; 203 doMove = FALSE;
204 } else { 204 } else {
205 location = QWSPointerCalibrationData::TopLeft; 205 location = QWSPointerCalibrationData::TopLeft;
206 } 206 }
207 } 207 }
208 208
209 if ( doMove ) { 209 if ( doMove ) {
210 QPoint target = fromDevice( cd.screenPoints[location] ); 210 QPoint target = fromDevice( cd.screenPoints[location] );
211 dx = (target.x() - crossPos.x())/10; 211 dx = (target.x() - crossPos.x())/10;
212 dy = (target.y() - crossPos.y())/10; 212 dy = (target.y() - crossPos.y())/10;
213 timer->start( 30 ); 213 timer->start( 30 );
214 } 214 }
215} 215}
216 216
@@ -223,18 +223,18 @@ void Calibrate::timeout()
223 QPoint newPos( crossPos.x() + dx, crossPos.y() + dy ); 223 QPoint newPos( crossPos.x() + dx, crossPos.y() + dy );
224 224
225 if ( QABS(crossPos.x() - target.x()) <= QABS(dx) ) { 225 if ( QABS(crossPos.x() - target.x()) <= QABS(dx) ) {
226 newPos.setX( target.x() ); 226 newPos.setX( target.x() );
227 doneX = TRUE; 227 doneX = TRUE;
228 } 228 }
229 229
230 if ( QABS(crossPos.y() - target.y()) <= QABS(dy) ) { 230 if ( QABS(crossPos.y() - target.y()) <= QABS(dy) ) {
231 newPos.setY(target.y()); 231 newPos.setY(target.y());
232 doneY = TRUE; 232 doneY = TRUE;
233 } 233 }
234 234
235 if ( doneX && doneY ) { 235 if ( doneX && doneY ) {
236 penPos = QPoint(); 236 penPos = QPoint();
237 timer->stop(); 237 timer->stop();
238 } 238 }
239 239
240 moveCrosshair( newPos ); 240 moveCrosshair( newPos );