From 417d7bd0d307921b4540e99b8f52d10a03729153 Mon Sep 17 00:00:00 2001 From: harlekin Date: Sun, 27 Oct 2002 16:24:16 +0000 Subject: next try for light and power gui --- (limited to 'core/settings/light-and-power') 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 @@ #include #include #include +#include #include #include #if QT_VERSION >= 300 @@ -58,19 +59,18 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) : LightSettingsBase( parent, name, TRUE, fl ) { - if ( ODevice::inst()->model() == Model_iPAQ_H31xx || - ODevice::inst()->model() == Model_iPAQ_H36xx || - ODevice::inst()->model() == Model_iPAQ_H37xx || - ODevice::inst()->model() == Model_iPAQ_H38xx ) { + if ( ODevice::inst()->hasLightSensor() ) { // Not supported yet - hide until implemented - IpaqGroupBox->setEnabled( false ); - IpaqGroupBoxAC->setEnabled( false ); - LightSensorGroupBox->setEnabled( false ); + auto_brightness->setEnabled( false ); + CalibrateLightSensor->setEnabled( false ); + auto_brightness_ac_3->setEnabled( false ); + CalibrateLightSensorAC->setEnabled( false ); } else { // if ipaq no need to show the sensor box - IpaqGroupBox->hide(); - IpaqGroupBoxAC->hide(); - LightSensorGroupBox->hide(); + auto_brightness->hide(); + CalibrateLightSensor->hide(); + auto_brightness_ac_3->hide(); + CalibrateLightSensorAC->hide(); } Config config( "qpe" ); @@ -80,28 +80,54 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) // battery spinboxes interval = config.readNumEntry( "Interval_Dim", 20 ); - interval_dim->setValue( interval ); + if ( config.readNumEntry("Dim",1) == 0 ) { + interval_dim->setSpecialValueText( tr("never") ); + } else { + interval_dim->setValue( interval ); + } + interval = config.readNumEntry( "Interval_LightOff", 30 ); - interval_lightoff->setValue( interval ); + if ( config.readNumEntry("LightOff",1) == 0 ) { + interval_lightoff->setSpecialValueText( tr("never") ); + } else { + interval_lightoff->setValue( interval ); + } + interval = config.readNumEntry( "Interval", 60 ); if ( interval > 3600 ) interval /= 1000; // compatibility (was millisecs) interval_suspend->setValue( interval ); // ac spinboxes interval = config.readNumEntry( "Interval_DimAC", 20 ); + if ( config.readNumEntry("DimAC",1) == 0 ) { + interval_dim_ac_3->setSpecialValueText( tr("never") ); + } else { interval_dim_ac_3->setValue( interval ); + } + interval = config.readNumEntry( "Interval_LightOffAC", 30 ); - interval_lightoff_ac_3->setValue( interval ); + if ( config.readNumEntry("LightOffAC",1) == 0 ) { + interval_lightoff_ac_3->setSpecialValueText( tr("never") ); + } else { + interval_lightoff_ac_3->setValue( interval ); + } + interval = config.readNumEntry( "IntervalAC", 60 ); if ( interval > 3600 ) { interval /= 1000; // compatibility (was millisecs) } - interval_suspend_ac_3->setValue( interval ); + if ( config.readNumEntry("NoApmAC", 0) == 0 ) { + interval_suspend_ac_3->setSpecialValueText( tr("never") ); + } else { + interval_suspend_ac_3->setValue( interval ); + } // battery check and slider - screensaver_dim->setChecked( config.readNumEntry("Dim",1) != 0 ); - screensaver_lightoff->setChecked( config.readNumEntry("LightOff",1) != 0 ); + + + + LcdOffOnly->setChecked( config.readNumEntry("LcdOffOnly",0) != 0 ); int maxbright = ODevice::inst ( )-> displayBrightnessResolution ( ); initbright = config.readNumEntry("Brightness",255); @@ -112,10 +138,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) brightness->setValue( (maxbright*255 - initbright*maxbright)/255 ); // ac check and slider - screensaver_dim_ac_3->setChecked( config.readNumEntry("DimAC",1) != 0 ); - screensaver_lightoff_ac_3->setChecked( config.readNumEntry("LightOffAC",1) != 0 ); LcdOffOnly_2_3->setChecked( config.readNumEntry("LcdOffOnlyAC",0) != 0 ); - noApmAC->setChecked( config.readNumEntry("NoApmAC",0) != 0 ); int maxbright_ac = ODevice::inst ( )-> displayBrightnessResolution ( ); initbright_ac = config.readNumEntry("BrightnessAC",255); brightness_ac_3->setMaxValue( maxbright_ac ); @@ -129,10 +152,10 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) config.setGroup( "Ipaqlightsensor" ); auto_brightness->setChecked( config.readNumEntry("LightSensor",1) != 0 ); auto_brightness_ac_3->setChecked( config.readNumEntry("LightSensorAC",1) != 0 ); - LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); - LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); - connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; - LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); + //LightStepSpin->setValue( config.readNumEntry("Steps", 10 ) ); + //LightMinValueSlider->setValue( config.readNumEntry("MinValue", 70 ) ); + //connect( LightStepSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderTicks( int ) ) ) ; + //LightShiftSpin->setValue( config.readNumEntry("Shift", 0 ) ); // advanced settings Config conf("apm"); @@ -141,8 +164,6 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags fl ) lowSpinBox->setValue( conf.readNumEntry("powerverylow", 10 ) ); criticalSpinBox->setValue( conf.readNumEntry("powercritical", 5 ) ); - - connect( brightness, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightness() ) ); connect( brightness_ac_3, SIGNAL( valueChanged(int) ), this, SLOT( applyBrightnessAC() ) ); } @@ -152,7 +173,7 @@ LightSettings::~LightSettings() } void LightSettings::slotSliderTicks( int steps ) { - LightMinValueSlider->setTickInterval( steps ); +// LightMinValueSlider->setTickInterval( steps ); } static void set_fl(int bright) @@ -171,21 +192,22 @@ void LightSettings::reject() void LightSettings::accept() { - if ( qApp->focusWidget() ) + if ( qApp->focusWidget() ) { qApp->focusWidget()->clearFocus(); + } applyBrightness(); // bat - int i_dim = (screensaver_dim->isChecked() ? interval_dim->value() : 0); - int i_lightoff = (screensaver_lightoff->isChecked() ? interval_lightoff->value() : 0); + int i_dim = ( !( interval_dim->specialValueText() == tr("never") ) ? interval_dim->value() : 0); + int i_lightoff = ( !( interval_lightoff->specialValueText() == tr("never") ) ? interval_lightoff->value() : 0); int i_suspend = interval_suspend->value(); QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); e << i_dim << i_lightoff << i_suspend; // ac - int i_dim_ac = (screensaver_dim_ac_3->isChecked() ? interval_dim_ac_3->value() : 0); - int i_lightoff_ac = (screensaver_lightoff_ac_3->isChecked() ? interval_lightoff_ac_3->value() : 0); + int i_dim_ac = ( !( interval_dim_ac_3->specialValueText() == tr("never") ) ? interval_dim_ac_3->value() : 0); + int i_lightoff_ac = ( !( interval_lightoff_ac_3->specialValueText() == tr("never") ) ? interval_lightoff_ac_3->value() : 0); int i_suspend_ac = interval_suspend_ac_3->value(); QCopEnvelope e_ac("QPE/System", "setScreenSaverIntervalsAC(int,int,int)" ); e << i_dim_ac << i_lightoff_ac << i_suspend_ac; @@ -194,8 +216,8 @@ void LightSettings::accept() config.setGroup( "Screensaver" ); // bat - config.writeEntry( "Dim", (int)screensaver_dim->isChecked() ); - config.writeEntry( "LightOff", (int)screensaver_lightoff->isChecked() ); + config.writeEntry( "Dim", interval_dim->specialValueText() == tr("never") ); + config.writeEntry( "LightOff", interval_lightoff->specialValueText() == tr("never") ); config.writeEntry( "LcdOffOnly", (int)LcdOffOnly->isChecked() ); config.writeEntry( "Interval_Dim", interval_dim->value() ); config.writeEntry( "Interval_LightOff", interval_lightoff->value() ); @@ -204,10 +226,10 @@ void LightSettings::accept() ( brightness->value() ) * 255 / brightness->maxValue() ); // ac - config.writeEntry( "DimAC", (int)screensaver_dim_ac_3->isChecked() ); - config.writeEntry( "LightOffAC", (int)screensaver_lightoff_ac_3->isChecked() ); + config.writeEntry( "DimAC", interval_dim_ac_3->specialValueText() == tr("never") ); + config.writeEntry( "LightOffAC", interval_lightoff_ac_3->specialValueText() == tr("never") ); config.writeEntry( "LcdOffOnlyAC", (int)LcdOffOnly_2_3->isChecked() ); - config.writeEntry( "NoAPmAC", (int)noApmAC->isChecked() ); + config.writeEntry( "NoAPmAC", interval_suspend_ac_3->specialValueText() == tr("never") ); config.writeEntry( "Interval_DimAC", interval_dim_ac_3->value() ); config.writeEntry( "Interval_LightOffAC", interval_lightoff_ac_3->value() ); config.writeEntry( "IntervalAC", interval_suspend_ac_3->value() ); @@ -216,19 +238,14 @@ void LightSettings::accept() // only make ipaq light sensor entries in config file if on an ipaq - if ( ODevice::inst()->model() == Model_iPAQ_H31xx || - ODevice::inst()->model() == Model_iPAQ_H36xx || - ODevice::inst()->model() == Model_iPAQ_H37xx || - ODevice::inst()->model() == Model_iPAQ_H38xx ) { - + if ( ODevice::inst()->hasLightSensor() ) { // ipaq sensor config.setGroup( "Ipaqlightsensor" ); - config.writeEntry( "LightSensor", (int)auto_brightness->isChecked() ); config.writeEntry( "LightSensorAC", (int)auto_brightness_ac_3->isChecked() ); - config.writeEntry( "Steps", LightStepSpin->value() ); - config.writeEntry( "MinValue", LightMinValueSlider->value() ); - config.writeEntry( "Shift", LightShiftSpin->value() ); + //config.writeEntry( "Steps", LightStepSpin->value() ); + //onfig.writeEntry( "MinValue", LightMinValueSlider->value() ); + //config.writeEntry( "Shift", LightShiftSpin->value() ); } config.write(); diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui index 2d0457f..fee5c2c 100644 --- a/core/settings/light-and-power/lightsettingsbase.ui +++ b/core/settings/light-and-power/lightsettingsbase.ui @@ -11,11 +11,18 @@ 0 0 - 411 + 403 532 + sizePolicy + + 7 + 5 + + + caption Light and Power Settings @@ -102,26 +109,36 @@ QLayoutWidget name - Layout8 + Layout11 + + + layoutMargin + + + layoutSpacing margin - 0 + 3 spacing - 6 + 3 - + QSpinBox name - interval_dim + interval_lightoff suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -137,40 +154,51 @@ lineStep - 15 + 10 - QCheckBox + QLabel name - screensaver_lightoff + TextLabel2_2 + + + text + Light off after + + + + QLabel + + name + TextLabel1_3 sizePolicy - 1 - 0 + 7 + 1 text - Light off after - - - checked - true + Dim light after - + QSpinBox name - interval_suspend + interval_dim suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -186,18 +214,22 @@ lineStep - 15 + 10 - + QSpinBox name - interval_lightoff + interval_suspend suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -213,29 +245,7 @@ lineStep - 15 - - - - QCheckBox - - name - screensaver_dim - - - sizePolicy - - 1 - 0 - - - - text - Dim light after - - - checked - true + 10 @@ -301,7 +311,7 @@ lineStep - 16 + 1 pageStep @@ -414,47 +424,48 @@ - - - - QGroupBox - - name - IpaqGroupBox - - - title - iPAQ - - - layoutMargin - - - layoutSpacing - - - - margin - 3 - - - spacing - 3 - - QCheckBox + QLayoutWidget name - auto_brightness - - - text - Use light sensor - - - whatsThis - By sensing the ambient light where you are using your device, the screen light can be adjusted automatically. The brightness setting still affects the average brightness. + Layout9 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + auto_brightness + + + text + Use Light Sensor + + + whatsThis + By sensing the ambient light where you are using your device, the screen light can be adjusted automatically. The brightness setting still affects the average brightness. + + + + QPushButton + + name + CalibrateLightSensor + + + text + Calibrate + + + @@ -533,37 +544,36 @@ QLayoutWidget name - Layout9_3 + Layout14 + + + layoutMargin + + + layoutSpacing margin - 0 + 3 spacing - 6 + 3 - - QLabel - - name - TextLabel1_2_2_3 - - - text - Suspend after - - - + QSpinBox name - interval_dim_ac_3 + interval_lightoff_ac_3 suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -579,7 +589,25 @@ lineStep - 15 + 10 + + + + QLabel + + name + TextLabel1_3_2 + + + sizePolicy + + 7 + 1 + + + + text + Dim light after @@ -590,7 +618,11 @@ suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -606,18 +638,33 @@ lineStep - 15 + 10 - + + QLabel + + name + TextLabel1_2_2_3 + + + text + Suspend after + + + QSpinBox name - interval_lightoff_ac_3 + interval_dim_ac_3 suffix - seconds + sec + + + specialValueText + never buttonSymbols @@ -633,52 +680,19 @@ lineStep - 15 + 10 - QCheckBox + QLabel name - screensaver_lightoff_ac_3 - - - sizePolicy - - 1 - 0 - + TextLabel2_2_2 text Light off after - - checked - true - - - - QCheckBox - - name - screensaver_dim_ac_3 - - - sizePolicy - - 1 - 0 - - - - text - Dim light after - - - checked - true - @@ -693,17 +707,6 @@ Deactivate LCD only (does not suspend) - - QCheckBox - - name - noApmAC - - - text - No power saving features - - @@ -860,47 +863,48 @@ - - - - QGroupBox - - name - IpaqGroupBoxAC - - - title - iPAQ - - - layoutMargin - - - layoutSpacing - - - - margin - 3 - - - spacing - 3 - - QCheckBox + QLayoutWidget name - auto_brightness_ac_3 - - - text - Use light sensor - - - whatsThis - By sensing the ambient light where you are using your device, the screen light can be adjusted automatically. The brightness setting still affects the average brightness. + Layout10 + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + auto_brightness_ac_3 + + + text + Use Light Sensor + + + whatsThis + By sensing the ambient light where you are using your device, the screen light can be adjusted automatically. The brightness setting still affects the average brightness. + + + + QPushButton + + name + CalibrateLightSensorAC + + + text + Calibrate + + + @@ -965,7 +969,7 @@ margin - 4 + 3 spacing @@ -977,14 +981,20 @@ name Layout18 + + layoutMargin + + + layoutSpacing + margin - 0 + 3 spacing - 6 + 3 QLabel @@ -993,9 +1003,15 @@ TextLabel1 + sizePolicy + + 7 + 5 + + + text - Low power warning -interval + Low power warning interval alignment @@ -1036,7 +1052,7 @@ interval suffix - seconds + sec maxValue @@ -1085,218 +1101,36 @@ interval TextLabel2 - text - very low battery -warning at - - - - QLabel - - name - TextLabel3 - - - text - critical power -warning at - - - - - - - - QGroupBox - - name - LightSensorGroupBox - - - title - iPAQ Light Sensor (127 steps) - - - layoutMargin - - - layoutSpacing - - - - margin - 3 - - - spacing - 3 - - - QLayoutWidget - - name - Layout7 - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - TextLabel9 + sizePolicy + + 1 + 5 + text - Steps - - - - QSpinBox - - name - LightStepSpin - - - maxValue - 126 - - - minValue - 1 - - - whatsThis - How many different steps should be handled by the light sensor. Values between 1 and 126 are allowed. - - - - - - QLabel - - name - TextLabel10 - - - text - Minimum value to turn display on - - - - QLayoutWidget - - name - Layout9 - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - PixmapLabel2_2 - - - pixmap - image0 - - - scaledContents - false + very low battery warning at - - QSlider - - name - LightMinValueSlider - - - maxValue - 127 - - - tracking - false - - - orientation - Horizontal - - - tickmarks - Right - - - + QLabel name - PixmapLabel1_2 - - - pixmap - image1 + TextLabel3 - scaledContents - false - - - - - - QLayoutWidget - - name - Layout8 - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - TextLabel11 + sizePolicy + + 1 + 5 + text - Shift - - - - QSpinBox - - name - LightShiftSpin - - - maxValue - 126 + critical power warning at - + @@ -1340,67 +1174,9 @@ warning at 789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022130543251d2e253d856405bffcbc54105b19c856360003103711c4354b344b314b04719340dcb434b31488ac1e1a2020a6acac8c2ea60cc54862606ea232b218541b5810452c3111432c510f550c22886a1e482c115d0c2c88e6168818babaa4a42462c48082cae8e68102011a06b5d65c0041d3518e - - - screensaver_dim - toggled(bool) - interval_dim - setEnabled(bool) - - - screensaver_lightoff - toggled(bool) - interval_lightoff - setEnabled(bool) - - - noApmAC - toggled(bool) - screensaver_dim_ac_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - interval_dim_ac_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - screensaver_lightoff_ac_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - interval_lightoff_ac_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - interval_suspend_ac_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - LcdOffOnly_2_3 - setDisabled(bool) - - - noApmAC - toggled(bool) - TextLabel1_2_2_3 - setDisabled(bool) - - auto_brightness - screensaver_dim interval_dim - screensaver_lightoff interval_lightoff interval_suspend brightness -- cgit v0.9.0.2