summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-20 16:14:46 (UTC)
committer harlekin <harlekin>2002-10-20 16:14:46 (UTC)
commitd3936c24518e9fea48a060eaef02e64a89646657 (patch) (unidiff)
tree0dc08dc1c757e0d7a2b32d53ed2a56d8b0442fa3
parent56ac4499a8e13a58d006b35ea023153df9995f7a (diff)
downloadopie-d3936c24518e9fea48a060eaef02e64a89646657.zip
opie-d3936c24518e9fea48a060eaef02e64a89646657.tar.gz
opie-d3936c24518e9fea48a060eaef02e64a89646657.tar.bz2
fixed emmited slider values
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp17
-rw-r--r--core/settings/light-and-power/lightsettingsbase.ui22
-rw-r--r--core/settings/light-and-power/settings.h1
3 files changed, 34 insertions, 6 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 8721a95..1a94209 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -119,61 +119,62 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl )
119 int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); 119 int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( );
120 initbright_ac = config.readNumEntry("BrightnessAC",255); 120 initbright_ac = config.readNumEntry("BrightnessAC",255);
121 brightness_ac_3->setMaxValue( maxbright_ac ); 121 brightness_ac_3->setMaxValue( maxbright_ac );
122 brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) ); 122 brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) );
123 brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) ); 123 brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) );
124 brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) ); 124 brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) );
125 brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 ); 125 brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 );
126 126
127 // advanced settings 127 // advanced settings
128 config.setGroup( "APM" ); 128 config.setGroup( "APM" );
129 warnintervalBox->setValue( config.readNumEntry("check_interval", 10000)/1000 ); 129 warnintervalBox->setValue( config.readNumEntry("check_interval", 10000)/1000 );
130 lowSpinBox->setValue( config.readNumEntry("power_verylow", 10 ) ); 130 lowSpinBox->setValue( config.readNumEntry("power_verylow", 10 ) );
131 criticalSpinBox->setValue( config.readNumEntry("power_critical", 5 ) ); 131 criticalSpinBox->setValue( config.readNumEntry("power_critical", 5 ) );
132 132
133 // ipaq sensor 133 // ipaq sensor
134 config.setGroup( "Ipaq_light_sensor" ); 134 config.setGroup( "Ipaq_light_sensor" );
135 auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 ); 135 auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 );
136 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 ); 136 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 );
137 LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); 137 LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) );
138 LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); 138 LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) );
139 connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; 139 connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ;
140 LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); 140 LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) );
141 141
142 connect(brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness())); 142 connect(brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness()));
143 connect(brightness_ac_3, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness())); 143 connect(brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) );
144} 144}
145 145
146LightSettings::~LightSettings() 146LightSettings::~LightSettings()
147{ 147{
148} 148}
149 149
150void LightSettings::slotSliderTicks( int steps ) { 150void LightSettings::slotSliderTicks( int steps ) {
151 LightMinValueSlider->setTickInterval( steps ); 151 LightMinValueSlider->setTickInterval( steps );
152} 152}
153 153
154static void set_fl(int bright) 154static void set_fl(int bright)
155{ 155{
156 qDebug( QString("BRIGHT !! : %1").arg( bright ) );
156 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 157 QCopEnvelope e("QPE/System", "setBacklight(int)" );
157 e << bright; 158 e << bright;
158} 159}
159 160
160void LightSettings::reject() 161void LightSettings::reject()
161{ 162{
162 set_fl(initbright); 163 set_fl(initbright);
163 164
164 QDialog::reject(); 165 QDialog::reject();
165} 166}
166 167
167void LightSettings::accept() 168void LightSettings::accept()
168{ 169{
169 if ( qApp->focusWidget() ) 170 if ( qApp->focusWidget() )
170 qApp->focusWidget()->clearFocus(); 171 qApp->focusWidget()->clearFocus();
171 172
172 applyBrightness(); 173 applyBrightness();
173 174
174 // bat 175 // bat
175 int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); 176 int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0);
176 int i_lightoff = (screensaver_lightoff->isChecked() ? interval_lightoff->value() : 0); 177 int i_lightoff = (screensaver_lightoff->isChecked() ? interval_lightoff->value() : 0);
177 int i_suspend = interval_suspend->value(); 178 int i_suspend = interval_suspend->value();
178 QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); 179 QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" );
179 e << i_dim << i_lightoff << i_suspend; 180 e << i_dim << i_lightoff << i_suspend;
@@ -218,41 +219,47 @@ void LightSettings::accept()
218 219
219 // only make ipaq light sensor entries in config file if on an ipaq 220 // only make ipaq light sensor entries in config file if on an ipaq
220 if ( ODevice::inst()->model() == Model_iPAQ_H31xx || 221 if ( ODevice::inst()->model() == Model_iPAQ_H31xx ||
221 ODevice::inst()->model() == Model_iPAQ_H36xx || 222 ODevice::inst()->model() == Model_iPAQ_H36xx ||
222 ODevice::inst()->model() == Model_iPAQ_H37xx || 223 ODevice::inst()->model() == Model_iPAQ_H37xx ||
223 ODevice::inst()->model() == Model_iPAQ_H38xx ) { 224 ODevice::inst()->model() == Model_iPAQ_H38xx ) {
224 225
225 // ipaq sensor 226 // ipaq sensor
226 config.setGroup( "Ipaq_light_sensor" ); 227 config.setGroup( "Ipaq_light_sensor" );
227 228
228 config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); 229 config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() );
229 config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); 230 config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() );
230 config.writeEntry( "Steps", LightStepSpin->value() ); 231 config.writeEntry( "Steps", LightStepSpin->value() );
231 config.writeEntry( "MinValue", LightMinValueSlider->value() ); 232 config.writeEntry( "MinValue", LightMinValueSlider->value() );
232 config.writeEntry( "Shift", LightShiftSpin->value() ); 233 config.writeEntry( "Shift", LightShiftSpin->value() );
233 } 234 }
234 235
235 config.write(); 236 config.write();
236 237
237 QDialog::accept(); 238 QDialog::accept();
238} 239}
239 240
240void LightSettings::applyBrightness() 241void LightSettings::applyBrightness()
241{ 242{
243 if ( !PowerStatus::Online ) {
244 int bright = ( brightness->value() ) * 255 / brightness->maxValue();
245 set_fl(bright);
246 }
247}
248
249void LightSettings::applyBrightnessAC()
250{
251 qDebug( QString("SLIDER : %1").arg( brightness_ac_3->value() ) );
242 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting 252 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting
243 if ( PowerStatus::Online ) { 253 if ( PowerStatus::Online ) {
244 int bright = (brightness_ac_3->maxValue() - brightness_ac_3->value())*255 / brightness_ac_3->maxValue(); 254 int bright = ( brightness_ac_3->value() ) * 255 / brightness_ac_3->maxValue();
245 set_fl(bright);
246 } else {
247 int bright = (brightness->maxValue()-brightness->value())*255 / brightness->maxValue();
248 set_fl(bright); 255 set_fl(bright);
249 } 256 }
250} 257}
251 258
252 259
253 260
254void LightSettings::done(int r) 261void LightSettings::done(int r)
255{ 262{
256 QDialog::done(r); 263 QDialog::done(r);
257 close ( ); 264 close ( );
258} 265}
diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui
index fd85017..5e62626 100644
--- a/core/settings/light-and-power/lightsettingsbase.ui
+++ b/core/settings/light-and-power/lightsettingsbase.ui
@@ -1,38 +1,38 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>LightSettingsBase</class> 2<class>LightSettingsBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>LightSettingsBase</cstring> 7 <cstring>LightSettingsBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>419</width> 14 <width>415</width>
15 <height>532</height> 15 <height>532</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Light and Power Settings</string> 20 <string>Light and Power Settings</string>
21 </property> 21 </property>
22 <property stdset="1"> 22 <property stdset="1">
23 <name>sizeGripEnabled</name> 23 <name>sizeGripEnabled</name>
24 <bool>false</bool> 24 <bool>false</bool>
25 </property> 25 </property>
26 <property> 26 <property>
27 <name>layoutMargin</name> 27 <name>layoutMargin</name>
28 </property> 28 </property>
29 <property> 29 <property>
30 <name>layoutSpacing</name> 30 <name>layoutSpacing</name>
31 </property> 31 </property>
32 <vbox> 32 <vbox>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>margin</name> 34 <name>margin</name>
35 <number>3</number> 35 <number>3</number>
36 </property> 36 </property>
37 <property stdset="1"> 37 <property stdset="1">
38 <name>spacing</name> 38 <name>spacing</name>
@@ -287,48 +287,52 @@
287 </property> 287 </property>
288 <property stdset="1"> 288 <property stdset="1">
289 <name>spacing</name> 289 <name>spacing</name>
290 <number>3</number> 290 <number>3</number>
291 </property> 291 </property>
292 <widget> 292 <widget>
293 <class>QSlider</class> 293 <class>QSlider</class>
294 <property stdset="1"> 294 <property stdset="1">
295 <name>name</name> 295 <name>name</name>
296 <cstring>brightness</cstring> 296 <cstring>brightness</cstring>
297 </property> 297 </property>
298 <property stdset="1"> 298 <property stdset="1">
299 <name>maxValue</name> 299 <name>maxValue</name>
300 <number>255</number> 300 <number>255</number>
301 </property> 301 </property>
302 <property stdset="1"> 302 <property stdset="1">
303 <name>lineStep</name> 303 <name>lineStep</name>
304 <number>16</number> 304 <number>16</number>
305 </property> 305 </property>
306 <property stdset="1"> 306 <property stdset="1">
307 <name>pageStep</name> 307 <name>pageStep</name>
308 <number>16</number> 308 <number>16</number>
309 </property> 309 </property>
310 <property stdset="1"> 310 <property stdset="1">
311 <name>tracking</name>
312 <bool>true</bool>
313 </property>
314 <property stdset="1">
311 <name>orientation</name> 315 <name>orientation</name>
312 <enum>Horizontal</enum> 316 <enum>Horizontal</enum>
313 </property> 317 </property>
314 <property stdset="1"> 318 <property stdset="1">
315 <name>tickmarks</name> 319 <name>tickmarks</name>
316 <enum>Right</enum> 320 <enum>Right</enum>
317 </property> 321 </property>
318 <property stdset="1"> 322 <property stdset="1">
319 <name>tickInterval</name> 323 <name>tickInterval</name>
320 <number>32</number> 324 <number>32</number>
321 </property> 325 </property>
322 </widget> 326 </widget>
323 <widget> 327 <widget>
324 <class>QLayoutWidget</class> 328 <class>QLayoutWidget</class>
325 <property stdset="1"> 329 <property stdset="1">
326 <name>name</name> 330 <name>name</name>
327 <cstring>Layout10</cstring> 331 <cstring>Layout10</cstring>
328 </property> 332 </property>
329 <hbox> 333 <hbox>
330 <property stdset="1"> 334 <property stdset="1">
331 <name>margin</name> 335 <name>margin</name>
332 <number>0</number> 336 <number>0</number>
333 </property> 337 </property>
334 <property stdset="1"> 338 <property stdset="1">
@@ -702,60 +706,72 @@
702 <string>Backlight</string> 706 <string>Backlight</string>
703 </property> 707 </property>
704 <property> 708 <property>
705 <name>layoutMargin</name> 709 <name>layoutMargin</name>
706 </property> 710 </property>
707 <property> 711 <property>
708 <name>layoutSpacing</name> 712 <name>layoutSpacing</name>
709 </property> 713 </property>
710 <vbox> 714 <vbox>
711 <property stdset="1"> 715 <property stdset="1">
712 <name>margin</name> 716 <name>margin</name>
713 <number>3</number> 717 <number>3</number>
714 </property> 718 </property>
715 <property stdset="1"> 719 <property stdset="1">
716 <name>spacing</name> 720 <name>spacing</name>
717 <number>3</number> 721 <number>3</number>
718 </property> 722 </property>
719 <widget> 723 <widget>
720 <class>QSlider</class> 724 <class>QSlider</class>
721 <property stdset="1"> 725 <property stdset="1">
722 <name>name</name> 726 <name>name</name>
723 <cstring>brightness_ac_3</cstring> 727 <cstring>brightness_ac_3</cstring>
724 </property> 728 </property>
725 <property stdset="1"> 729 <property stdset="1">
730 <name>minValue</name>
731 <number>0</number>
732 </property>
733 <property stdset="1">
726 <name>maxValue</name> 734 <name>maxValue</name>
727 <number>255</number> 735 <number>255</number>
728 </property> 736 </property>
729 <property stdset="1"> 737 <property stdset="1">
730 <name>lineStep</name> 738 <name>lineStep</name>
731 <number>16</number> 739 <number>16</number>
732 </property> 740 </property>
733 <property stdset="1"> 741 <property stdset="1">
734 <name>pageStep</name> 742 <name>pageStep</name>
735 <number>16</number> 743 <number>16</number>
736 </property> 744 </property>
737 <property stdset="1"> 745 <property stdset="1">
746 <name>value</name>
747 <number>255</number>
748 </property>
749 <property stdset="1">
750 <name>tracking</name>
751 <bool>true</bool>
752 </property>
753 <property stdset="1">
738 <name>orientation</name> 754 <name>orientation</name>
739 <enum>Horizontal</enum> 755 <enum>Horizontal</enum>
740 </property> 756 </property>
741 <property stdset="1"> 757 <property stdset="1">
742 <name>tickmarks</name> 758 <name>tickmarks</name>
743 <enum>Right</enum> 759 <enum>Right</enum>
744 </property> 760 </property>
745 <property stdset="1"> 761 <property stdset="1">
746 <name>tickInterval</name> 762 <name>tickInterval</name>
747 <number>32</number> 763 <number>32</number>
748 </property> 764 </property>
749 </widget> 765 </widget>
750 <widget> 766 <widget>
751 <class>QLayoutWidget</class> 767 <class>QLayoutWidget</class>
752 <property stdset="1"> 768 <property stdset="1">
753 <name>name</name> 769 <name>name</name>
754 <cstring>Layout20</cstring> 770 <cstring>Layout20</cstring>
755 </property> 771 </property>
756 <hbox> 772 <hbox>
757 <property stdset="1"> 773 <property stdset="1">
758 <name>margin</name> 774 <name>margin</name>
759 <number>0</number> 775 <number>0</number>
760 </property> 776 </property>
761 <property stdset="1"> 777 <property stdset="1">
@@ -1186,48 +1202,52 @@ warning at</string>
1186 <property stdset="1"> 1202 <property stdset="1">
1187 <name>name</name> 1203 <name>name</name>
1188 <cstring>PixmapLabel2_2</cstring> 1204 <cstring>PixmapLabel2_2</cstring>
1189 </property> 1205 </property>
1190 <property stdset="1"> 1206 <property stdset="1">
1191 <name>pixmap</name> 1207 <name>pixmap</name>
1192 <pixmap>image0</pixmap> 1208 <pixmap>image0</pixmap>
1193 </property> 1209 </property>
1194 <property stdset="1"> 1210 <property stdset="1">
1195 <name>scaledContents</name> 1211 <name>scaledContents</name>
1196 <bool>false</bool> 1212 <bool>false</bool>
1197 </property> 1213 </property>
1198 </widget> 1214 </widget>
1199 <widget> 1215 <widget>
1200 <class>QSlider</class> 1216 <class>QSlider</class>
1201 <property stdset="1"> 1217 <property stdset="1">
1202 <name>name</name> 1218 <name>name</name>
1203 <cstring>LightMinValueSlider</cstring> 1219 <cstring>LightMinValueSlider</cstring>
1204 </property> 1220 </property>
1205 <property stdset="1"> 1221 <property stdset="1">
1206 <name>maxValue</name> 1222 <name>maxValue</name>
1207 <number>127</number> 1223 <number>127</number>
1208 </property> 1224 </property>
1209 <property stdset="1"> 1225 <property stdset="1">
1226 <name>tracking</name>
1227 <bool>false</bool>
1228 </property>
1229 <property stdset="1">
1210 <name>orientation</name> 1230 <name>orientation</name>
1211 <enum>Horizontal</enum> 1231 <enum>Horizontal</enum>
1212 </property> 1232 </property>
1213 <property stdset="1"> 1233 <property stdset="1">
1214 <name>tickmarks</name> 1234 <name>tickmarks</name>
1215 <enum>Right</enum> 1235 <enum>Right</enum>
1216 </property> 1236 </property>
1217 </widget> 1237 </widget>
1218 <widget> 1238 <widget>
1219 <class>QLabel</class> 1239 <class>QLabel</class>
1220 <property stdset="1"> 1240 <property stdset="1">
1221 <name>name</name> 1241 <name>name</name>
1222 <cstring>PixmapLabel1_2</cstring> 1242 <cstring>PixmapLabel1_2</cstring>
1223 </property> 1243 </property>
1224 <property stdset="1"> 1244 <property stdset="1">
1225 <name>pixmap</name> 1245 <name>pixmap</name>
1226 <pixmap>image1</pixmap> 1246 <pixmap>image1</pixmap>
1227 </property> 1247 </property>
1228 <property stdset="1"> 1248 <property stdset="1">
1229 <name>scaledContents</name> 1249 <name>scaledContents</name>
1230 <bool>false</bool> 1250 <bool>false</bool>
1231 </property> 1251 </property>
1232 </widget> 1252 </widget>
1233 </hbox> 1253 </hbox>
diff --git a/core/settings/light-and-power/settings.h b/core/settings/light-and-power/settings.h
index 77f90d6..adfd735 100644
--- a/core/settings/light-and-power/settings.h
+++ b/core/settings/light-and-power/settings.h
@@ -21,34 +21,35 @@
21#define SETTINGS_H 21#define SETTINGS_H
22 22
23 23
24#include <qstrlist.h> 24#include <qstrlist.h>
25#include <qasciidict.h> 25#include <qasciidict.h>
26#include "lightsettingsbase.h" 26#include "lightsettingsbase.h"
27 27
28 28
29class LightSettings : public LightSettingsBase 29class LightSettings : public LightSettingsBase
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 34 LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
35 ~LightSettings(); 35 ~LightSettings();
36 36
37protected: 37protected:
38 void accept(); 38 void accept();
39 void reject(); 39 void reject();
40 40
41 void done ( int r ); 41 void done ( int r );
42 42
43private slots: 43private slots:
44 void applyBrightness(); 44 void applyBrightness();
45 void applyBrightnessAC();
45 void slotSliderTicks( int steps ); 46 void slotSliderTicks( int steps );
46 47
47private: 48private:
48 int initbright; 49 int initbright;
49 int initbright_ac; 50 int initbright_ac;
50}; 51};
51 52
52 53
53#endif // SETTINGS_H 54#endif // SETTINGS_H
54 55