summaryrefslogtreecommitdiffstats
path: root/src/tdepowersave.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tdepowersave.cpp')
-rw-r--r--src/tdepowersave.cpp493
1 files changed, 308 insertions, 185 deletions
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index e3f6ce5..a08e8de 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -19,6 +19,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <math.h>
+
// KDE headers:
#include <tdeaboutapplication.h>
#include <tdeapplication.h>
@@ -30,7 +36,7 @@
#include <knotifydialog.h>
#include <kpassivepopup.h>
#include <tdepopupmenu.h>
-#include <kglobalaccel.h>
+#include <tdeglobalaccel.h>
#include <khelpmenu.h>
// other TQt headers:
@@ -75,12 +81,12 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
config->writeEntry("AlreadyStarted", true);
// check whether APM, ACPI, PMU, CPUFreq or Suspend2Disk/ram supported, otherwise end up
// and don't start tdepowersave ever again until force_acpi_check == true.
- if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() &&
- !hwinfo->supportCPUFreq() && !suspend.suspend2disk && !suspend.suspend2ram){
+ if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && !hwinfo->supportCPUFreq() &&
+ !suspend.suspend2disk && !suspend.suspend2ram && !suspend.suspend_hybrid) {
config->writeEntry("Autostart", false);
config->sync();
- kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk nor "
- << "Suspend2RAM. Please close tdepowersave now." << endl;
+ kdError() << "This machine does not support ACPI, APM, PMU, CPUFreq, Suspend2Disk, "
+ << "Suspend2RAM nor Hybrid Suspend. Please close tdepowersave now." << endl;
exit(-1);
}
}
@@ -97,33 +103,33 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
settings->batteryCriticalLevel);
// connect to signals for changes
- connect(hwinfo, TQT_SIGNAL(generalDataChanged()), this, TQT_SLOT(update()));
- connect(hwinfo, TQT_SIGNAL(primaryBatteryChanged()), this, TQT_SLOT(update()));
- connect(hwinfo, TQT_SIGNAL(ACStatus(bool)), this, TQT_SLOT(handleACStatusChange (bool)));
- connect(hwinfo, TQT_SIGNAL(resumed(int)), this, TQT_SLOT(forwardResumeSignal(int)));
+ connect(hwinfo, TQ_SIGNAL(generalDataChanged()), this, TQ_SLOT(update()));
+ connect(hwinfo, TQ_SIGNAL(primaryBatteryChanged()), this, TQ_SLOT(update()));
+ connect(hwinfo, TQ_SIGNAL(ACStatus(bool)), this, TQ_SLOT(handleACStatusChange (bool)));
+ connect(hwinfo, TQ_SIGNAL(resumed(int)), this, TQ_SLOT(forwardResumeSignal(int)));
// connect to error messages
- connect(autoSuspend, TQT_SIGNAL(displayErrorMsg(TQString)), this, TQT_SLOT(showErrorMessage(TQString)));
+ connect(autoSuspend, TQ_SIGNAL(displayErrorMsg(TQString)), this, TQ_SLOT(showErrorMessage(TQString)));
// connect to events
- connect(hwinfo, TQT_SIGNAL(lidclosetStatus(bool)), this, TQT_SLOT(handleLidEvent(bool)));
- connect(hwinfo, TQT_SIGNAL(powerButtonPressed()), this, TQT_SLOT (handlePowerButtonEvent()));
- connect(hwinfo, TQT_SIGNAL(sleepButtonPressed()), this, TQT_SLOT (handleSleepButtonEvent()));
- connect(hwinfo, TQT_SIGNAL(s2diskButtonPressed()), this, TQT_SLOT (handleS2DiskButtonEvent()));
- connect(hwinfo, TQT_SIGNAL(batteryWARNState(int,int)), this, TQT_SLOT(notifyBatteryStatusChange (int,int)));
- connect(hwinfo, TQT_SIGNAL(desktopSessionIsActive(bool)), this, TQT_SLOT (handleSessionState(bool)));
- connect(autoSuspend, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_autosuspendWarn()));
- connect(autoDimm, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_downDimm()));
- connect(autoDimm, TQT_SIGNAL(UserIsActiveAgain()), this, TQT_SLOT(do_upDimm()));
+ connect(hwinfo, TQ_SIGNAL(lidclosetStatus(bool)), this, TQ_SLOT(handleLidEvent(bool)));
+ connect(hwinfo, TQ_SIGNAL(powerButtonPressed()), this, TQ_SLOT (handlePowerButtonEvent()));
+ connect(hwinfo, TQ_SIGNAL(sleepButtonPressed()), this, TQ_SLOT (handleSuspendButtonEvent()));
+ connect(hwinfo, TQ_SIGNAL(s2diskButtonPressed()), this, TQ_SLOT (handleS2DiskButtonEvent()));
+ connect(hwinfo, TQ_SIGNAL(batteryWARNState(int,int)), this, TQ_SLOT(notifyBatteryStatusChange (int,int)));
+ connect(hwinfo, TQ_SIGNAL(desktopSessionIsActive(bool)), this, TQ_SLOT (handleSessionState(bool)));
+ connect(autoSuspend, TQ_SIGNAL(inactivityTimeExpired()), this, TQ_SLOT(do_autosuspendWarn()));
+ connect(autoDimm, TQ_SIGNAL(inactivityTimeExpired()), this, TQ_SLOT(do_downDimm()));
+ connect(autoDimm, TQ_SIGNAL(UserIsActiveAgain()), this, TQ_SLOT(do_upDimm()));
// connect to hotkeys
- m_globalAccel = new TDEGlobalAccel( TQT_TQOBJECT(this) );
+ m_globalAccel = new TDEGlobalAccel( this );
m_globalAccel->insert( "Power button", i18n( "Execute configured power button action"), TQString(),
- TDEShortcut(TQString("XF86PowerOff")), TDEShortcut(TQString("XF86PowerOff")), TQT_TQOBJECT(this), TQT_SLOT( handlePowerButtonEvent() ) );
- m_globalAccel->insert( "Sleep button", i18n( "Sleep configured power button action"), TQString(),
- TDEShortcut(TQString("XF86Sleep")), TDEShortcut(TQString("XF86Sleep")), TQT_TQOBJECT(this), TQT_SLOT( handleSleepButtonEvent() ) );
+ TDEShortcut(TQString("XF86PowerOff")), TDEShortcut(TQString("XF86PowerOff")), this, TQ_SLOT( handlePowerButtonEvent() ) );
+ m_globalAccel->insert( "Suspend button", i18n( "Suspend configured power button action"), TQString(),
+ TDEShortcut(TQString("XF86Suspend")), TDEShortcut(TQString("XF86Suspend")), this, TQ_SLOT( handleSuspendButtonEvent() ) );
m_globalAccel->insert( "Hibernate button", i18n( "Hibernate configured power button action"), TQString(),
- TDEShortcut(TQString("XF86Suspend")), TDEShortcut(TQString("XF86Suspend")), TQT_TQOBJECT(this), TQT_SLOT( handleS2DiskButtonEvent() ) );
+ TDEShortcut(TQString("XF86Suspend")), TDEShortcut(TQString("XF86Suspend")), this, TQ_SLOT( handleS2DiskButtonEvent() ) );
m_globalAccel->readSettings();
m_globalAccel->updateConnections();
@@ -142,9 +148,10 @@ tdepowersave::tdepowersave( bool force_acpi_check, bool trace_func ) : KSystemTr
suspendType = "NULL";
BAT_WARN_ICON_Timer = new TQTimer(this);
- connect(BAT_WARN_ICON_Timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(do_setIconBG()));
+ connect(BAT_WARN_ICON_Timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(do_setIconBG()));
- AUTODIMM_Timer = new TQTimer(this);
+ m_autoDimmTimer = new TQTimer(this);
+ connect(m_autoDimmTimer, TQ_SIGNAL(timeout()), this, TQ_SLOT(do_dimm()));
initMenu();
update();
@@ -163,6 +170,7 @@ tdepowersave::~tdepowersave(){
delete display;
delete settings;
delete autoSuspend;
+ delete m_autoDimmTimer;
#ifdef ENABLE_YAST_ENTRY
delete yast2;
#endif
@@ -176,29 +184,27 @@ void tdepowersave::initMenu() {
CONFIGURE_ID = this->contextMenu()->insertItem(SmallIcon("configure", TQIconSet::Automatic),
i18n("Configure TDEPowersave..."),
- this, TQT_SLOT(showConfigureDialog()));
+ this, TQ_SLOT(showConfigureDialog()));
CONFIGURE_EVENTS_ID = this->contextMenu()->insertItem(SmallIcon("knotify", TQIconSet::Automatic),
i18n("Configure Notifications..."),
- this, TQT_SLOT(showConfigureNotificationsDialog()));
+ this, TQ_SLOT(showConfigureNotificationsDialog()));
#ifdef ENABLE_YAST_ENTRY
YAST_MODULE_MENU_ID = this->contextMenu()->insertItem(SmallIcon("yast", TQIconSet::Automatic),
i18n("Start YaST2 Power Management Module..."),
- this, TQT_SLOT(do_config()));
+ this, TQ_SLOT(do_config()));
#endif
SLEEP_SEPARATOR_MENU_ID = this->contextMenu()->insertSeparator();
- SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
- TQIconSet::Automatic),
- i18n("Suspend to Disk"), this,
- TQT_SLOT(do_suspend2disk()));
- SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram",
- TQIconSet::Automatic),
- i18n("Suspend to RAM"), this,
- TQT_SLOT(do_suspend2ram()));
FREEZE_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", TQIconSet::Automatic),
- i18n("Freeze"), this, TQT_SLOT(do_freeze()));
+ i18n("Freeze"), this, TQ_SLOT(do_freeze()));
STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic),
- i18n("Standby"), this, TQT_SLOT(do_standby()));
+ i18n("Standby"), this, TQ_SLOT(do_standby()));
+ SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram",
+ TQIconSet::Automatic), i18n("Suspend"), this, TQ_SLOT(do_suspend2ram()));
+ SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
+ TQIconSet::Automatic), i18n("Hibernate"), this, TQ_SLOT(do_suspend2disk()));
+ SUSPEND_HYBRID_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
+ TQIconSet::Automatic), i18n("Hybrid Suspend"), this, TQ_SLOT(do_suspend_hybrid()));
speed_menu = new TQPopupMenu(this, i18n("Set CPU Frequency Policy").utf8());
speed_menu->insertItem(i18n("Performance"), PERFORMANCE);
@@ -208,21 +214,21 @@ void tdepowersave::initMenu() {
CPUFREQ_SEPARATOR_MENU_ID = contextMenu()->insertSeparator();
CPUFREQ_MENU_ID = contextMenu()->insertItem(i18n("Set CPU Frequency Policy"), speed_menu);
- connect(speed_menu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(do_setSpeedPolicy(int)));
- connect(hwinfo, TQT_SIGNAL(currentCPUFreqPolicyChanged()), this, TQT_SLOT(updateCPUFreqMenu()));
+ connect(speed_menu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(do_setSpeedPolicy(int)));
+ connect(hwinfo, TQ_SIGNAL(currentCPUFreqPolicyChanged()), this, TQ_SLOT(updateCPUFreqMenu()));
SCHEME_SEPARATOR_MENU_ID = contextMenu()->insertSeparator();
scheme_menu = new TQPopupMenu(this, i18n("Set Active Scheme").utf8());
SCHEME_MENU_ID = contextMenu()->insertItem(i18n("Set Active Scheme"), scheme_menu);
- connect(scheme_menu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(do_setActiveScheme(int)));
+ connect(scheme_menu, TQ_SIGNAL(activated(int)), this, TQ_SLOT(do_setActiveScheme(int)));
// menu entry for the autosuspend disable checkbox, disabled by default, only
// displayed if autosuspend for the current scheme is activated
AUTOSUSPEND_SEPARATOR_MENU_ID = contextMenu()->insertSeparator();
AUTOSUSPEND_MENU_ID = this->contextMenu()->insertItem( i18n("Disable Actions on Inactivity"),
- this,TQT_SLOT(do_setAutosuspend()));
+ this,TQ_SLOT(do_setAutosuspend()));
this->contextMenu()->setItemVisible(AUTOSUSPEND_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(AUTOSUSPEND_MENU_ID, false);
@@ -231,10 +237,10 @@ void tdepowersave::initMenu() {
// Create help submenu
KHelpMenu *m_help = new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection());
TDEPopupMenu *help = m_help->menu();
- help->connectItem(KHelpMenu::menuHelpContents, this, TQT_SLOT(slotHelpContents()));
+ help->connectItem(KHelpMenu::menuHelpContents, this, TQ_SLOT(slotHelpContents()));
this->contextMenu()->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), help);
- connect(this, TQT_SIGNAL(quitSelected()), this, TQT_SLOT(_quit()));
+ connect(this, TQ_SIGNAL(quitSelected()), this, TQ_SLOT(_quit()));
kdDebugFuncOut(trace);
}
@@ -280,9 +286,9 @@ void tdepowersave::showConfigureDialog() {
configDlg = new ConfigureDialog(config, hwinfo, settings);
configDlg->show();
config_dialog_shown = true;
- connect(configDlg, TQT_SIGNAL(destroyed()), this, TQT_SLOT(observeConfigDlg()));
- connect(configDlg, TQT_SIGNAL(openHelp()), this, TQT_SLOT(slotHelp()));
- connect(configDlg, TQT_SIGNAL(openKNotify()), this, TQT_SLOT(showConfigureNotificationsDialog()));
+ connect(configDlg, TQ_SIGNAL(destroyed()), this, TQ_SLOT(observeConfigDlg()));
+ connect(configDlg, TQ_SIGNAL(openHelp()), this, TQ_SLOT(slotHelp()));
+ connect(configDlg, TQ_SIGNAL(openKNotify()), this, TQ_SLOT(showConfigureNotificationsDialog()));
}
else {
KPassivePopup::message(i18n("WARNING"), i18n("Cannot find any schemes."),
@@ -290,7 +296,7 @@ void tdepowersave::showConfigureDialog() {
i18n("Warning").utf8(), 15000);
}
} else {
- configDlg->setWindowState((configDlg->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
+ configDlg->setWindowState((configDlg->windowState() & ~TQt::WindowMinimized) | TQt::WindowActive);
configDlg->setActiveWindow();
}
@@ -514,7 +520,7 @@ void tdepowersave::updateTooltip(){
}
/*!
- * \b TQT_SLOT to starts the Yast2-power-management module. This called by the menuentry
+ * \b Slot to starts the Yast2-power-management module. This called by the menuentry
* with ID \ref YAST_MODULE_MENU_ID, named "Start YaST2 Power Management Module".
* It create a new TDEProcess and execute "/sbin/yast2 power-management" with tdesu.
*/
@@ -527,8 +533,8 @@ void tdepowersave::do_config(){
yast2 = new TDEProcess;
*yast2 << "tdesu" << "--nonewdcop" << "/sbin/yast2" << "power-management";
- connect(yast2, TQT_SIGNAL(processExited(TDEProcess *)),
- TQT_SLOT(slotConfigProcessExited(TDEProcess *)));
+ connect(yast2, TQ_SIGNAL(processExited(TDEProcess *)),
+ TQ_SLOT(slotConfigProcessExited(TDEProcess *)));
if(!yast2->start(TDEProcess::NotifyOnExit))
{
delete yast2;
@@ -543,15 +549,15 @@ void tdepowersave::do_config(){
}
/*!
- * \b TQT_SLOT to open the tdepowersave help
+ * \b Slot to open the tdepowersave help
*/
void tdepowersave::slotHelp()
{
- kapp->invokeHelp( "", "tdepowersave" );
+ tdeApp->invokeHelp( "", "tdepowersave" );
}
/*!
- * \b TQT_SLOT to open the tdepowersave About dialog
+ * \b Slot to open the tdepowersave About dialog
*/
void tdepowersave::slotAbout()
{
@@ -560,7 +566,7 @@ void tdepowersave::slotAbout()
}
/*!
- * \b TQT_SLOT to set the icon background on/off if battery is in critical, low or warning-state. Within
+ * \b Slot to set the icon background on/off if battery is in critical, low or warning-state. Within
* this function we set \ref icon_state_changed to true and call \ref redrawPixmap() to redraw the
* kickerapplet icon and create a icon with blinking background. \n \n
* The slot called by the TQTimer \ref BAT_WARN_ICON_Timer . The interval of the timer is defined
@@ -576,7 +582,7 @@ void tdepowersave::do_setIconBG(){
}
/*!
- * \b TQT_SLOT to enable/disable the autosuspend.
+ * \b Slot to enable/disable the autosuspend.
*/
void tdepowersave::do_setAutosuspend(){
kdDebugFuncIn(trace);
@@ -601,7 +607,7 @@ void tdepowersave::do_setAutosuspend(){
}
/*!
- * \b TQT_SLOT which called if the \ref configDlg is destroyed. We set within this SLOT
+ * \b Slot which called if the \ref configDlg is destroyed. We set within this slot
* \ref config_dialog_shown to false.
* TODO: check if we maybe should force here the current default scheme depending on the AC/battery state
*/
@@ -627,7 +633,7 @@ void tdepowersave::observeConfigDlg(){
}
/*!
- * \b TQT_SLOT which called from \ref do_config() if the 'tdesu yast2' TDEProcess exited.
+ * \b Slot which called from \ref do_config() if the 'tdesu yast2' TDEProcess exited.
* This function control the return value and display if needed a errormessage on failure.
*/
void tdepowersave::slotConfigProcessExited(TDEProcess *proc){
@@ -658,8 +664,8 @@ void tdepowersave::slotConfigProcessExited(TDEProcess *proc){
}
/*!
- * \b TQT_SLOT to send the command for "suspend to disk" to TDE hardware library.
- * If there is a error while "suspend to disk" the user get e messagebox.
+ * \b Slot to send the command for "suspend to disk" to TDE hardware library.
+ * If there is a error while "suspend to disk" the user get a messagebox.
* This function need a power management backend in TDE hardware library for "suspend to disk".
* \return boolean with the result of the operation
* \retval true if successful
@@ -691,7 +697,7 @@ bool tdepowersave::do_suspend2disk(){
kdDebugFuncOut(trace);
return true;
} else {
- KPassivePopup::message( i18n("WARNING"),i18n("Suspend to disk failed"),
+ KPassivePopup::message( i18n("WARNING"),i18n("Hibernation failed"),
SmallIcon("messagebox_warning", 20), this,
i18n("Warning").utf8(), 15000);
kdDebugFuncOut(trace);
@@ -699,7 +705,7 @@ bool tdepowersave::do_suspend2disk(){
}
} else {
KPassivePopup::message( i18n("WARNING"),
- i18n("Suspend to disk disabled by administrator."),
+ i18n("Hibernation disabled by administrator."),
SmallIcon("messagebox_warning", 20),
this, i18n("Warning").utf8(), 15000);
this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false);
@@ -707,14 +713,70 @@ bool tdepowersave::do_suspend2disk(){
return false;
}
} else {
- kdWarning() << "This machine does not provide suspend to disk state" << endl;
+ kdWarning() << "This machine does not provide hibernation state" << endl;
kdDebugFuncOut(trace);
return false;
}
}
/*!
- * \b TQT_SLOT to send the command for "suspend to RAM" to the TDE hardware library.
+ * \b Slot to send the command for "hybrid suspend" to TDE hardware library.
+ * If there is a error while "hybrid suspend" the user get a messagebox.
+ * This function need a power management backend in TDE hardware library for "hybrid suspend".
+ * \return boolean with the result of the operation
+ * \retval true if successful
+ * \retval false if command not supported or if powersaved not running
+ */
+bool tdepowersave::do_suspend_hybrid(){
+ kdDebugFuncIn(trace);
+
+ if (suspend.suspend_hybrid) {
+ if (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1) {
+ calledSuspend = SUSPEND_HYBRID;
+ if (!handleMounts(true)) {
+ kdWarning() << "Could not umount ..." << endl;
+ calledSuspend = -1;
+ kdDebugFuncOut(trace);
+ return false;
+ }
+
+ if(settings->lockOnSuspend) {
+ display->lockScreen( settings->lockmethod );
+ }
+
+ autoSuspend->stop();
+ autoDimm->stop();
+ notifySuspend(calledSuspend);
+ bool ret = hwinfo->suspend(SUSPEND_HYBRID);
+
+ if (ret) {
+ kdDebugFuncOut(trace);
+ return true;
+ } else {
+ KPassivePopup::message( i18n("WARNING"),i18n("Hybrid Suspend failed"),
+ SmallIcon("messagebox_warning", 20), this,
+ i18n("Warning").utf8(), 15000);
+ kdDebugFuncOut(trace);
+ return false;
+ }
+ } else {
+ KPassivePopup::message( i18n("WARNING"),
+ i18n("Hybrid Suspend disabled by administrator."),
+ SmallIcon("messagebox_warning", 20),
+ this, i18n("Warning").utf8(), 15000);
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, false);
+ kdDebugFuncOut(trace);
+ return false;
+ }
+ } else {
+ kdWarning() << "This machine does not provide hybrid suspend state" << endl;
+ kdDebugFuncOut(trace);
+ return false;
+ }
+}
+
+/*!
+ * \b Slot to send the command for "suspend to RAM" to the TDE hardware library.
* If there is a error while "suspend to RAM" the user get a messagebox.
* This function need a power management backend in TDE hardware library for "suspend to RAM".
* \return boolean with the result of the operation
@@ -747,7 +809,7 @@ bool tdepowersave::do_suspend2ram(){
kdDebugFuncOut(trace);
return true;
} else {
- KPassivePopup::message( i18n("WARNING"),i18n("Suspend to RAM failed"),
+ KPassivePopup::message( i18n("WARNING"),i18n("Suspend mode failed"),
SmallIcon("messagebox_warning", 20), this,
i18n("Warning").utf8(), 15000);
kdDebugFuncOut(trace);
@@ -755,7 +817,7 @@ bool tdepowersave::do_suspend2ram(){
}
} else {
KPassivePopup::message( i18n("WARNING"),
- i18n("Suspend to RAM disabled by administrator."),
+ i18n("Suspend mode disabled by administrator."),
SmallIcon("messagebox_warning", 20), this,
i18n("Warning").utf8(), 15000);
this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, false);
@@ -763,14 +825,14 @@ bool tdepowersave::do_suspend2ram(){
return false;
}
} else {
- kdWarning() << "This machine does not provide suspend to ram state" << endl;
+ kdWarning() << "This machine does not provide Suspend state" << endl;
kdDebugFuncOut(trace);
return false;
}
}
/*!
- * \b TQT_SLOT to send the command for "freeze" to the TDE hardware library.
+ * \b Slot to send the command for "freeze" to the TDE hardware library.
* If there is a error while "freeze" the user get e messagebox.
* This function need a power management backend in TDE hardware library for "freeze".
* \return boolean with the result of the operation
@@ -825,7 +887,7 @@ bool tdepowersave::do_freeze(){
}
/*!
- * \b TQT_SLOT to send the command for "stand-by" to the TDE hardware library.
+ * \b Slot to send the command for "stand-by" to the TDE hardware library.
* If there is a error while "stand-by" the user get e messagebox.
* This function need a power management backend in TDE hardware library for "stand-by".
* \return boolean with the result of the operation
@@ -880,7 +942,7 @@ bool tdepowersave::do_standby(){
}
/*!
- * \b TQT_SLOT to send check if we should display the warning dialog and display
+ * \b Slot to send check if we should display the warning dialog and display
* the dialog if needed or call directly autosuspend after the signal
* \ref autosuspend::inactivityTimeExpired was recieved.
*/
@@ -890,12 +952,17 @@ void tdepowersave::do_autosuspendWarn() {
// Verify that the desired suspend action is allowed before displaying the dialog
SuspendStates suspend = hwinfo->getSuspendSupport();
bool allowed = false;
- if(settings->autoInactiveAction == "Suspend to Disk") {
+ if(settings->autoInactiveAction == "Hibernate") {
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
allowed = true;
}
}
- else if (settings->autoInactiveAction == "Suspend to RAM") {
+ else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Suspend") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true;
}
@@ -919,9 +986,11 @@ void tdepowersave::do_autosuspendWarn() {
countdown = new countDownDialog(settings->autoSuspendCountdownTimeout);
- if(settings->autoInactiveAction == "Suspend to Disk") {
+ if(settings->autoInactiveAction == "Hibernate") {
+ countdown->setPixmap("suspend2disk");
+ } else if(settings->autoInactiveAction == "Hybrid Suspend") {
countdown->setPixmap("suspend2disk");
- } else if (settings->autoInactiveAction == "Suspend to RAM") {
+ } else if (settings->autoInactiveAction == "Suspend") {
countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Freeze") {
countdown->setPixmap("suspend2ram");
@@ -939,7 +1008,7 @@ void tdepowersave::do_autosuspendWarn() {
countdown->setMessageText(message);
- connect(countdown, TQT_SIGNAL(dialogClosed(bool)), this, TQT_SLOT(do_autosuspend(bool)));
+ connect(countdown, TQ_SIGNAL(dialogClosed(bool)), this, TQ_SLOT(do_autosuspend(bool)));
countdown->showDialog();
}
}
@@ -953,7 +1022,7 @@ void tdepowersave::do_autosuspendWarn() {
}
/*!
- * \b TQT_SLOT to send the related suspend command for autosuspend
+ * \b Slot to send the related suspend command for autosuspend
* \param cancel boolean with info if the autosuspend should get canceled
* \return boolean with the result of the operation
* \retval true if successful
@@ -963,8 +1032,6 @@ void tdepowersave::do_autosuspendWarn() {
*/
bool tdepowersave::do_autosuspend(bool cancel) {
kdDebugFuncIn(trace);
-
- // TODO: check if this is really needed, it get called also on the suspend methodes
autoSuspend->stop();
if (!cancel) {
@@ -974,9 +1041,11 @@ bool tdepowersave::do_autosuspend(bool cancel) {
}
if(settings->autoSuspend && !contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) {
- if(settings->autoInactiveAction == "Suspend to Disk") {
+ if(settings->autoInactiveAction == "Hibernate") {
return do_suspend2disk();
- } else if (settings->autoInactiveAction == "Suspend to RAM") {
+ } else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ return do_suspend_hybrid();
+ } else if (settings->autoInactiveAction == "Suspend") {
return do_suspend2ram();
} else if (settings->autoInactiveAction == "Freeze") {
return do_freeze();
@@ -996,7 +1065,7 @@ bool tdepowersave::do_autosuspend(bool cancel) {
}
/*!
- * \b TQT_SLOT to dimm the display down to the configured level if the signal
+ * \b Slot to dimm the display down to the configured level if the signal
* \ref autodimm::inactivityTimeExpired was recieved.
* \param
* \return boolean with the result of the operation
@@ -1007,25 +1076,22 @@ void tdepowersave::do_downDimm() {
kdDebugFuncIn(trace);
if (hwinfo->supportBrightness()) {
- if (!AUTODIMM_Timer->isActive()) {
- int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->autoDimmTo/100.0));
+ if (!m_autoDimmTimer->isActive()) {
+ int dimmToLevel = (int)round(hwinfo->getMaxBrightnessLevel() * settings->autoDimmTo / 100.0);
// check if we really need to dimm down
if (dimmToLevel < hwinfo->getCurrentBrightnessLevel()) {
- int steps = hwinfo->getCurrentBrightnessLevel() - dimmToLevel;
- int timePerStep = (1500 / steps);
-
+ m_dimmRequestedLevel = dimmToLevel;
+ m_dimmStep = (hwinfo->getCurrentBrightnessLevel() - dimmToLevel) / 10 + 1;
+ m_dimmTimeoutCounter = 0;
autoDimmDown = true;
-
- AUTODIMM_Timer = new TQTimer(this);
- connect(AUTODIMM_Timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(do_dimm()));
- AUTODIMM_Timer->start(timePerStep, false);
+ m_autoDimmTimer->start(100, false);
} else {
kdWarning() << "Don't dimm down, current level is already lower than requested Level" << endl;
}
} else {
// wait until the timer is stopped, try later!
- TQTimer::singleShot(1500, this, TQT_SLOT(do_downDimm()));
+ TQTimer::singleShot(2000, this, TQ_SLOT(do_downDimm()));
}
}
@@ -1033,7 +1099,7 @@ void tdepowersave::do_downDimm() {
}
/*!
- * \b TQT_SLOT to dimm the display up to the configured level if the signal
+ * \b Slot to dimm the display up to the configured level if the signal
* \ref autodimm::UserIsActiveAgain was recieved.
* \param
* \return boolean with the result of the operation
@@ -1046,28 +1112,24 @@ void tdepowersave::do_upDimm() {
//NOTE we go back to the value of the scheme and not the last on, to reduce trouble with the scheme
if (hwinfo->supportBrightness()) {
- if (!AUTODIMM_Timer->isActive()) {
- int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->brightnessValue/100.0));
+ if (!m_autoDimmTimer->isActive()) {
+ int dimmToLevel = (int)round(hwinfo->getMaxBrightnessLevel() * settings->brightnessValue / 100.0);
// check if we really need to dimm up
if (dimmToLevel > hwinfo->getCurrentBrightnessLevel()) {
- int steps = dimmToLevel - hwinfo->getCurrentBrightnessLevel();
- int timePerStep = (750 / steps);
-
+ m_dimmRequestedLevel = dimmToLevel;
+ m_dimmStep = (dimmToLevel - hwinfo->getCurrentBrightnessLevel()) / 10 + 1;
+ m_dimmTimeoutCounter = 0;
autoDimmDown = false;
-
- AUTODIMM_Timer = new TQTimer(this);
- connect(AUTODIMM_Timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(do_dimm()));
- AUTODIMM_Timer->start(timePerStep, false);
-
- // start autodimm again
- setAutoDimm(false);
+ m_autoDimmTimer->start(100, false);
} else {
kdWarning() << "Don't dimm up, current level is already above requested Level" << endl;
}
+ // start autodimm again
+ setAutoDimm(false);
} else {
// wait until the timer is stopped, try later!
- TQTimer::singleShot(750, this, TQT_SLOT(do_downDimm()));
+ TQTimer::singleShot(2000, this, TQ_SLOT(do_downDimm()));
}
}
@@ -1076,7 +1138,7 @@ void tdepowersave::do_upDimm() {
/*!
- * \b TQT_SLOT to dimm the display down
+ * \b Slot to dimm the display down
* \return boolean with the result of the operation
* \retval true if successful
* \retval false else
@@ -1084,15 +1146,22 @@ void tdepowersave::do_upDimm() {
void tdepowersave::do_dimm() {
kdDebugFuncIn(trace);
+ if (m_dimmStep <= 0 || m_dimmTimeoutCounter > 30)
+ {
+ m_autoDimmTimer->stop();
+ return;
+ }
+
+ ++m_dimmTimeoutCounter;
int current = hwinfo->getCurrentBrightnessLevel();
if (autoDimmDown) {
// dimm the display down
- if (current > 0 &&
- current > ((int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->autoDimmTo/100.0))-1)) {
- hwinfo->setBrightness((current -1) , -1);
+ if (current > 0 && current > (m_dimmRequestedLevel * 1.005)) {
+ hwinfo->setBrightnessLevel(current - m_dimmStep);
} else {
- AUTODIMM_Timer->stop();
+ m_autoDimmTimer->stop();
+ m_dimmStep = 0;
// start checking if the user get active again
// NOTE: we start this here because the X-Server detect brightness changes as
@@ -1101,10 +1170,11 @@ void tdepowersave::do_dimm() {
}
} else {
// dimm the display up
- if (current < ((int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->brightnessValue/100.0))-1)) {
- hwinfo->setBrightness((current +1) , -1);
+ if (current < (m_dimmRequestedLevel * 0.995)) {
+ hwinfo->setBrightnessLevel(current + m_dimmStep);
} else {
- AUTODIMM_Timer->stop();
+ m_autoDimmTimer->stop();
+ m_dimmStep = 0;
}
}
@@ -1208,7 +1278,7 @@ void tdepowersave::handlePowerButtonEvent( ) {
/*!
* Handle the event for the suspend2ram/sleep button and call the related action.
*/
-void tdepowersave::handleSleepButtonEvent() {
+void tdepowersave::handleSuspendButtonEvent() {
kdDebugFuncIn(trace);
// Only go to suspend on button event if we already resumed successful.
@@ -1234,7 +1304,7 @@ void tdepowersave::handleS2DiskButtonEvent() {
}
/*!
- * \b TQT_SLOT to handle the lidclose event. If the screen get locked
+ * \b Slot to handle the lidclose event. If the screen get locked
* depends on the user specific settings.
* \param closed boolean with info if the lid is closed or not
*/
@@ -1292,7 +1362,7 @@ void tdepowersave::handleLidEvent( bool closed ){
}
/*!
- * \b TQT_SLOT to show the login dialog if the desktop was locked before the suspend.
+ * \b Slot to show the login dialog if the desktop was locked before the suspend.
*/
void tdepowersave::activateLoginScreen(){
kdDebugFuncIn(trace);
@@ -1302,14 +1372,14 @@ void tdepowersave::activateLoginScreen(){
settings->load_general_settings();
if(settings->timeToFakeKeyAfterLock >= 0) {
- TQTimer::singleShot(settings->timeToFakeKeyAfterLock, display, TQT_SLOT(fakeShiftKeyEvent()));
+ TQTimer::singleShot(settings->timeToFakeKeyAfterLock, display, TQ_SLOT(fakeShiftKeyEvent()));
}
kdDebugFuncOut(trace);
}
/*!
- * \b TQT_SLOT to set the current suspend type for later use.
+ * \b Slot to set the current suspend type for later use.
*/
void tdepowersave::setSuspendType( TQString suspendtype){
kdDebugFuncIn(trace);
@@ -1320,7 +1390,7 @@ void tdepowersave::setSuspendType( TQString suspendtype){
}
/*!
- * \b TQT_SLOT which called if tdepowersave is exited by the user. In this case the user
+ * \b Slot which called if tdepowersave is exited by the user. In this case the user
* is asked through a yes/no box if "tdepowersave start automatically on log in" and the
* result is written to the KDE configfile.
*/
@@ -1365,7 +1435,7 @@ void tdepowersave::_quit (){
}
/*!
- * \b TQT_SLOT called if the user select a 'CPU Frequency Policy' from the menu ( \ref CPUFREQ_MENU_ID ).
+ * \b Slot called if the user select a 'CPU Frequency Policy' from the menu ( \ref CPUFREQ_MENU_ID ).
*/
void tdepowersave::do_setSpeedPolicy(int menu_id){
if (trace) kdDebug() << funcinfo << "IN: " << "menu_id/set policy to: " << menu_id << endl;
@@ -1383,7 +1453,7 @@ void tdepowersave::do_setSpeedPolicy(int menu_id){
}
/*!
- * \b TQT_SLOT called if the user select a scheme from the menu. If there is any errormessage
+ * \b Slot called if the user select a scheme from the menu. If there is any errormessage
* while try to set the selected scheme, the user get a messagebox with info.
*/
void tdepowersave::do_setActiveScheme( int i ){
@@ -1424,10 +1494,11 @@ void tdepowersave::update(){
redraw_pixmap = 1;
}
if (!hwinfo->isOnline()){
- this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
- this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, false);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, false);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, false);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, false);
@@ -1447,10 +1518,11 @@ void tdepowersave::update(){
hwinfo->update_info_cpufreq_policy_changed = true;
suspend = hwinfo->getSuspendSupport();
}
- this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, true);
- this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, true);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, true);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, true);
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, true);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_MENU_ID, true);
@@ -1468,6 +1540,16 @@ void tdepowersave::update(){
this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false);
}
+ if (suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed ||
+ suspend.suspend_hybrid_allowed == -1)) {
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, true);
+ } else {
+ if (!suspend.suspend_hybrid)
+ this->contextMenu()->setItemVisible(SUSPEND_HYBRID_MENU_ID, false);
+ else
+ this->contextMenu()->setItemEnabled(SUSPEND_HYBRID_MENU_ID, false);
+ }
+
if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)) {
this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, true);
@@ -1683,7 +1765,7 @@ void tdepowersave::wheelEvent (TQWheelEvent *qwe)
if (!hwinfo->supportBrightness() && settings->brightness)
return;
- if (qwe->orientation () == Qt::Vertical) {
+ if (qwe->orientation () == TQt::Vertical) {
if (qwe->delta() > 0) {
do_brightnessUp(5);
} else {
@@ -1705,10 +1787,10 @@ void tdepowersave::mousePressEvent(TQMouseEvent *qme){
KSystemTray::mousePressEvent(qme);
if (hwinfo->isOnline()) {
- if (qme->button() == Qt::RightButton){
+ if (qme->button() == TQt::RightButton){
// TODO check if maybe some rechecks needed
this->contextMenu()->exec(TQCursor::pos());
- } else if (qme->button() == Qt::LeftButton) {
+ } else if (qme->button() == TQt::LeftButton) {
showDetailedDialog();
}
}
@@ -1717,7 +1799,7 @@ void tdepowersave::mousePressEvent(TQMouseEvent *qme){
}
/*!
- * \b TQT_SLOT called if the detaileddialog is closed. With this we prevent open
+ * \b Slot called if the detaileddialog is closed. With this we prevent open
* the dialog twice, use this function to reset the used variables.
*/
void tdepowersave::closedetaileddialog() {
@@ -1725,7 +1807,7 @@ void tdepowersave::closedetaileddialog() {
}
/*!
- * \b TQT_SLOT used to display messeges in tdepowersave. This function
+ * \b Slot used to display messeges in tdepowersave. This function
* block all messeges which we have in tdepowersave!
*/
void tdepowersave::showErrorMessage( TQString msg ){
@@ -1735,7 +1817,7 @@ void tdepowersave::showErrorMessage( TQString msg ){
KPassivePopup::message("tdepowersave", msg, SmallIcon("messagebox_warning", 20),
this, i18n("Warning").utf8(), 10000);
} else {
- kapp->updateUserTimestamp();
+ tdeApp->updateUserTimestamp();
// KMessageBox::error( 0, msg);
KMessageBox::queuedMessageBox(0, KMessageBox::Error, msg);
}
@@ -1848,7 +1930,7 @@ void tdepowersave::setSchemeSettings(){
// --> set brightness settings
if(settings->brightness && hwinfo->supportBrightness()) {
// set to given values
- hwinfo->setBrightness (-1, settings->brightnessValue);
+ hwinfo->setBrightnessPercentage(settings->brightnessValue);
}
// --> set CPU Freq settings
@@ -1860,7 +1942,7 @@ void tdepowersave::setSchemeSettings(){
}
/*!
- * \b TQT_SLOT which called to set and start the autosuspend monitoring.
+ * \b Slot which called to set and start the autosuspend monitoring.
* \param resumed boolean value which represent information if machine
* currently back from suspend/standby
*/
@@ -1870,12 +1952,17 @@ void tdepowersave::setAutoSuspend( bool resumed ){
// Verify that the desired suspend action is allowed before enabling autosuspend
SuspendStates suspend = hwinfo->getSuspendSupport();
bool allowed = false;
- if(settings->autoInactiveAction == "Suspend to Disk") {
+ if(settings->autoInactiveAction == "Hibernate") {
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
allowed = true;
}
}
- else if (settings->autoInactiveAction == "Suspend to RAM") {
+ else if(settings->autoInactiveAction == "Hybrid Suspend") {
+ if ( suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed || suspend.suspend_hybrid_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Suspend") {
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
allowed = true;
}
@@ -1905,7 +1992,7 @@ void tdepowersave::setAutoSuspend( bool resumed ){
autoSuspend->stop();
delete autoSuspend;
autoSuspend = new autosuspend(display);
- connect(autoSuspend, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_autosuspendWarn()));
+ connect(autoSuspend, TQ_SIGNAL(inactivityTimeExpired()), this, TQ_SLOT(do_autosuspendWarn()));
}
if (settings->autoSuspendCountdown && (settings->autoSuspendCountdownTimeout > 0)) {
@@ -1938,7 +2025,7 @@ void tdepowersave::setAutoSuspend( bool resumed ){
}
/*!
- * \b TQT_SLOT which called to set and start the autodimm monitoring.
+ * \b Slot which called to set and start the autodimm monitoring.
* \param resumed boolean value which represent information if machine
* currently back from suspend/standby
*/
@@ -1955,8 +2042,8 @@ void tdepowersave::setAutoDimm( bool resumed ){
autoDimm->stop();
delete autoDimm;
autoDimm = new autodimm(display);
- connect(autoDimm, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_downDimm()));
- connect(autoDimm, TQT_SIGNAL(UserIsActiveAgain()), this, TQT_SLOT(do_upDimm()));
+ connect(autoDimm, TQ_SIGNAL(inactivityTimeExpired()), this, TQ_SLOT(do_downDimm()));
+ connect(autoDimm, TQ_SIGNAL(UserIsActiveAgain()), this, TQ_SLOT(do_upDimm()));
}
if (settings->autoDimmSBlistEnabled) {
@@ -1976,7 +2063,7 @@ void tdepowersave::setAutoDimm( bool resumed ){
// -------- start KNotify functions ------------- //
/*!
- * \b TQT_SLOT called if a battery warning state reached and related signal recieved.
+ * \b Slot called if a battery warning state reached and related signal recieved.
* Here we emit the related KNotify event, if not disabled.
* \param type integer with the type of the battery
* \param state integer represent the reached battery state
@@ -2033,7 +2120,7 @@ void tdepowersave::notifyBatteryStatusChange ( int type, int state ) {
"will go shutdown in 30 seconds")
.arg(min/ 60).arg(min%60));
- TQTimer::singleShot(30000, this, TQT_SLOT(handleCriticalBatteryActionCall()));
+ TQTimer::singleShot(30000, this, TQ_SLOT(handleCriticalBatteryActionCall()));
} else {
if (!settings->disableNotifications)
KNotifyClient::event(this->winId(), "battery_critical_event",
@@ -2111,16 +2198,19 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
}
break;
case GO_SUSPEND2RAM:
- TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2ram()));
+ TQTimer::singleShot(100, this, TQ_SLOT(do_suspend2ram()));
break;
case GO_SUSPEND2DISK:
- TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk()));
+ TQTimer::singleShot(100, this, TQ_SLOT(do_suspend2disk()));
+ break;
+ case GO_SUSPEND_HYBRID:
+ TQTimer::singleShot(100, this, TQ_SLOT(do_suspend_hybrid()));
break;
case GO_FREEZE:
- TQTimer::singleShot(100, this, TQT_SLOT(do_freeze()));
+ TQTimer::singleShot(100, this, TQ_SLOT(do_freeze()));
break;
case BRIGHTNESS:
- hwinfo->setBrightness( -1, value );
+ hwinfo->setBrightnessPercentage(value);
break;
case CPUFREQ_POWERSAVE:
hwinfo->setCPUFreq( POWERSAVE );
@@ -2162,7 +2252,7 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
}
/*!
- * \b TQT_SLOT called if ac stated changed. Here we emit the related KNotify event.
+ * \b Slot called if ac stated changed. Here we emit the related KNotify event.
* and switch to the AC/battery scheme depending on the state of AC
* \param acstate boolean represent the state of AC (true == AC plugged in ...)
*/
@@ -2200,7 +2290,7 @@ void tdepowersave::handleACStatusChange ( bool acstate , bool notifyEvent ) {
}
/*!
- * \b TQT_SLOT called if scheme switched. Here we emit the related KNotify events
+ * \b Slot called if scheme switched. Here we emit the related KNotify events
* if they are not disabled.
*/
void tdepowersave::notifySchemeSwitch() {
@@ -2224,7 +2314,7 @@ void tdepowersave::notifySchemeSwitch() {
}
/*!
- * \b TQT_SLOT called if the machine suspend. Here we emit the related KNotify events
+ * \b Slot called if the machine suspend. Here we emit the related KNotify events
* if they are not disabled.
*/
void tdepowersave::notifySuspend( int suspendType ) {
@@ -2235,22 +2325,27 @@ void tdepowersave::notifySuspend( int suspendType ) {
case SUSPEND2DISK:
KNotifyClient::event( this->winId(), "suspend2disk_event",
i18n("System is going into %1 now.").
- arg(i18n("Suspend to Disk")));
+ arg(i18n("hibernation")));
+ break;
+ case SUSPEND_HYBRID:
+ KNotifyClient::event( this->winId(), "suspend_hybrid_event",
+ i18n("System is going into %1 now.").
+ arg(i18n("hybrid suspension")));
break;
case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "suspend2ram_event",
i18n("System is going into %1 now.").
- arg(i18n("Suspend to RAM")));
+ arg(i18n("sleep")));
break;
case FREEZE:
KNotifyClient::event( this->winId(), "freeze_event",
i18n("System is going into %1 now.").
- arg(i18n("Freeze")));
+ arg(i18n("freeze")));
break;
case STANDBY:
KNotifyClient::event( this->winId(), "standby_event",
i18n("System is going into %1 now.").
- arg(i18n("Standby")));
+ arg(i18n("standby")));
break;
default:
break;
@@ -2261,7 +2356,7 @@ void tdepowersave::notifySuspend( int suspendType ) {
}
/*!
- * \b TQT_SLOT called to independent handleResumeSignal() from event loop and
+ * \b Slot called to independent handleResumeSignal() from event loop and
* to avoid problems with the QT3 D-Bus bindings
*/
void tdepowersave::forwardResumeSignal( int result ) {
@@ -2269,13 +2364,13 @@ void tdepowersave::forwardResumeSignal( int result ) {
resume_result = result;
- TQTimer::singleShot(100, this, TQT_SLOT(handleResumeSignal()));
+ TQTimer::singleShot(100, this, TQ_SLOT(handleResumeSignal()));
kdDebugFuncOut(trace);
}
/*!
- * \b TQT_SLOT called if the machine suspend. Here we emit the related KNotify events
+ * \b Slot called if the machine suspend. Here we emit the related KNotify events
* if they are not disabled.
*/
void tdepowersave::handleResumeSignal() {
@@ -2300,22 +2395,27 @@ void tdepowersave::handleResumeSignal() {
case SUSPEND2DISK:
KNotifyClient::event( this->winId(), "resume_from_suspend2disk_event",
i18n("System is resumed from %1.").arg(
- i18n("Suspend to Disk")));
+ i18n("hibernation")));
+ break;
+ case SUSPEND_HYBRID:
+ KNotifyClient::event( this->winId(), "resume_from_suspend_hybrid_event",
+ i18n("System is resumed from %1.").arg(
+ i18n("hybrid suspension")));
break;
case SUSPEND2RAM:
KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event",
i18n("System is resumed from %1.").arg(
- i18n("Suspend to RAM")));
+ i18n("sleep")));
break;
case FREEZE:
KNotifyClient::event( this->winId(), "resume_from_freeze_event",
i18n("System is resumed from %1.").arg(
- i18n("Freeze")));
+ i18n("freeze")));
break;
case STANDBY:
KNotifyClient::event( this->winId(), "resume_from_standby_event",
i18n("System is resumed from %1.").arg(
- i18n("Standby")));
+ i18n("standby")));
break;
default:
kdError() << "called suspend type unknown" << endl;
@@ -2357,6 +2457,10 @@ void tdepowersave::handleResumeSignal() {
logview = new LogViewer ("/var/log/suspend2disk.log");
logview->show();
break;
+ case SUSPEND_HYBRID:
+ logview = new LogViewer ("/var/log/suspend_hybrid.log");
+ logview->show();
+ break;
case SUSPEND2RAM:
logview = new LogViewer ("/var/log/suspend2ram.log");
logview->show();
@@ -2389,7 +2493,7 @@ void tdepowersave::handleResumeSignal() {
}
/*!
- * \b TQT_SLOT called if the state of the current session change
+ * \b Slot called if the state of the current session change
* \param state boolean represent the state of the session
* TODO: fix scheme handling
* TODO: fix critical battery situations (see the todo file in the source)
@@ -2427,10 +2531,13 @@ TQString tdepowersave::getSuspendString (int type) {
switch (type) {
case SUSPEND2DISK:
- return i18n("Suspend to Disk");
+ return i18n("Hibernate");
+ break;
+ case SUSPEND_HYBRID:
+ return i18n("Hybrid Suspend");
break;
case SUSPEND2RAM:
- return i18n("Suspend to RAM");
+ return i18n("Suspend");
break;
case FREEZE:
return i18n("Freeze");
@@ -2544,24 +2651,20 @@ TQStringList tdepowersave::listCPUFreqPolicies() {
bool tdepowersave::do_setCPUFreqPolicy( TQString policy ) {
if (trace) kdDebug() << funcinfo << "IN: " << "policy: " << policy << endl;
-
- bool ret = true;
- /*
+ bool ret = false;
if (hwinfo->isCpuFreqAllowed() && hwinfo->isOnline()) {
if (policy == "PERFORMANCE") {
hwinfo->setCPUFreq(PERFORMANCE);
+ ret = true;
} else if (policy == "DYNAMIC") {
hwinfo->setCPUFreq(DYNAMIC, settings->cpuFreqDynamicPerformance);
+ ret = true;
} else if (policy == "POWERSAVE") {
hwinfo->setCPUFreq(POWERSAVE);
- } else {
- kdDebugFuncOut(trace);
- ret = false;
+ ret = true;
}
- } else {
- ret = false;
}
- */
+
kdDebugFuncOut(trace);
return ret;
}
@@ -2580,6 +2683,10 @@ TQStringList tdepowersave::allowed_sleepingStates(){
suspend.suspend2disk_allowed == -1)){
sleepList.append("suspendToDisk");
}
+ if (suspend.suspend_hybrid && (suspend.suspend_hybrid_allowed ||
+ suspend.suspend_hybrid_allowed == -1)){
+ sleepList.append("suspendHybrid");
+ }
if (suspend.suspend2ram && (suspend.suspend2ram_allowed ||
suspend.suspend2ram_allowed == -1)){
sleepList.append("suspendToRAM");
@@ -2632,22 +2739,17 @@ TQStringList tdepowersave::listSchemes(){
* \param _scheme TQString with the scheme to set, scheme should be
* named as list from list_schemes()
*/
-bool tdepowersave::do_setScheme( TQString /*_scheme*/ ) {
- kdDebugFuncIn(trace);
-
-/* int index;
- index = settings->schemes.findIndex(_scheme);
+bool tdepowersave::do_setScheme( TQString _scheme ) {
+ if (trace) kdDebug() << funcinfo << "IN: scheme: " << _scheme << endl;
+ int index = settings->schemes.findIndex(_scheme);
+ if (trace) kdDebug() << funcinfo << " index: " << index << endl;
if (index != -1) {
do_setActiveScheme(index);
kdDebugFuncOut(trace);
return true;
}
- else {
- kdDebugFuncOut(trace);
- return false;
- }
-*/
+
kdDebugFuncOut(trace);
return false;
}
@@ -2665,6 +2767,18 @@ bool tdepowersave::do_suspendToDisk(){
}
/*!
+ * DCOP Interface funtion to send the hybrid suspend command to powersave.
+ * \return boolean with the result of calling do_suspend_hybrid()
+ * \retval true if successful
+ * \retval false if not supported or powersaved not running
+ */
+bool tdepowersave::do_suspendHybrid(){
+ kdDebugFuncIn(trace);
+ kdDebugFuncOut(trace);
+ return do_suspend_hybrid();
+}
+
+/*!
* DCOP Interface funtion to send the suspend to disk command to powersave.
* \return boolean with the result of calling do_suspend2ram()
* \retval true if successful
@@ -2773,7 +2887,7 @@ void tdepowersave::showDetailedDialog( ){
detailedIsShown = true;
}
- connect(detailedDlg, TQT_SIGNAL(destroyed()), this, TQT_SLOT(closedetaileddialog()));
+ connect(detailedDlg, TQ_SIGNAL(destroyed()), this, TQ_SLOT(closedetaileddialog()));
kdDebugFuncOut(trace);
}
@@ -2781,7 +2895,7 @@ void tdepowersave::showDetailedDialog( ){
/*!
* DCOP Interface funtion to open the configure dialog.
* \return boolean with the result of open the dialog
- * \retval false if failed (e.g. D-Bus or HAL is not running)
+ * \retval false if failed
* \retval true if correct opend
*/
bool tdepowersave::openConfigureDialog (){
@@ -2820,7 +2934,7 @@ int tdepowersave::brightnessGet() {
int retval = -1;
if (hwinfo->supportBrightness()) {
- retval = (int)(((float)hwinfo->getCurrentBrightnessLevel() / (float)hwinfo->getMaxBrightnessLevel()-1) * 100.0);
+ retval = (int)round(100.0 * hwinfo->getCurrentBrightnessLevel() / hwinfo->getMaxBrightnessLevel());
}
kdDebugFuncOut(trace);
@@ -2828,4 +2942,13 @@ int tdepowersave::brightnessGet() {
return retval;
}
+//! dcop funtion to set the brightness level
+void tdepowersave::brightnessSet(int percentage)
+{
+ kdDebugFuncIn(trace);
+
+ hwinfo->setBrightnessPercentage(percentage);
+
+ kdDebugFuncOut(trace);
+}
#include "tdepowersave.moc"