summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-28 04:43:12 (UTC)
committer sandman <sandman>2002-10-28 04:43:12 (UTC)
commitf3c9e44d9d694a0a803fb6a7d79cfa8d173b9864 (patch) (unidiff)
tree311e3d30ef5d8fe4713c6ea3cbf0af6abdb8cd57
parent226ddd19ef0adeb279c3a864e24cbfcf556b2f17 (diff)
downloadopie-f3c9e44d9d694a0a803fb6a7d79cfa8d173b9864.zip
opie-f3c9e44d9d694a0a803fb6a7d79cfa8d173b9864.tar.gz
opie-f3c9e44d9d694a0a803fb6a7d79cfa8d173b9864.tar.bz2
The brightness sliders do not need a reversed logik anymore, since they are
horizontal now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index aa36e06..572f8ea 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,247 +1,245 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// redone by Maximilian Reiss <harlekin@handhelds.org> 21// redone by Maximilian Reiss <harlekin@handhelds.org>
22 22
23#include "settings.h" 23#include "settings.h"
24 24
25#include <qpe/global.h> 25#include <qpe/global.h>
26#include <qpe/fontmanager.h> 26#include <qpe/fontmanager.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/applnk.h> 28#include <qpe/applnk.h>
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/power.h> 30#include <qpe/power.h>
31#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 31#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
32#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33#endif 33#endif
34 34
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37#include <qradiobutton.h> 37#include <qradiobutton.h>
38#include <qtabwidget.h> 38#include <qtabwidget.h>
39#include <qslider.h> 39#include <qslider.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qdatastream.h> 42#include <qdatastream.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
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 <qpushbutton.h>
48#include <qlistbox.h> 48#include <qlistbox.h>
49#include <qdir.h> 49#include <qdir.h>
50#if QT_VERSION >= 300 50#if QT_VERSION >= 300
51#include <qstylefactory.h> 51#include <qstylefactory.h>
52#endif 52#endif
53 53
54#include <opie/odevice.h> 54#include <opie/odevice.h>
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 58LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
59 : LightSettingsBase( parent, name, TRUE, WStyle_ContextHelp ) 59 : LightSettingsBase( parent, name, TRUE, WStyle_ContextHelp )
60{ 60{
61 int res = ODevice::inst ( )-> displayBrightnessResolution ( );
61 62
62 if ( ODevice::inst()->hasLightSensor() ) { 63 if ( ODevice::inst()->hasLightSensor() ) {
63 // Not supported yet - hide until implemented 64 // Not supported yet - hide until implemented
64 CalibrateLightSensor->setEnabled( false ); 65 CalibrateLightSensor->setEnabled( false );
65 CalibrateLightSensorAC->setEnabled( false ); 66 CalibrateLightSensorAC->setEnabled( false );
66 } else { 67 } else {
67 // if ipaq no need to show the sensor box 68 // if ipaq no need to show the sensor box
68 auto_brightness->hide(); 69 auto_brightness->hide();
69 CalibrateLightSensor->hide(); 70 CalibrateLightSensor->hide();
70 auto_brightness_ac_3->hide(); 71 auto_brightness_ac_3->hide();
71 CalibrateLightSensorAC->hide(); 72 CalibrateLightSensorAC->hide();
72 } 73 }
73 74
74 Config config( "apm" ); 75 Config config( "apm" );
75 config.setGroup( "Battery" ); 76 config.setGroup( "Battery" );
76 77
77 // battery spinboxes 78 // battery spinboxes
78 interval_dim->setValue( config.readNumEntry( "Dim", 20 )); 79 interval_dim->setValue( config.readNumEntry( "Dim", 20 ));
79 interval_lightoff->setValue( config.readNumEntry( "LightOff", 30 )); 80 interval_lightoff->setValue( config.readNumEntry( "LightOff", 30 ));
80 interval_suspend->setValue( config.readNumEntry( "Suspend", 60 )); 81 interval_suspend->setValue( config.readNumEntry( "Suspend", 60 ));
81 82
82 // battery check and slider 83 // battery check and slider
83 LcdOffOnly->setChecked( config.readBoolEntry("LcdOffOnly",false)); 84 LcdOffOnly->setChecked( config.readBoolEntry("LcdOffOnly",false));
84 int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); 85
85 initbright = config.readNumEntry("Brightness",255); 86 initbright = config. readNumEntry ( "Brightness", 255 );
86 brightness->setMaxValue( maxbright ); 87 brightness-> setMaxValue ( res - 1 );
87 brightness->setTickInterval( QMAX(1,maxbright/16) ); 88 brightness-> setTickInterval ( QMAX( 1, res / 16 ));
88 brightness->setLineStep( QMAX(1,maxbright/16) ); 89 brightness-> setLineStep ( QMAX( 1, res / 16 ));
89 brightness->setPageStep( QMAX(1,maxbright/16) ); 90 brightness-> setPageStep ( QMAX( 1, res / 16 ));
90 brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); 91 brightness-> setValue (( initbright * ( res - 1 ) + 127 ) / 255 );
91 92
92 // light sensor 93 // light sensor
93 auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 ); 94 auto_brightness->setChecked( config.readNumEntry("LightSensor",0) != 0 );
94 95
95
96
97 config.setGroup( "AC" ); 96 config.setGroup( "AC" );
98 // ac spinboxes 97 // ac spinboxes
99 interval_dim_ac_3->setValue( config.readNumEntry( "Dim", 20 )); 98 interval_dim_ac_3->setValue( config.readNumEntry( "Dim", 20 ));
100 interval_lightoff_ac_3->setValue( config.readNumEntry( "LightOff", 30 )); 99 interval_lightoff_ac_3->setValue( config.readNumEntry( "LightOff", 30 ));
101 interval_suspend_ac_3->setValue( config.readNumEntry( "Suspend", 60 )); 100 interval_suspend_ac_3->setValue( config.readNumEntry( "Suspend", 60 ));
102 101
103 // ac check and slider 102 // ac check and slider
104 LcdOffOnly_2_3->setChecked( config.readBoolEntry("LcdOffOnly",false)); 103 LcdOffOnly_2_3->setChecked( config.readBoolEntry("LcdOffOnly",false));
105 int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); 104
106 initbright_ac = config.readNumEntry("Brightness",255); 105 initbright_ac = config. readNumEntry ( "Brightness", 255 );
107 brightness_ac_3->setMaxValue( maxbright_ac ); 106 brightness_ac_3-> setMaxValue ( res - 1 );
108 brightness_ac_3->setTickInterval( QMAX(1,maxbright_ac/16) ); 107 brightness_ac_3-> setTickInterval ( QMAX( 1, res / 16 ));
109 brightness_ac_3->setLineStep( QMAX(1,maxbright_ac/16) ); 108 brightness_ac_3-> setLineStep ( QMAX( 1, res / 16 ));
110 brightness_ac_3->setPageStep( QMAX(1,maxbright_ac/16) ); 109 brightness_ac_3-> setPageStep ( QMAX( 1, res / 16 ));
111 brightness_ac_3->setValue( (maxbright_ac*255 - initbright_ac*maxbright_ac)/255 ); 110 brightness_ac_3-> setValue (( initbright_ac * ( res - 1 ) + 127 ) / 255 );
112 111
113 // light sensor 112 // light sensor
114 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensor",0) != 0 ); 113 auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensor",0) != 0 );
115 114
116 115
117 //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); 116 //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) );
118 //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); 117 //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) );
119 //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; 118 //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ;
120 //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); 119 //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) );
121 120
122 // advanced settings 121 // advanced settings
123 config.setGroup( "Warnings" ); 122 config.setGroup( "Warnings" );
124 warnintervalBox->setValue( config.readNumEntry("checkinterval", 10000)/1000 ); 123 warnintervalBox->setValue( config.readNumEntry("checkinterval", 10000)/1000 );
125 lowSpinBox->setValue( config.readNumEntry("powerverylow", 10 ) ); 124 lowSpinBox->setValue( config.readNumEntry("powerverylow", 10 ) );
126 criticalSpinBox->setValue( config.readNumEntry("powercritical", 5 ) ); 125 criticalSpinBox->setValue( config.readNumEntry("powercritical", 5 ) );
127 126
128 connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); 127 connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) );
129 connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); 128 connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) );
130} 129}
131 130
132LightSettings::~LightSettings() { 131LightSettings::~LightSettings() {
133} 132}
134 133
135void LightSettings::slotSliderTicks( int steps ) { 134void LightSettings::slotSliderTicks( int steps ) {
136// LightMinValueSlider->setTickInterval( steps ); 135// LightMinValueSlider->setTickInterval( steps );
137} 136}
138 137
139static void set_fl(int bright) 138static void set_fl(int bright)
140{ 139{
141 qDebug ( QString( "Brightness" ).arg( bright ) );
142 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 140 QCopEnvelope e("QPE/System", "setBacklight(int)" );
143 e << bright; 141 e << bright;
144} 142}
145 143
146void LightSettings::reject() 144void LightSettings::reject()
147{ 145{
148 set_fl(initbright); 146 set_fl(initbright);
149 QDialog::reject(); 147 QDialog::reject();
150} 148}
151 149
152void LightSettings::accept() 150void LightSettings::accept()
153{ 151{
154 if ( qApp->focusWidget() ) { 152 if ( qApp->focusWidget() ) {
155 qApp->focusWidget()->clearFocus(); 153 qApp->focusWidget()->clearFocus();
156 } 154 }
157 155
158 applyBrightness(); 156 applyBrightness();
159 157
160 // bat 158 // bat
161 int i_dim = interval_dim->value(); 159 int i_dim = interval_dim->value();
162 int i_lightoff = interval_lightoff->value(); 160 int i_lightoff = interval_lightoff->value();
163 int i_suspend = interval_suspend->value(); 161 int i_suspend = interval_suspend->value();
164 162
165 // ac 163 // ac
166 int i_dim_ac = interval_dim_ac_3->value(); 164 int i_dim_ac = interval_dim_ac_3->value();
167 int i_lightoff_ac = interval_lightoff_ac_3->value(); 165 int i_lightoff_ac = interval_lightoff_ac_3->value();
168 int i_suspend_ac = interval_suspend_ac_3->value(); 166 int i_suspend_ac = interval_suspend_ac_3->value();
169 167
170 Config config( "apm" ); 168 Config config( "apm" );
171 169
172 config.setGroup( "Battery" ); 170 config.setGroup( "Battery" );
173 171
174 // bat 172 // bat
175 config.writeEntry( "LcdOffOnly", LcdOffOnly->isChecked() ); 173 config.writeEntry( "LcdOffOnly", LcdOffOnly->isChecked() );
176 config.writeEntry( "Dim", i_dim ); 174 config.writeEntry( "Dim", i_dim );
177 config.writeEntry( "LightOff", i_lightoff ); 175 config.writeEntry( "LightOff", i_lightoff );
178 config.writeEntry( "Suspend", i_suspend ); 176 config.writeEntry( "Suspend", i_suspend );
179 config.writeEntry( "Brightness", 177 config.writeEntry( "Brightness",
180 ( brightness->value() ) * 255 / brightness->maxValue() ); 178 ( brightness->value() ) * 255 / brightness->maxValue() );
181 179
182 // ac 180 // ac
183 config.setGroup( "AC" ); 181 config.setGroup( "AC" );
184 config.writeEntry( "LcdOffOnly", LcdOffOnly_2_3->isChecked() ); 182 config.writeEntry( "LcdOffOnly", LcdOffOnly_2_3->isChecked() );
185 config.writeEntry( "Dim", i_dim_ac ); 183 config.writeEntry( "Dim", i_dim_ac );
186 config.writeEntry( "LightOff", i_lightoff_ac ); 184 config.writeEntry( "LightOff", i_lightoff_ac );
187 config.writeEntry( "Suspend", i_suspend_ac ); 185 config.writeEntry( "Suspend", i_suspend_ac );
188 config.writeEntry( "Brightness", 186 config.writeEntry( "Brightness",
189 ( brightness_ac_3->value()) * 255 / brightness_ac_3->maxValue() ); 187 ( brightness_ac_3->value()) * 255 / brightness_ac_3->maxValue() );
190 188
191 189
192 // only make light sensor stuff appear if the unit has a sensor 190 // only make light sensor stuff appear if the unit has a sensor
193 if ( ODevice::inst()->hasLightSensor() ) { 191 if ( ODevice::inst()->hasLightSensor() ) {
194 config.setGroup( "Battery" ); 192 config.setGroup( "Battery" );
195 config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); 193 config.writeEntry( "LightSensor", auto_brightness->isChecked() );
196 config.setGroup( "AC" ); 194 config.setGroup( "AC" );
197 config.writeEntry( "LightSensor", (int)auto_brightness_ac_3->isChecked() ); 195 config.writeEntry( "LightSensor", auto_brightness_ac_3->isChecked() );
198 //config.writeEntry( "Steps", LightStepSpin->value() ); 196 //config.writeEntry( "Steps", LightStepSpin->value() );
199 //onfig.writeEntry( "MinValue", LightMinValueSlider->value() ); 197 //onfig.writeEntry( "MinValue", LightMinValueSlider->value() );
200 //config.writeEntry( "Shift", LightShiftSpin->value() ); 198 //config.writeEntry( "Shift", LightShiftSpin->value() );
201 } 199 }
202 200
203 201
204 // advanced 202 // advanced
205 config.setGroup( "Warnings" ); 203 config.setGroup( "Warnings" );
206 config.writeEntry( "check_interval", warnintervalBox->value()*1000 ); 204 config.writeEntry( "check_interval", warnintervalBox->value()*1000 );
207 config.writeEntry( "power_verylow", lowSpinBox->value() ); 205 config.writeEntry( "power_verylow", lowSpinBox->value() );
208 config.writeEntry( "power_critical", criticalSpinBox->value() ); 206 config.writeEntry( "power_critical", criticalSpinBox->value() );
209 config.write(); 207 config.write();
210 208
211 { 209 {
212 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 210 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
213 } 211 }
214 { 212 {
215 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 213 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
216 e << -1; 214 e << -1;
217 } 215 }
218 { 216 {
219 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 217 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
220 e << -1; 218 e << -1;
221 } 219 }
222 220
223 QDialog::accept(); 221 QDialog::accept();
224} 222}
225 223
226void LightSettings::applyBrightness() 224void LightSettings::applyBrightness()
227{ 225{
228 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 226 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
229 int bright = ( brightness->value() ) * 255 / brightness->maxValue(); 227 int bright = ( brightness->value() ) * 255 / brightness->maxValue();
230 set_fl(bright); 228 set_fl(bright);
231 } 229 }
232} 230}
233 231
234void LightSettings::applyBrightnessAC() 232void LightSettings::applyBrightnessAC()
235{ 233{
236 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting 234 // if ac is attached, set directly that sliders setting, else the "on battery" sliders setting
237 if ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ) { 235 if ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ) {
238 int bright = ( brightness_ac_3->value() ) * 255 / brightness_ac_3->maxValue(); 236 int bright = ( brightness_ac_3->value() ) * 255 / brightness_ac_3->maxValue();
239 set_fl(bright); 237 set_fl(bright);
240 } 238 }
241} 239}
242 240
243void LightSettings::done(int r) 241void LightSettings::done(int r)
244{ 242{
245 QDialog::done(r); 243 QDialog::done(r);
246 close(); 244 close();
247} 245}