• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

klaptopdaemon

buttons.cpp

Go to the documentation of this file.
00001 /*
00002  * buttons.cpp
00003  *
00004  * Copyright (c) 1999 Paul Campbell <paul@taniwha.com>
00005  * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
00006  *
00007  * Requires the Qt widget libraries, available at no cost at
00008  * http://www.troll.no/
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023  */
00024 
00025 #include "buttons.h"
00026 #include "portable.h"
00027 #include "version.h"
00028 
00029 #include <kglobal.h>
00030 #include <klocale.h>
00031 #include <kconfig.h>
00032 #include <knumvalidator.h>
00033 #include <kdialog.h>
00034 #include <kapplication.h>
00035 #include <kcombobox.h>
00036 
00037 #include <QLayout>
00038 
00039 #include <QSpinBox>
00040 #include <qradiobutton.h>
00041 #include <QCheckBox>
00042 #include <q3hbox.h>
00043 #include <qslider.h>
00044 
00045 #include <Q3VButtonGroup>
00046 
00047 //Added by qt3to4:
00048 #include <QLabel>
00049 #include <QVBoxLayout>
00050 #include <QHBoxLayout>
00051 extern void wake_laptop_daemon();
00052 
00053 ButtonsConfig::ButtonsConfig (const KComponentData &inst,QWidget * parent)
00054   : KCModule(inst,parent),
00055     lidBox(0),
00056     lidStandby(0),
00057     lidSuspend(0),
00058     lidOff(0),
00059     lidHibernate(0),
00060     lidShutdown(0),
00061     lidLogout(0),
00062     lidBrightness(0),
00063     lidValBrightness(0),
00064     lidThrottle(0),
00065     lidValThrottle(0),
00066     lidPerformance(0),
00067     lidValPerformance(0),
00068 
00069     powerBox(0),
00070     powerStandby(0),
00071     powerSuspend(0),
00072     powerOff(0),
00073     powerHibernate(0),
00074     powerShutdown(0),
00075     powerLogout(0),
00076     powerBrightness(0),
00077     powerValBrightness(0),
00078     powerThrottle(0),
00079     powerValThrottle(0),
00080     powerPerformance(0),
00081     powerValPerformance(0)
00082 {
00083   int can_shutdown = 1; // fix me
00084   int can_logout = 1; // fix me
00085 
00086   KGlobal::locale()->insertCatalog("klaptopdaemon"); // For translation of klaptopdaemon messages
00087 
00088   apm = laptop_portable::has_power_management();
00089   config =  new KConfig("kcmlaptoprc");
00090   int can_brightness = laptop_portable::has_brightness();
00091     QStringList throttle_list;
00092     int current_throttle;
00093     bool *active_list;
00094     bool has_throttle = laptop_portable::get_system_throttling(0, current_throttle, throttle_list, active_list);
00095     QStringList performance_list;
00096     int current_performance;
00097     bool has_performance = laptop_portable::get_system_performance(0, current_performance, performance_list, active_list);
00098 
00099   if (!apm && !can_brightness && !has_throttle && !has_performance) {
00100     QVBoxLayout *top_layout = new QVBoxLayout(this );
00101     top_layout->setMargin( KDialog::marginHint() );
00102     top_layout->setSpacing( KDialog::spacingHint() );
00103 
00104     KActiveLabel* explain = laptop_portable::no_power_management_explanation(this);
00105     top_layout->addWidget(explain);
00106 
00107     top_layout->addStretch(1);
00108   } else {
00109     int can_standby = laptop_portable::has_standby();
00110     int can_suspend = laptop_portable::has_suspend();
00111     int can_hibernate = laptop_portable::has_hibernation();
00112 
00113     if (!can_standby && !can_suspend && !can_hibernate && !can_brightness && !has_throttle && !has_performance)
00114       apm = 0;
00115     if (!apm) {
00116       QVBoxLayout *top_layout = new QVBoxLayout(this );
00117       top_layout->setMargin( KDialog::marginHint() );
00118       top_layout->setSpacing( KDialog::spacingHint() );
00119 
00120       QLabel* explain = laptop_portable::how_to_do_suspend_resume(this);
00121       top_layout->addWidget(explain);
00122 
00123       top_layout->addStretch(1);
00124     } else {
00125       QVBoxLayout *top_layout = new QVBoxLayout(this );
00126       top_layout->setMargin( KDialog::marginHint() );
00127       top_layout->setSpacing( KDialog::spacingHint() );
00128 
00129       QHBoxLayout *hlay = new QHBoxLayout( );
00130       top_layout->addItem( hlay );
00131 
00132       if (laptop_portable::has_button(laptop_portable::LidButton)) {
00133         lidBox = new Q3VButtonGroup(i18n("Lid Switch Closed"), this);
00134         lidBox->layout()->setSpacing( KDialog::spacingHint() );
00135         lidBox->setToolTip( i18n( "Select which actions will occur when the laptop's lid is closed" ) );
00136         hlay->addWidget( lidBox );
00137 
00138         if (can_standby) {
00139         lidStandby = new QRadioButton(i18n("Standb&y"), lidBox);
00140             lidStandby->setToolTip( i18n( "Causes the laptop to move into the standby temporary low-power state" ) );
00141     }
00142         if (can_suspend) {
00143         lidSuspend = new QRadioButton(i18n("&Suspend"), lidBox);
00144             lidSuspend->setToolTip( i18n( "Causes the laptop to move into the suspend 'save-to-ram' state" ) );
00145     }
00146         if (can_hibernate) {
00147         lidHibernate = new QRadioButton(i18n("H&ibernate"), lidBox);
00148             lidHibernate->setToolTip( i18n( "Causes the laptop to move into the hibernate 'save-to-disk' state" ) );
00149     }
00150         if (can_shutdown) {
00151         lidShutdown = new QRadioButton(i18n("System power off"), lidBox);
00152             lidShutdown->setToolTip( i18n( "Causes the laptop to power down" ) );
00153     }
00154         if (can_logout) {
00155         lidLogout = new QRadioButton(i18n("Logout"), lidBox);
00156             lidShutdown->setToolTip( i18n( "Causes you to be logged out" ) );
00157     }
00158         if (can_suspend||can_standby||can_hibernate||can_shutdown||can_logout)
00159         lidOff = new QRadioButton(i18n("&Off"), lidBox);
00160         if (can_brightness) {
00161         lidBrightness = new QCheckBox(i18n("Brightness"), lidBox);
00162             lidBrightness->setToolTip( i18n( "Causes the back panel brightness to be set" ) );
00163         QWidget *wp = new QWidget(lidBox);
00164             QHBoxLayout *xl = new QHBoxLayout( wp);
00165         xl->addWidget(new QLabel("-", wp));
00166         lidValBrightness = new QSlider(0, 255, 16, 255, Qt::Horizontal, wp);
00167         lidValBrightness->setEnabled(0);
00168             lidValBrightness->setToolTip( i18n( "How bright the back panel will be set to" ) );
00169         connect (lidValBrightness, SIGNAL(valueChanged(int)), this, SLOT(configChanged()));
00170         xl->addWidget(lidValBrightness);
00171         xl->addWidget(new QLabel("+", wp));
00172         xl->addStretch(1);
00173         }
00174         if (has_performance) {
00175         lidPerformance = new QCheckBox(i18n("System performance"), lidBox);
00176             lidPerformance->setToolTip( i18n( "Causes the performance profile to be changed" ) );
00177 
00178         QWidget *wp = new QWidget(lidBox);
00179             QHBoxLayout *xl = new QHBoxLayout( wp);
00180             lidValPerformance = new KComboBox(0, wp);
00181             lidValPerformance->setToolTip( i18n( "The performance profile to switch to" ) );
00182         lidValPerformance->insertStringList(performance_list);
00183             lidValPerformance->setEnabled(0);
00184             connect (lidValPerformance, SIGNAL(activated(int)), this, SLOT(configChanged()));
00185         xl->addWidget(lidValPerformance);
00186         xl->addStretch(1);
00187         }
00188         if (has_throttle) {
00189         lidThrottle = new QCheckBox(i18n("CPU throttle"), lidBox);
00190             lidThrottle->setToolTip( i18n( "Causes the CPU to be throttled back" ) );
00191 
00192         QWidget *wp = new QWidget(lidBox);
00193             QHBoxLayout *xl = new QHBoxLayout( wp);
00194             lidValThrottle = new KComboBox(0, wp);
00195             lidValThrottle->setToolTip( i18n( "How much to throttle back the CPU" ) );
00196         lidValThrottle->insertStringList(throttle_list);
00197             lidValThrottle->setEnabled(0);
00198             connect (lidValThrottle, SIGNAL(activated(int)), this, SLOT(configChanged()));
00199         xl->addWidget(lidValThrottle);
00200         xl->addStretch(1);
00201 
00202 
00203         }
00204         connect(lidBox, SIGNAL(clicked(int)), this, SLOT(configChanged()));
00205       }
00206 
00207       if (laptop_portable::has_button(laptop_portable::PowerButton)) {
00208 
00209         powerBox = new Q3VButtonGroup(i18n("Power Switch Pressed"), this);
00210         powerBox->layout()->setSpacing( KDialog::spacingHint() );
00211         powerBox->setToolTip( i18n( "Select which actions will occur when the laptop's power button is pressed" ) );
00212         hlay->addWidget( powerBox );
00213 
00214         if (can_standby) {
00215         powerStandby = new QRadioButton(i18n("Sta&ndby"), powerBox);
00216             powerStandby->setToolTip( i18n( "Causes the laptop to move into the standby temporary low-power state" ) );
00217     }
00218         if (can_suspend) {
00219         powerSuspend = new QRadioButton(i18n("S&uspend"), powerBox);
00220             powerSuspend->setToolTip( i18n( "Causes the laptop to move into the suspend 'save-to-ram' state" ) );
00221     }
00222         if (can_hibernate) {
00223         powerHibernate = new QRadioButton(i18n("Hi&bernate"), powerBox);
00224             powerHibernate->setToolTip( i18n( "Causes the laptop to move into the hibernate 'save-to-disk' state" ) );
00225     }
00226         if (can_shutdown) {
00227         powerShutdown = new QRadioButton(i18n("System power off"), powerBox);
00228             powerShutdown->setToolTip( i18n( "Causes the laptop to power down" ) );
00229     }
00230         if (can_logout) {
00231         powerLogout = new QRadioButton(i18n("Logout"), powerBox);
00232             powerShutdown->setToolTip( i18n( "Causes you to be logged out" ) );
00233     }
00234         if (can_suspend||can_standby||can_hibernate||can_shutdown||can_logout)
00235         powerOff = new QRadioButton(i18n("O&ff"), powerBox);
00236         if (can_brightness) {
00237         powerBrightness = new QCheckBox(i18n("Brightness"), powerBox);
00238             powerBrightness->setToolTip( i18n( "Causes the back panel brightness to be set" ) );
00239         QWidget *wp = new QWidget(powerBox);
00240             QHBoxLayout *xl = new QHBoxLayout( wp);
00241         xl->addWidget(new QLabel("-", wp));
00242         powerValBrightness = new QSlider(0, 255, 16, 255, Qt::Horizontal, wp);
00243             powerValBrightness->setToolTip( i18n( "How bright the back panel will be set to" ) );
00244         powerValBrightness->setEnabled(0);
00245         connect (powerValBrightness, SIGNAL(valueChanged(int)), this, SLOT(configChanged()));
00246         xl->addWidget(powerValBrightness);
00247         xl->addWidget(new QLabel("+", wp));
00248         xl->addStretch(1);
00249         }
00250         if (has_performance) {
00251         powerPerformance = new QCheckBox(i18n("System performance"), powerBox);
00252             powerPerformance->setToolTip( i18n( "Causes the performance profile to be changed" ) );
00253 
00254         QWidget *wp = new QWidget(powerBox);
00255             QHBoxLayout *xl = new QHBoxLayout( wp);
00256             powerValPerformance = new KComboBox(0, wp);
00257             powerValPerformance->setToolTip( i18n( "The performance profile to switch to" ) );
00258         powerValPerformance->insertStringList(performance_list);
00259             powerValPerformance->setEnabled(0);
00260             connect (powerValPerformance, SIGNAL(activated(int)), this, SLOT(configChanged()));
00261         xl->addWidget(powerValPerformance);
00262         xl->addStretch(1);
00263         }
00264         if (has_throttle) {
00265         powerThrottle = new QCheckBox(i18n("CPU throttle"), powerBox);
00266             powerThrottle->setToolTip( i18n( "Causes the CPU to be throttled back" ) );
00267 
00268         QWidget *wp = new QWidget(powerBox);
00269             QHBoxLayout *xl = new QHBoxLayout( wp);
00270             powerValThrottle = new KComboBox(0, wp);
00271             powerValThrottle->setToolTip( i18n( "How much to throttle back the CPU" ) );
00272         powerValThrottle->insertStringList(throttle_list);
00273             powerValThrottle->setEnabled(0);
00274             connect (powerValThrottle, SIGNAL(activated(int)), this, SLOT(configChanged()));
00275         xl->addWidget(powerValThrottle);
00276         xl->addStretch(1);
00277         }
00278         connect(powerBox, SIGNAL(clicked(int)), this, SLOT(configChanged()));
00279       }
00280 
00281       hlay->addStretch(1);
00282 
00283       QLabel* explain = new QLabel(i18n("This panel enables actions that are triggered when the lid closure switch "
00284                             "or power switch on your laptop is pressed. Some laptops may already "
00285                     "automatically do things like this, if you cannot disable them in your BIOS "
00286                     "you probably should not enable anything in this panel."), this);
00287       explain->setWordWrap(true);
00288       top_layout->addWidget(explain);
00289 
00290       top_layout->addStretch(1);
00291 
00292       top_layout->addWidget( new QLabel( i18n("Version: %1", QString(LAPTOP_VERSION)), this ), 0, Qt::AlignRight );
00293     }
00294   }
00295 
00296   load();
00297 }
00298 
00299 ButtonsConfig::~ButtonsConfig()
00300 {
00301   delete config;
00302 }
00303 
00304 void ButtonsConfig::save()
00305 {
00306         power = getPower();
00307         lid = getLid();
00308     lid_bright_enabled = (lidBrightness?lidBrightness->isChecked():0);
00309     power_bright_enabled = (powerBrightness?powerBrightness->isChecked():0);
00310     lid_bright_val = (lidValBrightness?lidValBrightness->value():0);
00311     power_bright_val = (powerValBrightness?powerValBrightness->value():0);
00312     lid_performance_enabled = (lidPerformance?lidPerformance->isChecked():0);
00313     power_performance_enabled = (powerPerformance?powerPerformance->isChecked():0);
00314     lid_performance_val = (lidValPerformance?lidValPerformance->currentText():"");
00315     power_performance_val = (powerValPerformance?powerValPerformance->currentText():"");
00316     lid_throttle_enabled = (lidThrottle?lidThrottle->isChecked():0);
00317     power_throttle_enabled = (powerThrottle?powerThrottle->isChecked():0);
00318     lid_throttle_val = (lidValThrottle?lidValThrottle->currentText():"");
00319     power_throttle_val = (powerValThrottle?powerValThrottle->currentText():"");
00320 
00321   config->setGroup("LaptopButtons");
00322   config->writeEntry("LidSuspend", lid);
00323   config->writeEntry("PowerSuspend", power);
00324   config->writeEntry("PowerBrightnessEnabled", power_bright_enabled);
00325   config->writeEntry("LidBrightnessEnabled", lid_bright_enabled);
00326   config->writeEntry("PowerBrightness", power_bright_val);
00327   config->writeEntry("LidBrightness", lid_bright_val);
00328   config->writeEntry("PowerPerformanceEnabled", power_performance_enabled);
00329   config->writeEntry("LidPerformanceEnabled", lid_performance_enabled);
00330   config->writeEntry("PowerPerformance", power_performance_val);
00331   config->writeEntry("LidPerformance", lid_performance_val);
00332   config->writeEntry("PowerThrottleEnabled", power_throttle_enabled);
00333   config->writeEntry("LidThrottleEnabled", lid_throttle_enabled);
00334   config->writeEntry("PowerThrottle", power_throttle_val);
00335   config->writeEntry("LidThrottle", lid_throttle_val);
00336   config->sync();
00337   changed(false);
00338   wake_laptop_daemon();
00339 }
00340 
00341 void ButtonsConfig::load()
00342 {
00343   config->setGroup("LaptopButtons");
00344   lid = config->readEntry("LidSuspend", 0);
00345   power = config->readEntry("PowerSuspend", 0);
00346   lid_bright_enabled = config->readEntry("LidBrightnessEnabled", 0);
00347   power_bright_enabled = config->readEntry("PowerBrightnessEnabled", 0);
00348   lid_bright_val = config->readEntry("LidBrightness", 0);
00349   power_bright_val = config->readEntry("PowerBrightness", 0);
00350   lid_performance_enabled = config->readEntry("LidPerformanceEnabled", 0);
00351   power_performance_enabled = config->readEntry("PowerPerformanceEnabled", 0);
00352   lid_performance_val = config->readEntry("LidPerformance", "");
00353   power_performance_val = config->readEntry("PowerPerformance", "");
00354   lid_throttle_enabled = config->readEntry("LidThrottleEnabled", 0);
00355   power_throttle_enabled = config->readEntry("PowerThrottleEnabled", 0);
00356   lid_throttle_val = config->readEntry("LidThrottle", "");
00357   power_throttle_val = config->readEntry("PowerThrottle", "");
00358 
00359   // the GUI should reflect the real values
00360     setPower(power, lid);
00361     if (lidBrightness)
00362         lidBrightness->setChecked(lid_bright_enabled);
00363     if (powerBrightness)
00364         powerBrightness->setChecked(power_bright_enabled);
00365     if (lidValBrightness) {
00366         lidValBrightness->setValue(lid_bright_val);
00367         lidValBrightness->setEnabled(lid_bright_enabled);
00368     }
00369     if (powerValBrightness) {
00370         powerValBrightness->setValue(power_bright_val);
00371         powerValBrightness->setEnabled(power_bright_enabled);
00372     }
00373     if (lidPerformance)
00374         lidPerformance->setChecked(lid_performance_enabled);
00375     if (powerPerformance)
00376         powerPerformance->setChecked(power_performance_enabled);
00377     if (lidValPerformance) {
00378         int ind = 0;
00379         for (int i = 0; i < lidValPerformance->count(); i++)
00380         if (lidValPerformance->text(i) == lid_performance_val) {
00381             ind = i;
00382             break;
00383         }
00384         lidValPerformance->setCurrentItem(ind);
00385         lidValPerformance->setEnabled(lid_performance_enabled);
00386     }
00387     if (powerValPerformance) {
00388         int ind = 0;
00389         for (int i = 0; i < powerValPerformance->count(); i++)
00390         if (powerValPerformance->text(i) == power_performance_val) {
00391             ind = i;
00392             break;
00393         }
00394         powerValPerformance->setCurrentItem(ind);
00395         powerValPerformance->setEnabled(power_performance_enabled);
00396     }
00397     if (lidThrottle)
00398         lidThrottle->setChecked(lid_throttle_enabled);
00399     if (powerThrottle)
00400         powerThrottle->setChecked(power_throttle_enabled);
00401     if (lidValThrottle) {
00402         int ind = 0;
00403         for (int i = 0; i < lidValThrottle->count(); i++)
00404         if (lidValThrottle->text(i) == lid_throttle_val) {
00405             ind = i;
00406             break;
00407         }
00408         lidValThrottle->setCurrentItem(ind);
00409         lidValThrottle->setEnabled(lid_throttle_enabled);
00410     }
00411     if (powerValThrottle) {
00412         int ind = 0;
00413         for (int i = 0; i < powerValThrottle->count(); i++)
00414         if (powerValThrottle->text(i) == power_throttle_val) {
00415             ind = i;
00416             break;
00417         }
00418         powerValThrottle->setCurrentItem(ind);
00419         powerValThrottle->setEnabled(power_throttle_enabled);
00420     }
00421   changed(false);
00422 }
00423 
00424 void ButtonsConfig::defaults()
00425 {
00426   setPower(0, 0);
00427   lid_bright_enabled = 0;
00428   power_bright_enabled = 0;
00429   lid_bright_val = 0;
00430   power_bright_val = 0;
00431   lid_performance_enabled = 0;
00432   power_performance_enabled = 0;
00433   lid_performance_val = "";
00434   power_performance_val = "";
00435   lid_throttle_enabled = 0;
00436   power_throttle_enabled = 0;
00437   lid_throttle_val = "";
00438   power_throttle_val = "";
00439     if (lidBrightness)
00440         lidBrightness->setChecked(lid_bright_enabled);
00441     if (powerBrightness)
00442         powerBrightness->setChecked(power_bright_enabled);
00443     if (lidValBrightness) {
00444         lidValBrightness->setValue(lid_bright_val);
00445         lidValBrightness->setEnabled(lid_bright_enabled);
00446     }
00447     if (powerValBrightness) {
00448         powerValBrightness->setValue(power_bright_val);
00449         powerValBrightness->setEnabled(power_bright_enabled);
00450     }
00451 
00452 
00453     if (lidPerformance)
00454         lidPerformance->setChecked(lid_performance_enabled);
00455     if (powerPerformance)
00456         powerPerformance->setChecked(power_performance_enabled);
00457     if (lidValPerformance) {
00458         lidValPerformance->setCurrentItem(0);
00459         lidValPerformance->setEnabled(lid_performance_enabled);
00460     }
00461     if (powerValPerformance) {
00462         powerValPerformance->setCurrentItem(0);
00463         powerValPerformance->setEnabled(power_performance_enabled);
00464     }
00465     if (lidThrottle)
00466         lidThrottle->setChecked(lid_throttle_enabled);
00467     if (powerThrottle)
00468         powerThrottle->setChecked(power_throttle_enabled);
00469     if (lidValThrottle) {
00470         lidValThrottle->setCurrentItem(0);
00471         lidValThrottle->setEnabled(lid_throttle_enabled);
00472     }
00473     if (powerValThrottle) {
00474         powerValThrottle->setCurrentItem(0);
00475         powerValThrottle->setEnabled(power_throttle_enabled);
00476     }
00477 }
00478 
00479 int  ButtonsConfig::getLid()
00480 {
00481   if (!apm)
00482     return(lid);
00483   if (lidHibernate && lidHibernate->isChecked())
00484     return 3;
00485   if (lidStandby && lidStandby->isChecked())
00486     return 1;
00487   if (lidSuspend && lidSuspend->isChecked())
00488     return 2;
00489   if (lidLogout && lidLogout->isChecked())
00490     return 4;
00491   if (lidShutdown && lidShutdown->isChecked())
00492     return 5;
00493   return(0);
00494 }
00495 
00496 int  ButtonsConfig::getPower()
00497 {
00498   if (!apm)
00499     return(power);
00500   if (powerHibernate && powerHibernate->isChecked())
00501     return 3;
00502   if (powerStandby && powerStandby->isChecked())
00503     return 1;
00504   if (powerSuspend && powerSuspend->isChecked())
00505     return 2;
00506   if (powerLogout && powerLogout->isChecked())
00507     return 4;
00508   if (powerShutdown && powerShutdown->isChecked())
00509     return 5;
00510   return(0);
00511 }
00512 
00513 void ButtonsConfig::setPower(int p, int np)
00514 {
00515   if (!apm)
00516     return;
00517   if (lidSuspend) {
00518     lidSuspend->setChecked(false);
00519   } else {
00520     if (np == 2) np = 0;
00521   }
00522   if (lidShutdown) {
00523     lidShutdown->setChecked(false);
00524   } else {
00525     if (np == 5) np = 0;
00526   }
00527   if (lidLogout) {
00528     lidLogout->setChecked(false);
00529   } else {
00530     if (np == 4) np = 0;
00531   }
00532   if (lidStandby) {
00533     lidStandby->setChecked(false);
00534   } else {
00535     if (np == 1) np = 0;
00536   }
00537   if (lidHibernate) {
00538     lidHibernate->setChecked(false);
00539   } else {
00540     if (np == 3) np = 0;
00541   }
00542   if (lidOff)
00543       lidOff->setChecked(false);
00544   switch (np) {
00545   case 0: if (lidOff)
00546           lidOff->setChecked(true);
00547       break;
00548   case 1: lidStandby->setChecked(true);break;
00549   case 2: lidSuspend->setChecked(true);break;
00550   case 3: lidHibernate->setChecked(true);break;
00551   case 4: lidLogout->setChecked(true);break;
00552   case 5: lidShutdown->setChecked(true);break;
00553   }
00554   if (powerSuspend) {
00555     powerSuspend->setChecked(false);
00556   } else {
00557     if (p == 2) p = 0;
00558   }
00559   if (powerLogout) {
00560     powerLogout->setChecked(false);
00561   } else {
00562     if (p == 4) p = 0;
00563   }
00564   if (powerShutdown) {
00565     powerShutdown->setChecked(false);
00566   } else {
00567     if (p == 5) p = 0;
00568   }
00569   if (powerStandby) {
00570     powerStandby->setChecked(false);
00571   } else {
00572     if (p == 1) p = 0;
00573   }
00574   if (powerHibernate) {
00575     powerHibernate->setChecked(false);
00576   } else {
00577     if (p == 3) p = 0;
00578   }
00579   if (powerOff)
00580       powerOff->setChecked(false);
00581   switch (p) {
00582   case 0: if (powerOff)
00583           powerOff->setChecked(true);
00584       break;
00585   case 1: powerStandby->setChecked(true);break;
00586   case 2: powerSuspend->setChecked(true);break;
00587   case 3: powerHibernate->setChecked(true);break;
00588   case 4: powerLogout->setChecked(true);break;
00589   case 5: powerShutdown->setChecked(true);break;
00590   }
00591 }
00592 
00593 
00594 
00595 void ButtonsConfig::configChanged()
00596 {
00597   if (powerBrightness)
00598     powerValBrightness->setEnabled(powerBrightness->isChecked());
00599   if (lidBrightness)
00600     lidValBrightness->setEnabled(lidBrightness->isChecked());
00601 
00602   if (powerPerformance)
00603     powerValPerformance->setEnabled(powerPerformance->isChecked());
00604   if (lidPerformance)
00605     lidValPerformance->setEnabled(lidPerformance->isChecked());
00606 
00607   if (powerThrottle)
00608     powerValThrottle->setEnabled(powerThrottle->isChecked());
00609   if (lidThrottle)
00610     lidValThrottle->setEnabled(lidThrottle->isChecked());
00611 
00612   emit changed(true);
00613 }
00614 
00615 
00616 QString ButtonsConfig::quickHelp() const
00617 {
00618   return i18n("<h1>Laptop Power Control</h1>This module allows you to "
00619     "configure the power switch or lid closure switch on your laptop "
00620     "so they can trigger system actions");
00621 
00622 }
00623 
00624 #include "buttons.moc"

klaptopdaemon

Skip menu "klaptopdaemon"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal