Diffstat (limited to 'core/settings/light-and-power/light.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/light-and-power/light.cpp | 128 |
1 files changed, 122 insertions, 6 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index ded358c..8721a95 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -19,2 +19,5 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
21 | // redone by Maximilian Reiss <harlekin@handhelds.org> | ||
22 | |||
20 | #include "settings.h" | 23 | #include "settings.h" |
@@ -26,2 +29,3 @@ | |||
26 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/power.h> | ||
27 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 31 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
@@ -40,2 +44,3 @@ | |||
40 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
45 | #include <qgroupbox.h> | ||
41 | #include <qspinbox.h> | 46 | #include <qspinbox.h> |
@@ -54,4 +59,17 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
54 | { | 59 | { |
55 | // Not supported | 60 | |
56 | auto_brightness->hide(); | 61 | if ( ODevice::inst()->model() == Model_iPAQ_H31xx || |
62 | ODevice::inst()->model() == Model_iPAQ_H36xx || | ||
63 | ODevice::inst()->model() == Model_iPAQ_H37xx || | ||
64 | ODevice::inst()->model() == Model_iPAQ_H38xx ) { | ||
65 | // Not supported yet - hide until implemented | ||
66 | IpaqGroupBox->setEnabled( false ); | ||
67 | IpaqGroupBoxAC->setEnabled( false ); | ||
68 | LightSensorGroupBox->setEnabled( false ); | ||
69 | } else { | ||
70 | // if ipaq no need to show the sensor box | ||
71 | IpaqGroupBox->hide(); | ||
72 | IpaqGroupBoxAC->hide(); | ||
73 | LightSensorGroupBox->hide(); | ||
74 | } | ||
57 | 75 | ||
@@ -62,2 +80,4 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
62 | int interval; | 80 | int interval; |
81 | |||
82 | // battery spinboxes | ||
63 | interval = config.readNumEntry( "Interval_Dim", 20 ); | 83 | interval = config.readNumEntry( "Interval_Dim", 20 ); |
@@ -70,2 +90,15 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
70 | 90 | ||
91 | // ac spinboxes | ||
92 | interval = config.readNumEntry( "Interval_DimAC", 20 ); | ||
93 | interval_dim_ac_3->setValue( interval ); | ||
94 | interval = config.readNumEntry( "Interval_LightOffAC", 30 ); | ||
95 | interval_lightoff_ac_3->setValue( interval ); | ||
96 | interval = config.readNumEntry( "IntervalAC", 60 ); | ||
97 | if ( interval > 3600 ) { | ||
98 | interval /= 1000; // compatibility (was millisecs) | ||
99 | } | ||
100 | interval_suspend_ac_3->setValue( interval ); | ||
101 | |||
102 | |||
103 | // battery check and slider | ||
71 | screensaver_dim->setChecked( config.readNumEntry("Dim",1) != 0 ); | 104 | screensaver_dim->setChecked( config.readNumEntry("Dim",1) != 0 ); |
@@ -81,3 +114,31 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
81 | 114 | ||
115 | // ac check and slider | ||
116 | screensaver_dim_ac_3->setChecked( config.readNumEntry("DimAC",1) != 0 ); | ||
117 | screensaver_lightoff_ac_3->setChecked( config.readNumEntry("LightOffAC",1) != 0 ); | ||
118 | LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 ); | ||
119 | int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); | ||
120 | initbright_ac = config.readNumEntry("BrightnessAC",255); | ||
121 | brightness_ac_3->setMaxValue( maxbright_ac ); | ||
122 | brightness_ac_3->setTickInterval( 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) ); | ||
125 | brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 ); | ||
126 | |||
127 | // advanced settings | ||
128 | config.setGroup( "APM" ); | ||
129 | warnintervalBox->setValue( config.readNumEntry("check_interval", 10000)/1000 ); | ||
130 | lowSpinBox->setValue( config.readNumEntry("power_verylow", 10 ) ); | ||
131 | criticalSpinBox->setValue( config.readNumEntry("power_critical", 5 ) ); | ||
132 | |||
133 | // ipaq sensor | ||
134 | config.setGroup( "Ipaq_light_sensor" ); | ||
135 | auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 ); | ||
136 | auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 ); | ||
137 | LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); | ||
138 | LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); | ||
139 | connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; | ||
140 | LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); | ||
141 | |||
82 | 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())); | ||
83 | } | 144 | } |
@@ -88,2 +149,6 @@ LightSettings::~LightSettings() | |||
88 | 149 | ||
150 | void LightSettings::slotSliderTicks( int steps ) { | ||
151 | LightMinValueSlider->setTickInterval( steps ); | ||
152 | } | ||
153 | |||
89 | static void set_fl(int bright) | 154 | static void set_fl(int bright) |
@@ -104,3 +169,3 @@ void LightSettings::accept() | |||
104 | if ( qApp->focusWidget() ) | 169 | if ( qApp->focusWidget() ) |
105 | qApp->focusWidget()->clearFocus(); | 170 | qApp->focusWidget()->clearFocus(); |
106 | 171 | ||
@@ -108,2 +173,3 @@ void LightSettings::accept() | |||
108 | 173 | ||
174 | // bat | ||
109 | int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); | 175 | int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); |
@@ -114,4 +180,13 @@ void LightSettings::accept() | |||
114 | 180 | ||
181 | // ac | ||
182 | int i_dim_ac = (screensaver_dim_ac_3->isChecked() ? interval_dim_ac_3->value() : 0); | ||
183 | int i_lightoff_ac = (screensaver_lightoff_ac_3->isChecked() ? interval_lightoff_ac_3->value() : 0); | ||
184 | int i_suspend_ac = interval_suspend_ac_3->value(); | ||
185 | QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); | ||
186 | e << i_dim_ac << i_lightoff_ac << i_suspend_ac; | ||
187 | |||
115 | Config config( "qpe" ); | 188 | Config config( "qpe" ); |
116 | config.setGroup( "Screensaver" ); | 189 | config.setGroup( "Screensaver" ); |
190 | |||
191 | // bat | ||
117 | config.writeEntry( "Dim", (int)screensaver_dim->isChecked() ); | 192 | config.writeEntry( "Dim", (int)screensaver_dim->isChecked() ); |
@@ -124,2 +199,37 @@ void LightSettings::accept() | |||
124 | (brightness->maxValue()-brightness->value())*255/brightness->maxValue() ); | 199 | (brightness->maxValue()-brightness->value())*255/brightness->maxValue() ); |
200 | |||
201 | // ac | ||
202 | config.writeEntry( "DimAC", (int)screensaver_dim_ac_3->isChecked() ); | ||
203 | config.writeEntry( "LightOffAC", (int)screensaver_lightoff_ac_3->isChecked() ); | ||
204 | config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() ); | ||
205 | config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() ); | ||
206 | config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() ); | ||
207 | config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() ); | ||
208 | config.writeEntry( "BrightnessAC", | ||
209 | (brightness_ac_3->maxValue() - brightness_ac_3->value())*255/brightness_ac_3->maxValue() ); | ||
210 | |||
211 | // advanced | ||
212 | config.setGroup( "APM" ); | ||
213 | config.writeEntry( "check_interval", warnintervalBox->value()*1000 ); | ||
214 | config.writeEntry( "power_verylow", lowSpinBox->value() ); | ||
215 | config.writeEntry( "power_critical", criticalSpinBox->value() ); | ||
216 | QCopEnvelope e_warn("QPE/System", "reloadPowerWarnSettings()"); | ||
217 | |||
218 | |||
219 | // only make ipaq light sensor entries in config file if on an ipaq | ||
220 | if ( ODevice::inst()->model() == Model_iPAQ_H31xx || | ||
221 | ODevice::inst()->model() == Model_iPAQ_H36xx || | ||
222 | ODevice::inst()->model() == Model_iPAQ_H37xx || | ||
223 | ODevice::inst()->model() == Model_iPAQ_H38xx ) { | ||
224 | |||
225 | // ipaq sensor | ||
226 | config.setGroup( "Ipaq_light_sensor" ); | ||
227 | |||
228 | config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); | ||
229 | config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); | ||
230 | config.writeEntry( "Steps", LightStepSpin->value() ); | ||
231 | config.writeEntry( "MinValue", LightMinValueSlider->value() ); | ||
232 | config.writeEntry( "Shift", LightShiftSpin->value() ); | ||
233 | } | ||
234 | |||
125 | config.write(); | 235 | config.write(); |
@@ -131,5 +241,10 @@ void LightSettings::applyBrightness() | |||
131 | { | 241 | { |
132 | int bright = (brightness->maxValue()-brightness->value())*255 | 242 | // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting |
133 | / brightness->maxValue(); | 243 | if ( PowerStatus::Online ) { |
134 | set_fl(bright); | 244 | int bright = (brightness_ac_3->maxValue() - 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); | ||
249 | } | ||
135 | } | 250 | } |
@@ -137,2 +252,3 @@ void LightSettings::applyBrightness() | |||
137 | 252 | ||
253 | |||
138 | void LightSettings::done(int r) | 254 | void LightSettings::done(int r) |