summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-27 16:56:57 (UTC)
committer harlekin <harlekin>2002-10-27 16:56:57 (UTC)
commit3bdf11c7117e28cda91a1447b8510d7deba94b99 (patch) (unidiff)
treebd319dc62298cc1237adbc889beea099a1bbe409
parent27a2748d4a5893a888b19d3ed453be29cac0d75b (diff)
downloadopie-3bdf11c7117e28cda91a1447b8510d7deba94b99.zip
opie-3bdf11c7117e28cda91a1447b8510d7deba94b99.tar.gz
opie-3bdf11c7117e28cda91a1447b8510d7deba94b99.tar.bz2
light sensor more generell, not only ipaq
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 77c6b40..fb40adc 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -80,199 +80,196 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
80 interval_dim->setSpecialValueText( tr("never") ); 80 interval_dim->setSpecialValueText( tr("never") );
81 } else { 81 } else {
82 interval_dim->setValue( interval ); 82 interval_dim->setValue( interval );
83 } 83 }
84 84
85 interval = config.readNumEntry( "Interval_LightOff", 30 ); 85 interval = config.readNumEntry( "Interval_LightOff", 30 );
86 if ( config.readNumEntry("LightOff",1) == 0 ) { 86 if ( config.readNumEntry("LightOff",1) == 0 ) {
87 interval_lightoff->setSpecialValueText( tr("never") ); 87 interval_lightoff->setSpecialValueText( tr("never") );
88 } else { 88 } else {
89 interval_lightoff->setValue( interval ); 89 interval_lightoff->setValue( interval );
90 } 90 }
91 91
92 interval = config.readNumEntry( "Interval", 60 ); 92 interval = config.readNumEntry( "Interval", 60 );
93 if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) 93 if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs)
94 interval_suspend->setValue( interval ); 94 interval_suspend->setValue( interval );
95 95
96 // ac spinboxes 96 // ac spinboxes
97 interval = config.readNumEntry( "Interval_DimAC", 20 ); 97 interval = config.readNumEntry( "Interval_DimAC", 20 );
98 if ( config.readNumEntry("DimAC",1) == 0 ) { 98 if ( config.readNumEntry("DimAC",1) == 0 ) {
99 interval_dim_ac_3->setSpecialValueText( tr("never") ); 99 interval_dim_ac_3->setSpecialValueText( tr("never") );
100 } else { 100 } else {
101 interval_dim_ac_3->setValue( interval ); 101 interval_dim_ac_3->setValue( interval );
102 } 102 }
103 103
104 interval = config.readNumEntry( "Interval_LightOffAC", 30 ); 104 interval = config.readNumEntry( "Interval_LightOffAC", 30 );
105 if ( config.readNumEntry("LightOffAC",1) == 0 ) { 105 if ( config.readNumEntry("LightOffAC",1) == 0 ) {
106 interval_lightoff_ac_3->setSpecialValueText( tr("never") ); 106 interval_lightoff_ac_3->setSpecialValueText( tr("never") );
107 } else { 107 } else {
108 interval_lightoff_ac_3->setValue( interval ); 108 interval_lightoff_ac_3->setValue( interval );
109 } 109 }
110 110
111 interval = config.readNumEntry( "IntervalAC", 60 ); 111 interval = config.readNumEntry( "IntervalAC", 60 );
112 if ( interval > 3600 ) { 112 if ( interval > 3600 ) {
113 interval /= 1000; // compatibility (was millisecs) 113 interval /= 1000; // compatibility (was millisecs)
114 } 114 }
115 if ( config.readNumEntry("NoApmAC", 0) == 0 ) { 115 if ( config.readNumEntry("NoApmAC", 0) == 0 ) {
116 interval_suspend_ac_3->setSpecialValueText( tr("never") ); 116 interval_suspend_ac_3->setSpecialValueText( tr("never") );
117 } else { 117 } else {
118 interval_suspend_ac_3->setValue( interval ); 118 interval_suspend_ac_3->setValue( interval );
119 } 119 }
120 120
121 121
122 // battery check and slider 122 // battery check and slider
123 LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); 123 LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 );
124 int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); 124 int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( );
125 initbright = config.readNumEntry("Brightness",255); 125 initbright = config.readNumEntry("Brightness",255);
126 brightness->setMaxValue( maxbright ); 126 brightness->setMaxValue( maxbright );
127 brightness->setTickInterval( QMAX(1,maxbright/16) ); 127 brightness->setTickInterval( QMAX(1,maxbright/16) );
128 brightness->setLineStep( QMAX(1,maxbright/16) ); 128 brightness->setLineStep( QMAX(1,maxbright/16) );
129 brightness->setPageStep( QMAX(1,maxbright/16) ); 129 brightness->setPageStep( QMAX(1,maxbright/16) );
130 brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); 130 brightness->setValue( (maxbright*255 - initbright*maxbright)/255 );
131 131
132 // ac check and slider 132 // ac check and slider
133 LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 ); 133 LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 );
134 int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); 134 int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( );
135 initbright_ac = config.readNumEntry("BrightnessAC",255); 135 initbright_ac = config.readNumEntry("BrightnessAC",255);
136 brightness_ac_3->setMaxValue( maxbright_ac ); 136 brightness_ac_3->setMaxValue( maxbright_ac );
137 brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) ); 137 brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) );
138 brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) ); 138 brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) );
139 brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) ); 139 brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) );
140 brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 ); 140 brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 );
141 141
142 142
143 // ipaq sensor 143 // ipaq sensor
144 config.setGroup( "Ipaqlightsensor" ); 144 config.setGroup( "lightsensor" );
145 auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 ); 145 auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 );
146 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",0) != 0 ); 146 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",0) != 0 );
147 //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); 147 //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) );
148 //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); 148 //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) );
149 //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; 149 //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ;
150 //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); 150 //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) );
151 151
152 // advanced settings 152 // advanced settings
153 Config conf("apm"); 153 Config conf("apm");
154 conf.setGroup( "warnings" ); 154 conf.setGroup( "warnings" );
155 warnintervalBox->setValue( conf.readNumEntry("checkinterval", 10000)/1000 ); 155 warnintervalBox->setValue( conf.readNumEntry("checkinterval", 10000)/1000 );
156 lowSpinBox->setValue( conf.readNumEntry("powerverylow", 10 ) ); 156 lowSpinBox->setValue( conf.readNumEntry("powerverylow", 10 ) );
157 criticalSpinBox->setValue( conf.readNumEntry("powercritical", 5 ) ); 157 criticalSpinBox->setValue( conf.readNumEntry("powercritical", 5 ) );
158 158
159 connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); 159 connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) );
160 connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); 160 connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) );
161} 161}
162 162
163LightSettings::~LightSettings() { 163LightSettings::~LightSettings() {
164} 164}
165 165
166void LightSettings::slotSliderTicks( int steps ) { 166void LightSettings::slotSliderTicks( int steps ) {
167// LightMinValueSlider->setTickInterval( steps ); 167// LightMinValueSlider->setTickInterval( steps );
168} 168}
169 169
170static void set_fl(int bright) 170static void set_fl(int bright)
171{ 171{
172 qDebug ( QString( "Brightness" ).arg( bright ) ); 172 qDebug ( QString( "Brightness" ).arg( bright ) );
173 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 173 QCopEnvelope e("QPE/System", "setBacklight(int)" );
174 e << bright; 174 e << bright;
175} 175}
176 176
177void LightSettings::reject() 177void LightSettings::reject()
178{ 178{
179 set_fl(initbright); 179 set_fl(initbright);
180 QDialog::reject(); 180 QDialog::reject();
181} 181}
182 182
183void LightSettings::accept() 183void LightSettings::accept()
184{ 184{
185 if ( qApp->focusWidget() ) { 185 if ( qApp->focusWidget() ) {
186 qApp->focusWidget()->clearFocus(); 186 qApp->focusWidget()->clearFocus();
187 } 187 }
188 188
189 applyBrightness(); 189 applyBrightness();
190 190
191 // bat 191 // bat
192 int i_dim = ( !( interval_dim->specialValueText() == tr("never") ) ? interval_dim->value() : 0); 192 int i_dim = ( !( interval_dim->specialValueText() == tr("never") ) ? interval_dim->value() : 0);
193 int i_lightoff = ( !( interval_lightoff->specialValueText() == tr("never") ) ? interval_lightoff->value() : 0); 193 int i_lightoff = ( !( interval_lightoff->specialValueText() == tr("never") ) ? interval_lightoff->value() : 0);
194 int i_suspend = interval_suspend->value(); 194 int i_suspend = interval_suspend->value();
195 QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); 195 QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" );
196 e << i_dim << i_lightoff << i_suspend; 196 e << i_dim << i_lightoff << i_suspend;
197 197
198 // ac 198 // ac
199 int i_dim_ac = ( !( interval_dim_ac_3->specialValueText() == tr("never") ) ? interval_dim_ac_3->value() : 0); 199 int i_dim_ac = ( !( interval_dim_ac_3->specialValueText() == tr("never") ) ? interval_dim_ac_3->value() : 0);
200 int i_lightoff_ac = ( !( interval_lightoff_ac_3->specialValueText() == tr("never") ) ? interval_lightoff_ac_3->value() : 0); 200 int i_lightoff_ac = ( !( interval_lightoff_ac_3->specialValueText() == tr("never") ) ? interval_lightoff_ac_3->value() : 0);
201 int i_suspend_ac = interval_suspend_ac_3->value(); 201 int i_suspend_ac = interval_suspend_ac_3->value();
202 QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); 202 QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" );
203 e << i_dim_ac << i_lightoff_ac << i_suspend_ac; 203 e << i_dim_ac << i_lightoff_ac << i_suspend_ac;
204 204
205 Config config( "qpe" ); 205 Config config( "qpe" );
206 config.setGroup( "Screensaver" ); 206 config.setGroup( "Screensaver" );
207 207
208 // bat 208 // bat
209 config.writeEntry( "Dim", interval_dim->specialValueText() == tr("never") ); 209 config.writeEntry( "Dim", interval_dim->specialValueText() == tr("never") );
210 config.writeEntry( "LightOff", interval_lightoff->specialValueText() == tr("never") ); 210 config.writeEntry( "LightOff", interval_lightoff->specialValueText() == tr("never") );
211 config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() ); 211 config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() );
212 config.writeEntry( "Interval_Dim", interval_dim->value() ); 212 config.writeEntry( "Interval_Dim", interval_dim->value() );
213 config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); 213 config.writeEntry( "Interval_LightOff", interval_lightoff->value() );
214 config.writeEntry( "Interval", interval_suspend->value() ); 214 config.writeEntry( "Interval", interval_suspend->value() );
215 config.writeEntry( "Brightness", 215 config.writeEntry( "Brightness",
216 ( brightness->value() ) * 255 / brightness->maxValue() ); 216 ( brightness->value() ) * 255 / brightness->maxValue() );
217 217
218 // ac 218 // ac
219 config.writeEntry( "DimAC", interval_dim_ac_3->specialValueText() == tr("never") ); 219 config.writeEntry( "DimAC", interval_dim_ac_3->specialValueText() == tr("never") );
220 config.writeEntry( "LightOffAC", interval_lightoff_ac_3->specialValueText() == tr("never") ); 220 config.writeEntry( "LightOffAC", interval_lightoff_ac_3->specialValueText() == tr("never") );
221 config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() ); 221 config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() );
222 config.writeEntry( "NoAPmAC", interval_suspend_ac_3->specialValueText() == tr("never") ); 222 config.writeEntry( "NoAPmAC", interval_suspend_ac_3->specialValueText() == tr("never") );
223 config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() ); 223 config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() );
224 config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() ); 224 config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() );
225 config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() ); 225 config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() );
226 config.writeEntry( "BrightnessAC", 226 config.writeEntry( "BrightnessAC",
227 ( brightness_ac_3->value()) * 255 / brightness_ac_3->maxValue() ); 227 ( brightness_ac_3->value()) * 255 / brightness_ac_3->maxValue() );
228 228
229 229
230 // only make ipaq light sensor entries in config file if on an ipaq 230 // only make light sensor stuff appear if the unit has a sensor
231 if ( ODevice::inst()->hasLightSensor() ) { 231 if ( ODevice::inst()->hasLightSensor() ) {
232 // ipaq sensor 232 config.setGroup( "lightsensor" );
233 config.setGroup( "Ipaqlightsensor" );
234 config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); 233 config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() );
235 config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); 234 config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() );
236 //config.writeEntry( "Steps", LightStepSpin->value() ); 235 //config.writeEntry( "Steps", LightStepSpin->value() );
237 //onfig.writeEntry( "MinValue", LightMinValueSlider->value() ); 236 //onfig.writeEntry( "MinValue", LightMinValueSlider->value() );
238 //config.writeEntry( "Shift", LightShiftSpin->value() ); 237 //config.writeEntry( "Shift", LightShiftSpin->value() );
239 } 238 }
240 239
241 config.write(); 240 config.write();
242 241
243 // advanced 242 // advanced
244 Config conf("apm"); 243 Config conf("apm");
245 conf.setGroup( "Warnings" ); 244 conf.setGroup( "Warnings" );
246 conf.writeEntry( "check_interval", warnintervalBox->value()*1000 ); 245 conf.writeEntry( "check_interval", warnintervalBox->value()*1000 );
247 conf.writeEntry( "power_verylow", lowSpinBox->value() ); 246 conf.writeEntry( "power_verylow", lowSpinBox->value() );
248 conf.writeEntry( "power_critical", criticalSpinBox->value() ); 247 conf.writeEntry( "power_critical", criticalSpinBox->value() );
249 QCopEnvelope e_warn("QPE/System", "reloadPowerWarnSettings()"); 248 QCopEnvelope e_warn("QPE/System", "reloadPowerWarnSettings()");
250 conf.write(); 249 conf.write();
251 250
252 QDialog::accept(); 251 QDialog::accept();
253} 252}
254 253
255void LightSettings::applyBrightness() 254void LightSettings::applyBrightness()
256{ 255{
257 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 256 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
258 int bright = ( brightness->value() ) * 255 / brightness->maxValue(); 257 int bright = ( brightness->value() ) * 255 / brightness->maxValue();
259 set_fl(bright); 258 set_fl(bright);
260 } 259 }
261} 260}
262 261
263void LightSettings::applyBrightnessAC() 262void LightSettings::applyBrightnessAC()
264{ 263{
265 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting 264 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting
266 if ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ) { 265 if ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ) {
267 int bright = ( brightness_ac_3->value() ) * 255 / brightness_ac_3->maxValue(); 266 int bright = ( brightness_ac_3->value() ) * 255 / brightness_ac_3->maxValue();
268 set_fl(bright); 267 set_fl(bright);
269 } 268 }
270} 269}
271 270
272
273
274void LightSettings::done(int r) 271void LightSettings::done(int r)
275{ 272{
276 QDialog::done(r); 273 QDialog::done(r);
277 close (); 274 close ();
278} 275}