author | harlekin <harlekin> | 2002-10-27 16:24:16 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-27 16:24:16 (UTC) |
commit | 417d7bd0d307921b4540e99b8f52d10a03729153 (patch) (unidiff) | |
tree | 25d2ccf03282fc494c8a9e17ace70ad52b990a70 /core/settings/light-and-power/light.cpp | |
parent | 1d1fdae1ff88ed6f1e331cbbab59fc978c04b370 (diff) | |
download | opie-417d7bd0d307921b4540e99b8f52d10a03729153.zip opie-417d7bd0d307921b4540e99b8f52d10a03729153.tar.gz opie-417d7bd0d307921b4540e99b8f52d10a03729153.tar.bz2 |
next try for light and power gui
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 | 107 |
1 files changed, 62 insertions, 45 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index 04d2249..97120f2 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
45 | #include <qgroupbox.h> | 45 | #include <qgroupbox.h> |
46 | #include <qspinbox.h> | 46 | #include <qspinbox.h> |
47 | #include <qpushbutton.h> | ||
47 | #include <qlistbox.h> | 48 | #include <qlistbox.h> |
48 | #include <qdir.h> | 49 | #include <qdir.h> |
49 | #if QT_VERSION >= 300 | 50 | #if QT_VERSION >= 300 |
@@ -58,19 +59,18 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
58 | : LightSettingsBase( parent, name, TRUE, fl ) | 59 | : LightSettingsBase( parent, name, TRUE, fl ) |
59 | { | 60 | { |
60 | 61 | ||
61 | if ( ODevice::inst()->model() == Model_iPAQ_H31xx || | 62 | if ( ODevice::inst()->hasLightSensor() ) { |
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 | 63 | // Not supported yet - hide until implemented |
66 | IpaqGroupBox->setEnabled( false ); | 64 | auto_brightness->setEnabled( false ); |
67 | IpaqGroupBoxAC->setEnabled( false ); | 65 | CalibrateLightSensor->setEnabled( false ); |
68 | LightSensorGroupBox->setEnabled( false ); | 66 | auto_brightness_ac_3->setEnabled( false ); |
67 | CalibrateLightSensorAC->setEnabled( false ); | ||
69 | } else { | 68 | } else { |
70 | // if ipaq no need to show the sensor box | 69 | // if ipaq no need to show the sensor box |
71 | IpaqGroupBox->hide(); | 70 | auto_brightness->hide(); |
72 | IpaqGroupBoxAC->hide(); | 71 | CalibrateLightSensor->hide(); |
73 | LightSensorGroupBox->hide(); | 72 | auto_brightness_ac_3->hide(); |
73 | CalibrateLightSensorAC->hide(); | ||
74 | } | 74 | } |
75 | 75 | ||
76 | Config config( "qpe" ); | 76 | Config config( "qpe" ); |
@@ -80,28 +80,54 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
80 | 80 | ||
81 | // battery spinboxes | 81 | // battery spinboxes |
82 | interval = config.readNumEntry( "Interval_Dim", 20 ); | 82 | interval = config.readNumEntry( "Interval_Dim", 20 ); |
83 | interval_dim->setValue( interval ); | 83 | if ( config.readNumEntry("Dim",1) == 0 ) { |
84 | interval_dim->setSpecialValueText( tr("never") ); | ||
85 | } else { | ||
86 | interval_dim->setValue( interval ); | ||
87 | } | ||
88 | |||
84 | interval = config.readNumEntry( "Interval_LightOff", 30 ); | 89 | interval = config.readNumEntry( "Interval_LightOff", 30 ); |
85 | interval_lightoff->setValue( interval ); | 90 | if ( config.readNumEntry("LightOff",1) == 0 ) { |
91 | interval_lightoff->setSpecialValueText( tr("never") ); | ||
92 | } else { | ||
93 | interval_lightoff->setValue( interval ); | ||
94 | } | ||
95 | |||
86 | interval = config.readNumEntry( "Interval", 60 ); | 96 | interval = config.readNumEntry( "Interval", 60 ); |
87 | if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) | 97 | if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) |
88 | interval_suspend->setValue( interval ); | 98 | interval_suspend->setValue( interval ); |
89 | 99 | ||
90 | // ac spinboxes | 100 | // ac spinboxes |
91 | interval = config.readNumEntry( "Interval_DimAC", 20 ); | 101 | interval = config.readNumEntry( "Interval_DimAC", 20 ); |
102 | if ( config.readNumEntry("DimAC",1) == 0 ) { | ||
103 | interval_dim_ac_3->setSpecialValueText( tr("never") ); | ||
104 | } else { | ||
92 | interval_dim_ac_3->setValue( interval ); | 105 | interval_dim_ac_3->setValue( interval ); |
106 | } | ||
107 | |||
93 | interval = config.readNumEntry( "Interval_LightOffAC", 30 ); | 108 | interval = config.readNumEntry( "Interval_LightOffAC", 30 ); |
94 | interval_lightoff_ac_3->setValue( interval ); | 109 | if ( config.readNumEntry("LightOffAC",1) == 0 ) { |
110 | interval_lightoff_ac_3->setSpecialValueText( tr("never") ); | ||
111 | } else { | ||
112 | interval_lightoff_ac_3->setValue( interval ); | ||
113 | } | ||
114 | |||
95 | interval = config.readNumEntry( "IntervalAC", 60 ); | 115 | interval = config.readNumEntry( "IntervalAC", 60 ); |
96 | if ( interval > 3600 ) { | 116 | if ( interval > 3600 ) { |
97 | interval /= 1000; // compatibility (was millisecs) | 117 | interval /= 1000; // compatibility (was millisecs) |
98 | } | 118 | } |
99 | interval_suspend_ac_3->setValue( interval ); | 119 | if ( config.readNumEntry("NoApmAC", 0) == 0 ) { |
120 | interval_suspend_ac_3->setSpecialValueText( tr("never") ); | ||
121 | } else { | ||
122 | interval_suspend_ac_3->setValue( interval ); | ||
123 | } | ||
100 | 124 | ||
101 | 125 | ||
102 | // battery check and slider | 126 | // battery check and slider |
103 | screensaver_dim->setChecked( config.readNumEntry("Dim",1) != 0 ); | 127 | |
104 | screensaver_lightoff->setChecked( config.readNumEntry("LightOff",1) != 0 ); | 128 | |
129 | |||
130 | |||
105 | LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); | 131 | LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); |
106 | int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); | 132 | int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); |
107 | initbright = config.readNumEntry("Brightness",255); | 133 | initbright = config.readNumEntry("Brightness",255); |
@@ -112,10 +138,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
112 | brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); | 138 | brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); |
113 | 139 | ||
114 | // ac check and slider | 140 | // ac check and slider |
115 | screensaver_dim_ac_3->setChecked( config.readNumEntry("DimAC",1) != 0 ); | ||
116 | screensaver_lightoff_ac_3->setChecked( config.readNumEntry("LightOffAC",1) != 0 ); | ||
117 | LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 ); | 141 | LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 ); |
118 | noApmAC->setChecked( config.readNumEntry("NoApmAC",0) != 0 ); | ||
119 | int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); | 142 | int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); |
120 | initbright_ac = config.readNumEntry("BrightnessAC",255); | 143 | initbright_ac = config.readNumEntry("BrightnessAC",255); |
121 | brightness_ac_3->setMaxValue( maxbright_ac ); | 144 | brightness_ac_3->setMaxValue( maxbright_ac ); |
@@ -129,10 +152,10 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
129 | config.setGroup( "Ipaqlightsensor" ); | 152 | config.setGroup( "Ipaqlightsensor" ); |
130 | auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 ); | 153 | auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 ); |
131 | auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 ); | 154 | auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 ); |
132 | LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); | 155 | //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); |
133 | LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); | 156 | //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); |
134 | connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; | 157 | //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; |
135 | LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); | 158 | //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); |
136 | 159 | ||
137 | // advanced settings | 160 | // advanced settings |
138 | Config conf("apm"); | 161 | Config conf("apm"); |
@@ -141,8 +164,6 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) | |||
141 | lowSpinBox->setValue( conf.readNumEntry("powerverylow", 10 ) ); | 164 | lowSpinBox->setValue( conf.readNumEntry("powerverylow", 10 ) ); |
142 | criticalSpinBox->setValue( conf.readNumEntry("powercritical", 5 ) ); | 165 | criticalSpinBox->setValue( conf.readNumEntry("powercritical", 5 ) ); |
143 | 166 | ||
144 | |||
145 | |||
146 | connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); | 167 | connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); |
147 | connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); | 168 | connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); |
148 | } | 169 | } |
@@ -152,7 +173,7 @@ LightSettings::~LightSettings() | |||
152 | } | 173 | } |
153 | 174 | ||
154 | void LightSettings::slotSliderTicks( int steps ) { | 175 | void LightSettings::slotSliderTicks( int steps ) { |
155 | LightMinValueSlider->setTickInterval( steps ); | 176 | // LightMinValueSlider->setTickInterval( steps ); |
156 | } | 177 | } |
157 | 178 | ||
158 | static void set_fl(int bright) | 179 | static void set_fl(int bright) |
@@ -171,21 +192,22 @@ void LightSettings::reject() | |||
171 | 192 | ||
172 | void LightSettings::accept() | 193 | void LightSettings::accept() |
173 | { | 194 | { |
174 | if ( qApp->focusWidget() ) | 195 | if ( qApp->focusWidget() ) { |
175 | qApp->focusWidget()->clearFocus(); | 196 | qApp->focusWidget()->clearFocus(); |
197 | } | ||
176 | 198 | ||
177 | applyBrightness(); | 199 | applyBrightness(); |
178 | 200 | ||
179 | // bat | 201 | // bat |
180 | int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); | 202 | int i_dim = ( !( interval_dim->specialValueText() == tr("never") ) ? interval_dim->value() : 0); |
181 | int i_lightoff = (screensaver_lightoff->isChecked() ? interval_lightoff->value() : 0); | 203 | int i_lightoff = ( !( interval_lightoff->specialValueText() == tr("never") ) ? interval_lightoff->value() : 0); |
182 | int i_suspend = interval_suspend->value(); | 204 | int i_suspend = interval_suspend->value(); |
183 | QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 205 | QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
184 | e << i_dim << i_lightoff << i_suspend; | 206 | e << i_dim << i_lightoff << i_suspend; |
185 | 207 | ||
186 | // ac | 208 | // ac |
187 | int i_dim_ac = (screensaver_dim_ac_3->isChecked() ? interval_dim_ac_3->value() : 0); | 209 | int i_dim_ac = ( !( interval_dim_ac_3->specialValueText() == tr("never") ) ? interval_dim_ac_3->value() : 0); |
188 | int i_lightoff_ac = (screensaver_lightoff_ac_3->isChecked() ? interval_lightoff_ac_3->value() : 0); | 210 | int i_lightoff_ac = ( !( interval_lightoff_ac_3->specialValueText() == tr("never") ) ? interval_lightoff_ac_3->value() : 0); |
189 | int i_suspend_ac = interval_suspend_ac_3->value(); | 211 | int i_suspend_ac = interval_suspend_ac_3->value(); |
190 | QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); | 212 | QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); |
191 | e << i_dim_ac << i_lightoff_ac << i_suspend_ac; | 213 | e << i_dim_ac << i_lightoff_ac << i_suspend_ac; |
@@ -194,8 +216,8 @@ void LightSettings::accept() | |||
194 | config.setGroup( "Screensaver" ); | 216 | config.setGroup( "Screensaver" ); |
195 | 217 | ||
196 | // bat | 218 | // bat |
197 | config.writeEntry( "Dim", (int)screensaver_dim->isChecked() ); | 219 | config.writeEntry( "Dim", interval_dim->specialValueText() == tr("never") ); |
198 | config.writeEntry( "LightOff", (int)screensaver_lightoff->isChecked() ); | 220 | config.writeEntry( "LightOff", interval_lightoff->specialValueText() == tr("never") ); |
199 | config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() ); | 221 | config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() ); |
200 | config.writeEntry( "Interval_Dim", interval_dim->value() ); | 222 | config.writeEntry( "Interval_Dim", interval_dim->value() ); |
201 | config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); | 223 | config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); |
@@ -204,10 +226,10 @@ void LightSettings::accept() | |||
204 | ( brightness->value() ) * 255 / brightness->maxValue() ); | 226 | ( brightness->value() ) * 255 / brightness->maxValue() ); |
205 | 227 | ||
206 | // ac | 228 | // ac |
207 | config.writeEntry( "DimAC", (int)screensaver_dim_ac_3->isChecked() ); | 229 | config.writeEntry( "DimAC", interval_dim_ac_3->specialValueText() == tr("never") ); |
208 | config.writeEntry( "LightOffAC", (int)screensaver_lightoff_ac_3->isChecked() ); | 230 | config.writeEntry( "LightOffAC", interval_lightoff_ac_3->specialValueText() == tr("never") ); |
209 | config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() ); | 231 | config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() ); |
210 | config.writeEntry( "NoAPmAC", (int)noApmAC->isChecked() ); | 232 | config.writeEntry( "NoAPmAC", interval_suspend_ac_3->specialValueText() == tr("never") ); |
211 | config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() ); | 233 | config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() ); |
212 | config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() ); | 234 | config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() ); |
213 | config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() ); | 235 | config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() ); |
@@ -216,19 +238,14 @@ void LightSettings::accept() | |||
216 | 238 | ||
217 | 239 | ||
218 | // only make ipaq light sensor entries in config file if on an ipaq | 240 | // only make ipaq light sensor entries in config file if on an ipaq |
219 | if ( ODevice::inst()->model() == Model_iPAQ_H31xx || | 241 | if ( ODevice::inst()->hasLightSensor() ) { |
220 | ODevice::inst()->model() == Model_iPAQ_H36xx || | ||
221 | ODevice::inst()->model() == Model_iPAQ_H37xx || | ||
222 | ODevice::inst()->model() == Model_iPAQ_H38xx ) { | ||
223 | |||
224 | // ipaq sensor | 242 | // ipaq sensor |
225 | config.setGroup( "Ipaqlightsensor" ); | 243 | config.setGroup( "Ipaqlightsensor" ); |
226 | |||
227 | config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); | 244 | config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); |
228 | config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); | 245 | config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); |
229 | config.writeEntry( "Steps", LightStepSpin->value() ); | 246 | //config.writeEntry( "Steps", LightStepSpin->value() ); |
230 | config.writeEntry( "MinValue", LightMinValueSlider->value() ); | 247 | //onfig.writeEntry( "MinValue", LightMinValueSlider->value() ); |
231 | config.writeEntry( "Shift", LightShiftSpin->value() ); | 248 | //config.writeEntry( "Shift", LightShiftSpin->value() ); |
232 | } | 249 | } |
233 | 250 | ||
234 | config.write(); | 251 | config.write(); |