|
Lines 26-31
Link Here
|
| 26 |
#include <tqlabel.h> |
26 |
#include <tqlabel.h> |
| 27 |
#include <tqlayout.h> |
27 |
#include <tqlayout.h> |
| 28 |
#include <tqwhatsthis.h> |
28 |
#include <tqwhatsthis.h> |
|
|
29 |
#include <tqpushbutton.h> |
| 29 |
|
30 |
|
| 30 |
#include <kconfig.h> |
31 |
#include <kconfig.h> |
| 31 |
#include <kcursor.h> |
32 |
#include <kcursor.h> |
|
Lines 36-41
Link Here
|
| 36 |
#include <krun.h> |
37 |
#include <krun.h> |
| 37 |
#include <kstandarddirs.h> |
38 |
#include <kstandarddirs.h> |
| 38 |
#include <kurllabel.h> |
39 |
#include <kurllabel.h> |
|
|
40 |
#include <dcopref.h> |
| 39 |
|
41 |
|
| 40 |
#include <X11/X.h> |
42 |
#include <X11/X.h> |
| 41 |
#include <X11/Xlib.h> |
43 |
#include <X11/Xlib.h> |
|
Lines 140-145
Link Here
|
| 140 |
m_Suspend = DFLT_SUSPEND; |
142 |
m_Suspend = DFLT_SUSPEND; |
| 141 |
m_Off = DFLT_OFF; |
143 |
m_Off = DFLT_OFF; |
| 142 |
m_bDPMS = false; |
144 |
m_bDPMS = false; |
|
|
145 |
m_bKPowersave = false; |
| 143 |
m_bMaintainSanity = true; |
146 |
m_bMaintainSanity = true; |
| 144 |
|
147 |
|
| 145 |
setQuickHelp( i18n("<h1>Display Power Control</h1> If your display supports" |
148 |
setQuickHelp( i18n("<h1>Display Power Control</h1> If your display supports" |
|
Lines 154-159
Link Here
|
| 154 |
#ifdef HAVE_DPMS |
157 |
#ifdef HAVE_DPMS |
| 155 |
int dummy; |
158 |
int dummy; |
| 156 |
m_bDPMS = DPMSQueryExtension(qt_xdisplay(), &dummy, &dummy); |
159 |
m_bDPMS = DPMSQueryExtension(qt_xdisplay(), &dummy, &dummy); |
|
|
160 |
|
| 161 |
DCOPRef kpowersave("kpowersave", "KPowersaveIface"); |
| 162 |
DCOPReply managingDPMS = kpowersave.call("currentSchemeManagesDPMS()"); |
| 163 |
if (managingDPMS.isValid()) { |
| 164 |
m_bKPowersave = managingDPMS; |
| 165 |
m_bDPMS = !m_bKPowersave; |
| 166 |
} |
| 157 |
#endif |
167 |
#endif |
| 158 |
|
168 |
|
| 159 |
TQVBoxLayout *top = new TQVBoxLayout(this, 0, KDialog::spacingHint()); |
169 |
TQVBoxLayout *top = new TQVBoxLayout(this, 0, KDialog::spacingHint()); |
|
Lines 162-175
Link Here
|
| 162 |
|
172 |
|
| 163 |
TQLabel *lbl; |
173 |
TQLabel *lbl; |
| 164 |
if (m_bDPMS) { |
174 |
if (m_bDPMS) { |
| 165 |
m_pCBEnable= new TQCheckBox(i18n("&Enable display power management" ), this); |
175 |
KGlobal::locale()->insertCatalogue("kpowersave"); |
| 166 |
connect(m_pCBEnable, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotChangeEnable(bool))); |
176 |
// ### these i18n strings need to be synced with kpowersave !! |
| 167 |
hbox->addWidget(m_pCBEnable); |
177 |
m_pCBEnable= new TQCheckBox(i18n("&Enable display power management" ), this); |
|
|
178 |
connect(m_pCBEnable, SIGNAL(toggled(bool)), SLOT(slotChangeEnable(bool))); |
| 179 |
hbox->addWidget(m_pCBEnable); |
| 180 |
|
| 168 |
TQWhatsThis::add( m_pCBEnable, i18n("Check this option to enable the" |
181 |
TQWhatsThis::add( m_pCBEnable, i18n("Check this option to enable the" |
| 169 |
" power saving features of your display.") ); |
182 |
" power saving features of your display.") ); |
|
|
183 |
// ### |
| 184 |
} else if(m_bKPowersave) { |
| 185 |
m_pCBEnable = new TQCheckBox(i18n("&Enable specific display power management"), this); |
| 186 |
hbox->addWidget(m_pCBEnable); |
| 187 |
m_bEnabled = false; |
| 188 |
m_pCBEnable->setChecked(true); |
| 189 |
m_pCBEnable->setEnabled(false); |
| 170 |
} else { |
190 |
} else { |
| 171 |
lbl = new TQLabel(i18n("Your display does not support power saving."), this); |
191 |
lbl = new TQLabel(i18n("Your display does not support power saving."), this); |
| 172 |
hbox->addWidget(lbl); |
192 |
hbox->addWidget(lbl); |
| 173 |
} |
193 |
} |
| 174 |
|
194 |
|
| 175 |
KURLLabel *logo = new KURLLabel(this); |
195 |
KURLLabel *logo = new KURLLabel(this); |
|
Lines 183-188
Link Here
|
| 183 |
hbox->addWidget(logo); |
203 |
hbox->addWidget(logo); |
| 184 |
|
204 |
|
| 185 |
// Sliders |
205 |
// Sliders |
|
|
206 |
if (!m_bKPowersave) { |
| 186 |
m_pStandbySlider = new KIntNumInput(m_Standby, this); |
207 |
m_pStandbySlider = new KIntNumInput(m_Standby, this); |
| 187 |
m_pStandbySlider->setLabel(i18n("&Standby after:")); |
208 |
m_pStandbySlider->setLabel(i18n("&Standby after:")); |
| 188 |
m_pStandbySlider->setRange(0, 120, 10); |
209 |
m_pStandbySlider->setRange(0, 120, 10); |
|
Lines 218-223
Link Here
|
| 218 |
" greatest level of power saving that can be achieved while the" |
239 |
" greatest level of power saving that can be achieved while the" |
| 219 |
" display is still physically turned on.") ); |
240 |
" display is still physically turned on.") ); |
| 220 |
|
241 |
|
|
|
242 |
} else { |
| 243 |
m_pStandbySlider = 0; |
| 244 |
m_pSuspendSlider = 0; |
| 245 |
m_pOffSlider = 0; |
| 246 |
QPushButton* btnKPowersave = new QPushButton(this); |
| 247 |
btnKPowersave->setText(i18n("Configure KPowersave...")); |
| 248 |
connect(btnKPowersave, SIGNAL(clicked()), SLOT(slotLaunchKPowersave())); |
| 249 |
top->addWidget(btnKPowersave); |
| 250 |
} |
| 251 |
|
| 221 |
top->addStretch(); |
252 |
top->addStretch(); |
| 222 |
|
253 |
|
| 223 |
if (m_bDPMS) |
254 |
if (m_bDPMS) |
|
Lines 270-276
Link Here
|
| 270 |
|
301 |
|
| 271 |
void KEnergy::readSettings() |
302 |
void KEnergy::readSettings() |
| 272 |
{ |
303 |
{ |
| 273 |
m_bEnabled = m_pConfig->readBoolEntry("displayEnergySaving", false); |
304 |
if (m_bDPMS) { |
|
|
305 |
m_bEnabled = m_pConfig->readBoolEntry("displayEnergySaving", false); |
| 306 |
} |
| 274 |
m_Standby = m_pConfig->readNumEntry("displayStandby", DFLT_STANDBY); |
307 |
m_Standby = m_pConfig->readNumEntry("displayStandby", DFLT_STANDBY); |
| 275 |
m_Suspend = m_pConfig->readNumEntry("displaySuspend", DFLT_SUSPEND); |
308 |
m_Suspend = m_pConfig->readNumEntry("displaySuspend", DFLT_SUSPEND); |
| 276 |
m_Off = m_pConfig->readNumEntry("displayPowerOff", DFLT_OFF); |
309 |
m_Off = m_pConfig->readNumEntry("displayPowerOff", DFLT_OFF); |
|
Lines 298-316
Link Here
|
| 298 |
} |
331 |
} |
| 299 |
|
332 |
|
| 300 |
|
333 |
|
|
|
334 |
void KEnergy::slotLaunchKPowersave() |
| 335 |
{ |
| 336 |
DCOPRef r("kpowersave", "KPowersaveIface"); |
| 337 |
r.send("openConfigureDialog()"); |
| 338 |
} |
| 339 |
|
| 340 |
|
| 301 |
void KEnergy::showSettings() |
341 |
void KEnergy::showSettings() |
| 302 |
{ |
342 |
{ |
| 303 |
m_bMaintainSanity = false; |
343 |
m_bMaintainSanity = false; |
| 304 |
|
344 |
|
| 305 |
if (m_bDPMS) |
345 |
if (m_bDPMS) { |
| 306 |
m_pCBEnable->setChecked(m_bEnabled); |
346 |
m_pCBEnable->setChecked(m_bEnabled); |
|
|
347 |
} |
| 307 |
|
348 |
|
| 308 |
m_pStandbySlider->setEnabled(m_bEnabled); |
349 |
if (!m_bKPowersave) { |
| 309 |
m_pStandbySlider->setValue(m_Standby); |
350 |
m_pStandbySlider->setEnabled(m_bEnabled); |
| 310 |
m_pSuspendSlider->setEnabled(m_bEnabled); |
351 |
m_pStandbySlider->setValue(m_Standby); |
| 311 |
m_pSuspendSlider->setValue(m_Suspend); |
352 |
m_pSuspendSlider->setEnabled(m_bEnabled); |
| 312 |
m_pOffSlider->setEnabled(m_bEnabled); |
353 |
m_pSuspendSlider->setValue(m_Suspend); |
| 313 |
m_pOffSlider->setValue(m_Off); |
354 |
m_pOffSlider->setEnabled(m_bEnabled); |
|
|
355 |
m_pOffSlider->setValue(m_Off); |
| 356 |
} |
| 314 |
|
357 |
|
| 315 |
m_bMaintainSanity = true; |
358 |
m_bMaintainSanity = true; |
| 316 |
} |
359 |
} |