summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-10 22:10:54 (UTC)
committer harlekin <harlekin>2003-12-10 22:10:54 (UTC)
commitdffe105588cace5d96792155cee3a32a70a05017 (patch) (unidiff)
treecf935726a73caba96e22bb0eb180da147c94c829
parent7c21195c1dde6cc91c41e5b15ef5acce568a2f54 (diff)
downloadopie-dffe105588cace5d96792155cee3a32a70a05017.zip
opie-dffe105588cace5d96792155cee3a32a70a05017.tar.gz
opie-dffe105588cace5d96792155cee3a32a70a05017.tar.bz2
less includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/calibration.cpp1
-rw-r--r--core/settings/light-and-power/light.cpp2
-rw-r--r--core/settings/light-and-power/main.cpp3
-rw-r--r--core/settings/light-and-power/sensor.cpp1
4 files changed, 0 insertions, 7 deletions
diff --git a/core/settings/light-and-power/calibration.cpp b/core/settings/light-and-power/calibration.cpp
index c5377d0..504520e 100644
--- a/core/settings/light-and-power/calibration.cpp
+++ b/core/settings/light-and-power/calibration.cpp
@@ -1,346 +1,345 @@
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>
32#include <qpixmap.h> 31#include <qpixmap.h>
33 32
34#define BRD 3 33#define BRD 3
35 34
36Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl ) 35Calibration::Calibration ( QWidget *parent, const char *name, WFlags fl )
37 : QWidget ( parent, name, fl | WRepaintNoErase ) 36 : QWidget ( parent, name, fl | WRepaintNoErase )
38{ 37{
39 setBackgroundMode ( NoBackground ); 38 setBackgroundMode ( NoBackground );
40 39
41 m_scale = QSize ( 256, 256 ); 40 m_scale = QSize ( 256, 256 );
42 m_steps = 5; 41 m_steps = 5;
43 m_dragged = -1; 42 m_dragged = -1;
44 m_interval = 5; 43 m_interval = 5;
45 44
46 m_p [0] = QPoint ( 0, 0 ); 45 m_p [0] = QPoint ( 0, 0 );
47 m_p [1] = QPoint ( 255, 255 ); 46 m_p [1] = QPoint ( 255, 255 );
48} 47}
49 48
50Calibration::~Calibration ( ) 49Calibration::~Calibration ( )
51{ 50{
52} 51}
53 52
54void Calibration::setScale ( const QSize &s ) 53void Calibration::setScale ( const QSize &s )
55{ 54{
56 if ( s. width ( ) < 1 || s. height ( ) < 1 ) 55 if ( s. width ( ) < 1 || s. height ( ) < 1 )
57 return; 56 return;
58 57
59 m_scale = s; 58 m_scale = s;
60 checkPoints ( ); 59 checkPoints ( );
61 60
62 update ( ); 61 update ( );
63} 62}
64 63
65QSize Calibration::scale ( ) const 64QSize Calibration::scale ( ) const
66{ 65{
67 return m_scale; 66 return m_scale;
68} 67}
69 68
70void Calibration::setLineSteps ( int steps ) 69void Calibration::setLineSteps ( int steps )
71{ 70{
72 if ( m_steps < 2 ) 71 if ( m_steps < 2 )
73 return; 72 return;
74 73
75 m_steps = steps; 74 m_steps = steps;
76 update ( ); 75 update ( );
77} 76}
78 77
79int Calibration::lineSteps ( ) const 78int Calibration::lineSteps ( ) const
80{ 79{
81 return m_steps; 80 return m_steps;
82} 81}
83 82
84void Calibration::setInterval ( int iv ) 83void Calibration::setInterval ( int iv )
85{ 84{
86 if ( iv < 1 ) 85 if ( iv < 1 )
87 return; 86 return;
88 87
89 m_interval = iv; 88 m_interval = iv;
90 //update ( ); 89 //update ( );
91} 90}
92 91
93int Calibration::interval ( ) const 92int Calibration::interval ( ) const
94{ 93{
95 return m_interval; 94 return m_interval;
96} 95}
97 96
98void Calibration::setStartPoint ( const QPoint &p ) 97void Calibration::setStartPoint ( const QPoint &p )
99{ 98{
100 m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); 99 m_p [0] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 );
101 checkPoints ( ); 100 checkPoints ( );
102 update ( ); 101 update ( );
103} 102}
104 103
105QPoint Calibration::startPoint ( ) const 104QPoint Calibration::startPoint ( ) const
106{ 105{
107 return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 ); 106 return QPoint ( m_p [0]. x ( ), m_scale. height ( ) - m_p [0]. y ( ) - 1 );
108} 107}
109 108
110void Calibration::setEndPoint ( const QPoint &p ) 109void Calibration::setEndPoint ( const QPoint &p )
111{ 110{
112 m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 ); 111 m_p [1] = QPoint ( p. x ( ), m_scale. height ( ) - p. y ( ) - 1 );
113 checkPoints ( ); 112 checkPoints ( );
114 update ( ); 113 update ( );
115} 114}
116 115
117QPoint Calibration::endPoint ( ) const 116QPoint Calibration::endPoint ( ) const
118{ 117{
119 return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 ); 118 return QPoint ( m_p [1]. x ( ), m_scale. height ( ) - m_p [1]. y ( ) - 1 );
120} 119}
121 120
122void Calibration::checkPoints ( ) 121void Calibration::checkPoints ( )
123{ 122{
124 int dx = m_scale. width ( ); 123 int dx = m_scale. width ( );
125 int dy = m_scale. height ( ); 124 int dy = m_scale. height ( );
126 125
127 if ( m_p [1]. x ( ) < 0 ) 126 if ( m_p [1]. x ( ) < 0 )
128 m_p [1]. setX ( 0 ); 127 m_p [1]. setX ( 0 );
129 if ( m_p [1]. x ( ) >= dx ) 128 if ( m_p [1]. x ( ) >= dx )
130 m_p [1]. setX ( dx - 1 ); 129 m_p [1]. setX ( dx - 1 );
131 if ( m_p [0]. x ( ) < 0 ) 130 if ( m_p [0]. x ( ) < 0 )
132 m_p [0]. setX ( 0 ); 131 m_p [0]. setX ( 0 );
133 if ( m_p [0]. x ( ) > m_p [1]. x ( )) 132 if ( m_p [0]. x ( ) > m_p [1]. x ( ))
134 m_p [0]. setX ( m_p [1]. x ( )); 133 m_p [0]. setX ( m_p [1]. x ( ));
135 134
136 if ( m_p [1]. y ( ) < 0 ) 135 if ( m_p [1]. y ( ) < 0 )
137 m_p [1]. setY ( 0 ); 136 m_p [1]. setY ( 0 );
138 if ( m_p [1]. y ( ) >= dy ) 137 if ( m_p [1]. y ( ) >= dy )
139 m_p [1]. setY ( dy - 1 ); 138 m_p [1]. setY ( dy - 1 );
140 if ( m_p [0]. y ( ) < 0 ) 139 if ( m_p [0]. y ( ) < 0 )
141 m_p [0]. setY ( 0 ); 140 m_p [0]. setY ( 0 );
142 if ( m_p [0]. y ( ) >= dy ) 141 if ( m_p [0]. y ( ) >= dy )
143 m_p [0]. setY ( dy - 1 ); 142 m_p [0]. setY ( dy - 1 );
144} 143}
145 144
146 145
147#define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width()) 146#define SCALEX(x) (BRD+(x)*(width()- 2*BRD)/m_scale.width())
148#define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height()) 147#define SCALEY(y) (BRD+(y)*(height()-2*BRD)/m_scale.height())
149 148
150 149
151static QRect around ( int x, int y ) 150static QRect around ( int x, int y )
152{ 151{
153 return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 ); 152 return QRect ( x - BRD, y - BRD, 2 * BRD + 1, 2 * BRD + 1 );
154} 153}
155 154
156void Calibration::mousePressEvent ( QMouseEvent *e ) 155void Calibration::mousePressEvent ( QMouseEvent *e )
157{ 156{
158 if ( e-> button ( ) != LeftButton ) 157 if ( e-> button ( ) != LeftButton )
159 return QWidget::mousePressEvent ( e ); 158 return QWidget::mousePressEvent ( e );
160 159
161 int olddragged = m_dragged; 160 int olddragged = m_dragged;
162 int x [2], y [2]; 161 int x [2], y [2];
163 162
164 m_dragged = -1; 163 m_dragged = -1;
165 for ( int i = 0; i < 2; i++ ) { 164 for ( int i = 0; i < 2; i++ ) {
166 x [i] = SCALEX( m_p [i]. x ( )); 165 x [i] = SCALEX( m_p [i]. x ( ));
167 y [i] = SCALEY( m_p [i]. y ( )); 166 y [i] = SCALEY( m_p [i]. y ( ));
168 167
169 if (( QABS( e-> x ( ) - x [i] ) <= 2 * BRD ) && 168 if (( QABS( e-> x ( ) - x [i] ) <= 2 * BRD ) &&
170 ( QABS( e-> y ( ) - y [i] ) <= 2 * BRD )) { 169 ( QABS( e-> y ( ) - y [i] ) <= 2 * BRD )) {
171 m_dragged = i; 170 m_dragged = i;
172 break; 171 break;
173 } 172 }
174 } 173 }
175 174
176 if ( m_dragged != olddragged ) { 175 if ( m_dragged != olddragged ) {
177 QRect r; 176 QRect r;
178 177
179 if ( olddragged >= 0 ) 178 if ( olddragged >= 0 )
180 r |= around ( x [olddragged], y [olddragged] ); 179 r |= around ( x [olddragged], y [olddragged] );
181 if ( m_dragged >= 0 ) 180 if ( m_dragged >= 0 )
182 r |= around ( x [m_dragged], y [m_dragged] ); 181 r |= around ( x [m_dragged], y [m_dragged] );
183 repaint ( r, false ); 182 repaint ( r, false );
184 } 183 }
185} 184}
186 185
187void Calibration::mouseMoveEvent ( QMouseEvent *e ) 186void Calibration::mouseMoveEvent ( QMouseEvent *e )
188{ 187{
189 if ( m_dragged < 0 ) 188 if ( m_dragged < 0 )
190 return; 189 return;
191 190
192 QPoint n [2]; 191 QPoint n [2];
193 192
194 n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD )); 193 n [m_dragged]. setX (( e-> x ( ) - BRD ) * m_scale. width ( ) / ( width ( ) - 2 * BRD ));
195 n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD )); 194 n [m_dragged]. setY (( e-> y ( ) - BRD ) * m_scale. height ( ) / ( height ( ) - 2 * BRD ));
196 n [1 - m_dragged] = m_p [1 - m_dragged]; 195 n [1 - m_dragged] = m_p [1 - m_dragged];
197 196
198 if ( n [m_dragged]. x ( ) < 0 ) 197 if ( n [m_dragged]. x ( ) < 0 )
199 n [m_dragged]. setX ( 0 ); 198 n [m_dragged]. setX ( 0 );
200 if ( n [m_dragged]. x ( ) >= m_scale. width ( )) 199 if ( n [m_dragged]. x ( ) >= m_scale. width ( ))
201 n [m_dragged]. setX ( m_scale. width ( ) - 1 ); 200 n [m_dragged]. setX ( m_scale. width ( ) - 1 );
202 if ( n [0]. x ( ) > n [1]. x ( )) 201 if ( n [0]. x ( ) > n [1]. x ( ))
203 n [m_dragged]. setX ( n [1 - m_dragged]. x ( )); 202 n [m_dragged]. setX ( n [1 - m_dragged]. x ( ));
204 if ( n [m_dragged]. y ( ) < 0 ) 203 if ( n [m_dragged]. y ( ) < 0 )
205 n [m_dragged]. setY ( 0 ); 204 n [m_dragged]. setY ( 0 );
206 if ( n [m_dragged]. y ( ) >= m_scale. height ( )) 205 if ( n [m_dragged]. y ( ) >= m_scale. height ( ))
207 n [m_dragged]. setY ( m_scale. height ( ) - 1 ); 206 n [m_dragged]. setY ( m_scale. height ( ) - 1 );
208 //if ( n [0]. y ( ) > n [1]. y ( )) 207 //if ( n [0]. y ( ) > n [1]. y ( ))
209 // n [m_dragged]. setY ( n [1 - m_dragged]. y ( )); 208 // n [m_dragged]. setY ( n [1 - m_dragged]. y ( ));
210 209
211 QRect r; 210 QRect r;
212 int ox [2], oy [2], nx [2], ny [2]; 211 int ox [2], oy [2], nx [2], ny [2];
213 212
214 for ( int i = 0; i < 2; i++ ) { 213 for ( int i = 0; i < 2; i++ ) {
215 nx [i] = SCALEX( n [i]. x ( )); 214 nx [i] = SCALEX( n [i]. x ( ));
216 ny [i] = SCALEY( n [i]. y ( )); 215 ny [i] = SCALEY( n [i]. y ( ));
217 ox [i] = SCALEX( m_p [i]. x ( )); 216 ox [i] = SCALEX( m_p [i]. x ( ));
218 oy [i] = SCALEY( m_p [i]. y ( )); 217 oy [i] = SCALEY( m_p [i]. y ( ));
219 218
220 if ( n [i] != m_p [i] ){ 219 if ( n [i] != m_p [i] ){
221 r |= around ( nx [i], ny [i] ); 220 r |= around ( nx [i], ny [i] );
222 r |= around ( ox [i], oy [i] ); 221 r |= around ( ox [i], oy [i] );
223 m_p [i] = n [i]; 222 m_p [i] = n [i];
224 223
225 if ( i == 0 ) { 224 if ( i == 0 ) {
226 r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 ); 225 r |= QRect ( 0, ny [0], nx [0] - 0 + 1, 1 );
227 r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 ); 226 r |= QRect ( 0, oy [0], ox [0] - 0 + 1, 1 );
228 227
229 emit startPointChanged ( startPoint ( )); 228 emit startPointChanged ( startPoint ( ));
230 } 229 }
231 else if ( i == 1 ) { 230 else if ( i == 1 ) {
232 r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 ); 231 r |= QRect ( nx [1], ny [1], width ( ) - nx [1], 1 );
233 r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 ); 232 r |= QRect ( ox [1], oy [1], width ( ) - ox [1], 1 );
234 233
235 emit endPointChanged ( endPoint ( )); 234 emit endPointChanged ( endPoint ( ));
236 } 235 }
237 } 236 }
238 } 237 }
239 if ( r. isValid ( )) { 238 if ( r. isValid ( )) {
240 r |= QRect ( nx [0], ny [0], nx [1] - nx [0] + 1, ny [1] - ny [0] + 1 ). normalize ( ); 239 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 ). normalize ( ); 240 r |= QRect ( ox [0], oy [0], ox [1] - ox [0] + 1, oy [1] - oy [0] + 1 ). normalize ( );
242 241
243 repaint ( r, false ); 242 repaint ( r, false );
244 } 243 }
245} 244}
246 245
247void Calibration::mouseReleaseEvent ( QMouseEvent *e ) 246void Calibration::mouseReleaseEvent ( QMouseEvent *e )
248{ 247{
249 if ( e-> button ( ) != LeftButton ) 248 if ( e-> button ( ) != LeftButton )
250 return QWidget::mouseReleaseEvent ( e ); 249 return QWidget::mouseReleaseEvent ( e );
251 250
252 if ( m_dragged < 0 ) 251 if ( m_dragged < 0 )
253 return; 252 return;
254 253
255 int x = SCALEX( m_p [m_dragged]. x ( )); 254 int x = SCALEX( m_p [m_dragged]. x ( ));
256 int y = SCALEY( m_p [m_dragged]. y ( )); 255 int y = SCALEY( m_p [m_dragged]. y ( ));
257 m_dragged = -1; 256 m_dragged = -1;
258 257
259 repaint ( around ( x, y ), false ); 258 repaint ( around ( x, y ), false );
260} 259}
261 260
262void Calibration::paintEvent ( QPaintEvent *pe ) 261void Calibration::paintEvent ( QPaintEvent *pe )
263{ 262{
264 QPixmap pix ( size ( )); 263 QPixmap pix ( size ( ));
265 QPainter p ( &pix, this ); 264 QPainter p ( &pix, this );
266 QRect cr = pe-> rect ( ); 265 QRect cr = pe-> rect ( );
267 266
268 int x0 = SCALEX( m_p [0]. x ( )); 267 int x0 = SCALEX( m_p [0]. x ( ));
269 int y0 = SCALEY( m_p [0]. y ( )); 268 int y0 = SCALEY( m_p [0]. y ( ));
270 int x1 = SCALEX( m_p [1]. x ( )); 269 int x1 = SCALEX( m_p [1]. x ( ));
271 int y1 = SCALEY( m_p [1]. y ( )); 270 int y1 = SCALEY( m_p [1]. y ( ));
272 271
273 int dx = x1 - x0; 272 int dx = x1 - x0;
274 int dy = y1 - y0; 273 int dy = y1 - y0;
275 274
276 // restrict steps to real x and y resolution 275 // restrict steps to real x and y resolution
277 int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 )); 276 int st = QMIN( QMIN( m_steps, ( dx + 1 )), ( QABS( dy ) + 1 ));
278 277
279 QString stepstr = tr( "%1 Steps" ). arg ( st ); 278 QString stepstr = tr( "%1 Steps" ). arg ( st );
280 QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr ); 279 QRect tr = p. boundingRect ( BRD, BRD, width ( ) - 2*BRD, height() - 2*BRD, AlignTop | AlignRight, stepstr );
281 tr. setLeft ( tr. left ( ) - 20 ); 280 tr. setLeft ( tr. left ( ) - 20 );
282 if ( p. hasClipping ( )) 281 if ( p. hasClipping ( ))
283 p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr )); 282 p. setClipRegion ( p. clipRegion ( ) | QRegion ( tr ));
284 283
285 QColorGroup g = colorGroup ( ); 284 QColorGroup g = colorGroup ( );
286 285
287 p. fillRect ( cr, g. base ( )); 286 p. fillRect ( cr, g. base ( ));
288 p. fillRect ( tr, g. base ( )); 287 p. fillRect ( tr, g. base ( ));
289 288
290 int ex = x0, ey = y0; 289 int ex = x0, ey = y0;
291 290
292 p. setPen ( g. mid ( )); 291 p. setPen ( g. mid ( ));
293 292
294 int gx0 = SCALEX( 0 ); 293 int gx0 = SCALEX( 0 );
295 int gy0 = SCALEY( 0 ); 294 int gy0 = SCALEY( 0 );
296 int gx1 = SCALEX( m_scale. width ( ) - 1 ); 295 int gx1 = SCALEX( m_scale. width ( ) - 1 );
297 int gy1 = SCALEY( m_scale. height ( ) - 1 ); 296 int gy1 = SCALEY( m_scale. height ( ) - 1 );
298 297
299 int xdiv = QMIN( 4, m_scale. width ( )); 298 int xdiv = QMIN( 4, m_scale. width ( ));
300 int ydiv = QMIN( 4, m_scale. height ( )); 299 int ydiv = QMIN( 4, m_scale. height ( ));
301 300
302 xdiv = ( gx1 - gx0 + 1 ) / xdiv; 301 xdiv = ( gx1 - gx0 + 1 ) / xdiv;
303 ydiv = ( gy1 - gy0 + 1 ) / ydiv; 302 ydiv = ( gy1 - gy0 + 1 ) / ydiv;
304 303
305 for ( int i = gx0 + xdiv; i <= ( gx1 - xdiv ); i += xdiv ) 304 for ( int i = gx0 + xdiv; i <= ( gx1 - xdiv ); i += xdiv )
306 p. drawLine ( i, gy0, i, gy1 ); 305 p. drawLine ( i, gy0, i, gy1 );
307 306
308 for ( int i = gy0 + ydiv; i <= ( gy1 - ydiv ); i += ydiv ) 307 for ( int i = gy0 + ydiv; i <= ( gy1 - ydiv ); i += ydiv )
309 p. drawLine ( gx0, i, gx1, i ); 308 p. drawLine ( gx0, i, gx1, i );
310 309
311 p. setPen ( g. highlight ( )); 310 p. setPen ( g. highlight ( ));
312 311
313 p. drawLine ( BRD, ey, ex, ey ); 312 p. drawLine ( BRD, ey, ex, ey );
314 313
315 for ( int i = 1; i < st; i++ ) { 314 for ( int i = 1; i < st; i++ ) {
316 int fx = x0 + dx * i / st; 315 int fx = x0 + dx * i / st;
317 int fy = y0 + dy * i / ( st - 1 ); 316 int fy = y0 + dy * i / ( st - 1 );
318 317
319 p. drawLine ( ex, ey, fx, ey ); 318 p. drawLine ( ex, ey, fx, ey );
320 p. drawLine ( fx, ey, fx, fy ); 319 p. drawLine ( fx, ey, fx, fy );
321 320
322 ex = fx; 321 ex = fx;
323 ey = fy; 322 ey = fy;
324 } 323 }
325 if ( st == 1 ) { 324 if ( st == 1 ) {
326 p. drawLine ( ex, ey, ex, y1 ); 325 p. drawLine ( ex, ey, ex, y1 );
327 ey = y1; 326 ey = y1;
328 } 327 }
329 328
330 p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey ); 329 p. drawLine ( ex, ey, width ( ) - 1 - BRD, ey );
331 330
332 331
333 p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( )); 332 p. fillRect ( around ( x0, y0 ), m_dragged == 0 ? g. highlightedText ( ) : g. text ( ));
334 p. drawRect ( around ( x0, y0 )); 333 p. drawRect ( around ( x0, y0 ));
335 p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( )); 334 p. fillRect ( around ( x1, y1 ), m_dragged == 1 ? g. highlightedText ( ) : g. text ( ));
336 p. drawRect ( around ( x1, y1 )); 335 p. drawRect ( around ( x1, y1 ));
337 336
338 p. setPen ( g. text ( )); 337 p. setPen ( g. text ( ));
339 p. drawText ( tr, AlignTop | AlignRight, stepstr ); 338 p. drawText ( tr, AlignTop | AlignRight, stepstr );
340 339
341 p. end ( ); 340 p. end ( );
342 bitBlt ( this, cr. topLeft ( ), &pix, cr ); 341 bitBlt ( this, cr. topLeft ( ), &pix, cr );
343 if ( !cr. contains ( tr )) 342 if ( !cr. contains ( tr ))
344 bitBlt ( this, tr. topLeft ( ), &pix, tr ); 343 bitBlt ( this, tr. topLeft ( ), &pix, tr );
345} 344}
346 345
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index eda0c1f..6115178 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,283 +1,281 @@
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 "light.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/power.h> 32#include <qpe/power.h>
34#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 33#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
36#endif 35#endif
37 36
38#include <qcheckbox.h> 37#include <qcheckbox.h>
39#include <qtabwidget.h> 38#include <qtabwidget.h>
40#include <qslider.h> 39#include <qslider.h>
41#include <qtimer.h>
42#include <qspinbox.h> 40#include <qspinbox.h>
43#include <qpushbutton.h> 41#include <qpushbutton.h>
44#include <qgroupbox.h> 42#include <qgroupbox.h>
45#include <qcombobox.h> 43#include <qcombobox.h>
46 44
47#include <opie/odevice.h> 45#include <opie/odevice.h>
48 46
49#include "sensor.h" 47#include "sensor.h"
50 48
51using namespace Opie; 49using namespace Opie;
52 50
53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 51LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 52 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
55{ 53{
56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 54 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
57 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 55 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
58 56
59 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 57 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
60 auto_brightness-> hide ( ); 58 auto_brightness-> hide ( );
61 CalibrateLightSensor-> hide ( ); 59 CalibrateLightSensor-> hide ( );
62 auto_brightness_ac-> hide ( ); 60 auto_brightness_ac-> hide ( );
63 CalibrateLightSensor_ac-> hide ( ); 61 CalibrateLightSensor_ac-> hide ( );
64 } 62 }
65 if (m_cres) { 63 if (m_cres) {
66 GroupLight->setTitle(tr("Backlight && Contrast")); 64 GroupLight->setTitle(tr("Backlight && Contrast"));
67 GroupLight_ac->setTitle(GroupLight->title()); 65 GroupLight_ac->setTitle(GroupLight->title());
68 } else { 66 } else {
69 contrast->hide(); 67 contrast->hide();
70 contrast_ac->hide(); 68 contrast_ac->hide();
71 } 69 }
72 70
73 QStrList freq = ODevice::inst()->allowedCpuFrequencies(); 71 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
74 if ( freq.count() ) { 72 if ( freq.count() ) {
75 frequency->insertStrList( freq ); 73 frequency->insertStrList( freq );
76 frequency_ac->insertStrList( freq ); 74 frequency_ac->insertStrList( freq );
77 } else { 75 } else {
78 frequency->hide(); 76 frequency->hide();
79 frequency_ac->hide(); 77 frequency_ac->hide();
80 } 78 }
81 79
82 Config config ( "apm" ); 80 Config config ( "apm" );
83 config. setGroup ( "Battery" ); 81 config. setGroup ( "Battery" );
84 82
85 // battery spinboxes 83 // battery spinboxes
86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 84 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 85 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 86 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
89 87
90 // battery check and slider 88 // battery check and slider
91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 89 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
92 90
93 // CPU frequency 91 // CPU frequency
94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 92 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
95 93
96 int bright = config. readNumEntry ( "Brightness", 127 ); 94 int bright = config. readNumEntry ( "Brightness", 127 );
97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 95 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
98 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 96 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
99 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 97 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
100 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 98 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
101 brightness-> setValue ( bright ); 99 brightness-> setValue ( bright );
102 100
103 if (m_cres) { 101 if (m_cres) {
104 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 102 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
105 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 103 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
106 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 104 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
107 contrast-> setValue ( contr ); 105 contrast-> setValue ( contr );
108 } 106 }
109 107
110 // light sensor 108 // light sensor
111 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 109 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
112 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 110 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
113 111
114 config. setGroup ( "AC" ); 112 config. setGroup ( "AC" );
115 113
116 // ac spinboxes 114 // ac spinboxes
117 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 115 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
118 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 116 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
119 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 117 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
120 118
121 // ac check and slider 119 // ac check and slider
122 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 120 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
123 121
124 // CPU frequency 122 // CPU frequency
125 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 123 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
126 124
127 bright = config. readNumEntry ( "Brightness", 255 ); 125 bright = config. readNumEntry ( "Brightness", 255 );
128 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 126 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
129 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 127 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
130 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 128 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
131 brightness_ac-> setValue ( bright ); 129 brightness_ac-> setValue ( bright );
132 130
133 if (m_cres) { 131 if (m_cres) {
134 contr = config. readNumEntry ( "Contrast", 127); 132 contr = config. readNumEntry ( "Contrast", 127);
135 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 133 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
136 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 134 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
137 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 135 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
138 contrast_ac-> setValue ( contr ); 136 contrast_ac-> setValue ( contr );
139 } 137 }
140 138
141 // light sensor 139 // light sensor
142 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 140 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
143 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 141 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
144 142
145 // advanced settings 143 // advanced settings
146 config. setGroup ( "Warnings" ); 144 config. setGroup ( "Warnings" );
147 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 145 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
148 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 146 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
149 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 147 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
150 148
151 m_resettimer = new QTimer ( this ); 149 m_resettimer = new QTimer ( this );
152 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 150 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
153 151
154 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 152 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
155 tabs-> setCurrentPage ( 0 ); 153 tabs-> setCurrentPage ( 0 );
156 } 154 }
157 else { 155 else {
158 tabs-> setCurrentPage ( 1 ); 156 tabs-> setCurrentPage ( 1 );
159 } 157 }
160 158
161 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 159 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
162 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 160 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
163 if (m_cres) { 161 if (m_cres) {
164 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 162 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
165 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 163 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
166 } 164 }
167 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 165 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
168} 166}
169 167
170LightSettings::~LightSettings ( ) 168LightSettings::~LightSettings ( )
171{ 169{
172} 170}
173 171
174void LightSettings::calibrateSensor ( ) 172void LightSettings::calibrateSensor ( )
175{ 173{
176 Sensor *s = new Sensor ( m_sensordata, this ); 174 Sensor *s = new Sensor ( m_sensordata, this );
177 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 175 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
178 s-> showMaximized ( ); 176 s-> showMaximized ( );
179 s-> exec ( ); 177 s-> exec ( );
180 delete s; 178 delete s;
181} 179}
182 180
183void LightSettings::calibrateSensorAC ( ) 181void LightSettings::calibrateSensorAC ( )
184{ 182{
185 Sensor *s = new Sensor ( m_sensordata_ac, this ); 183 Sensor *s = new Sensor ( m_sensordata_ac, this );
186 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 184 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
187 s-> showMaximized ( ); 185 s-> showMaximized ( );
188 s-> exec ( ); 186 s-> exec ( );
189 delete s; 187 delete s;
190} 188}
191 189
192void LightSettings::setBacklight ( int bright ) 190void LightSettings::setBacklight ( int bright )
193{ 191{
194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 192 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
195 e << bright; 193 e << bright;
196 194
197 if ( bright != -1 ) { 195 if ( bright != -1 ) {
198 m_resettimer-> stop ( ); 196 m_resettimer-> stop ( );
199 m_resettimer-> start ( 4000, true ); 197 m_resettimer-> start ( 4000, true );
200 } 198 }
201} 199}
202 200
203void LightSettings::setContrast ( int contr ) 201void LightSettings::setContrast ( int contr )
204{ 202{
205 if (contr == -1) contr = m_oldcontrast; 203 if (contr == -1) contr = m_oldcontrast;
206 204
207 ODevice::inst ( )-> setDisplayContrast(contr); 205 ODevice::inst ( )-> setDisplayContrast(contr);
208} 206}
209 207
210void LightSettings::setFrequency ( int index ) 208void LightSettings::setFrequency ( int index )
211{ 209{
212qWarning("LightSettings::setFrequency(%d)", index); 210qWarning("LightSettings::setFrequency(%d)", index);
213 ODevice::inst ( )-> setCurrentCpuFrequency(index); 211 ODevice::inst ( )-> setCurrentCpuFrequency(index);
214} 212}
215 213
216void LightSettings::resetBacklight ( ) 214void LightSettings::resetBacklight ( )
217{ 215{
218 setBacklight ( -1 ); 216 setBacklight ( -1 );
219 setContrast ( -1 ); 217 setContrast ( -1 );
220} 218}
221 219
222void LightSettings::accept ( ) 220void LightSettings::accept ( )
223{ 221{
224 Config config ( "apm" ); 222 Config config ( "apm" );
225 223
226 // bat 224 // bat
227 config. setGroup ( "Battery" ); 225 config. setGroup ( "Battery" );
228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 226 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
229 config. writeEntry ( "Dim", interval_dim-> value ( )); 227 config. writeEntry ( "Dim", interval_dim-> value ( ));
230 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 228 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
231 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 229 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
232 config. writeEntry ( "Brightness", brightness-> value () ); 230 config. writeEntry ( "Brightness", brightness-> value () );
233 if (m_cres) 231 if (m_cres)
234 config. writeEntry ( "Contrast", contrast-> value () ); 232 config. writeEntry ( "Contrast", contrast-> value () );
235 config. writeEntry ( "Freq", frequency->currentItem() ); 233 config. writeEntry ( "Freq", frequency->currentItem() );
236 234
237 // ac 235 // ac
238 config. setGroup ( "AC" ); 236 config. setGroup ( "AC" );
239 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 237 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
240 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 238 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
241 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 239 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
242 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 240 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
243 config. writeEntry ( "Brightness", brightness_ac-> value () ); 241 config. writeEntry ( "Brightness", brightness_ac-> value () );
244 if (m_cres) 242 if (m_cres)
245 config. writeEntry ( "Contrast", contrast_ac-> value () ); 243 config. writeEntry ( "Contrast", contrast_ac-> value () );
246 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 244 config. writeEntry ( "Freq", frequency_ac->currentItem() );
247 245
248 // only make light sensor stuff appear if the unit has a sensor 246 // only make light sensor stuff appear if the unit has a sensor
249 if ( ODevice::inst ( )-> hasLightSensor ( )) { 247 if ( ODevice::inst ( )-> hasLightSensor ( )) {
250 config. setGroup ( "Battery" ); 248 config. setGroup ( "Battery" );
251 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 249 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
252 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 250 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
253 config. setGroup ( "AC" ); 251 config. setGroup ( "AC" );
254 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 252 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
255 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 253 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
256 } 254 }
257 255
258 // advanced 256 // advanced
259 config. setGroup ( "Warnings" ); 257 config. setGroup ( "Warnings" );
260 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 258 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
261 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 259 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
262 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 260 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
263 config. write ( ); 261 config. write ( );
264 262
265 // notify the launcher 263 // notify the launcher
266 { 264 {
267 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 265 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
268 } 266 }
269 { 267 {
270 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 268 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
271 e << -1; 269 e << -1;
272 } 270 }
273 LightSettingsBase::accept ( ); 271 LightSettingsBase::accept ( );
274} 272}
275 273
276void LightSettings::done ( int r ) 274void LightSettings::done ( int r )
277{ 275{
278 m_resettimer-> stop ( ); 276 m_resettimer-> stop ( );
279 resetBacklight ( ); 277 resetBacklight ( );
280 278
281 LightSettingsBase::done ( r ); 279 LightSettingsBase::done ( r );
282 close ( ); 280 close ( );
283} 281}
diff --git a/core/settings/light-and-power/main.cpp b/core/settings/light-and-power/main.cpp
index 68d433b..cb43ce0 100644
--- a/core/settings/light-and-power/main.cpp
+++ b/core/settings/light-and-power/main.cpp
@@ -1,29 +1,26 @@
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 "light.h" 21#include "light.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/global.h>
26#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
27 24
28 25
29OPIE_EXPORT_APP( OApplicationFactory<LightSettings> ) 26OPIE_EXPORT_APP( OApplicationFactory<LightSettings> )
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp
index 5ca54d4..41de851 100644
--- a/core/settings/light-and-power/sensor.cpp
+++ b/core/settings/light-and-power/sensor.cpp
@@ -1,103 +1,102 @@
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>
29#include <qlayout.h> 28#include <qlayout.h>
30#include <qslider.h> 29#include <qslider.h>
31#include <qspinbox.h> 30#include <qspinbox.h>
32 31
33#include <opie/odevice.h> 32#include <opie/odevice.h>
34 33
35using namespace Opie; 34using namespace Opie;
36 35
37#include "calibration.h" 36#include "calibration.h"
38#include "sensor.h" 37#include "sensor.h"
39 38
40Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name ) 39Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name )
41 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) 40 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params )
42{ 41{
43 int steps = 12; 42 int steps = 12;
44 int inter = 2; 43 int inter = 2;
45 44
46 int smin = 40; 45 int smin = 40;
47 int smax = 215; 46 int smax = 215;
48 int lmin = 1; 47 int lmin = 1;
49 int lmax = 255; 48 int lmax = 255;
50 49
51 switch ( params. count ( )) { 50 switch ( params. count ( )) {
52 case 6: lmax = params [5]. toInt ( ); 51 case 6: lmax = params [5]. toInt ( );
53 case 5: lmin = params [4]. toInt ( ); 52 case 5: lmin = params [4]. toInt ( );
54 case 4: smax = params [3]. toInt ( ); 53 case 4: smax = params [3]. toInt ( );
55 case 3: smin = params [2]. toInt ( ); 54 case 3: smin = params [2]. toInt ( );
56 case 2: steps = params [1]. toInt ( ); 55 case 2: steps = params [1]. toInt ( );
57 case 1: inter = params [0]. toInt ( ) / 1000; 56 case 1: inter = params [0]. toInt ( ) / 1000;
58 } 57 }
59 58
60 int xscale = ODevice::inst ( )-> lightSensorResolution ( ); 59 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
61 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); 60 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
62 61
63 QVBoxLayout *lay = new QVBoxLayout ( frame ); 62 QVBoxLayout *lay = new QVBoxLayout ( frame );
64 lay-> setMargin ( 2 ); 63 lay-> setMargin ( 2 );
65 m_calib = new Calibration ( frame ); 64 m_calib = new Calibration ( frame );
66 lay-> add ( m_calib ); 65 lay-> add ( m_calib );
67 66
68 m_calib-> setScale ( QSize ( xscale, yscale )); 67 m_calib-> setScale ( QSize ( xscale, yscale ));
69 m_calib-> setLineSteps ( steps ); 68 m_calib-> setLineSteps ( steps );
70 m_calib-> setInterval ( inter ); 69 m_calib-> setInterval ( inter );
71 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 )); 70 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 ));
72 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 )); 71 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 ));
73 72
74 interval-> setValue ( inter ); 73 interval-> setValue ( inter );
75 linesteps-> setValue ( steps ); 74 linesteps-> setValue ( steps );
76 75
77 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); 76 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int )));
78 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); 77 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int )));
79 78
80 connect ( m_calib, SIGNAL( startPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & ))); 79 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 & ))); 80 connect ( m_calib, SIGNAL( endPointChanged ( const QPoint & )), this, SLOT( pointDrag ( const QPoint & )));
82} 81}
83 82
84void Sensor::accept ( ) 83void Sensor::accept ( )
85{ 84{
86 int xscale = ODevice::inst ( )-> lightSensorResolution ( ); 85 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
87 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); 86 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
88 87
89 m_params. clear ( ); 88 m_params. clear ( );
90 m_params << QString::number ( m_calib-> interval ( ) * 1000 ) 89 m_params << QString::number ( m_calib-> interval ( ) * 1000 )
91 << QString::number ( m_calib-> lineSteps ( )) 90 << QString::number ( m_calib-> lineSteps ( ))
92 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale ) 91 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale )
93 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale ) 92 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale )
94 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale ) 93 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale )
95 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale ); 94 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale );
96 95
97 QDialog::accept ( ); 96 QDialog::accept ( );
98} 97}
99 98
100void Sensor::pointDrag ( const QPoint &p ) 99void Sensor::pointDrag ( const QPoint &p )
101{ 100{
102 emit viewBacklight ( p. y ( )); 101 emit viewBacklight ( p. y ( ));
103} 102}