summaryrefslogtreecommitdiff
path: root/core/settings/light-and-power
authoralwin <alwin>2004-03-02 12:14:15 (UTC)
committer alwin <alwin>2004-03-02 12:14:15 (UTC)
commit0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff)
tree503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /core/settings/light-and-power
parenta0981652d61776d70f25980f035748b21339e946 (diff)
downloadopie-0d59c780513da78033f4d9040475dee9db0256d4.zip
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz
opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you can check the diff (but it had compiled and run here)
Diffstat (limited to 'core/settings/light-and-power') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp14
-rw-r--r--core/settings/light-and-power/sensor.cpp8
2 files changed, 11 insertions, 11 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 4baff8e..ce45836 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -79,229 +79,229 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
79 QStrList freq = ODevice::inst()->allowedCpuFrequencies(); 79 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
80 if ( freq.count() ) { 80 if ( freq.count() ) {
81 frequency->insertStrList( freq ); 81 frequency->insertStrList( freq );
82 frequency_ac->insertStrList( freq ); 82 frequency_ac->insertStrList( freq );
83 } else { 83 } else {
84 frequencyLabel->hide(); 84 frequencyLabel->hide();
85 frequency->hide(); 85 frequency->hide();
86 frequencyLabel_ac->hide(); 86 frequencyLabel_ac->hide();
87 frequency_ac->hide(); 87 frequency_ac->hide();
88 } 88 }
89 89
90 // check whether to show the hinge action stuff 90 // check whether to show the hinge action stuff
91 91
92 if ( !ODevice::inst()->hasHingeSensor() ) { 92 if ( !ODevice::inst()->hasHingeSensor() ) {
93 closeHingeLabel->hide(); 93 closeHingeLabel->hide();
94 closeHingeAction->hide(); 94 closeHingeAction->hide();
95 closeHingeLabel_ac->hide(); 95 closeHingeLabel_ac->hide();
96 closeHingeAction_ac->hide(); 96 closeHingeAction_ac->hide();
97 } 97 }
98 98
99 Config config ( "apm" ); 99 Config config ( "apm" );
100 config. setGroup ( "Battery" ); 100 config. setGroup ( "Battery" );
101 101
102 // battery spinboxes 102 // battery spinboxes
103 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 103 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
104 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 104 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
105 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 105 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
106 106
107 // battery check and slider 107 // battery check and slider
108 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 108 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
109 109
110 // CPU frequency 110 // CPU frequency
111 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 111 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
112 112
113 // hinge action 113 // hinge action
114 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 114 closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
115 115
116 int bright = config. readNumEntry ( "Brightness", 127 ); 116 int bright = config. readNumEntry ( "Brightness", 127 );
117 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 117 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
118 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 118 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
119 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 119 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
120 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 120 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
121 brightness-> setValue ( bright ); 121 brightness-> setValue ( bright );
122 122
123 if (m_cres) { 123 if (m_cres) {
124 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 124 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
125 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 125 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
126 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 126 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
127 contrast-> setValue ( contr ); 127 contrast-> setValue ( contr );
128 } 128 }
129 129
130 // light sensor 130 // light sensor
131 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 131 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
132 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 132 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
133 133
134 config. setGroup ( "AC" ); 134 config. setGroup ( "AC" );
135 135
136 // ac spinboxes 136 // ac spinboxes
137 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 137 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
138 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 138 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
139 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 139 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
140 140
141 // ac check and slider 141 // ac check and slider
142 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 142 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
143 143
144 // CPU frequency 144 // CPU frequency
145 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); 145 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
146 146
147 // hinge action 147 // hinge action
148 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); 148 closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) );
149 149
150 bright = config. readNumEntry ( "Brightness", 255 ); 150 bright = config. readNumEntry ( "Brightness", 255 );
151 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 151 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
152 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 152 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
153 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 153 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
154 brightness_ac-> setValue ( bright ); 154 brightness_ac-> setValue ( bright );
155 155
156 if (m_cres) { 156 if (m_cres) {
157 contr = config. readNumEntry ( "Contrast", 127); 157 contr = config. readNumEntry ( "Contrast", 127);
158 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 158 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
159 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 159 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
160 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 160 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
161 contrast_ac-> setValue ( contr ); 161 contrast_ac-> setValue ( contr );
162 } 162 }
163 163
164 // light sensor 164 // light sensor
165 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 165 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
166 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 166 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
167 167
168 // warnings 168 // warnings
169 config. setGroup ( "Warnings" ); 169 config. setGroup ( "Warnings" );
170 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 170 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
171 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 171 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
172 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 172 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
173 173
174 m_resettimer = new QTimer ( this ); 174 m_resettimer = new QTimer ( this );
175 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 175 connect ( m_resettimer, SIGNAL( timeout()), this, SLOT( resetBacklight()));
176 176
177 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 177 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
178 tabs-> setCurrentPage ( 0 ); 178 tabs-> setCurrentPage ( 0 );
179 } 179 }
180 else { 180 else {
181 tabs-> setCurrentPage ( 1 ); 181 tabs-> setCurrentPage ( 1 );
182 } 182 }
183 183
184 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 184 connect ( brightness, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int)));
185 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 185 connect ( brightness_ac, SIGNAL( valueChanged(int)), this, SLOT( setBacklight(int)));
186 if (m_cres) { 186 if (m_cres) {
187 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 187 connect ( contrast, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int)));
188 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 188 connect ( contrast_ac, SIGNAL( valueChanged(int)), this, SLOT( setContrast(int)));
189 } 189 }
190 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 190 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
191 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); 191 connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
192 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 192 connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
193 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); 193 connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) );
194} 194}
195 195
196LightSettings::~LightSettings ( ) 196LightSettings::~LightSettings ( )
197{ 197{
198} 198}
199 199
200void LightSettings::calibrateSensor ( ) 200void LightSettings::calibrateSensor ( )
201{ 201{
202 Sensor *s = new Sensor ( m_sensordata, this ); 202 Sensor *s = new Sensor ( m_sensordata, this );
203 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 203 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int)));
204 QPEApplication::execDialog( s ); 204 QPEApplication::execDialog( s );
205 delete s; 205 delete s;
206} 206}
207 207
208void LightSettings::calibrateSensorAC ( ) 208void LightSettings::calibrateSensorAC ( )
209{ 209{
210 Sensor *s = new Sensor ( m_sensordata_ac, this ); 210 Sensor *s = new Sensor ( m_sensordata_ac, this );
211 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 211 connect ( s, SIGNAL( viewBacklight(int)), this, SLOT( setBacklight(int)));
212 QPEApplication::execDialog ( s ); 212 QPEApplication::execDialog ( s );
213 delete s; 213 delete s;
214} 214}
215 215
216void LightSettings::setBacklight ( int bright ) 216void LightSettings::setBacklight ( int bright )
217{ 217{
218 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 218 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
219 e << bright; 219 e << bright;
220 220
221 if ( bright != -1 ) { 221 if ( bright != -1 ) {
222 m_resettimer-> stop ( ); 222 m_resettimer-> stop ( );
223 m_resettimer-> start ( 4000, true ); 223 m_resettimer-> start ( 4000, true );
224 } 224 }
225} 225}
226 226
227void LightSettings::setContrast ( int contr ) 227void LightSettings::setContrast ( int contr )
228{ 228{
229 if (contr == -1) contr = m_oldcontrast; 229 if (contr == -1) contr = m_oldcontrast;
230 ODevice::inst ( )-> setDisplayContrast(contr); 230 ODevice::inst ( )-> setDisplayContrast(contr);
231} 231}
232 232
233void LightSettings::setFrequency ( int index ) 233void LightSettings::setFrequency ( int index )
234{ 234{
235 qWarning("LightSettings::setFrequency(%d)", index); 235 qWarning("LightSettings::setFrequency(%d)", index);
236 ODevice::inst ( )-> setCurrentCpuFrequency(index); 236 ODevice::inst ( )-> setCurrentCpuFrequency(index);
237} 237}
238 238
239void LightSettings::resetBacklight ( ) 239void LightSettings::resetBacklight ( )
240{ 240{
241 setBacklight ( -1 ); 241 setBacklight ( -1 );
242 setContrast ( -1 ); 242 setContrast ( -1 );
243} 243}
244 244
245void LightSettings::setCloseHingeAction ( int index ) 245void LightSettings::setCloseHingeAction ( int index )
246{ 246{
247 qWarning("LightSettings::setCloseHingeStatus(%d)", index); 247 qWarning("LightSettings::setCloseHingeStatus(%d)", index);
248} 248}
249 249
250void LightSettings::accept ( ) 250void LightSettings::accept ( )
251{ 251{
252 Config config ( "apm" ); 252 Config config ( "apm" );
253 253
254 // bat 254 // bat
255 config. setGroup ( "Battery" ); 255 config. setGroup ( "Battery" );
256 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 256 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
257 config. writeEntry ( "Dim", interval_dim-> value ( )); 257 config. writeEntry ( "Dim", interval_dim-> value ( ));
258 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 258 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
259 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 259 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
260 config. writeEntry ( "Brightness", brightness-> value () ); 260 config. writeEntry ( "Brightness", brightness-> value () );
261 if (m_cres) 261 if (m_cres)
262 config. writeEntry ( "Contrast", contrast-> value () ); 262 config. writeEntry ( "Contrast", contrast-> value () );
263 config. writeEntry ( "Freq", frequency->currentItem() ); 263 config. writeEntry ( "Freq", frequency->currentItem() );
264 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); 264 config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() );
265 265
266 // ac 266 // ac
267 config. setGroup ( "AC" ); 267 config. setGroup ( "AC" );
268 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 268 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
269 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 269 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
270 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 270 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
271 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 271 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
272 config. writeEntry ( "Brightness", brightness_ac-> value () ); 272 config. writeEntry ( "Brightness", brightness_ac-> value () );
273 if (m_cres) 273 if (m_cres)
274 config. writeEntry ( "Contrast", contrast_ac-> value () ); 274 config. writeEntry ( "Contrast", contrast_ac-> value () );
275 config. writeEntry ( "Freq", frequency_ac->currentItem() ); 275 config. writeEntry ( "Freq", frequency_ac->currentItem() );
276 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); 276 config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() );
277 277
278 // only make light sensor stuff appear if the unit has a sensor 278 // only make light sensor stuff appear if the unit has a sensor
279 if ( ODevice::inst ( )-> hasLightSensor ( )) { 279 if ( ODevice::inst ( )-> hasLightSensor ( )) {
280 config. setGroup ( "Battery" ); 280 config. setGroup ( "Battery" );
281 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 281 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
282 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 282 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
283 config. setGroup ( "AC" ); 283 config. setGroup ( "AC" );
284 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 284 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
285 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 285 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
286 } 286 }
287 287
288 // advanced 288 // advanced
289 config. setGroup ( "Warnings" ); 289 config. setGroup ( "Warnings" );
290 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 290 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
291 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 291 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
292 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 292 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
293 config. write ( ); 293 config. write ( );
294 294
295 // notify the launcher 295 // notify the launcher
296 { 296 {
297 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 297 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
298 } 298 }
299 { 299 {
300 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 300 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
301 e << -1; 301 e << -1;
302 } 302 }
303 LightSettingsBase::accept ( ); 303 LightSettingsBase::accept ( );
304} 304}
305 305
306void LightSettings::done ( int r ) 306void LightSettings::done ( int r )
307{ 307{
diff --git a/core/settings/light-and-power/sensor.cpp b/core/settings/light-and-power/sensor.cpp
index 41de851..013e655 100644
--- a/core/settings/light-and-power/sensor.cpp
+++ b/core/settings/light-and-power/sensor.cpp
@@ -1,102 +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 <qlayout.h> 28#include <qlayout.h>
29#include <qslider.h> 29#include <qslider.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31 31
32#include <opie/odevice.h> 32#include <opie/odevice.h>
33 33
34using namespace Opie; 34using namespace Opie;
35 35
36#include "calibration.h" 36#include "calibration.h"
37#include "sensor.h" 37#include "sensor.h"
38 38
39Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name ) 39Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name )
40 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params ) 40 : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params )
41{ 41{
42 int steps = 12; 42 int steps = 12;
43 int inter = 2; 43 int inter = 2;
44 44
45 int smin = 40; 45 int smin = 40;
46 int smax = 215; 46 int smax = 215;
47 int lmin = 1; 47 int lmin = 1;
48 int lmax = 255; 48 int lmax = 255;
49 49
50 switch ( params. count ( )) { 50 switch ( params. count ( )) {
51 case 6: lmax = params [5]. toInt ( ); 51 case 6: lmax = params [5]. toInt ( );
52 case 5: lmin = params [4]. toInt ( ); 52 case 5: lmin = params [4]. toInt ( );
53 case 4: smax = params [3]. toInt ( ); 53 case 4: smax = params [3]. toInt ( );
54 case 3: smin = params [2]. toInt ( ); 54 case 3: smin = params [2]. toInt ( );
55 case 2: steps = params [1]. toInt ( ); 55 case 2: steps = params [1]. toInt ( );
56 case 1: inter = params [0]. toInt ( ) / 1000; 56 case 1: inter = params [0]. toInt ( ) / 1000;
57 } 57 }
58 58
59 int xscale = ODevice::inst ( )-> lightSensorResolution ( ); 59 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
60 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); 60 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
61 61
62 QVBoxLayout *lay = new QVBoxLayout ( frame ); 62 QVBoxLayout *lay = new QVBoxLayout ( frame );
63 lay-> setMargin ( 2 ); 63 lay-> setMargin ( 2 );
64 m_calib = new Calibration ( frame ); 64 m_calib = new Calibration ( frame );
65 lay-> add ( m_calib ); 65 lay-> add ( m_calib );
66 66
67 m_calib-> setScale ( QSize ( xscale, yscale )); 67 m_calib-> setScale ( QSize ( xscale, yscale ));
68 m_calib-> setLineSteps ( steps ); 68 m_calib-> setLineSteps ( steps );
69 m_calib-> setInterval ( inter ); 69 m_calib-> setInterval ( inter );
70 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 )); 70 m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 ));
71 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 )); 71 m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 ));
72 72
73 interval-> setValue ( inter ); 73 interval-> setValue ( inter );
74 linesteps-> setValue ( steps ); 74 linesteps-> setValue ( steps );
75 75
76 connect ( interval, SIGNAL( valueChanged ( int )), m_calib, SLOT( setInterval ( int ))); 76 connect ( interval, SIGNAL( valueChanged(int)), m_calib, SLOT( setInterval(int)));
77 connect ( linesteps, SIGNAL( valueChanged ( int )), m_calib, SLOT( setLineSteps ( int ))); 77 connect ( linesteps, SIGNAL( valueChanged(int)), m_calib, SLOT( setLineSteps(int)));
78 78
79 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&)));
80 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&)));
81} 81}
82 82
83void Sensor::accept ( ) 83void Sensor::accept ( )
84{ 84{
85 int xscale = ODevice::inst ( )-> lightSensorResolution ( ); 85 int xscale = ODevice::inst ( )-> lightSensorResolution ( );
86 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( ); 86 int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
87 87
88 m_params. clear ( ); 88 m_params. clear ( );
89 m_params << QString::number ( m_calib-> interval ( ) * 1000 ) 89 m_params << QString::number ( m_calib-> interval ( ) * 1000 )
90 << QString::number ( m_calib-> lineSteps ( )) 90 << QString::number ( m_calib-> lineSteps ( ))
91 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale ) 91 << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale )
92 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale ) 92 << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale )
93 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale ) 93 << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale )
94 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale ); 94 << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale );
95 95
96 QDialog::accept ( ); 96 QDialog::accept ( );
97} 97}
98 98
99void Sensor::pointDrag ( const QPoint &p ) 99void Sensor::pointDrag ( const QPoint &p )
100{ 100{
101 emit viewBacklight ( p. y ( )); 101 emit viewBacklight ( p. y ( ));
102} 102}