author | sandman <sandman> | 2002-11-21 02:27:43 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-21 02:27:43 (UTC) |
commit | ba08c640278399f412e66f906283068a099a2f03 (patch) (unidiff) | |
tree | b4237f428c02ba4277561e765a0be51e300032b1 | |
parent | a65963a06def8cb064bf7d99ff2776877f5f6315 (diff) | |
download | opie-ba08c640278399f412e66f906283068a099a2f03.zip opie-ba08c640278399f412e66f906283068a099a2f03.tar.gz opie-ba08c640278399f412e66f906283068a099a2f03.tar.bz2 |
The light sensor can now be calibrated "reverse" - less backlight in the
dark and more backlight in the light
-rw-r--r-- | core/settings/light-and-power/calibration.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp index aed2bc8..c5377d0 100644 --- a/core/settings/light-and-power/calibration.cpp +++ b/core/settings/light-and-power/calibration.cpp | |||
@@ -130,26 +130,26 @@ void Calibration::checkPoints ( ) | |||
130 | m_p [1]. setX ( dx - 1 ); | 130 | m_p [1]. setX ( dx - 1 ); |
131 | if ( m_p [0]. x ( ) < 0 ) | 131 | if ( m_p [0]. x ( ) < 0 ) |
132 | m_p [0]. setX ( 0 ); | 132 | m_p [0]. setX ( 0 ); |
133 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) | 133 | if ( m_p [0]. x ( ) > m_p [1]. x ( )) |
134 | m_p [0]. setX ( m_p [1]. x ( )); | 134 | m_p [0]. setX ( m_p [1]. x ( )); |
135 | 135 | ||
136 | if ( m_p [1]. y ( ) < 0 ) | 136 | if ( m_p [1]. y ( ) < 0 ) |
137 | m_p [1]. setY ( 0 ); | 137 | m_p [1]. setY ( 0 ); |
138 | if ( m_p [1]. y ( ) >= dy ) | 138 | if ( m_p [1]. y ( ) >= dy ) |
139 | m_p [1]. setY ( dy - 1 ); | 139 | m_p [1]. setY ( dy - 1 ); |
140 | if ( m_p [0]. y ( ) < 0 ) | 140 | if ( m_p [0]. y ( ) < 0 ) |
141 | m_p [0]. setY ( 0 ); | 141 | m_p [0]. setY ( 0 ); |
142 | if ( m_p [0]. y ( ) > m_p [1]. y ( )) | 142 | if ( m_p [0]. y ( ) >= dy ) |
143 | m_p [0]. setY ( m_p [1]. y ( )); | 143 | m_p [0]. setY ( dy - 1 ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) | 147 | #define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) |
148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) | 148 | #define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) |
149 | 149 | ||
150 | 150 | ||
151 | static QRect around ( int x, int y ) | 151 | static QRect around ( int x, int y ) |
152 | { | 152 | { |
153 | return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 ); | 153 | return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 ); |
154 | } | 154 | } |
155 | 155 | ||
@@ -196,26 +196,26 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) | |||
196 | n [1 - m_dragged] = m_p [1 - m_dragged]; | 196 | n [1 - m_dragged] = m_p [1 - m_dragged]; |
197 | 197 | ||
198 | if ( n [m_dragged]. x ( ) < 0 ) | 198 | if ( n [m_dragged]. x ( ) < 0 ) |
199 | n [m_dragged]. setX ( 0 ); | 199 | n [m_dragged]. setX ( 0 ); |
200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) | 200 | if ( n [m_dragged]. x ( ) >= m_scale. width ( )) |
201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); | 201 | n [m_dragged]. setX ( m_scale. width ( ) - 1 ); |
202 | if ( n [0]. x ( ) > n [1]. x ( )) | 202 | if ( n [0]. x ( ) > n [1]. x ( )) |
203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); | 203 | n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); |
204 | if ( n [m_dragged]. y ( ) < 0 ) | 204 | if ( n [m_dragged]. y ( ) < 0 ) |
205 | n [m_dragged]. setY ( 0 ); | 205 | n [m_dragged]. setY ( 0 ); |
206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) | 206 | if ( n [m_dragged]. y ( ) >= m_scale. height ( )) |
207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); | 207 | n [m_dragged]. setY ( m_scale. height ( ) - 1 ); |
208 | if ( n [0]. y ( ) > n [1]. y ( )) | 208 | //if ( n [0]. y ( ) > n [1]. y ( )) |
209 | n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); | 209 | // n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); |
210 | 210 | ||
211 | QRect r; | 211 | QRect r; |
212 | int ox [2], oy [2], nx [2], ny [2]; | 212 | int ox [2], oy [2], nx [2], ny [2]; |
213 | 213 | ||
214 | for ( int i = 0; i < 2; i++ ) { | 214 | for ( int i = 0; i < 2; i++ ) { |
215 | nx [i] = SCALEX( n [i]. x ( )); | 215 | nx [i] = SCALEX( n [i]. x ( )); |
216 | ny [i] = SCALEY( n [i]. y ( )); | 216 | ny [i] = SCALEY( n [i]. y ( )); |
217 | ox [i] = SCALEX( m_p [i]. x ( )); | 217 | ox [i] = SCALEX( m_p [i]. x ( )); |
218 | oy [i] = SCALEY( m_p [i]. y ( )); | 218 | oy [i] = SCALEY( m_p [i]. y ( )); |
219 | 219 | ||
220 | if ( n [i] != m_p [i] ){ | 220 | if ( n [i] != m_p [i] ){ |
221 | r |= around ( nx [i], ny [i] ); | 221 | r |= around ( nx [i], ny [i] ); |
@@ -228,26 +228,26 @@ void Calibration::mouseMoveEvent ( QMouseEvent *e ) | |||
228 | 228 | ||
229 | emit startPointChanged ( startPoint ( )); | 229 | emit startPointChanged ( startPoint ( )); |
230 | } | 230 | } |
231 | else if ( i == 1 ) { | 231 | else if ( i == 1 ) { |
232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); | 232 | r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); |
233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); | 233 | r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); |
234 | 234 | ||
235 | emit endPointChanged ( endPoint ( )); | 235 | emit endPointChanged ( endPoint ( )); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | if ( r. isValid ( )) { | 239 | if ( r. isValid ( )) { |
240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ); | 240 | r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( ); |
241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ); | 241 | r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( ); |
242 | 242 | ||
243 | repaint ( r, false ); | 243 | repaint ( r, false ); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) | 247 | void Calibration::mouseReleaseEvent ( QMouseEvent *e ) |
248 | { | 248 | { |
249 | if ( e-> button ( ) != LeftButton ) | 249 | if ( e-> button ( ) != LeftButton ) |
250 | return QWidget::mouseReleaseEvent ( e ); | 250 | return QWidget::mouseReleaseEvent ( e ); |
251 | 251 | ||
252 | if ( m_dragged < 0 ) | 252 | if ( m_dragged < 0 ) |
253 | return; | 253 | return; |
@@ -265,25 +265,25 @@ void Calibration::paintEvent ( QPaintEvent *pe ) | |||
265 | QPainter p ( &pix, this ); | 265 | QPainter p ( &pix, this ); |
266 | QRect cr = pe-> rect ( ); | 266 | QRect cr = pe-> rect ( ); |
267 | 267 | ||
268 | int x0 = SCALEX( m_p [0]. x ( )); | 268 | int x0 = SCALEX( m_p [0]. x ( )); |
269 | int y0 = SCALEY( m_p [0]. y ( )); | 269 | int y0 = SCALEY( m_p [0]. y ( )); |
270 | int x1 = SCALEX( m_p [1]. x ( )); | 270 | int x1 = SCALEX( m_p [1]. x ( )); |
271 | int y1 = SCALEY( m_p [1]. y ( )); | 271 | int y1 = SCALEY( m_p [1]. y ( )); |
272 | 272 | ||
273 | int dx = x1 - x0; | 273 | int dx = x1 - x0; |
274 | int dy = y1 - y0; | 274 | int dy = y1 - y0; |
275 | 275 | ||
276 | // restrict steps to real x and y resolution | 276 | // restrict steps to real x and y resolution |
277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 )); | 277 | int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 )); |
278 | 278 | ||
279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); | 279 | QString stepstr = tr( "%1 Steps" ). arg ( st ); |
280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); | 280 | QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); |
281 | tr. setLeft ( tr. left ( ) - 20 ); | 281 | tr. setLeft ( tr. left ( ) - 20 ); |
282 | if ( p. hasClipping ( )) | 282 | if ( p. hasClipping ( )) |
283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); | 283 | p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); |
284 | 284 | ||
285 | QColorGroup g = colorGroup ( ); | 285 | QColorGroup g = colorGroup ( ); |
286 | 286 | ||
287 | p. fillRect ( cr, g. base ( )); | 287 | p. fillRect ( cr, g. base ( )); |
288 | p. fillRect ( tr, g. base ( )); | 288 | p. fillRect ( tr, g. base ( )); |
289 | 289 | ||