summaryrefslogtreecommitdiffstats
path: root/src/tdepowersave.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tdepowersave.cpp')
-rw-r--r--src/tdepowersave.cpp308
1 files changed, 147 insertions, 161 deletions
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index 9f92adf..3519d45 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>
@@ -31,6 +37,7 @@
#include <kpassivepopup.h>
#include <tdepopupmenu.h>
#include <kglobalaccel.h>
+#include <khelpmenu.h>
// other TQt headers:
#include <tqcursor.h>
@@ -96,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 (handleSuspendButtonEvent()));
- 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() ) );
+ 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")), TQT_TQOBJECT(this), TQT_SLOT( handleSuspendButtonEvent() ) );
+ 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();
@@ -141,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();
@@ -162,6 +170,7 @@ tdepowersave::~tdepowersave(){
delete display;
delete settings;
delete autoSuspend;
+ delete m_autoDimmTimer;
#ifdef ENABLE_YAST_ENTRY
delete yast2;
#endif
@@ -175,27 +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();
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, TQT_SLOT(do_suspend2ram()));
+ TQIconSet::Automatic), i18n("Suspend"), this, TQ_SLOT(do_suspend2ram()));
SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk",
- TQIconSet::Automatic), i18n("Hibernate"), this, TQT_SLOT(do_suspend2disk()));
+ 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, TQT_SLOT(do_suspend_hybrid()));
+ 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);
@@ -205,39 +214,33 @@ 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);
HELP_SEPARATOR_MENU_ID = contextMenu()->insertSeparator();
- help_menu = new TQPopupMenu(this, i18n("&Help").utf8());
-
- help_menu->insertItem( SmallIcon("help", TQIconSet::Automatic), i18n("&TDEPowersave Handbook"),
- this, TQT_SLOT(slotHelp()));
- help_menu->insertSeparator();
- help_menu->insertItem( i18n("&Report a bug ..."), this, TQT_SLOT(slotReportBug()));
- help_menu->insertItem( SmallIcon("tdepowersave", TQIconSet::Automatic),
- i18n("&About TDEPowersave"), this, TQT_SLOT(slotAbout()));
+ // Create help submenu
+ KHelpMenu *m_help = new KHelpMenu(this, TDEGlobal::instance()->aboutData(), false, actionCollection());
+ TDEPopupMenu *help = m_help->menu();
+ help->connectItem(KHelpMenu::menuHelpContents, this, TQ_SLOT(slotHelpContents()));
+ this->contextMenu()->insertItem(SmallIcon("help"), KStdGuiItem::help().text(), help);
- HELP_MENU = contextMenu()->insertItem(SmallIcon("help", TQIconSet::Automatic),
- i18n("&Help"), help_menu);
-
- connect(this, TQT_SIGNAL(quitSelected()), this, TQT_SLOT(_quit()));
+ connect(this, TQ_SIGNAL(quitSelected()), this, TQ_SLOT(_quit()));
kdDebugFuncOut(trace);
}
@@ -283,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."),
@@ -293,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();
}
@@ -517,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.
*/
@@ -530,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;
@@ -546,7 +549,7 @@ void tdepowersave::do_config(){
}
/*!
- * \b TQT_SLOT to open the tdepowersave help
+ * \b Slot to open the tdepowersave help
*/
void tdepowersave::slotHelp()
{
@@ -554,7 +557,7 @@ void tdepowersave::slotHelp()
}
/*!
- * \b TQT_SLOT to open the tdepowersave About dialog
+ * \b Slot to open the tdepowersave About dialog
*/
void tdepowersave::slotAbout()
{
@@ -563,35 +566,7 @@ void tdepowersave::slotAbout()
}
/*!
- * \b TQT_SLOT to open the website to report bugs
- */
-void tdepowersave::slotReportBug()
-{
-#ifdef DISTRO_IS_SUSE
- #ifdef DISTRO_IS_SLES_SLED
- kapp->invokeBrowser("https://bugzilla.novell.com/");
- #else
- kapp->invokeBrowser("http://en.opensuse.org/Submitting_Bug_Reports");
- #endif
-#else
- #ifdef DISTRO_IS_ALTLINUX
- kapp->invokeBrowser("http://bugzilla.altlinux.org/");
- #else
- #ifdef DISTRO_IS_UBUNTU
- kapp->invokeBrowser("https://launchpad.net/distros/ubuntu/+bugs");
- #else
- #ifdef DISTRO_IS_PARDUS
- kapp->invokeBrowser("http://bugs.pardus.org.tr/");
- #else
- kapp->invokeBrowser("http://sourceforge.net/tracker/?group_id=124576&atid=700009");
- #endif
- #endif
- #endif
-#endif
-}
-
-/*!
- * \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
@@ -605,8 +580,9 @@ void tdepowersave::do_setIconBG(){
kdDebugFuncOut(trace);
}
+
/*!
- * \b TQT_SLOT to enable/disable the autosuspend.
+ * \b Slot to enable/disable the autosuspend.
*/
void tdepowersave::do_setAutosuspend(){
kdDebugFuncIn(trace);
@@ -631,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
*/
@@ -657,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){
@@ -688,7 +664,7 @@ void tdepowersave::slotConfigProcessExited(TDEProcess *proc){
}
/*!
- * \b TQT_SLOT to send the command for "suspend to disk" to TDE hardware library.
+ * \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
@@ -744,7 +720,7 @@ bool tdepowersave::do_suspend2disk(){
}
/*!
- * \b TQT_SLOT to send the command for "hybrid suspend" to 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
@@ -800,7 +776,7 @@ bool tdepowersave::do_suspend_hybrid(){
}
/*!
- * \b TQT_SLOT to send the command for "suspend to RAM" to the TDE hardware library.
+ * \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
@@ -856,7 +832,7 @@ bool tdepowersave::do_suspend2ram(){
}
/*!
- * \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
@@ -911,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
@@ -966,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.
*/
@@ -1032,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();
}
}
@@ -1046,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
@@ -1089,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
@@ -1100,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()));
}
}
@@ -1126,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
@@ -1139,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()));
}
}
@@ -1169,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
@@ -1177,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
@@ -1194,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;
}
}
@@ -1327,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
*/
@@ -1385,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);
@@ -1395,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);
@@ -1413,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.
*/
@@ -1458,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;
@@ -1476,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 ){
@@ -1788,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 {
@@ -1810,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();
}
}
@@ -1822,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() {
@@ -1830,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 ){
@@ -1953,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
@@ -1965,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
*/
@@ -2015,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)) {
@@ -2048,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
*/
@@ -2065,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) {
@@ -2086,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
@@ -2143,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",
@@ -2221,19 +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, TQT_SLOT(do_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 );
@@ -2275,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 ...)
*/
@@ -2313,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() {
@@ -2337,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 ) {
@@ -2379,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 ) {
@@ -2387,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() {
@@ -2516,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)
@@ -2919,7 +2896,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);
}
@@ -2927,7 +2904,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 (){
@@ -2966,7 +2943,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);
@@ -2974,4 +2951,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"