summaryrefslogtreecommitdiff
authorsandman <sandman>2002-11-01 18:13:18 (UTC)
committer sandman <sandman>2002-11-01 18:13:18 (UTC)
commit2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba (patch) (unidiff)
treef3e6bb8ee6c0d8f2671a63c240d1145e710da82d
parent7b7b760ca3886d5b6562a88b5c2ef8e610b73eb8 (diff)
downloadopie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.zip
opie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.tar.gz
opie-2259e3ab9f2e06a4ee4dbd633c17221a47fdb7ba.tar.bz2
- Completly reworked the backlight "preview":
every slider/control that relates to backlight levels, is now switching the lcd to this level for 2 seconds - after that the backlight switches back to the standard level (or light sensor control) - Many bugfixes and usability improvements in light sensor calibration
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/calibration.cpp111
-rw-r--r--core/settings/light-and-power/calibration.h4
-rw-r--r--core/settings/light-and-power/light-and-power.pro4
-rw-r--r--core/settings/light-and-power/light.cpp57
-rw-r--r--core/settings/light-and-power/lightsettingsbase.ui86
-rw-r--r--core/settings/light-and-power/main.cpp2
-rw-r--r--core/settings/light-and-power/sensor.cpp34
-rw-r--r--core/settings/light-and-power/sensor.h8
8 files changed, 164 insertions, 142 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp
index 6a3360f..aed2bc8 100644
--- a/core/settings/light-and-power/calibration.cpp
+++ b/core/settings/light-and-power/calibration.cpp
@@ -1,277 +1,346 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include "calibration.h" 28#include "calibration.h"
29 29
30#include <qpainter.h> 30#include <qpainter.h>
31#include <qpalette.h> 31#include <qpalette.h>
32#include <qpixmap.h>
32 33
33#define BRD 2 34#define BRD 3
34 35
35Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl ) 36Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl )
36 : QWidget ( parent, name, fl ) 37 : QWidget ( parent, name, fl | WRepaintNoErase )
37{ 38{
39 setBackgroundMode ( NoBackground );
40
38 m_scale = QSize ( 256, 256 ); 41 m_scale = QSize ( 256, 256 );
39 m_steps = 5; 42 m_steps = 5;
40 m_dragged = -1; 43 m_dragged = -1;
41 m_interval = 5; 44 m_interval = 5;
42 45
43 m_p [0] = QPoint ( 0, 0 ); 46 m_p [0] = QPoint ( 0, 0 );
44 m_p [1] = QPoint ( 255, 255 ); 47 m_p [1] = QPoint ( 255, 255 );
45} 48}
46 49
47Calibration::~Calibration ( ) 50Calibration::~Calibration ( )
48{ 51{
49} 52}
50 53
51void Calibration::setScale ( const QSize &s ) 54void Calibration::setScale ( const QSize &s )
52{ 55{
53 if ( s. width ( ) < 1 || s. height ( ) < 1 ) 56 if ( s. width ( ) < 1 || s. height ( ) < 1 )
54 return; 57 return;
55 58
56 m_scale = s; 59 m_scale = s;
57 checkPoints ( ); 60 checkPoints ( );
58 61
59 update ( ); 62 update ( );
60} 63}
61 64
62QSize Calibration::scale ( ) const 65QSize Calibration::scale ( ) const
63{ 66{
64 return m_scale; 67 return m_scale;
65} 68}
66 69
67void Calibration::setLineSteps ( int steps ) 70void Calibration::setLineSteps ( int steps )
68{ 71{
69 if ( m_steps < 2 ) 72 if ( m_steps < 2 )
70 return; 73 return;
71 74
72 m_steps = steps; 75 m_steps = steps;
73 update ( ); 76 update ( );
74} 77}
75 78
76int Calibration::lineSteps ( ) const 79int Calibration::lineSteps ( ) const
77{ 80{
78 return m_steps; 81 return m_steps;
79} 82}
80 83
81void Calibration::setInterval ( int iv ) 84void Calibration::setInterval ( int iv )
82{ 85{
83 if ( iv < 1 ) 86 if ( iv < 1 )
84 return; 87 return;
85 88
86 m_interval = iv; 89 m_interval = iv;
87 //update ( ); 90 //update ( );
88} 91}
89 92
90int Calibration::interval ( ) const 93int Calibration::interval ( ) const
91{ 94{
92 return m_interval; 95 return m_interval;
93} 96}
94 97
95void Calibration::setStartPoint ( const QPoint &p ) 98void Calibration::setStartPoint ( const QPoint &p )
96{ 99{
97 m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); 100 m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 );
98 checkPoints ( ); 101 checkPoints ( );
99 update ( ); 102 update ( );
100} 103}
101 104
102QPoint Calibration::startPoint ( ) const 105QPoint Calibration::startPoint ( ) const
103{ 106{
104 return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 ); 107 return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 );
105} 108}
106 109
107void Calibration::setEndPoint ( const QPoint &p ) 110void Calibration::setEndPoint ( const QPoint &p )
108{ 111{
109 m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); 112 m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 );
110 checkPoints ( ); 113 checkPoints ( );
111 update ( ); 114 update ( );
112} 115}
113 116
114QPoint Calibration::endPoint ( ) const 117QPoint Calibration::endPoint ( ) const
115{ 118{
116 return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 ); 119 return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 );
117} 120}
118 121
119void Calibration::checkPoints ( ) 122void Calibration::checkPoints ( )
120{ 123{
121 int dx = m_scale. width ( ); 124 int dx = m_scale. width ( );
122 int dy = m_scale. height ( ); 125 int dy = m_scale. height ( );
123 126
127 if ( m_p [1]. x ( ) < 0 )
128 m_p [1]. setX ( 0 );
124 if ( m_p [1]. x ( ) >= dx ) 129 if ( m_p [1]. x ( ) >= dx )
125 m_p [1]. setX ( dx - 1 ); 130 m_p [1]. setX ( dx - 1 );
131 if ( m_p [0]. x ( ) < 0 )
132 m_p [0]. setX ( 0 );
126 if ( m_p [0]. x ( ) > m_p [1]. x ( )) 133 if ( m_p [0]. x ( ) > m_p [1]. x ( ))
127 m_p [0]. setX ( m_p [1]. x ( )); 134 m_p [0]. setX ( m_p [1]. x ( ));
128 135
136 if ( m_p [1]. y ( ) < 0 )
137 m_p [1]. setY ( 0 );
129 if ( m_p [1]. y ( ) >= dy ) 138 if ( m_p [1]. y ( ) >= dy )
130 m_p [1]. setY ( dy - 1 ); 139 m_p [1]. setY ( dy - 1 );
140 if ( m_p [0]. y ( ) < 0 )
141 m_p [0]. setY ( 0 );
131 if ( m_p [0]. y ( ) > m_p [1]. y ( )) 142 if ( m_p [0]. y ( ) > m_p [1]. y ( ))
132 m_p [0]. setY ( m_p [1]. y ( )); 143 m_p [0]. setY ( m_p [1]. y ( ));
133} 144}
134 145
135 146
136#define SCALEX(x) (BRD+x*(width()- 2*BRD)/m_scale.width()) 147#define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width())
137#define SCALEY(y) (BRD+y*(height()-2*BRD)/m_scale.height()) 148#define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height())
138 149
139 150
140static QRect around ( int x, int y ) 151static QRect around ( int x, int y )
141{ 152{
142 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 );
143} 154}
144 155
145void Calibration::mousePressEvent ( QMouseEvent *e ) 156void Calibration::mousePressEvent ( QMouseEvent *e )
146{ 157{
147 if ( e-> button ( ) != LeftButton ) 158 if ( e-> button ( ) != LeftButton )
148 return QWidget::mousePressEvent ( e ); 159 return QWidget::mousePressEvent ( e );
149 160
150 int olddragged = m_dragged; 161 int olddragged = m_dragged;
151 int x [2], y [2]; 162 int x [2], y [2];
152 163
153 m_dragged = -1; 164 m_dragged = -1;
154 for ( int i = 0; i < 2; i++ ) { 165 for ( int i = 0; i < 2; i++ ) {
155 x [i] = SCALEX( m_p [i]. x ( )); 166 x [i] = SCALEX( m_p [i]. x ( ));
156 y [i] = SCALEY( m_p [i]. y ( )); 167 y [i] = SCALEY( m_p [i]. y ( ));
157 168
158 if (( QABS( e-> x ( ) - x [i] ) <= BRD ) && 169 if (( QABS( e-> x ( ) - x [i] ) <= 2 * BRD ) &&
159 ( QABS( e-> y ( ) - y [i] ) <= BRD )) { 170 ( QABS( e-> y ( ) - y [i] ) <= 2 * BRD )) {
160 m_dragged = i; 171 m_dragged = i;
161 break; 172 break;
162 } 173 }
163 } 174 }
164 175
165 if ( m_dragged != olddragged ) { 176 if ( m_dragged != olddragged ) {
166 QRect r; 177 QRect r;
167 178
168 if ( olddragged >= 0 ) 179 if ( olddragged >= 0 )
169 r |= around ( x [olddragged], y [olddragged] ); 180 r |= around ( x [olddragged], y [olddragged] );
170 if ( m_dragged >= 0 ) 181 if ( m_dragged >= 0 )
171 r |= around ( x [m_dragged], y [m_dragged] ); 182 r |= around ( x [m_dragged], y [m_dragged] );
172 repaint ( r ); 183 repaint ( r, false );
173 } 184 }
174} 185}
175 186
176void Calibration::mouseMoveEvent ( QMouseEvent *e ) 187void Calibration::mouseMoveEvent ( QMouseEvent *e )
177{ 188{
178 if ( m_dragged < 0 ) 189 if ( m_dragged < 0 )
179 return; 190 return;
180 191
181 QPoint n [2]; 192 QPoint n [2];
182 193
183 n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD )); 194 n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD ));
184 n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD )); 195 n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD ));
185 n [1 - m_dragged] = m_p [1 - m_dragged]; 196 n [1 - m_dragged] = m_p [1 - m_dragged];
186 197
187 if (( n [0]. x ( ) > n [1]. x ( )) || ( n [m_dragged]. x ( ) < 0 ) || ( n [m_dragged]. x ( ) >= m_scale. width ( ))) 198 if ( n [m_dragged]. x ( ) < 0 )
188 n [m_dragged]. setX ( m_p [m_dragged]. x ( )); 199 n [m_dragged]. setX ( 0 );
189 if (( n [0]. y ( ) > n [1]. y ( )) || ( n [m_dragged]. y ( ) < 0 ) || ( n [m_dragged]. y ( ) >= m_scale. height ( ))) 200 if ( n [m_dragged]. x ( ) >= m_scale. width ( ))
190 n [m_dragged]. setY ( m_p [m_dragged]. y ( )); 201 n [m_dragged]. setX ( m_scale. width ( ) - 1 );
202 if ( n [0]. x ( ) > n [1]. x ( ))
203 n [m_dragged]. setX ( n [1 - m_dragged]. x ( ));
204 if ( n [m_dragged]. y ( ) < 0 )
205 n [m_dragged]. setY ( 0 );
206 if ( n [m_dragged]. y ( ) >= m_scale. height ( ))
207 n [m_dragged]. setY ( m_scale. height ( ) - 1 );
208 if ( n [0]. y ( ) > n [1]. y ( ))
209 n [m_dragged]. setY ( n [1 - m_dragged]. y ( ));
191 210
192 QRect r; 211 QRect r;
193 int ox [2], oy [2], nx [2], ny [2]; 212 int ox [2], oy [2], nx [2], ny [2];
194 213
195 for ( int i = 0; i < 2; i++ ) { 214 for ( int i = 0; i < 2; i++ ) {
196 nx [i] = SCALEX( n [i]. x ( )); 215 nx [i] = SCALEX( n [i]. x ( ));
197 ny [i] = SCALEY( n [i]. y ( )); 216 ny [i] = SCALEY( n [i]. y ( ));
198 ox [i] = SCALEX( m_p [i]. x ( )); 217 ox [i] = SCALEX( m_p [i]. x ( ));
199 oy [i] = SCALEY( m_p [i]. y ( )); 218 oy [i] = SCALEY( m_p [i]. y ( ));
200 219
201 if ( n [i] != m_p [i] ){ 220 if ( n [i] != m_p [i] ){
202 r |= around ( nx [i], ny [i] ); 221 r |= around ( nx [i], ny [i] );
203 r |= around ( ox [i], oy [i] ); 222 r |= around ( ox [i], oy [i] );
204 m_p [i] = n [i]; 223 m_p [i] = n [i];
205 224
206 if ( i == 0 ) { 225 if ( i == 0 ) {
207 r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 ); 226 r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 );
208 r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 ); 227 r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 );
228
229 emit startPointChanged ( startPoint ( ));
209 } 230 }
210 else if ( i == 1 ) { 231 else if ( i == 1 ) {
211 r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); 232 r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 );
212 r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); 233 r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 );
234
235 emit endPointChanged ( endPoint ( ));
213 } 236 }
214 } 237 }
215 } 238 }
216 if ( r. isValid ( )) { 239 if ( r. isValid ( )) {
217 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 );
218 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 );
219 242
220 repaint ( r ); 243 repaint ( r, false );
221 } 244 }
222} 245}
223 246
224void Calibration::mouseReleaseEvent ( QMouseEvent *e ) 247void Calibration::mouseReleaseEvent ( QMouseEvent *e )
225{ 248{
226 if ( e-> button ( ) != LeftButton ) 249 if ( e-> button ( ) != LeftButton )
227 return QWidget::mouseReleaseEvent ( e ); 250 return QWidget::mouseReleaseEvent ( e );
228 251
229 if ( m_dragged < 0 ) 252 if ( m_dragged < 0 )
230 return; 253 return;
231 254
232 int x = SCALEX( m_p [m_dragged]. x ( )); 255 int x = SCALEX( m_p [m_dragged]. x ( ));
233 int y = SCALEY( m_p [m_dragged]. y ( )); 256 int y = SCALEY( m_p [m_dragged]. y ( ));
234 m_dragged = -1; 257 m_dragged = -1;
235 258
236 repaint ( around ( x, y )); 259 repaint ( around ( x, y ), false );
237} 260}
238 261
239void Calibration::paintEvent ( QPaintEvent * ) 262void Calibration::paintEvent ( QPaintEvent *pe )
240{ 263{
241 QPainter p ( this ); 264 QPixmap pix ( size ( ));
242 QColorGroup g = colorGroup ( ); 265 QPainter p ( &pix, this );
243 266 QRect cr = pe-> rect ( );
267
244 int x0 = SCALEX( m_p [0]. x ( )); 268 int x0 = SCALEX( m_p [0]. x ( ));
245 int y0 = SCALEY( m_p [0]. y ( )); 269 int y0 = SCALEY( m_p [0]. y ( ));
246 int x1 = SCALEX( m_p [1]. x ( )); 270 int x1 = SCALEX( m_p [1]. x ( ));
247 int y1 = SCALEY( m_p [1]. y ( )); 271 int y1 = SCALEY( m_p [1]. y ( ));
248 272
249 int dx = x1 - x0; 273 int dx = x1 - x0;
250 int dy = y1 - y0; 274 int dy = y1 - y0;
251 275
276 // restrict steps to real x and y resolution
277 int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( dy + 1 ));
278
279 QString stepstr = tr( "%1 Steps" ). arg ( st );
280 QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr );
281 tr. setLeft ( tr. left ( ) - 20 );
282 if ( p. hasClipping ( ))
283 p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr ));
284
285 QColorGroup g = colorGroup ( );
286
287 p. fillRect ( cr, g. base ( ));
288 p. fillRect ( tr, g. base ( ));
289
252 int ex = x0, ey = y0; 290 int ex = x0, ey = y0;
253 291
292 p. setPen ( g. mid ( ));
293
294 int gx0 = SCALEX( 0 );
295 int gy0 = SCALEY( 0 );
296 int gx1 = SCALEX( m_scale. width ( ) - 1 );
297 int gy1 = SCALEY( m_scale. height ( ) - 1 );
298
299 int xdiv = QMIN( 4, m_scale. width ( ));
300 int ydiv = QMIN( 4, m_scale. height ( ));
301
302 xdiv = ( gx1 - gx0 + 1 ) / xdiv;
303 ydiv = ( gy1 - gy0 + 1 ) / ydiv;
304
305 for ( int i = gx0 + xdiv; i <= ( gx1 - xdiv ); i += xdiv )
306 p. drawLine ( i, gy0, i, gy1 );
307
308 for ( int i = gy0 + ydiv; i <= ( gy1 - ydiv ); i += ydiv )
309 p. drawLine ( gx0, i, gx1, i );
310
254 p. setPen ( g. highlight ( )); 311 p. setPen ( g. highlight ( ));
255 312
256 p. drawLine ( BRD, ey, ex, ey ); 313 p. drawLine ( BRD, ey, ex, ey );
257 314
258 for ( int i = 1; i < m_steps; i++ ) { 315 for ( int i = 1; i < st; i++ ) {
259 int fx = x0 + dx * i / m_steps; 316 int fx = x0 + dx * i / st;
260 int fy = y0 + dy * i / ( m_steps - 1 ); 317 int fy = y0 + dy * i / ( st - 1 );
261 318
262 p. drawLine ( ex, ey, fx, ey ); 319 p. drawLine ( ex, ey, fx, ey );
263 p. drawLine ( fx, ey, fx, fy ); 320 p. drawLine ( fx, ey, fx, fy );
264 321
265 ex = fx; 322 ex = fx;
266 ey = fy; 323 ey = fy;
267 } 324 }
325 if ( st == 1 ) {
326 p. drawLine ( ex, ey, ex, y1 );
327 ey = y1;
328 }
268 329
269 p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey ); 330 p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey );
270 331
332
271 p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( )); 333 p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( ));
334 p. drawRect ( around ( x0, y0 ));
272 p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( )); 335 p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( ));
336 p. drawRect ( around ( x1, y1 ));
273 337
274 p. setPen ( g. text ( )); 338 p. setPen ( g. text ( ));
275 p. drawText ( QRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD ), AlignTop | AlignRight, tr( "%1 Steps" ). arg ( m_steps )); 339 p. drawText ( tr, AlignTop | AlignRight, stepstr );
340
341 p. end ( );
342 bitBlt ( this, cr. topLeft ( ), &pix, cr );
343 if ( !cr. contains ( tr ))
344 bitBlt ( this, tr. topLeft ( ), &pix, tr );
276} 345}
277 346
diff --git a/core/settings/light-and-power/calibration.h b/core/settings/light-and-power/calibration.h
index 2bff69a..ffa63b2 100644
--- a/core/settings/light-and-power/calibration.h
+++ b/core/settings/light-and-power/calibration.h
@@ -1,71 +1,75 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#ifndef __CALIBRATION_H__ 28#ifndef __CALIBRATION_H__
29#define __CALIBRATION_H__ 29#define __CALIBRATION_H__
30 30
31#include <qwidget.h> 31#include <qwidget.h>
32 32
33class Calibration : public QWidget { 33class Calibration : public QWidget {
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 Calibration ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 37 Calibration ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
38 virtual ~Calibration ( ); 38 virtual ~Calibration ( );
39 39
40 QSize scale ( ) const; 40 QSize scale ( ) const;
41 int lineSteps ( ) const; 41 int lineSteps ( ) const;
42 int interval ( ) const; 42 int interval ( ) const;
43 QPoint startPoint ( ) const; 43 QPoint startPoint ( ) const;
44 QPoint endPoint ( ) const; 44 QPoint endPoint ( ) const;
45 45
46signals:
47 void startPointChanged ( const QPoint & );
48 void endPointChanged ( const QPoint & );
49
46public slots: 50public slots:
47 void setScale ( const QSize &s ); 51 void setScale ( const QSize &s );
48 void setLineSteps ( int step ); 52 void setLineSteps ( int step );
49 void setInterval ( int iv ); 53 void setInterval ( int iv );
50 void setStartPoint ( const QPoint &p ); 54 void setStartPoint ( const QPoint &p );
51 void setEndPoint ( const QPoint &p ); 55 void setEndPoint ( const QPoint &p );
52 56
53protected: 57protected:
54 virtual void paintEvent ( QPaintEvent * ); 58 virtual void paintEvent ( QPaintEvent * );
55 virtual void mousePressEvent ( QMouseEvent * ); 59 virtual void mousePressEvent ( QMouseEvent * );
56 virtual void mouseMoveEvent ( QMouseEvent * ); 60 virtual void mouseMoveEvent ( QMouseEvent * );
57 virtual void mouseReleaseEvent ( QMouseEvent * ); 61 virtual void mouseReleaseEvent ( QMouseEvent * );
58 62
59 void checkPoints ( ); 63 void checkPoints ( );
60 64
61private: 65private:
62 QSize m_scale; 66 QSize m_scale;
63 QPoint m_p [2]; 67 QPoint m_p [2];
64 int m_dragged; 68 int m_dragged;
65 int m_steps; 69 int m_steps;
66 int m_interval; 70 int m_interval;
67}; 71};
68 72
69#endif 73#endif
70 74
71 75
diff --git a/core/settings/light-and-power/light-and-power.pro b/core/settings/light-and-power/light-and-power.pro
index c89a26d..80c6631 100644
--- a/core/settings/light-and-power/light-and-power.pro
+++ b/core/settings/light-and-power/light-and-power.pro
@@ -1,26 +1,26 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on release 2 CONFIG += qt warn_on debug
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = settings.h sensor.h calibration.h 4 HEADERS = light.h sensor.h calibration.h
5 SOURCES = light.cpp main.cpp sensor.cpp calibration.cpp 5 SOURCES = light.cpp main.cpp sensor.cpp calibration.cpp
6 INTERFACES= lightsettingsbase.ui sensorbase.ui 6 INTERFACES= lightsettingsbase.ui sensorbase.ui
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= ../$(OPIEDIR)/include 8 DEPENDPATH+= ../$(OPIEDIR)/include
9LIBS += -lqpe -lopie 9LIBS += -lqpe -lopie
10 TARGET = light-and-power 10 TARGET = light-and-power
11 11
12TRANSLATIONS = ../../../i18n/de/light-and-power.ts \ 12TRANSLATIONS = ../../../i18n/de/light-and-power.ts \
13 ../../../i18n/en/light-and-power.ts \ 13 ../../../i18n/en/light-and-power.ts \
14 ../../../i18n/es/light-and-power.ts \ 14 ../../../i18n/es/light-and-power.ts \
15 ../../../i18n/fr/light-and-power.ts \ 15 ../../../i18n/fr/light-and-power.ts \
16 ../../../i18n/hu/light-and-power.ts \ 16 ../../../i18n/hu/light-and-power.ts \
17 ../../../i18n/ja/light-and-power.ts \ 17 ../../../i18n/ja/light-and-power.ts \
18 ../../../i18n/ko/light-and-power.ts \ 18 ../../../i18n/ko/light-and-power.ts \
19 ../../../i18n/no/light-and-power.ts \ 19 ../../../i18n/no/light-and-power.ts \
20 ../../../i18n/pl/light-and-power.ts \ 20 ../../../i18n/pl/light-and-power.ts \
21 ../../../i18n/pt/light-and-power.ts \ 21 ../../../i18n/pt/light-and-power.ts \
22 ../../../i18n/pt_BR/light-and-power.ts \ 22 ../../../i18n/pt_BR/light-and-power.ts \
23 ../../../i18n/sl/light-and-power.ts \ 23 ../../../i18n/sl/light-and-power.ts \
24 ../../../i18n/zh_CN/light-and-power.ts \ 24 ../../../i18n/zh_CN/light-and-power.ts \
25 ../../../i18n/zh_TW/light-and-power.ts \ 25 ../../../i18n/zh_TW/light-and-power.ts \
26 ../../../i18n/it/light-and-power.ts 26 ../../../i18n/it/light-and-power.ts
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index c0ba60b..21377b7 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,215 +1,222 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "settings.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/power.h> 33#include <qpe/power.h>
34#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 34#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#endif 36#endif
37 37
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qslider.h> 40#include <qslider.h>
41#include <qtimer.h>
41#include <qspinbox.h> 42#include <qspinbox.h>
42#include <qpushbutton.h> 43#include <qpushbutton.h>
43 44
44#include <opie/odevice.h> 45#include <opie/odevice.h>
45 46
46#include "sensor.h" 47#include "sensor.h"
47 48
48using namespace Opie; 49using namespace Opie;
49 50
50LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 51LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
51 : LightSettingsBase( parent, name, true, WStyle_ContextHelp ) 52 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
52{ 53{
53 m_res = ODevice::inst ( )-> displayBrightnessResolution ( ); 54 m_res = ODevice::inst ( )-> displayBrightnessResolution ( );
54 55
55 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 56 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
56 auto_brightness-> hide ( ); 57 auto_brightness-> hide ( );
57 CalibrateLightSensor-> hide ( ); 58 CalibrateLightSensor-> hide ( );
58 auto_brightness_ac_3-> hide ( ); 59 auto_brightness_ac_3-> hide ( );
59 CalibrateLightSensorAC-> hide ( ); 60 CalibrateLightSensorAC-> hide ( );
60 } 61 }
61 62
62 Config config ( "apm" ); 63 Config config ( "apm" );
63 config. setGroup ( "Battery" ); 64 config. setGroup ( "Battery" );
64 65
65 // battery spinboxes 66 // battery spinboxes
66 interval_dim-> setValue ( config. readNumEntry ( "Dim", 20 )); 67 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
67 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 30 )); 68 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
68 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 69 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
69 70
70 // battery check and slider 71 // battery check and slider
71 LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 72 LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
72 73
73 int bright = config. readNumEntry ( "Brightness", 255 ); 74 int bright = config. readNumEntry ( "Brightness", 127 );
74 brightness-> setMaxValue ( m_res - 1 ); 75 brightness-> setMaxValue ( m_res - 1 );
75 brightness-> setTickInterval ( QMAX( 1, m_res / 16 )); 76 brightness-> setTickInterval ( QMAX( 1, m_res / 16 ));
76 brightness-> setLineStep ( QMAX( 1, m_res / 16 )); 77 brightness-> setLineStep ( QMAX( 1, m_res / 16 ));
77 brightness-> setPageStep ( QMAX( 1, m_res / 16 )); 78 brightness-> setPageStep ( QMAX( 1, m_res / 16 ));
78 brightness-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); 79 brightness-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 );
79 80
80 // light sensor 81 // light sensor
81 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 82 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
82 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 83 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
83 84
84 config. setGroup ( "AC" ); 85 config. setGroup ( "AC" );
85 86
86 // ac spinboxes 87 // ac spinboxes
87 interval_dim_ac_3-> setValue ( config. readNumEntry ( "Dim", 20 )); 88 interval_dim_ac_3-> setValue ( config. readNumEntry ( "Dim", 60 ));
88 interval_lightoff_ac_3-> setValue ( config. readNumEntry ( "LightOff", 30 )); 89 interval_lightoff_ac_3-> setValue ( config. readNumEntry ( "LightOff", 120 ));
89 interval_suspend_ac_3-> setValue ( config. readNumEntry ( "Suspend", 60 )); 90 interval_suspend_ac_3-> setValue ( config. readNumEntry ( "Suspend", 0 ));
90 91
91 // ac check and slider 92 // ac check and slider
92 LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 93 LcdOffOnly_2_3-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
93 94
94 bright = config. readNumEntry ( "Brightness", 255 ); 95 bright = config. readNumEntry ( "Brightness", 255 );
95 brightness_ac_3-> setMaxValue ( m_res - 1 ); 96 brightness_ac_3-> setMaxValue ( m_res - 1 );
96 brightness_ac_3-> setTickInterval ( QMAX( 1, m_res / 16 )); 97 brightness_ac_3-> setTickInterval ( QMAX( 1, m_res / 16 ));
97 brightness_ac_3-> setLineStep ( QMAX( 1, m_res / 16 )); 98 brightness_ac_3-> setLineStep ( QMAX( 1, m_res / 16 ));
98 brightness_ac_3-> setPageStep ( QMAX( 1, m_res / 16 )); 99 brightness_ac_3-> setPageStep ( QMAX( 1, m_res / 16 ));
99 brightness_ac_3-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 ); 100 brightness_ac_3-> setValue (( bright * ( m_res - 1 ) + 127 ) / 255 );
100 101
101 // light sensor 102 // light sensor
102 auto_brightness_ac_3-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 103 auto_brightness_ac_3-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
103 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 104 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
104 105
105 // advanced settings 106 // advanced settings
106 config. setGroup ( "Warnings" ); 107 config. setGroup ( "Warnings" );
107 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 108 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
108 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 109 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
109 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 110 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
110 111
112 m_resettimer = new QTimer ( this );
113 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
114
111 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 115 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
112 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
113 tabs-> setCurrentPage ( 0 ); 116 tabs-> setCurrentPage ( 0 );
114 } 117 }
115 else { 118 else {
116 connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
117 tabs-> setCurrentPage ( 1 ); 119 tabs-> setCurrentPage ( 1 );
118 } 120 }
121
122 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
123 connect ( brightness_ac_3, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
119} 124}
120 125
121LightSettings::~LightSettings ( ) 126LightSettings::~LightSettings ( )
122{ 127{
123} 128}
124 129
125
126void LightSettings::calibrateSensor ( ) 130void LightSettings::calibrateSensor ( )
127{ 131{
128 Sensor *s = new Sensor ( m_sensordata, this ); 132 Sensor *s = new Sensor ( m_sensordata, this );
133 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
129 s-> showMaximized ( ); 134 s-> showMaximized ( );
130 s-> exec ( ); 135 s-> exec ( );
131 delete s; 136 delete s;
132} 137}
133 138
134void LightSettings::calibrateSensorAC ( ) 139void LightSettings::calibrateSensorAC ( )
135{ 140{
136 Sensor *s = new Sensor ( m_sensordata_ac, this ); 141 Sensor *s = new Sensor ( m_sensordata_ac, this );
142 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
137 s-> showMaximized ( ); 143 s-> showMaximized ( );
138 s-> exec ( ); 144 s-> exec ( );
139 delete s; 145 delete s;
140} 146}
141 147
142void LightSettings::setBacklight ( int bright ) 148void LightSettings::setBacklight ( int bright )
143{ 149{
144 bright = bright * 255 / ( m_res - 1 ); 150 if ( bright >= 0 )
151 bright = bright * 255 / ( m_res - 1 );
152
145 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 153 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
146 e << bright; 154 e << bright;
155
156 if ( bright != -1 ) {
157 m_resettimer-> stop ( );
158 m_resettimer-> start ( 2000, true );
159 }
147} 160}
148 161
149void LightSettings::reject ( ) 162void LightSettings::resetBacklight ( )
150{ 163{
151 { 164 setBacklight ( -1 );
152 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
153 e << -1;
154 }
155 QDialog::reject ( );
156} 165}
157 166
158void LightSettings::accept ( ) 167void LightSettings::accept ( )
159{ 168{
160 Config config ( "apm" ); 169 Config config ( "apm" );
161 170
162 // bat 171 // bat
163 config. setGroup ( "Battery" ); 172 config. setGroup ( "Battery" );
164 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 173 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
165 config. writeEntry ( "Dim", interval_dim-> value ( )); 174 config. writeEntry ( "Dim", interval_dim-> value ( ));
166 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 175 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
167 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 176 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
168 config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_res - 1 ) ); 177 config. writeEntry ( "Brightness", brightness-> value ( ) * 255 / ( m_res - 1 ) );
169 178
170 // ac 179 // ac
171 config. setGroup ( "AC" ); 180 config. setGroup ( "AC" );
172 config. writeEntry ( "LcdOffOnly", LcdOffOnly_2_3-> isChecked ( )); 181 config. writeEntry ( "LcdOffOnly", LcdOffOnly_2_3-> isChecked ( ));
173 config. writeEntry ( "Dim", interval_dim_ac_3-> value ( )); 182 config. writeEntry ( "Dim", interval_dim_ac_3-> value ( ));
174 config. writeEntry ( "LightOff", interval_lightoff_ac_3-> value ( )); 183 config. writeEntry ( "LightOff", interval_lightoff_ac_3-> value ( ));
175 config. writeEntry ( "Suspend", interval_suspend_ac_3-> value ( )); 184 config. writeEntry ( "Suspend", interval_suspend_ac_3-> value ( ));
176 config. writeEntry ( "Brightness", brightness_ac_3-> value ( ) * 255 / ( m_res - 1 )); 185 config. writeEntry ( "Brightness", brightness_ac_3-> value ( ) * 255 / ( m_res - 1 ));
177 186
178 // only make light sensor stuff appear if the unit has a sensor 187 // only make light sensor stuff appear if the unit has a sensor
179 if ( ODevice::inst ( )-> hasLightSensor ( )) { 188 if ( ODevice::inst ( )-> hasLightSensor ( )) {
180 config. setGroup ( "Battery" ); 189 config. setGroup ( "Battery" );
181 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 190 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
182 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 191 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
183 config. setGroup ( "AC" ); 192 config. setGroup ( "AC" );
184 config. writeEntry ( "LightSensor", auto_brightness_ac_3->isChecked() ); 193 config. writeEntry ( "LightSensor", auto_brightness_ac_3->isChecked() );
185 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 194 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
186 } 195 }
187 196
188 // advanced 197 // advanced
189 config. setGroup ( "Warnings" ); 198 config. setGroup ( "Warnings" );
190 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 199 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
191 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 200 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
192 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 201 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
193 config. write ( ); 202 config. write ( );
194 203
195 // notify the launcher 204 // notify the launcher
196 { 205 {
197 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 206 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
198 } 207 }
199 { 208 {
200 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 209 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
201 e << -1; 210 e << -1;
202 } 211 }
203 { 212 LightSettingsBase::accept ( );
204 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
205 e << -1;
206 }
207
208 QDialog::accept ( );
209} 213}
210 214
211void LightSettings::done ( int r ) 215void LightSettings::done ( int r )
212{ 216{
213 QDialog::done ( r ); 217 m_resettimer-> stop ( );
218 resetBacklight ( );
219
220 LightSettingsBase::done ( r );
214 close ( ); 221 close ( );
215} 222}
diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui
index 04c6726..309b95d 100644
--- a/core/settings/light-and-power/lightsettingsbase.ui
+++ b/core/settings/light-and-power/lightsettingsbase.ui
@@ -1,62 +1,62 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>LightSettingsBase</class> 2<class>LightSettingsBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>LightSettingsBase</cstring> 7 <cstring>LightSettingsBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>379</width> 14 <width>371</width>
15 <height>532</height> 15 <height>532</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>sizePolicy</name> 19 <name>sizePolicy</name>
20 <sizepolicy> 20 <sizepolicy>
21 <hsizetype>7</hsizetype> 21 <hsizetype>7</hsizetype>
22 <vsizetype>5</vsizetype> 22 <vsizetype>5</vsizetype>
23 </sizepolicy> 23 </sizepolicy>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>caption</name> 26 <name>caption</name>
27 <string>Light and Power Settings</string> 27 <string>Light and Power Settings</string>
28 </property> 28 </property>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>sizeGripEnabled</name> 30 <name>sizeGripEnabled</name>
31 <bool>false</bool> 31 <bool>false</bool>
32 </property> 32 </property>
33 <property> 33 <property>
34 <name>layoutMargin</name> 34 <name>layoutMargin</name>
35 </property> 35 </property>
36 <property> 36 <property>
37 <name>layoutSpacing</name> 37 <name>layoutSpacing</name>
38 </property> 38 </property>
39 <vbox> 39 <vbox>
40 <property stdset="1"> 40 <property stdset="1">
41 <name>margin</name> 41 <name>margin</name>
42 <number>3</number> 42 <number>3</number>
43 </property> 43 </property>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>spacing</name> 45 <name>spacing</name>
46 <number>3</number> 46 <number>3</number>
47 </property> 47 </property>
48 <widget> 48 <widget>
49 <class>QTabWidget</class> 49 <class>QTabWidget</class>
50 <property stdset="1"> 50 <property stdset="1">
51 <name>name</name> 51 <name>name</name>
52 <cstring>tabs</cstring> 52 <cstring>tabs</cstring>
53 </property> 53 </property>
54 <property> 54 <property>
55 <name>layoutMargin</name> 55 <name>layoutMargin</name>
56 </property> 56 </property>
57 <property> 57 <property>
58 <name>layoutSpacing</name> 58 <name>layoutSpacing</name>
59 </property> 59 </property>
60 <widget> 60 <widget>
61 <class>QWidget</class> 61 <class>QWidget</class>
62 <property stdset="1"> 62 <property stdset="1">
@@ -1144,167 +1144,83 @@
1144 <name>text</name> 1144 <name>text</name>
1145 <string>critical power warning at</string> 1145 <string>critical power warning at</string>
1146 </property> 1146 </property>
1147 </widget> 1147 </widget>
1148 </grid> 1148 </grid>
1149 </widget> 1149 </widget>
1150 <spacer> 1150 <spacer>
1151 <property> 1151 <property>
1152 <name>name</name> 1152 <name>name</name>
1153 <cstring>Spacer1</cstring> 1153 <cstring>Spacer1</cstring>
1154 </property> 1154 </property>
1155 <property stdset="1"> 1155 <property stdset="1">
1156 <name>orientation</name> 1156 <name>orientation</name>
1157 <enum>Vertical</enum> 1157 <enum>Vertical</enum>
1158 </property> 1158 </property>
1159 <property stdset="1"> 1159 <property stdset="1">
1160 <name>sizeType</name> 1160 <name>sizeType</name>
1161 <enum>Expanding</enum> 1161 <enum>Expanding</enum>
1162 </property> 1162 </property>
1163 <property> 1163 <property>
1164 <name>sizeHint</name> 1164 <name>sizeHint</name>
1165 <size> 1165 <size>
1166 <width>20</width> 1166 <width>20</width>
1167 <height>20</height> 1167 <height>20</height>
1168 </size> 1168 </size>
1169 </property> 1169 </property>
1170 </spacer> 1170 </spacer>
1171 </vbox> 1171 </vbox>
1172 </widget> 1172 </widget>
1173 </widget> 1173 </widget>
1174 </vbox> 1174 </vbox>
1175</widget> 1175</widget>
1176<images> 1176<images>
1177 <image> 1177 <image>
1178 <name>image0</name> 1178 <name>image0</name>
1179 <data format="XPM.GZ" length="424">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b324b364b06719340dcb434b36488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c004336518f</data> 1179 <data format="XPM.GZ" length="424">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b324b364b06719340dcb434b36488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c004336518f</data>
1180 </image> 1180 </image>
1181 <image> 1181 <image>
1182 <name>image1</name> 1182 <name>image1</name>
1183 <data format="XPM.GZ" length="439">789c6d8ec10ac2300c86ef7b8ad0ff36a4730777111f41f1288887b4b3e8610a3a0f22bebb6dd3d54d0ca5cdffe54f9aaaa4dd764d6555dc7beecf96ec896f54b68fae7bee0fab57a1ea86fc5950ad6685d2646973bd1c43ce3ec73c46903648e79a5624443a27d20cd2b9382704747e124382f11a7c5e30b364b957b331866331b3800c38f70282121c7c628367c098c1e0eb03121ccd4b46fcb0f80b26bb4833987f76b6d6f274de5fe6a1a031d30969f55e161fe4715f7b</data> 1183 <data format="XPM.GZ" length="439">789c6d8ec10ac2300c86ef7b8ad0ff36a4730777111f41f1288887b4b3e8610a3a0f22bebb6dd3d54d0ca5cdffe54f9aaaa4dd764d6555dc7beecf96ec896f54b68fae7bee0fab57a1ea86fc5950ad6685d2646973bd1c43ce3ec73c46903648e79a5624443a27d20cd2b9382704747e124382f11a7c5e30b364b957b331866331b3800c38f70282121c7c628367c098c1e0eb03121ccd4b46fcb0f80b26bb4833987f76b6d6f274de5fe6a1a031d30969f55e161fe4715f7b</data>
1184 </image> 1184 </image>
1185 <image> 1185 <image>
1186 <name>image2</name> 1186 <name>image2</name>
1187 <data format="XPM.GZ" length="424">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b344b314b04719340dcb434b31488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c0041d3518e</data> 1187 <data format="XPM.GZ" length="424">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b344b314b04719340dcb434b31488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c0041d3518e</data>
1188 </image> 1188 </image>
1189</images> 1189</images>
1190<connections> 1190<connections>
1191 <connection> 1191 <connection>
1192 <sender>auto_brightness</sender>
1193 <signal>toggled(bool)</signal>
1194 <receiver>brightness</receiver>
1195 <slot>setDisabled(bool)</slot>
1196 </connection>
1197 <connection>
1198 <sender>auto_brightness_ac_3</sender>
1199 <signal>toggled(bool)</signal>
1200 <receiver>brightness_ac_3</receiver>
1201 <slot>setDisabled(bool)</slot>
1202 </connection>
1203 <connection>
1204 <sender>auto_brightness_ac_3</sender>
1205 <signal>toggled(bool)</signal>
1206 <receiver>TextLabel1_3_2</receiver>
1207 <slot>setDisabled(bool)</slot>
1208 </connection>
1209 <connection>
1210 <sender>auto_brightness</sender>
1211 <signal>toggled(bool)</signal>
1212 <receiver>TextLabel1_3</receiver>
1213 <slot>setDisabled(bool)</slot>
1214 </connection>
1215 <connection>
1216 <sender>auto_brightness</sender>
1217 <signal>toggled(bool)</signal>
1218 <receiver>interval_dim</receiver>
1219 <slot>setDisabled(bool)</slot>
1220 </connection>
1221 <connection>
1222 <sender>auto_brightness_ac_3</sender>
1223 <signal>toggled(bool)</signal>
1224 <receiver>interval_dim_ac_3</receiver>
1225 <slot>setDisabled(bool)</slot>
1226 </connection>
1227 <connection>
1228 <sender>auto_brightness</sender>
1229 <signal>toggled(bool)</signal>
1230 <receiver>PixmapLabel2</receiver>
1231 <slot>setDisabled(bool)</slot>
1232 </connection>
1233 <connection>
1234 <sender>auto_brightness</sender>
1235 <signal>toggled(bool)</signal>
1236 <receiver>TextLabel4</receiver>
1237 <slot>setDisabled(bool)</slot>
1238 </connection>
1239 <connection>
1240 <sender>auto_brightness</sender>
1241 <signal>toggled(bool)</signal>
1242 <receiver>TextLabel5</receiver>
1243 <slot>setDisabled(bool)</slot>
1244 </connection>
1245 <connection>
1246 <sender>auto_brightness</sender>
1247 <signal>toggled(bool)</signal>
1248 <receiver>PixmapLabel1</receiver>
1249 <slot>setDisabled(bool)</slot>
1250 </connection>
1251 <connection>
1252 <sender>auto_brightness_ac_3</sender>
1253 <signal>toggled(bool)</signal>
1254 <receiver>PixmapLabel2_2_3</receiver>
1255 <slot>setDisabled(bool)</slot>
1256 </connection>
1257 <connection>
1258 <sender>auto_brightness_ac_3</sender>
1259 <signal>toggled(bool)</signal>
1260 <receiver>TextLabel6</receiver>
1261 <slot>setDisabled(bool)</slot>
1262 </connection>
1263 <connection>
1264 <sender>auto_brightness_ac_3</sender>
1265 <signal>toggled(bool)</signal>
1266 <receiver>TextLabel7</receiver>
1267 <slot>setDisabled(bool)</slot>
1268 </connection>
1269 <connection>
1270 <sender>auto_brightness_ac_3</sender>
1271 <signal>toggled(bool)</signal>
1272 <receiver>PixmapLabel1_2_3</receiver>
1273 <slot>setDisabled(bool)</slot>
1274 </connection>
1275 <connection>
1276 <sender>CalibrateLightSensor</sender> 1192 <sender>CalibrateLightSensor</sender>
1277 <signal>clicked()</signal> 1193 <signal>clicked()</signal>
1278 <receiver>LightSettingsBase</receiver> 1194 <receiver>LightSettingsBase</receiver>
1279 <slot>calibrateSensor()</slot> 1195 <slot>calibrateSensor()</slot>
1280 </connection> 1196 </connection>
1281 <connection> 1197 <connection>
1282 <sender>CalibrateLightSensorAC</sender> 1198 <sender>CalibrateLightSensorAC</sender>
1283 <signal>clicked()</signal> 1199 <signal>clicked()</signal>
1284 <receiver>LightSettingsBase</receiver> 1200 <receiver>LightSettingsBase</receiver>
1285 <slot>calibrateSensorAC()</slot> 1201 <slot>calibrateSensorAC()</slot>
1286 </connection> 1202 </connection>
1287 <slot access="public">calibrateSensor()</slot> 1203 <slot access="public">calibrateSensor()</slot>
1288 <slot access="public">calibrateSensorAC()</slot> 1204 <slot access="public">calibrateSensorAC()</slot>
1289</connections> 1205</connections>
1290<tabstops> 1206<tabstops>
1291 <tabstop>interval_dim</tabstop> 1207 <tabstop>interval_dim</tabstop>
1292 <tabstop>interval_lightoff</tabstop> 1208 <tabstop>interval_lightoff</tabstop>
1293 <tabstop>interval_suspend</tabstop> 1209 <tabstop>interval_suspend</tabstop>
1294 <tabstop>LcdOffOnly</tabstop> 1210 <tabstop>LcdOffOnly</tabstop>
1295 <tabstop>brightness</tabstop> 1211 <tabstop>brightness</tabstop>
1296 <tabstop>auto_brightness</tabstop> 1212 <tabstop>auto_brightness</tabstop>
1297 <tabstop>CalibrateLightSensor</tabstop> 1213 <tabstop>CalibrateLightSensor</tabstop>
1298 <tabstop>tabs</tabstop> 1214 <tabstop>tabs</tabstop>
1299 <tabstop>interval_lightoff_ac_3</tabstop> 1215 <tabstop>interval_lightoff_ac_3</tabstop>
1300 <tabstop>interval_suspend_ac_3</tabstop> 1216 <tabstop>interval_suspend_ac_3</tabstop>
1301 <tabstop>interval_dim_ac_3</tabstop> 1217 <tabstop>interval_dim_ac_3</tabstop>
1302 <tabstop>LcdOffOnly_2_3</tabstop> 1218 <tabstop>LcdOffOnly_2_3</tabstop>
1303 <tabstop>brightness_ac_3</tabstop> 1219 <tabstop>brightness_ac_3</tabstop>
1304 <tabstop>auto_brightness_ac_3</tabstop> 1220 <tabstop>auto_brightness_ac_3</tabstop>
1305 <tabstop>CalibrateLightSensorAC</tabstop> 1221 <tabstop>CalibrateLightSensorAC</tabstop>
1306 <tabstop>lowSpinBox</tabstop> 1222 <tabstop>lowSpinBox</tabstop>
1307 <tabstop>warnintervalBox</tabstop> 1223 <tabstop>warnintervalBox</tabstop>
1308 <tabstop>criticalSpinBox</tabstop> 1224 <tabstop>criticalSpinBox</tabstop>
1309</tabstops> 1225</tabstops>
1310</UI> 1226</UI>
diff --git a/core/settings/light-and-power/main.cpp b/core/settings/light-and-power/main.cpp
index 051fdec..ecacf69 100644
--- a/core/settings/light-and-power/main.cpp
+++ b/core/settings/light-and-power/main.cpp
@@ -1,38 +1,38 @@
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 "settings.h" 21#include "light.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/global.h> 25#include <qpe/global.h>
26 26
27 27
28int main(int argc, char** argv) 28int main(int argc, char** argv)
29{ 29{
30 QPEApplication a(argc,argv); 30 QPEApplication a(argc,argv);
31 31
32 LightSettings dlg; 32 LightSettings dlg;
33 33
34 a.showMainWidget(&dlg); 34 a.showMainWidget(&dlg);
35 35
36 return a.exec(); 36 return a.exec();
37} 37}
38 38
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp
index c1df04d..5ca54d4 100644
--- a/core/settings/light-and-power/sensor.cpp
+++ b/core/settings/light-and-power/sensor.cpp
@@ -1,85 +1,103 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qspinbox.h> 31#include <qspinbox.h>
32 32
33#include <opie/odevice.h>
34
35using namespace Opie;
36
33#include "calibration.h" 37#include "calibration.h"
34#include "sensor.h" 38#include "sensor.h"
35 39
36Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name ) 40Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name )
37 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) 41 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params )
38{ 42{
39 int steps = 12; 43 int steps = 12;
40 int inter = 2; 44 int inter = 2;
41 45
42 int smin = 40; 46 int smin = 40;
43 int smax = 215; 47 int smax = 215;
44 int lmin = 1; 48 int lmin = 1;
45 int lmax = 255; 49 int lmax = 255;
46 50
47 switch ( params. count ( )) { 51 switch ( params. count ( )) {
48 case 6: lmax = params [5]. toInt ( ); 52 case 6: lmax = params [5]. toInt ( );
49 case 5: lmin = params [4]. toInt ( ); 53 case 5: lmin = params [4]. toInt ( );
50 case 4: smax = params [3]. toInt ( ); 54 case 4: smax = params [3]. toInt ( );
51 case 3: smin = params [2]. toInt ( ); 55 case 3: smin = params [2]. toInt ( );
52 case 2: steps = params [1]. toInt ( ); 56 case 2: steps = params [1]. toInt ( );
53 case 1: inter = params [0]. toInt ( ) / 1000; 57 case 1: inter = params [0]. toInt ( ) / 1000;
54 } 58 }
59
60 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
61 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
55 62
56 QVBoxLayout *lay = new QVBoxLayout ( frame ); 63 QVBoxLayout *lay = new QVBoxLayout ( frame );
57 lay-> setMargin ( 2 ); 64 lay-> setMargin ( 2 );
58 m_calib = new Calibration ( frame ); 65 m_calib = new Calibration ( frame );
59 lay-> add ( m_calib ); 66 lay-> add ( m_calib );
60 67
61 m_calib-> setScale ( QSize ( 256, 256 )); 68 m_calib-> setScale ( QSize ( xscale, yscale ));
62 m_calib-> setLineSteps ( steps ); 69 m_calib-> setLineSteps ( steps );
63 m_calib-> setInterval ( inter ); 70 m_calib-> setInterval ( inter );
64 m_calib-> setStartPoint ( QPoint ( smin, lmax )); 71 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 ));
65 m_calib-> setEndPoint ( QPoint ( smax, lmin )); 72 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 ));
66 73
67 interval-> setValue ( inter ); 74 interval-> setValue ( inter );
68 linesteps-> setValue ( steps ); 75 linesteps-> setValue ( steps );
69 76
70 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); 77 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int )));
71 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); 78 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int )));
79
80 connect ( m_calib, SIGNAL( startPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & )));
81 connect ( m_calib, SIGNAL( endPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & )));
72} 82}
73 83
74void Sensor::accept ( ) 84void Sensor::accept ( )
75{ 85{
86 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
87 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
88
76 m_params. clear ( ); 89 m_params. clear ( );
77 m_params << QString::number ( m_calib-> interval ( ) * 1000 ) 90 m_params << QString::number ( m_calib-> interval ( ) * 1000 )
78 << QString::number ( m_calib-> lineSteps ( )) 91 << QString::number ( m_calib-> lineSteps ( ))
79 << QString::number ( m_calib-> startPoint ( ). x ( )) 92 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale )
80 << QString::number ( m_calib-> endPoint ( ). x ( )) 93 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale )
81 << QString::number ( m_calib-> endPoint ( ). y ( )) 94 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale )
82 << QString::number ( m_calib-> startPoint ( ). y ( )); 95 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale );
83 96
84 QDialog::accept ( ); 97 QDialog::accept ( );
85} 98}
99
100void Sensor::pointDrag ( const QPoint &p )
101{
102 emit viewBacklight ( p. y ( ));
103}
diff --git a/core/settings/light-and-power/sensor.h b/core/settings/light-and-power/sensor.h
index 7a26d81..b484519 100644
--- a/core/settings/light-and-power/sensor.h
+++ b/core/settings/light-and-power/sensor.h
@@ -1,47 +1,55 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#ifndef __SENSOR_H__ 28#ifndef __SENSOR_H__
29#define __SENSOR_H__ 29#define __SENSOR_H__
30 30
31#include "sensorbase.h" 31#include "sensorbase.h"
32 32
33class Calibration; 33class Calibration;
34class QStringList; 34class QStringList;
35 35
36class Sensor : public SensorBase { 36class Sensor : public SensorBase {
37 Q_OBJECT
38
37public: 39public:
38 Sensor ( QStringList &params, QWidget *parent = 0, const char *name = 0 ); 40 Sensor ( QStringList &params, QWidget *parent = 0, const char *name = 0 );
39 41
40 virtual void accept ( ); 42 virtual void accept ( );
43
44signals:
45 void viewBacklight ( int );
46
47private slots:
48 void pointDrag ( const QPoint & );
41 49
42private: 50private:
43 QStringList &m_params; 51 QStringList &m_params;
44 Calibration *m_calib; 52 Calibration *m_calib;
45}; 53};
46 54
47#endif \ No newline at end of file 55#endif \ No newline at end of file