From 7fc2c05f9d705fbb18a511b2973e146b2794f333 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 3 Sep 2011 22:49:00 +0000 Subject: Add DPMS configuration to kdebase git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1251243 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcontrol/displayconfig/displayconfig.cpp | 60 ++++++++++ kcontrol/displayconfig/displayconfig.h | 5 +- kcontrol/displayconfig/displayconfigbase.ui | 166 ++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+), 1 deletion(-) (limited to 'kcontrol/displayconfig') diff --git a/kcontrol/displayconfig/displayconfig.cpp b/kcontrol/displayconfig/displayconfig.cpp index 3498327b0..ad2d31fff 100644 --- a/kcontrol/displayconfig/displayconfig.cpp +++ b/kcontrol/displayconfig/displayconfig.cpp @@ -761,6 +761,13 @@ KDisplayConfig::KDisplayConfig(TQWidget *parent, const char *name, const TQStrin connect(base->gammaBlueSlider, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(gammaBlueSliderChanged(int))); connect(base->monitorDisplaySelectDD, TQT_SIGNAL(activated(int)), TQT_SLOT(selectScreen(int))); connect(base->gammamonitorDisplaySelectDD, TQT_SIGNAL(activated(int)), TQT_SLOT(gammaselectScreen(int))); + connect(base->systemEnableDPMS, TQT_SIGNAL(clicked()), TQT_SLOT(dpmsChanged())); + connect(base->systemEnableDPMSStandby, TQT_SIGNAL(clicked()), TQT_SLOT(dpmsChanged())); + connect(base->systemEnableDPMSSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(dpmsChanged())); + connect(base->systemEnableDPMSPowerDown, TQT_SIGNAL(clicked()), TQT_SLOT(dpmsChanged())); + connect(base->dpmsStandbyTimeout, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dpmsChanged())); + connect(base->dpmsSuspendTimeout, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dpmsChanged())); + connect(base->dpmsPowerDownTimeout, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(dpmsChanged())); connect(base->monitorPhyArrange, TQT_SIGNAL(workspaceRelayoutNeeded()), this, TQT_SLOT(layoutDragDropDisplay())); connect(base->isPrimaryMonitorCB, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); @@ -1014,6 +1021,17 @@ void KDisplayConfig::refreshDisplayedInformation () { updateDisplayedInformation(); updateDragDropDisplay(); + + screendata = m_screenInfoArray.at(0); + base->systemEnableDPMS->setEnabled(screendata->has_dpms); + base->systemEnableDPMS->setChecked(screendata->enable_dpms); + base->systemEnableDPMSStandby->setChecked(screendata->dpms_standby_delay!=0); + base->systemEnableDPMSSuspend->setChecked(screendata->dpms_suspend_delay!=0); + base->systemEnableDPMSPowerDown->setChecked(screendata->dpms_off_delay!=0); + base->dpmsStandbyTimeout->setValue(screendata->dpms_standby_delay/60); + base->dpmsSuspendTimeout->setValue(screendata->dpms_suspend_delay/60); + base->dpmsPowerDownTimeout->setValue(screendata->dpms_off_delay/60); + processDPMSControls(); } void KDisplayConfig::updateDragDropDisplay() { @@ -1322,21 +1340,63 @@ void KDisplayConfig::gammaTargetChanged (int slotNumber) { base->gammaTestImage->setBackgroundPixmap( gammaPixmap ); } +void KDisplayConfig::dpmsChanged() { + SingleScreenData *screendata; + screendata = m_screenInfoArray.at(0); + + processDPMSControls(); + + screendata->enable_dpms = base->systemEnableDPMS->isChecked(); + screendata->dpms_standby_delay = (base->systemEnableDPMSStandby->isChecked())?base->dpmsStandbyTimeout->value()*60:0; + screendata->dpms_suspend_delay = (base->systemEnableDPMSSuspend->isChecked())?base->dpmsSuspendTimeout->value()*60:0; + screendata->dpms_off_delay = (base->systemEnableDPMSPowerDown->isChecked())?base->dpmsPowerDownTimeout->value()*60:0; + + changed(); +} + +void KDisplayConfig::processDPMSControls() { + if (base->systemEnableDPMS->isChecked()) { + base->systemEnableDPMSStandby->setEnabled(true); + base->systemEnableDPMSSuspend->setEnabled(true); + base->systemEnableDPMSPowerDown->setEnabled(true); + base->dpmsStandbyTimeout->setEnabled(base->systemEnableDPMSStandby->isChecked()); + base->dpmsSuspendTimeout->setEnabled(base->systemEnableDPMSSuspend->isChecked()); + base->dpmsPowerDownTimeout->setEnabled(base->systemEnableDPMSPowerDown->isChecked()); + } + else { + base->systemEnableDPMSStandby->setEnabled(false); + base->systemEnableDPMSSuspend->setEnabled(false); + base->systemEnableDPMSPowerDown->setEnabled(false); + base->dpmsStandbyTimeout->setEnabled(false); + base->dpmsSuspendTimeout->setEnabled(false); + base->dpmsPowerDownTimeout->setEnabled(false); + } + + if (base->systemEnableDPMSStandby->isChecked()) base->dpmsSuspendTimeout->setMinValue(base->dpmsStandbyTimeout->value()); + else base->dpmsSuspendTimeout->setMinValue(1); + if (base->systemEnableDPMSSuspend->isChecked()) base->dpmsPowerDownTimeout->setMinValue(base->dpmsSuspendTimeout->value()); + else if (base->systemEnableDPMSStandby->isChecked()) base->dpmsPowerDownTimeout->setMinValue(base->dpmsStandbyTimeout->value()); + else base->dpmsPowerDownTimeout->setMinValue(1); +} + void KDisplayConfig::processLockoutControls() { if (getuid() != 0 || !systemconfig->checkConfigFilesWritable( true )) { base->globalTab->setEnabled(false); base->resolutionTab->setEnabled(false); base->gammaTab->setEnabled(false); + base->powerTab->setEnabled(false); } else { base->globalTab->setEnabled(true); if (base->systemEnableSupport->isChecked()) { base->resolutionTab->setEnabled(true); base->gammaTab->setEnabled(true); + base->powerTab->setEnabled(true); } else { base->resolutionTab->setEnabled(false); base->gammaTab->setEnabled(false); + base->powerTab->setEnabled(false); } } diff --git a/kcontrol/displayconfig/displayconfig.h b/kcontrol/displayconfig/displayconfig.h index cddb8186e..35cf7fa6c 100644 --- a/kcontrol/displayconfig/displayconfig.h +++ b/kcontrol/displayconfig/displayconfig.h @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -122,9 +123,11 @@ private slots: void gammaRedSliderChanged(int index); void gammaGreenSliderChanged(int index); void gammaBlueSliderChanged(int index); - void applyGamma(); + void applyGamma (void); void gammaselectScreen (int slotNumber); void gammaTargetChanged (int slotNumber); + void dpmsChanged (void); + void processDPMSControls (void); }; #endif diff --git a/kcontrol/displayconfig/displayconfigbase.ui b/kcontrol/displayconfig/displayconfigbase.ui index a0d73f4e9..a71dca758 100644 --- a/kcontrol/displayconfig/displayconfigbase.ui +++ b/kcontrol/displayconfig/displayconfigbase.ui @@ -55,6 +55,23 @@ + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + @@ -592,6 +609,155 @@ + + + powerTab + + + Power Management + + + + unnamed + + + + groupPowerManagement + + + Energy Star (DPMS) + + + + unnamed + + + + systemEnableDPMS + + + &Enable DPMS power save modes + + + + + Spacer4 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + systemEnableDPMSStandby + + + Enable &standby after + + + + + dpmsStandbyTimeout + + + 1 + + + 360 + + + + + textLabel9_1 + + + minutes. + + + + + systemEnableDPMSSuspend + + + Enable &suspend after + + + + + dpmsSuspendTimeout + + + 1 + + + 360 + + + + + textLabel9_2 + + + minutes. + + + + + systemEnableDPMSPowerDown + + + Enable &power down after + + + + + dpmsPowerDownTimeout + + + 1 + + + 360 + + + + + textLabel9_3 + + + minutes. + + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + -- cgit v1.2.1