From 2ecab614a6b91658b1608c62134cd14e257e55b7 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Mon, 29 Dec 2003 16:52:29 +0000 Subject: - add customization of the action to take when closing the hinge - hide hinge customization on models which doesn't support that - hide frequency label on models which doesn't support changing the CPU frequency --- diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp index 6115178..d6d09a1 100644 --- a/core/settings/light-and-power/light.cpp +++ b/core/settings/light-and-power/light.cpp @@ -16,7 +16,7 @@     =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A   _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.=       =       ; Public License for more details. -++=   -.     .`     .: +++=   -.     .`     .:  :     =  ...= . :.=- You should have received a copy of the GNU  -.   .:....=;==+<; General Public License along with this file;   -_. . .   )=.  = see the file COPYING. If not, write to the @@ -34,6 +34,7 @@ #include #endif +#include #include #include #include @@ -54,12 +55,17 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); m_cres = ODevice::inst ( )-> displayContrastResolution ( ); + // check whether to show the light sensor stuff + if ( !ODevice::inst ( )-> hasLightSensor ( )) { auto_brightness-> hide ( ); CalibrateLightSensor-> hide ( ); auto_brightness_ac-> hide ( ); CalibrateLightSensor_ac-> hide ( ); } + + // check whether to show the contrast stuff + if (m_cres) { GroupLight->setTitle(tr("Backlight && Contrast")); GroupLight_ac->setTitle(GroupLight->title()); @@ -68,15 +74,28 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) contrast_ac->hide(); } + // check whether to show the cpu frequency stuff + QStrList freq = ODevice::inst()->allowedCpuFrequencies(); if ( freq.count() ) { frequency->insertStrList( freq ); frequency_ac->insertStrList( freq ); } else { + frequencyLabel->hide(); frequency->hide(); + frequencyLabel_ac->hide(); frequency_ac->hide(); } + // check whether to show the hinge action stuff + + if ( !ODevice::inst()->hasHingeSensor() ) { + closeHingeLabel->hide(); + closeHingeAction->hide(); + closeHingeLabel_ac->hide(); + closeHingeAction_ac->hide(); + } + Config config ( "apm" ); config. setGroup ( "Battery" ); @@ -91,7 +110,10 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // CPU frequency frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); - int bright = config. readNumEntry ( "Brightness", 127 ); + // hinge action + closeHingeAction->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); + + int bright = config. readNumEntry ( "Brightness", 127 ); int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); @@ -110,7 +132,7 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) m_sensordata = config. readListEntry ( "LightSensorData", ';' ); config. setGroup ( "AC" ); - + // ac spinboxes interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); @@ -122,6 +144,9 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // CPU frequency frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) ); + // hinge action + closeHingeAction_ac->setCurrentItem( config.readNumEntry("CloseHingeAction", 0) ); + bright = config. readNumEntry ( "Brightness", 255 ); brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); @@ -139,8 +164,8 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) // light sensor auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); - - // advanced settings + + // warnings config. setGroup ( "Warnings" ); warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); @@ -150,22 +175,25 @@ LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { - tabs-> setCurrentPage ( 0 ); + tabs-> setCurrentPage ( 0 ); } else { tabs-> setCurrentPage ( 1 ); } - + connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); if (m_cres) { connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); } - connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); + connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); + connect( frequency_ac, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) ); + connect( closeHingeAction, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); + connect( closeHingeAction_ac, SIGNAL( activated(int) ), this, SLOT( setCloseHingeAction(int) ) ); } -LightSettings::~LightSettings ( ) +LightSettings::~LightSettings ( ) { } @@ -191,23 +219,22 @@ void LightSettings::setBacklight ( int bright ) { QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); e << bright; - + if ( bright != -1 ) { m_resettimer-> stop ( ); m_resettimer-> start ( 4000, true ); - } + } } void LightSettings::setContrast ( int contr ) { if (contr == -1) contr = m_oldcontrast; - ODevice::inst ( )-> setDisplayContrast(contr); } void LightSettings::setFrequency ( int index ) { -qWarning("LightSettings::setFrequency(%d)", index); + qWarning("LightSettings::setFrequency(%d)", index); ODevice::inst ( )-> setCurrentCpuFrequency(index); } @@ -217,6 +244,11 @@ void LightSettings::resetBacklight ( ) setContrast ( -1 ); } +void LightSettings::setCloseHingeAction ( int index ) +{ + qWarning("LightSettings::setCloseHingeStatus(%d)", index); +} + void LightSettings::accept ( ) { Config config ( "apm" ); @@ -231,6 +263,7 @@ void LightSettings::accept ( ) if (m_cres) config. writeEntry ( "Contrast", contrast-> value () ); config. writeEntry ( "Freq", frequency->currentItem() ); + config. writeEntry ( "CloseHingeAction", closeHingeAction->currentItem() ); // ac config. setGroup ( "AC" ); @@ -242,8 +275,9 @@ void LightSettings::accept ( ) if (m_cres) config. writeEntry ( "Contrast", contrast_ac-> value () ); config. writeEntry ( "Freq", frequency_ac->currentItem() ); + config. writeEntry ( "CloseHingeAction", closeHingeAction_ac->currentItem() ); - // only make light sensor stuff appear if the unit has a sensor + // only make light sensor stuff appear if the unit has a sensor if ( ODevice::inst ( )-> hasLightSensor ( )) { config. setGroup ( "Battery" ); config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); @@ -275,7 +309,7 @@ void LightSettings::done ( int r ) { m_resettimer-> stop ( ); resetBacklight ( ); - + LightSettingsBase::done ( r ); close ( ); } diff --git a/core/settings/light-and-power/light.h b/core/settings/light-and-power/light.h index 83d5520..2167817 100644 --- a/core/settings/light-and-power/light.h +++ b/core/settings/light-and-power/light.h @@ -54,6 +54,7 @@ protected slots: void setBacklight ( int ); void setContrast ( int ); void setFrequency ( int ); + void setCloseHingeAction ( int ); void resetBacklight ( ); private: diff --git a/core/settings/light-and-power/lightsettingsbase.ui b/core/settings/light-and-power/lightsettingsbase.ui index e4d5f0e..2af0331 100644 --- a/core/settings/light-and-power/lightsettingsbase.ui +++ b/core/settings/light-and-power/lightsettingsbase.ui @@ -11,7 +11,7 @@ 0 0 - 343 + 331 532 @@ -105,42 +105,65 @@ spacing 3 - - QSpinBox + + QLabel name - interval_lightoff + TL1 - suffix - sec + sizePolicy + + 3 + 1 + - specialValueText - never + text + Dim light after + + + QLabel - buttonSymbols - PlusMinus + name + TL3 - maxValue - 3600 + sizePolicy + + 3 + 1 + - minValue - 0 + text + Suspend after + + + QCheckBox - lineStep - 10 + name + LcdOffOnly + + + sizePolicy + + 7 + 0 + + + + text + Deactivate LCD only (does not suspend) - + QLabel name - TL1 + frequencyLabel sizePolicy @@ -151,10 +174,21 @@ text - Dim light after + CPU Frequency - + + QLabel + + name + closeHingeLabel + + + text + On closing the hinge + + + QSpinBox name @@ -185,79 +219,38 @@ 10 - - QCheckBox - - name - LcdOffOnly - - - sizePolicy - - 7 - 0 - - - - text - Deactivate LCD only (does not suspend) - - - - QLabel + + QSpinBox name - TL3 - - - sizePolicy - - 3 - 1 - + interval_lightoff - text - Suspend after - - - - QLabel - - name - TL2 + suffix + sec - sizePolicy - - 3 - 1 - + specialValueText + never - text - Light off after + buttonSymbols + PlusMinus - - - QLabel - name - TL3_2 + maxValue + 3600 - sizePolicy - - 3 - 1 - + minValue + 0 - text - CPU Frequency + lineStep + 10 - + QSpinBox name @@ -288,13 +281,56 @@ 10 - + QComboBox name frequency + + QComboBox + + + text + ignore + + + + + text + display off + + + + + text + suspend + + + + name + closeHingeAction + + + + QLabel + + name + TL2 + + + sizePolicy + + 3 + 1 + + + + text + Light off after + + @@ -552,11 +588,11 @@ margin - -1 + 5 spacing - -1 + 3 QGroupBox @@ -618,24 +654,6 @@ 10 - - QLabel - - name - TextLabel1_3_2 - - - sizePolicy - - 3 - 1 - - - - text - Dim light after - - QSpinBox @@ -698,6 +716,31 @@ 10 + + QComboBox + + name + frequency_ac + + + + QLabel + + name + frequencyLabel_ac + + + sizePolicy + + 3 + 1 + + + + text + CPU Frequency + + QLabel @@ -716,11 +759,11 @@ Light off after - + QLabel name - TextLabel1_2_2_3 + TextLabel1_3_2 sizePolicy @@ -731,17 +774,28 @@ text - Suspend after + Dim light after - - QComboBox + + QLabel name - frequency_ac + TextLabel1_2_2_3 + + + sizePolicy + + 3 + 1 + + + + text + Suspend after - + QCheckBox name @@ -759,22 +813,40 @@ Deactivate LCD only (does not suspend) - - QLabel + + QComboBox + + + text + ignore + + + + + text + display off + + + + + text + suspend + + name - TextLabel1_2_2_3_2 + closeHingeAction_ac + + + QLabel - sizePolicy - - 3 - 1 - + name + closeHingeLabel_ac text - CPU frequency + On closing the hinge -- cgit v0.9.0.2