From 65b5cd4b6c373089958268c9c0772458a9d1128f Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 10 Apr 2010 05:44:39 +0000 Subject: [PATCH] Fixed extraneous error message on suspend git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kpowersave@1113226 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/kpowersave.cpp | 467 +++++++++++++++++++++++---------------------- src/kpowersave.h | 72 +++---- 2 files changed, 270 insertions(+), 269 deletions(-) diff --git a/src/kpowersave.cpp b/src/kpowersave.cpp index ab6c088..c746399 100644 --- a/src/kpowersave.cpp +++ b/src/kpowersave.cpp @@ -44,17 +44,17 @@ #include "kpowersave.h" #include "infodialog.h" -/*! +/*! * \file kpowersave.cpp * \brief This file contains the main functionality of the kpowersave-applet.*/ -/*! - * This is the default constructor of the class kpowersave. +/*! + * This is the default constructor of the class kpowersave. */ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0, "kpowersave"), DCOPObject("KPowersaveIface") { trace = trace_func; - kdDebugFuncIn(trace); + kdDebugFuncIn(trace); display = new screen(); settings = new Settings(); @@ -62,7 +62,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 autoDimm = new autodimm(); hwinfo = new HardwareInfo(); suspend = hwinfo->getSuspendSupport(); - + yast2 = NULL; resume_result = 0; @@ -73,7 +73,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 config->writeEntry("AlreadyStarted", true); // check whether APM, ACPI, PMU, CPUFreq or Suspend2Disk/ram supported, otherwise end up // and don't start kpowersave ever again until force_acpi_check == true. - if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && + if (!hwinfo->hasACPI() && !hwinfo->hasAPM() && !hwinfo->hasPMU() && !hwinfo->supportCPUFreq() && !suspend.suspend2disk && !suspend.suspend2ram){ config->writeEntry("Autostart", false); config->sync(); @@ -90,7 +90,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 settings->load_scheme_settings( settings->battery_scheme); } // set the battery warning levels - hwinfo->setPrimaryBatteriesWarningLevel(settings->batteryWarningLevel, + hwinfo->setPrimaryBatteriesWarningLevel(settings->batteryWarningLevel, settings->batteryLowLevel, settings->batteryCriticalLevel); @@ -101,7 +101,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 connect(hwinfo, SIGNAL(resumed(int)), this, SLOT(forwardResumeSignal(int))); // connect to error mesages - connect(autoSuspend, SIGNAL(displayErrorMsg(QString)), this, SLOT(showErrorMessage(QString))); + connect(autoSuspend, SIGNAL(displayErrorMsg(QString)), this, SLOT(showErrorMessage(QString))); connect(hwinfo, SIGNAL(halRunning(bool)), this, SLOT(showHalErrorMsg())); connect(hwinfo, SIGNAL(dbusRunning(int)), this, SLOT(showDBusErrorMsg(int))); @@ -115,16 +115,16 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 connect(autoSuspend, SIGNAL(inactivityTimeExpired()), this, SLOT(do_autosuspendWarn())); connect(autoDimm, SIGNAL(inactivityTimeExpired()), this, SLOT(do_downDimm())); connect(autoDimm, SIGNAL(UserIsActiveAgain()), this, SLOT(do_upDimm())); - + config->sync(); - + config_dialog_shown = false; suspend_dialog_shown = false; detailedIsShown = false; hal_error_shown = false; icon_set_colored = false; icon_BG_is_colored = false; - + calledSuspend = -1; countWhiteIconPixel = 0; @@ -133,7 +133,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 BAT_WARN_ICON_Timer = new QTimer(this); connect(BAT_WARN_ICON_Timer, SIGNAL(timeout()), this, SLOT(do_setIconBG())); - + DISPLAY_HAL_ERROR_Timer = new QTimer(this); connect(DISPLAY_HAL_ERROR_Timer, SIGNAL(timeout()), this, SLOT(showHalErrorMsg())); @@ -146,7 +146,7 @@ kpowersave::kpowersave( bool force_acpi_check, bool trace_func ) : KSystemTray(0 kdDebugFuncOut(trace); } - + /*! This is the default destructor of class kpowersave. */ kpowersave::~kpowersave(){ @@ -168,51 +168,51 @@ void kpowersave::initMenu() { kdDebugFuncIn(trace); CONFIGURE_ID = this->contextMenu()->insertItem(SmallIcon("configure", QIconSet::Automatic), - i18n("Configure KPowersave..."), + i18n("Configure KPowersave..."), this, SLOT(showConfigureDialog())); CONFIGURE_EVENTS_ID = this->contextMenu()->insertItem(SmallIcon("knotify", QIconSet::Automatic), - i18n("Configure Notifications..."), + i18n("Configure Notifications..."), this, SLOT(showConfigureNotificationsDialog())); #ifdef ENABLE_YAST_ENTRY YAST_MODULE_MENU_ID = this->contextMenu()->insertItem(SmallIcon("yast", QIconSet::Automatic), - i18n("Start YaST2 Power Management Module..."), + i18n("Start YaST2 Power Management Module..."), this, SLOT(do_config())); #endif - + SLEEP_SEPARATOR_MENU_ID = this->contextMenu()->insertSeparator(); - SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk", + SUSPEND2DISK_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_disk", QIconSet::Automatic), i18n("Suspend to Disk"), this, SLOT(do_suspend2disk())); - SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", + SUSPEND2RAM_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", QIconSet::Automatic), i18n("Suspend to RAM"), this, SLOT(do_suspend2ram())); STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", QIconSet::Automatic), i18n("Standby"), this, SLOT(do_standby())); - + speed_menu = new QPopupMenu(this, i18n("Set CPU Frequency Policy")); speed_menu->insertItem(i18n("Performance"), PERFORMANCE); speed_menu->insertItem(i18n("Dynamic"), DYNAMIC); speed_menu->insertItem(i18n("Powersave"), POWERSAVE); - + CPUFREQ_SEPARATOR_MENU_ID = contextMenu()->insertSeparator(); - + CPUFREQ_MENU_ID = contextMenu()->insertItem(i18n("Set CPU Frequency Policy"), speed_menu); connect(speed_menu, SIGNAL(activated(int)), this, SLOT(do_setSpeedPolicy(int))); connect(hwinfo, SIGNAL(currentCPUFreqPolicyChanged()), this, SLOT(updateCPUFreqMenu())); SCHEME_SEPARATOR_MENU_ID = contextMenu()->insertSeparator(); - + scheme_menu = new QPopupMenu(this, i18n("Set Active Scheme")); SCHEME_MENU_ID = contextMenu()->insertItem(i18n("Set Active Scheme"), scheme_menu); connect(scheme_menu, SIGNAL(activated(int)), this, SLOT(do_setActiveScheme(int))); - - // menu entry for the autosuspend disable checkbox, disabled by default, only + + // 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"), + AUTOSUSPEND_MENU_ID = this->contextMenu()->insertItem( i18n("Disable Actions on Inactivity"), this,SLOT(do_setAutosuspend())); this->contextMenu()->setItemVisible(AUTOSUSPEND_SEPARATOR_MENU_ID, false); this->contextMenu()->setItemVisible(AUTOSUSPEND_MENU_ID, false); @@ -220,24 +220,24 @@ void kpowersave::initMenu() { HELP_SEPARATOR_MENU_ID = contextMenu()->insertSeparator(); help_menu = new QPopupMenu(this, i18n("&Help")); - - help_menu->insertItem( SmallIcon("help", QIconSet::Automatic), i18n("&KPowersave Handbook"), + + help_menu->insertItem( SmallIcon("help", QIconSet::Automatic), i18n("&KPowersave Handbook"), this, SLOT(slotHelp())); help_menu->insertSeparator(); help_menu->insertItem( i18n("&Report a bug ..."), this, SLOT(slotReportBug())); - help_menu->insertItem( SmallIcon("kpowersave", QIconSet::Automatic), + help_menu->insertItem( SmallIcon("kpowersave", QIconSet::Automatic), i18n("&About KPowersave"), this, SLOT(slotAbout())); HELP_MENU = contextMenu()->insertItem(SmallIcon("help", QIconSet::Automatic), i18n("&Help"), help_menu); - + connect(this, SIGNAL(quitSelected()), this, SLOT(_quit())); - + kdDebugFuncOut(trace); } /*! - * This funtion load and manipulate the icons for the kickerapplet-section. + * This funtion load and manipulate the icons for the kickerapplet-section. * The redraw interval depends on \ref icon_set_colored and \ref BAT_icon_BG_intervall. */ void kpowersave::redrawPixmap(){ @@ -266,7 +266,7 @@ void kpowersave::showConfigureDialog() { kdDebugFuncIn(trace); if(!config_dialog_shown) { - if (settings->schemes.count() > 0){ + if (settings->schemes.count() > 0){ configDlg = new ConfigureDialog(config, hwinfo, settings); configDlg->show(); config_dialog_shown = true; @@ -276,14 +276,14 @@ void kpowersave::showConfigureDialog() { } else { KPassivePopup::message(i18n("WARNING"), i18n("Cannot find any schemes."), - SmallIcon("messagebox_warning", 20), this, + SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); } } else { configDlg->setWindowState(configDlg->windowState() & ~WindowMinimized | WindowActive); configDlg->setActiveWindow(); } - + kdDebugFuncOut(trace); } @@ -315,7 +315,7 @@ void kpowersave::loadIcon(){ } else if (hwinfo->getAcAdapter() || primary->getBatteryState() == BAT_NONE) { icon_set_colored = false; - + if (primary->getBatteryState() == BAT_NONE || (primary->getRemainingPercent() < 0 || primary->getRemainingPercent() >= 99)) pixmap_name_tmp = QString("laptoppower"); @@ -343,7 +343,7 @@ void kpowersave::loadIcon(){ icon_set_colored = false; icon_BG_is_colored = false; } - + if (icon_set_colored){ icon_state_changed = false; BAT_WARN_ICON_Timer->start(BAT_icon_BG_intervall, true); @@ -356,10 +356,10 @@ void kpowersave::loadIcon(){ if (pixmap_name.startsWith("ERROR")) { pixmap = SmallIcon("laptoppower", 22, KIcon::DisabledState); } - else + else pixmap = SmallIcon(pixmap_name, 22); } - + kdDebugFuncOut(trace); } @@ -379,20 +379,20 @@ void kpowersave::drawIcon(){ int w = image.width(); int h = image.height(); int x, y; - - if((pixmap_name.contains("laptopbattery") || pixmap_name.contains("charge")) && + + if((pixmap_name.contains("laptopbattery") || pixmap_name.contains("charge")) && countWhiteIconPixel == 0) { for (x = 0; x < w; x++) for (y = 0; y < h; y++) if(QColor(image.pixel(x, y)) == Qt::white) countWhiteIconPixel++; } - + int c = (countWhiteIconPixel * primary->getRemainingPercent()) / 100; - + if (c > 0) { uint ui; QRgb Rgb_set; - + if (hwinfo->getAcAdapter()) { Rgb_set = qRgb(0x00, 0xff, 0x00); //green } @@ -415,7 +415,7 @@ void kpowersave::drawIcon(){ image.setColor(ui, Rgb_set); } ui = 0xff000000 | Rgb_set; - + for (y = h - 1; y >= 0; y--) { for (x = 0; x < w ; x++) { if(QColor(image.pixel(x, y)) == Qt::white) { @@ -436,8 +436,8 @@ quit: /*! * By this function we fill and update the Tooltip for the icon in the kicker applet. * The content of the tooltip alway updated, if something change. -* \todo Check if the tooltip also updated if mouse \b is over the icon, if not we maybe -* should implement this.\n If it is possible we should update the tooltip permanently +* \todo Check if the tooltip also updated if mouse \b is over the icon, if not we maybe +* should implement this.\n If it is possible we should update the tooltip permanently * while the mouse cursor is over the widget */ void kpowersave::updateTooltip(){ @@ -454,14 +454,14 @@ void kpowersave::updateTooltip(){ if (hwinfo->hal_terminated){ tmp = i18n("No information about battery and AC status available"); - } + } else if (hwinfo->getAcAdapter()) { if (percent == 100) tmp = i18n("Plugged in -- fully charged"); // assume that no battery is there else { if ((percent < 0 && minutes < 0) || primary->getBatteryState() == BAT_NONE) { tmp = i18n("Plugged in"); - } + } else if (minutes > 0){ if (charging_state == CHARGING) tmp = i18n("Plugged in -- %1% charged (%2:%3 h until full " @@ -488,9 +488,9 @@ void kpowersave::updateTooltip(){ } } // add string whether battery is charging, but only if < 100% to avoid - // stupid tooltip message on machines which always with 100% and on AC + // stupid tooltip message on machines which always with 100% and on AC // are charging, as e.g. Sony Vaio FS vgn-fs115b - if (charging_state == CHARGING && percent < 100) + if (charging_state == CHARGING && percent < 100) tmp += i18n(" -- battery is charging"); QToolTip::add(this, tmp); @@ -499,16 +499,16 @@ void kpowersave::updateTooltip(){ } /*! - * \b 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 KProcess and execute "/sbin/yast2 power-management" with kdesu. */ void kpowersave::do_config(){ kdDebugFuncIn(trace); - + #ifdef ENABLE_YAST_ENTRY delete yast2; - + yast2 = new KProcess; *yast2 << "kdesu" << "--nonewdcop" << "/sbin/yast2" << "power-management"; @@ -555,7 +555,7 @@ void kpowersave::slotReportBug() #else kapp->invokeBrowser("http://en.opensuse.org/Submitting_Bug_Reports"); #endif -#else +#else #ifdef DISTRO_IS_ALTLINUX kapp->invokeBrowser("http://bugzilla.altlinux.org/"); #else @@ -573,15 +573,15 @@ void kpowersave::slotReportBug() } /*! - * \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 + * \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 QTimer \ref BAT_WARN_ICON_Timer . The interval of the timer is defined - * trough \ref BAT_icon_BG_intervall and starts here: \ref loadIcon() . + * The slot called by the QTimer \ref BAT_WARN_ICON_Timer . The interval of the timer is defined + * trough \ref BAT_icon_BG_intervall and starts here: \ref loadIcon() . */ void kpowersave::do_setIconBG(){ kdDebugFuncIn(trace); - + if (icon_set_colored) icon_state_changed = true; redrawPixmap(); @@ -595,7 +595,7 @@ void kpowersave::do_setAutosuspend(){ if(!contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) { autoSuspend->stop(); - contextMenu()->setItemChecked(AUTOSUSPEND_MENU_ID, true); + contextMenu()->setItemChecked(AUTOSUSPEND_MENU_ID, true); } else { if(settings->autoSuspend) { @@ -608,30 +608,30 @@ void kpowersave::do_setAutosuspend(){ contextMenu()->setItemVisible(AUTOSUSPEND_SEPARATOR_MENU_ID, false); } } - + kdDebugFuncOut(trace); } /*! - * \b 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 */ void kpowersave::observeConfigDlg(){ kdDebugFuncIn(trace); - + // reload general settings settings->load_general_settings(); - // set the battery warning levels - all other general settings don't need to + // set the battery warning levels - all other general settings don't need to // get set, since we check the settings only on events. - hwinfo->setPrimaryBatteriesWarningLevel(settings->batteryWarningLevel, + hwinfo->setPrimaryBatteriesWarningLevel(settings->batteryWarningLevel, settings->batteryLowLevel, settings->batteryCriticalLevel); // reload the maybe changed scheme settings settings->load_scheme_settings( settings->currentScheme ); // set the scheme - setSchemeSettings(); + setSchemeSettings(); config_dialog_shown=false; @@ -651,7 +651,7 @@ void kpowersave::slotConfigProcessExited(KProcess *proc){ KPassivePopup::message( i18n("WARNING"), i18n("Could not start YaST Power Management Module. " "Check if it is installed."), - SmallIcon("messagebox_warning", 20), this, + SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); } } @@ -674,7 +674,7 @@ void kpowersave::slotConfigProcessExited(KProcess *proc){ * If there is a error while "suspend to disk" the user get e messagebox. * This function need a running HAL daemon for "suspend to disk". * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false if command not supported or if powersaved not running */ bool kpowersave::do_suspend2disk(){ @@ -712,7 +712,7 @@ bool kpowersave::do_suspend2disk(){ } else { KPassivePopup::message( i18n("WARNING"), i18n("Suspend to disk disabled by administrator."), - SmallIcon("messagebox_warning", 20), + SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false); kdDebugFuncOut(trace); @@ -730,7 +730,7 @@ bool kpowersave::do_suspend2disk(){ * If there is a error while "suspend to RAM" the user get e messagebox. * This function need a running HAL daemon for "suspend to RAM". * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false if command not supported or if powersaved not running */ bool kpowersave::do_suspend2ram(){ @@ -768,7 +768,7 @@ bool kpowersave::do_suspend2ram(){ } else { KPassivePopup::message( i18n("WARNING"), i18n("Suspend to RAM disabled by administrator."), - SmallIcon("messagebox_warning", 20), this, + SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, false); kdDebugFuncOut(trace); @@ -786,7 +786,7 @@ bool kpowersave::do_suspend2ram(){ * If there is a error while "stand-by" the user get e messagebox. * This function need a running HAL daemon for "stand-by". * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false if command not supported or if powersaved not running */ bool kpowersave::do_standby(){ @@ -823,7 +823,7 @@ bool kpowersave::do_standby(){ } } else { KPassivePopup::message( i18n("WARNING"),i18n("Standby disabled by administrator."), - SmallIcon("messagebox_warning", 20), this, + SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, false); kdDebugFuncOut(trace); @@ -839,7 +839,7 @@ bool kpowersave::do_standby(){ /*! * \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. + * \ref autosuspend::inactivityTimeExpired was recieved. */ void kpowersave::do_autosuspendWarn() { kdDebugFuncIn(trace); @@ -850,7 +850,7 @@ void kpowersave::do_autosuspendWarn() { QString message; countdown = new countDownDialog(settings->autoSuspendCountdownTimeout); - + if(settings->autoInactiveAction == "Suspend to Disk") { countdown->setPixmap("suspend2disk"); } else if (settings->autoInactiveAction == "Suspend to RAM") { @@ -860,7 +860,7 @@ void kpowersave::do_autosuspendWarn() { } else { countdown->setPixmap("kpowersave"); } - + // TODO: rework this after translation round for openSUSE 10.3 ! message = i18n("Inactivity detected.") + " " + i18n("To stop the %1 press the 'Cancel' button before the countdown " @@ -871,7 +871,7 @@ void kpowersave::do_autosuspendWarn() { connect(countdown, SIGNAL(dialogClosed(bool)), this, SLOT(do_autosuspend(bool))); countdown->showDialog(); - } + } } else { // call directly autosuspend do_autosuspend(false); @@ -883,23 +883,23 @@ void kpowersave::do_autosuspendWarn() { * \b SLOT to send the related suspend command for autosuspend * \param chancel boolean with info if the autosuspend should get chanceld * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false if command not supported or on any other error - * \todo add check if the requested command is supported befor send and + * \todo add check if the requested command is supported befor send and * add message for this case to tell that maybe changed config! */ bool kpowersave::do_autosuspend(bool chancel) { kdDebugFuncIn(trace); - + // TODO: check if this is really needed, it get called also on the suspend methodes autoSuspend->stop(); - if (!chancel) { + if (!chancel) { if(!settings->disableNotifications) { - KNotifyClient::event( this->winId(), "autosuspend_event", + KNotifyClient::event( this->winId(), "autosuspend_event", i18n("System is going into suspend mode now")); } - + if(settings->autoSuspend && !contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) { if(settings->autoInactiveAction == "Suspend to Disk") { return do_suspend2disk(); @@ -922,10 +922,10 @@ bool kpowersave::do_autosuspend(bool chancel) { /*! * \b SLOT to dimm the display down to the configured level if the signal - * \ref autodimm::inactivityTimeExpired was recieved. - * \param + * \ref autodimm::inactivityTimeExpired was recieved. + * \param * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false else */ void kpowersave::do_downDimm() { @@ -934,14 +934,14 @@ void kpowersave::do_downDimm() { if (hwinfo->supportBrightness()) { if (!AUTODIMM_Timer->isActive()) { int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)settings->autoDimmTo/100.0)); - - // check if we really need to dimm down + + // check if we really need to dimm down if (dimmToLevel < hwinfo->getCurrentBrightnessLevel()) { int steps = hwinfo->getCurrentBrightnessLevel() - dimmToLevel; int timePerStep = (1500 / steps); autoDimmDown = true; - + AUTODIMM_Timer = new QTimer(this); connect(AUTODIMM_Timer, SIGNAL(timeout()), this, SLOT(do_dimm())); AUTODIMM_Timer->start(timePerStep, false); @@ -959,28 +959,28 @@ void kpowersave::do_downDimm() { /*! * \b SLOT to dimm the display up to the configured level if the signal - * \ref autodimm::UserIsActiveAgain was recieved. - * \param + * \ref autodimm::UserIsActiveAgain was recieved. + * \param * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false else */ void kpowersave::do_upDimm() { kdDebugFuncIn(trace); - + //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 (hwinfo->supportBrightness()) { if (!AUTODIMM_Timer->isActive()) { int dimmToLevel = (int)((float)hwinfo->getMaxBrightnessLevel()*((float)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); autoDimmDown = false; - + AUTODIMM_Timer = new QTimer(this); connect(AUTODIMM_Timer, SIGNAL(timeout()), this, SLOT(do_dimm())); AUTODIMM_Timer->start(timePerStep, false); @@ -1003,7 +1003,7 @@ void kpowersave::do_upDimm() { /*! * \b SLOT to dimm the display down * \return boolean with the result of the operation - * \retval true if successful + * \retval true if successful * \retval false else */ void kpowersave::do_dimm() { @@ -1037,7 +1037,7 @@ void kpowersave::do_dimm() { } /*! - * Function handle umount/remount external storage media before/after + * Function handle umount/remount external storage media before/after * suspend. * \param suspend boolean with info if the machine go into suspend or not * \return result of the operation @@ -1053,7 +1053,7 @@ bool kpowersave::handleMounts( bool suspend ) { if (settings->unmountExternalOnSuspend) { QString _method; DCOPRef dcop_ref = DCOPRef( "kded", "mediamanager" ); - + if (suspend) { _method = "unmountAllSuspend()"; } else { @@ -1076,8 +1076,8 @@ bool kpowersave::handleMounts( bool suspend ) { kdDebugFuncOut(trace); return true; } - - // this is only needed for suspend case and an error ... + + // this is only needed for suspend case and an error ... // on resume a simple error msg should be enough if (!_ret && suspend) { // handle error case @@ -1092,7 +1092,7 @@ bool kpowersave::handleMounts( bool suspend ) { } // ugly: need qt-tags because mediamanager can return html formated strings !!! - _msg = "" + + _msg = "" + i18n("Could not umount external media before suspend/standby. \n " "(Reason: %1)\n \n Would you like to continue suspend/standby " "anyway? \n(Warning: Continue suspend can cause data loss!)").arg(_e_msg) + @@ -1100,9 +1100,9 @@ bool kpowersave::handleMounts( bool suspend ) { _suspend = getSuspendString(calledSuspend); - int answer = KMessageBox::questionYesNo( 0, _msg, + int answer = KMessageBox::questionYesNo( 0, _msg, i18n("Error while prepare %1").arg(_suspend), - i18n("Suspend anyway"), i18n("Cancel suspend"), + i18n("Suspend anyway"), i18n("Cancel suspend"), "ignoreMountOnSuspend"); if (answer == KMessageBox::Yes) { @@ -1126,7 +1126,7 @@ void kpowersave::handlePowerButtonEvent( ) { if (calledSuspend == -1) { handleActionCall(settings->powerButtonAction, settings->powerButtonActionValue); } - + kdDebugFuncOut(trace); } @@ -1165,23 +1165,23 @@ void kpowersave::handleS2DiskButtonEvent(){ */ void kpowersave::handleLidEvent( bool closed ){ if (trace) kdDebug() << funcinfo << "IN: " << "Lid closed? " << closed << endl; - + if (closed) { - // get new general settings! This could maybe removed if we + // get new general settings! This could maybe removed if we // could be shure, that the settings are actuall settings->load_general_settings(); - + // handle screen lock if (settings->lidcloseAction < 0) { if(settings->lockOnLidClose) { if(!display->lockScreen( settings->lockmethod )) { KPassivePopup::message( i18n("WARNING"), i18n("Could not lock the screen. There may " - "be a problem with the selected \nlock " + "be a problem with the selected \nlock " "method or something else."), SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 10000); - + } } if(settings->forceDpmsOffOnLidClose) { @@ -1203,12 +1203,12 @@ void kpowersave::handleLidEvent( bool closed ){ if(settings->forceDpmsOffOnLidClose) { // reset the scheme settings to avoid problems related to call xset on lidclose setSchemeSettings(); - } + } if (settings->lockOnLidClose) { activateLoginScreen(); } - + if(!settings->disableNotifications) KNotifyClient::event( this->winId(), "lid_opened_event", i18n("The Lid was opened.")); } @@ -1222,14 +1222,14 @@ void kpowersave::handleLidEvent( bool closed ){ void kpowersave::activateLoginScreen(){ kdDebugFuncIn(trace); - // get new general settings! This could maybe removed if we + // get new general settings! This could maybe removed if we // could be shure, that the settings are actuall settings->load_general_settings(); - + if(settings->timeToFakeKeyAfterLock >= 0) { QTimer::singleShot(settings->timeToFakeKeyAfterLock, display, SLOT(fakeShiftKeyEvent())); } - + kdDebugFuncOut(trace); } @@ -1246,12 +1246,12 @@ void kpowersave::setSuspendType( QString suspendtype){ /*! * \b SLOT which called if kpowersave is exited by the user. In this case the user - * is asked through a yes/no box if "KPowersave start automatically on log in" and the + * is asked through a yes/no box if "KPowersave start automatically on log in" and the * result is written to the KDE configfile. */ void kpowersave::_quit (){ kdDebugFuncIn(trace); - + // set the KDE-Settings back to user default if(getenv("KDE_FULL_SESSION")) { // first try to call the KDE method via DCOP to reset, if not fall back @@ -1261,36 +1261,36 @@ void kpowersave::_quit (){ display->blankOnlyScreen(false); if(!settings->kde->enabled) display->setScreenSaver(false); else display->setScreenSaver(true); - + if(!settings->kde->displayEnergySaving) display->setDPMS(false); else display->setDPMS(true); - + display->has_DPMS = display->setDPMSTimeouts( settings->kde->displayStandby, settings->kde->displaySuspend, settings->kde->displayPowerOff); } } - + // set, if this is a GNOME session, XScreensaver settings back to user default QString session = getenv("DESKTOP_SESSION"); if(session.startsWith("gnome")) { display->resetXScreensaver(); } - - if(!settings->autostartNeverAsk) { + + if(!settings->autostartNeverAsk) { QString tmp1 = i18n ("Start KPowersave automatically when you log in?"); - int tmp2 = KMessageBox::questionYesNo ( 0, tmp1, i18n("Question"), + int tmp2 = KMessageBox::questionYesNo ( 0, tmp1, i18n("Question"), i18n("Start Automatically"), i18n("Do Not Start")); config->setGroup("General"); config->writeEntry ("Autostart", tmp2 == KMessageBox::Yes); config->sync (); } - + kdDebugFuncOut(trace); } /*! - * \b 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 kpowersave::do_setSpeedPolicy(int menu_id){ if (trace) kdDebug() << funcinfo << "IN: " << "menu_id/set policy to: " << menu_id << endl; @@ -1328,22 +1328,22 @@ void kpowersave::do_setActiveScheme( int i ){ KPassivePopup::message( i18n("WARNING"), i18n("Scheme %1 could not be activated.").arg(scheme_menu->text(i)), SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 5000); - } + } kdDebugFuncOut(trace); } /*! * This function is invoked if something has to be updated. This including also menu entries. - * If the battery is in warning state (and powersave set pdaemon->send_battery_state_change_message) + * If the battery is in warning state (and powersave set pdaemon->send_battery_state_change_message) * the function pop-up a messagebox. */ void kpowersave::update(){ kdDebugFuncIn(trace); - + int redraw_pixmap = 0; QString justMins; - + /* need to redraw pixmap in toolbar */ if (hwinfo->update_info_ac_changed){ redraw_pixmap = 1; @@ -1380,8 +1380,8 @@ void kpowersave::update(){ this->contextMenu()->setItemVisible(HELP_SEPARATOR_MENU_ID, true); this->contextMenu()->setItemVisible(CONFIGURE_ID, true); this->contextMenu()->setItemVisible(CONFIGURE_EVENTS_ID, true); - - if (suspend.suspend2disk && (suspend.suspend2disk_allowed || + + if (suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) { this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, true); } else { @@ -1391,7 +1391,7 @@ void kpowersave::update(){ this->contextMenu()->setItemEnabled(SUSPEND2DISK_MENU_ID, false); } - if (suspend.suspend2ram && (suspend.suspend2ram_allowed || + if (suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) { this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, true); } else { @@ -1404,7 +1404,7 @@ void kpowersave::update(){ if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) { this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, true); } else { - if (!suspend.standby) + if (!suspend.standby) this->contextMenu()->setItemVisible(STANDBY_MENU_ID, false); else this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, false); @@ -1420,11 +1420,11 @@ void kpowersave::update(){ if (hwinfo->update_info_primBattery_changed == true){ justMins.setNum(primary->getRemainingMinutes() % 60); justMins = justMins.rightJustify(2, '0'); - + redraw_pixmap = 1; hwinfo->update_info_primBattery_changed = false; } - + updateSchemeMenu(); if (redraw_pixmap){ @@ -1446,7 +1446,7 @@ void kpowersave::updateCPUFreqMenu(){ contextMenu()->setItemVisible(CPUFREQ_MENU_ID, true); contextMenu()->setItemEnabled(CPUFREQ_MENU_ID, true); contextMenu()->setItemVisible(CPUFREQ_SEPARATOR_MENU_ID, true); - + switch (hwinfo->getCurrentCPUFreqPolicy()){ case PERFORMANCE: speed_menu->setItemChecked(PERFORMANCE, true); @@ -1478,16 +1478,16 @@ void kpowersave::updateCPUFreqMenu(){ contextMenu()->setItemVisible(CPUFREQ_SEPARATOR_MENU_ID, false); } } - + hwinfo->update_info_cpufreq_policy_changed = false; kdDebugFuncOut(trace); } /*! - * The function used to update the scheme menu. A update is needed if + * The function used to update the scheme menu. A update is needed if * if there is maybe new schemes or if the current scheme changed or switched - * By this way also set the settings for screensaver and other parameter + * By this way also set the settings for screensaver and other parameter * related to the selected scheme. */ void kpowersave::updateSchemeMenu(){ @@ -1516,7 +1516,7 @@ void kpowersave::updateSchemeMenu(){ int x = 0; for ( QStringList::iterator it = org_schemenames.begin(); it != org_schemenames.end(); ++it ) { - + QString _t = *it; if ( *it == settings->ac_scheme ){ @@ -1529,16 +1529,16 @@ void kpowersave::updateSchemeMenu(){ i18n( *it ), x, x); } else{ - if ((QString)*it == "Acoustic"){ + if ((QString)*it == "Acoustic"){ scheme_menu->insertItem(SmallIcon("scheme_acoustic", - QIconSet::Automatic), + QIconSet::Automatic), i18n("Acoustic"), x, x); } else if ((QString)*it == "Presentation"){ scheme_menu->insertItem(SmallIcon("scheme_presentation", - QIconSet::Automatic), + QIconSet::Automatic), i18n("Presentation"), x, x); - + } else if((QString)*it == "AdvancedPowersave") { scheme_menu->insertItem(SmallIcon("scheme_advanced_powersave", @@ -1556,7 +1556,7 @@ void kpowersave::updateSchemeMenu(){ } ++x; } - + if (x == 0 && scheme_menu){ // this should not happen, scheme_list should have been NULL before // now we'd have an empty menu ... @@ -1571,7 +1571,7 @@ void kpowersave::updateSchemeMenu(){ /*! - * Reimplemented eventhandler for mouse enterEvent. This is called if the mouse cursor + * Reimplemented eventhandler for mouse enterEvent. This is called if the mouse cursor * enters the widget. In this case if the user move the mouse cursor over the kpowersave * trayicon. \n \n * We use this event to update the Tooltip with all needed information. The time beetween @@ -1587,7 +1587,7 @@ void kpowersave::enterEvent( QEvent */*qee*/ ){ /*! * Event handler for mouse wheel events. If the system supports changing display * brightness and changing brightness is enabled in the current scheme settings, - * this will raise the brightness by one level for wheel up events and lower the + * this will raise the brightness by one level for wheel up events and lower the * brightness by one level for wheel down events. */ void kpowersave::wheelEvent (QWheelEvent *qwe) @@ -1609,10 +1609,10 @@ void kpowersave::wheelEvent (QWheelEvent *qwe) } /*! - * Reimplemented eventhandler for mousePressEvents which is involved if the user click - * on the icon on the kickerapplet. This was written to guarantee that a click with the - * right and the left mousebutton activate the menu. In the future this can also used - * to popup maybe a other menu. + * Reimplemented eventhandler for mousePressEvents which is involved if the user click + * on the icon on the kickerapplet. This was written to guarantee that a click with the + * right and the left mousebutton activate the menu. In the future this can also used + * to popup maybe a other menu. */ void kpowersave::mousePressEvent(QMouseEvent *qme){ kdDebugFuncIn(trace); @@ -1620,7 +1620,7 @@ void kpowersave::mousePressEvent(QMouseEvent *qme){ KSystemTray::mousePressEvent(qme); if (hwinfo->isOnline()) { if (qme->button() == RightButton){ - // TODO check if maybe some rechecks needed + // TODO check if maybe some rechecks needed this->contextMenu()->exec(QCursor::pos()); } else if (qme->button() == LeftButton) { showDetailedDialog(); @@ -1631,7 +1631,7 @@ void kpowersave::mousePressEvent(QMouseEvent *qme){ } /*! - * \b 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 kpowersave::closedetaileddialog() { @@ -1639,7 +1639,7 @@ void kpowersave::closedetaileddialog() { } /*! - * \b SLOT used to display error messages related to D-Bus in kpowersave. This function + * \b SLOT used to display error messages related to D-Bus in kpowersave. This function * block all messeges which we have in kpowersave! * TODO: do something usefull */ @@ -1649,7 +1649,7 @@ void kpowersave::showDBusErrorMsg( int type ){ static bool displayed = false; QString msg; - QString dlg_name; + QString dlg_name; switch (type) { case DBUS_RUNNING: @@ -1663,10 +1663,10 @@ void kpowersave::showDBusErrorMsg( int type ){ default: kdDebugFuncOut(trace); return; - } + } if (!displayed && !dlg_name.isEmpty()) { - infoDialog *dlg = new infoDialog( config, i18n("Warning"), msg, + infoDialog *dlg = new infoDialog( config, i18n("Warning"), msg, i18n("Don't show this message again."), dlg_name); if (!dlg->dialogIsDisabled()) { @@ -1679,8 +1679,8 @@ void kpowersave::showDBusErrorMsg( int type ){ kdDebugFuncOut(trace); } -/*! - * \b SLOT to display the HAL error message. We use this +/*! + * \b SLOT to display the HAL error message. We use this * function to delay the message, and prevent display them is HAL or * powersaved restarted. */ @@ -1696,7 +1696,7 @@ void kpowersave::showHalErrorMsg() { KPassivePopup::message( i18n("ERROR"), i18n("Could not get information from HAL. The haldaemon is " "maybe not running."), - SmallIcon("messagebox_warning", 20), this, + SmallIcon("messagebox_warning", 20), this, i18n("Error"), 5000); } else if (hwinfo->hal_terminated && !hal_error_shown && !DISPLAY_HAL_ERROR_Timer->isActive()) { @@ -1738,7 +1738,7 @@ void kpowersave::showErrorMessage( QString msg ){ /*! - * Use this function to set the SchemeSettings. This function currently set the + * Use this function to set the SchemeSettings. This function currently set the * e.g. the screensaver and dpms settings. Don't forget to call this function if * a scheme is changed or if the settings changed. */ @@ -1761,7 +1761,7 @@ void kpowersave::setSchemeSettings(){ else hwinfo->setPowerSave(true); } - + // --> set autosuspend settings if(settings->autoSuspend) { setAutoSuspend(false); @@ -1789,7 +1789,7 @@ void kpowersave::setSchemeSettings(){ display->blankOnlyScreen(false); } } - + } // TODO: check if this really work !!! else if(getenv("KDE_FULL_SESSION")) { // try to reset the complete screensaver settings. Ff this fail, use own methodes @@ -1806,14 +1806,14 @@ void kpowersave::setSchemeSettings(){ display->setScreenSaver(true); // What should we do with settings->kde->lock ? // Maybe nothing ?! - } + } } } else if ((getenv("DESKTOP_SESSION") != NULL) && !strcmp(getenv("DESKTOP_SESSION"), "gnome")) { // use this to set XScreensaver back to default settings this should // also cover the DPMS settings for GNOME/XScreensaver display->resetXScreensaver(); } - + // --> set DPMS settings if(settings->specPMSettings){ // set the new DPMS settings @@ -1828,7 +1828,7 @@ void kpowersave::setSchemeSettings(){ } } else if(getenv("KDE_FULL_SESSION")){ - // try to reset the KDE screensaver/DPMS settings (if there are also + // try to reset the KDE screensaver/DPMS settings (if there are also // no special screensaver settings) otherwise fall back and set values from files if (!settings->specSsSettings && !display->resetKDEScreensaver()) { settings->load_kde(); @@ -1844,7 +1844,7 @@ void kpowersave::setSchemeSettings(){ } } } - + // --> set brightness settings if(settings->brightness && hwinfo->supportBrightness()) { // set to given values @@ -1861,7 +1861,7 @@ void kpowersave::setSchemeSettings(){ /*! * \b SLOT which called to set and start the autosuspend monitoring. - * \param resumed boolean value which represent information if machine + * \param resumed boolean value which represent information if machine * currently back from suspend/standby */ void kpowersave::setAutoSuspend( bool resumed ){ @@ -1878,10 +1878,10 @@ void kpowersave::setAutoSuspend( bool resumed ){ autoSuspend->stop(); delete autoSuspend; autoSuspend = new autosuspend(); - connect(autoSuspend, SIGNAL(inactivityTimeExpired()), this, + connect(autoSuspend, SIGNAL(inactivityTimeExpired()), this, SLOT(do_autosuspendWarn())); } - + if (settings->autoSuspendCountdown && (settings->autoSuspendCountdownTimeout > 0)) { autoInactiveActionAfter = ((settings->autoInactiveActionAfter * 60) - settings->autoSuspendCountdownTimeout); @@ -1913,13 +1913,13 @@ void kpowersave::setAutoSuspend( bool resumed ){ /*! * \b SLOT which called to set and start the autodimm monitoring. - * \param resumed boolean value which represent information if machine + * \param resumed boolean value which represent information if machine * currently back from suspend/standby */ void kpowersave::setAutoDimm( bool resumed ){ if (trace) kdDebug() << funcinfo << "IN: " << "resumed? " << resumed << endl; - if(settings->autoDimmAfter > 0 && settings->autoDimm) { + if(settings->autoDimmAfter > 0 && settings->autoDimm) { if(settings->autoDimmTo < 0) { autoDimm->stop(); kdWarning() << "Not allowed or set level for dimm" << endl; @@ -1942,7 +1942,7 @@ void kpowersave::setAutoDimm( bool resumed ){ } else { if (autoDimm) autoDimm->stop(); - } + } kdDebugFuncOut(trace); } @@ -1950,7 +1950,7 @@ void kpowersave::setAutoDimm( bool resumed ){ // -------- start KNotify functions ------------- // /*! - * \b 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 @@ -2006,7 +2006,7 @@ void kpowersave::notifyBatteryStatusChange ( int type, int state ) { "cable immediately. Otherwise the machine\n" "will go shutdown in 30 seconds") .arg(min/ 60).arg(min%60)); - + QTimer::singleShot(30000, this, SLOT(handleCriticalBatteryActionCall())); } else { if (!settings->disableNotifications) @@ -2023,7 +2023,7 @@ void kpowersave::notifyBatteryStatusChange ( int type, int state ) { break; default: break; - } + } } else { // TODO: add some code later for the other batteries } @@ -2034,7 +2034,7 @@ void kpowersave::notifyBatteryStatusChange ( int type, int state ) { /*! * Function to call the action for battery critical event. This is ugly, but - * because of QTimer::singleShot() can't take param ... + * because of QTimer::singleShot() can't take param ... * NOTE: Use this only for SHUTDOWN atm */ void kpowersave::handleCriticalBatteryActionCall () { @@ -2052,7 +2052,7 @@ void kpowersave::handleCriticalBatteryActionCall () { * \param checkAC bool if there should be a check for AC state befor call the action */ void kpowersave::handleActionCall ( action action, int value , bool checkAC, bool batWarnCall ) { - if (trace) kdDebug() << funcinfo << "IN: " << "action: " << action << "value: " << value + if (trace) kdDebug() << funcinfo << "IN: " << "action: " << action << "value: " << value << "checkAC: " << checkAC << endl; if (hwinfo->currentSessionIsActive()) { @@ -2136,17 +2136,17 @@ void kpowersave::handleACStatusChange ( bool acstate , bool notifyEvent ) { KNotifyClient::event(this->winId(), "unplug_event", i18n("AC adapter unplugged")); } } - + // handle switch to AC/battery default scheme if (acstate) { index = settings->schemes.findIndex(settings->ac_scheme); } else { index = settings->schemes.findIndex(settings->battery_scheme); } - + if (index != -1) do_setActiveScheme(index); - + // update applet update(); } @@ -2171,7 +2171,7 @@ void kpowersave::notifySchemeSwitch() { else eventType = "scheme_" + _scheme; - KNotifyClient::event( this->winId(), eventType, + KNotifyClient::event( this->winId(), eventType, i18n("Switched to scheme: %1").arg(i18n(_scheme))); } @@ -2188,17 +2188,17 @@ void kpowersave::notifySuspend( int suspendType ) { if(!settings->disableNotifications) { switch (suspendType) { case SUSPEND2DISK: - KNotifyClient::event( this->winId(), "suspend2disk_event", + KNotifyClient::event( this->winId(), "suspend2disk_event", i18n("System is going into %1 now."). arg(i18n("Suspend to Disk"))); break; case SUSPEND2RAM: - KNotifyClient::event( this->winId(), "suspend2ram_event", + KNotifyClient::event( this->winId(), "suspend2ram_event", i18n("System is going into %1 now."). arg(i18n("Suspend to RAM"))); break; case STANDBY: - KNotifyClient::event( this->winId(), "standby_event", + KNotifyClient::event( this->winId(), "standby_event", i18n("System is going into %1 now."). arg(i18n("Standby"))); break; @@ -2216,7 +2216,7 @@ void kpowersave::notifySuspend( int suspendType ) { */ void kpowersave::forwardResumeSignal( int result ) { if (trace) kdDebug() << funcinfo << "IN: " << "result: " << result << endl; - + resume_result = result; QTimer::singleShot(100, this, SLOT(handleResumeSignal())); @@ -2235,7 +2235,7 @@ void kpowersave::handleResumeSignal() { if(settings->lockOnSuspend) { activateLoginScreen(); } - + // reset autosuspend and autodimm setAutoSuspend(true); setAutoDimm(true); @@ -2248,38 +2248,39 @@ void kpowersave::handleResumeSignal() { if(!settings->disableNotifications) { switch (calledSuspend) { case SUSPEND2DISK: - KNotifyClient::event( this->winId(), "resume_from_suspend2disk_event", + KNotifyClient::event( this->winId(), "resume_from_suspend2disk_event", i18n("System is resumed from %1.").arg( i18n("Suspend to Disk"))); break; case SUSPEND2RAM: - KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event", + KNotifyClient::event( this->winId(), "resume_from_suspend2ram_event", i18n("System is resumed from %1.").arg( i18n("Suspend to RAM"))); break; case STANDBY: - KNotifyClient::event( this->winId(), "resume_from_standby_event", + KNotifyClient::event( this->winId(), "resume_from_standby_event", i18n("System is resumed from %1.").arg( i18n("Standby"))); break; default: kdError() << "called suspend type unknown" << endl; break; - + } } // handle result of the resume/suspend - if (resume_result == 0 || resume_result == INT_MAX) { + // 1 is a valid return code; don't error out when it is received! + if ((resume_result == 0) || (resume_result == 1) || (resume_result == INT_MAX)) { if ( resume_result == INT_MAX ) kdWarning() << "Unknown if we successful resumed, look like a D-Bus timeout since " << "elapsed time between suspend and resume is higher than 6 hours" << endl; // successful resumed ... remount only in this case if (!handleMounts(false)) { - KPassivePopup::message( i18n("WARNING"), + KPassivePopup::message( i18n("WARNING"), i18n("Could not remount (all) external storage" - " media."), SmallIcon("messagebox_warning", 20), + " media."), SmallIcon("messagebox_warning", 20), this, i18n("Warning"), 15000); } } else { @@ -2311,7 +2312,7 @@ void kpowersave::handleResumeSignal() { break; default: break; - } + } #else logview = new LogViewer ("/var/log/pm-suspend.log"); logview->show(); @@ -2331,7 +2332,7 @@ void kpowersave::handleResumeSignal() { /*! * \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 scheme handling * TODO: fix critical battery situations (see the todo file in the source) */ void kpowersave::handleSessionState (bool state) { @@ -2341,15 +2342,15 @@ void kpowersave::handleSessionState (bool state) { // session is active again if (settings->autoSuspend) disableAutosuspend(false); if (settings->autoDimm) setAutoDimm(false); - /* handle may missed/not set AC status changes while the + /* handle may missed/not set AC status changes while the session was inactive and set them to the default schemes ?! */ handleACStatusChange(hwinfo->getAcAdapter(), false); - + } else { // session is now inactive if (settings->autoSuspend) disableAutosuspend(true); if (settings->autoDimm) autoDimm->stop(); - } + } kdDebugFuncOut(trace); } @@ -2393,9 +2394,9 @@ QString kpowersave::getSuspendString (int type) { */ bool kpowersave::lockScreen(){ kdDebugFuncIn(trace); - + settings->load_general_settings(); - + return display->lockScreen( settings->lockmethod ); kdDebugFuncOut(trace); @@ -2407,7 +2408,7 @@ bool kpowersave::lockScreen(){ */ QString kpowersave::currentScheme (){ kdDebugFuncIn(trace); - + if(hwinfo->isOnline()) { return settings->currentScheme; } else { @@ -2444,12 +2445,12 @@ QString kpowersave::currentCPUFreqPolicy() { } else { return "ERROR: HAL or/and DBus not running"; } - + kdDebugFuncOut(trace); } /*! - * DCOP Interface funtion to send a list with the allowed + * DCOP Interface funtion to send a list with the allowed * CPU Frequency states. * \return QStringList with the supported CPUFreq states */ @@ -2475,13 +2476,13 @@ QStringList kpowersave::listCPUFreqPolicies() { * \param policy QString with the policy to set, only values from * list_CPUFreqPolicies are allowed (except "NOT SUPPORTED") * \return boolean with the result of set the requested CPUFreq policy - * \retval true if successful set + * \retval true if successful set * \retval false if not supported or any other failure */ bool kpowersave::do_setCPUFreqPolicy( QString policy ) { if (trace) kdDebug() << funcinfo << "IN: " << "policy: " << policy << endl; - + bool ret = true; /* if (hwinfo->isCpuFreqAllowed() && hwinfo->isOnline()) { @@ -2504,26 +2505,26 @@ bool kpowersave::do_setCPUFreqPolicy( QString policy ) { } /*! - * DCOP Interface funtion to send a list with the supported and enabled + * DCOP Interface funtion to send a list with the supported and enabled * sleeping states. * \return QStringList with the supported spleeping states */ QStringList kpowersave::allowed_sleepingStates(){ kdDebugFuncIn(trace); - - QStringList sleepList; + + QStringList sleepList; if(hwinfo->isOnline()) { - if (suspend.suspend2disk && (suspend.suspend2disk_allowed || - suspend.suspend2disk_allowed == -1)){ + if (suspend.suspend2disk && (suspend.suspend2disk_allowed || + suspend.suspend2disk_allowed == -1)){ sleepList.append("suspendToDisk"); } - if (suspend.suspend2ram && (suspend.suspend2ram_allowed || - suspend.suspend2ram_allowed == -1)){ + if (suspend.suspend2ram && (suspend.suspend2ram_allowed || + suspend.suspend2ram_allowed == -1)){ sleepList.append("suspendToRAM"); } - if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)){ + if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)){ sleepList.append("standBy"); - } + } if(sleepList.isEmpty()){ sleepList.append("NO_SLEEPING_STATES_SUPPORTED"); } @@ -2531,7 +2532,7 @@ QStringList kpowersave::allowed_sleepingStates(){ else { sleepList.append("ERROR: D-Bus and/or HAL not running"); } - + kdDebugFuncOut(trace); return sleepList; } @@ -2543,7 +2544,7 @@ QStringList kpowersave::allowed_sleepingStates(){ QStringList kpowersave::listSchemes(){ kdDebugFuncIn(trace); - QStringList _schemeList; + QStringList _schemeList; if(hwinfo->isOnline()) { if (settings->schemes.count() > 0){ _schemeList = settings->schemes; @@ -2563,7 +2564,7 @@ QStringList kpowersave::listSchemes(){ * \return boolean with the result of set the requested scheme * \retval false if failed (e.g. scheme is not in the list) * \retval true if scheme found and set - * \param _scheme QString with the scheme to set, scheme should be + * \param _scheme QString with the scheme to set, scheme should be * named as list from list_schemes() */ bool kpowersave::do_setScheme( QString /*_scheme*/ ) { @@ -2625,13 +2626,13 @@ bool kpowersave::do_standBy(){ //! dcop function to set the brightness up bool kpowersave::do_brightnessUp(int percentageStep) { kdDebugFuncIn(trace); - + bool retval = false; - + if(hwinfo->isOnline()) { retval = hwinfo->setBrightnessUp(percentageStep); - } - + } + kdDebugFuncOut(trace); return retval; } @@ -2639,20 +2640,20 @@ bool kpowersave::do_brightnessUp(int percentageStep) { //! dcop function to set the brightness down bool kpowersave::do_brightnessDown(int percentageStep) { kdDebugFuncIn(trace); - + bool retval = false; - + if(hwinfo->isOnline()) { retval = hwinfo->setBrightnessDown(percentageStep); - } - + } + kdDebugFuncOut(trace); return retval; } /*! - * DCOP Interface funtion to stop/start the Autosuspend + * DCOP Interface funtion to stop/start the Autosuspend * \param disable boolean which tell if the autosuspend should be stopped (true) * or started (false). */ @@ -2694,7 +2695,7 @@ void kpowersave::showDetailedDialog( ){ detailedDlg->show(); detailedIsShown = true; } - + connect(detailedDlg, SIGNAL(destroyed()), this, SLOT(closedetaileddialog())); kdDebugFuncOut(trace); @@ -2704,11 +2705,11 @@ void kpowersave::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 true if correct opend + * \retval true if correct opend */ bool kpowersave::openConfigureDialog (){ kdDebugFuncIn(trace); - + if(hwinfo->isOnline()) { showConfigureDialog(); kdDebugFuncOut(trace); @@ -2730,7 +2731,7 @@ bool kpowersave::currentSchemeManagesDPMS () { kdDebugFuncIn(trace); return settings->specPMSettings; - + kdDebugFuncOut(trace); } @@ -2746,7 +2747,7 @@ int kpowersave::brightnessGet() { } kdDebugFuncOut(trace); - + return retval; } diff --git a/src/kpowersave.h b/src/kpowersave.h index cfd7e01..bd588cd 100644 --- a/src/kpowersave.h +++ b/src/kpowersave.h @@ -53,15 +53,15 @@ #include "settings.h" -/*! +/*! * \file kpowersave.h * \brief Headerfile for kpowersave.cpp and the class \ref kpowersave. */ - /*! + /*! * \class kpowersave * \brief The central class for the kpowersave-applet * \author Danny Kukawka, , - * \author Thomas Renninger, + * \author Thomas Renninger, * \date 2004 - 2007 */ @@ -74,7 +74,7 @@ private: // permanent pointers //! to configure kpowersave - KConfig *config; + KConfig *config; //! instance of \ref screen screen *display; //! instance of \ref settings @@ -97,13 +97,13 @@ private: //! instance of \ref countDownDialog countDownDialog *countdown; - + //! struct wth information about suspend states and permissions SuspendStates suspend; //! enum with the last called suspend, this need to be reset if needed int calledSuspend; - //! instance of \ref detaileddialog + //! instance of \ref detaileddialog detaileddialog *detailedDlg; //! represent the state of opened \ref detailedDlg @@ -132,8 +132,8 @@ private: bool icon_BG_is_colored; //! represent color status of the kickerapplet icon /*! - * This boolean represent the state of the kickerapplet icon. It don't display - * information about the icon backgrund like \ref icon_BG_is_colored . It say + * This boolean represent the state of the kickerapplet icon. It don't display + * information about the icon backgrund like \ref icon_BG_is_colored . It say * only that the icon is in state to have a blinking background . * \li true: if icon set to be colored * \li false: if icon isn't set to be colored @@ -144,7 +144,7 @@ private: * This boolean represent information about changing the icon background. It's used to * change the intervall of redraw the kickerapplet icon. * \li true: if the state of icon is changed - * \li false: if the state of icon isn't change + * \li false: if the state of icon isn't change */ bool icon_state_changed; //! represent the state of the suspend/progress dialog @@ -179,10 +179,10 @@ private: //! a menu entry ID /*! contains the ID of the menuentry for kpowersave configure Dialog */ int CONFIGURE_ID; - + int CONFIGURE_EVENTS_ID; - - //! a menu entry ID + + //! a menu entry ID /*! contains the ID of the menuentry for YaST-configuration */ int YAST_MODULE_MENU_ID; //! a menu seperator ID @@ -221,7 +221,7 @@ private: //! a menu ID /*! contains the ID of the help menu*/ int HELP_MENU; - + //! number of white pixel in the kickerapplet icon /*! * This integer value represent the number of white pixel in the icon for @@ -231,25 +231,25 @@ private: int countWhiteIconPixel; //! QTimer-interval for icon background - /*! + /*! * Time intervall to set the colored background of the batteryicon on/off. * The value is 1000 msec/ 1 sec. */ static const int BAT_icon_BG_intervall = 1000; //! QTimer-interval for display HAL error message - /*! + /*! * Time intervall to delay display the HAL error message to prevent displayed * the message if only HAL or powersave is restarted. The value is 15000 msec/ 15 sec. */ static const int HAL_ERROR_MSG_intervall = 15000; - + //! type of current running suspend /*! QString store the name of the current running suspend*/ QString suspendType; - - //! current name of the pixmap - /*! + + //! current name of the pixmap + /*! * Contains the current name of the icon/pixmap. The value must be a filename of a existing iconfile. * \sa power_icon, no_battery_icon, charge_icon, battery, battery_RED or battery_ORANGE */ @@ -259,10 +259,10 @@ private: /*! * This list store the real schemenames (not the i18n()-version) * regarding to position in the scheme-menu - */ + */ QStringList org_schemenames; - - //! a sub-menu of the kickerapplet + + //! a sub-menu of the kickerapplet /*! QPopupMenu for the cpufreq-entries. */ QPopupMenu *speed_menu; //! a sub-menu of the kickerapplet @@ -279,8 +279,8 @@ private: //! icon-pixmap /*! QPixmap with the full draw applet Icon (to be used in other classes) .*/ QPixmap fullIcon; - - + + //! Timer for the blinking Icon background /*! * This timer is used to let blink the background of a icon in kicker. @@ -295,11 +295,11 @@ private: QTimer *DISPLAY_HAL_ERROR_Timer; //! Timer to dimm down/up the brightness /*! - * This timer is used dimm the display up and down. The timerinterval + * This timer is used dimm the display up and down. The timerinterval * depends on calculated timePerStep in the calling function. */ QTimer *AUTODIMM_Timer; - + //! draw all icon related things for \ref redrawPixmap() void drawIcon(); //! to intialise the menu for the kickerapplet @@ -313,7 +313,7 @@ private: //! to update the Tooltip of the kickerapplet void updateTooltip(); - //! Eventhandler to catch mouse-press-events and react + //! Eventhandler to catch mouse-press-events and react void mousePressEvent( QMouseEvent *qme ); //! Event handler to catch mouse wheel events and react void wheelEvent( QWheelEvent *qwe ); @@ -334,7 +334,7 @@ private slots: bool do_suspend2disk(); //! send command for suspend_to_RAM to the HAL daemon bool do_suspend2ram(); - + //! show warning dialog or call autosuspend if signal \ref inactivity::inactivityTimeExpired() recieved void do_autosuspendWarn(); //! execute the autosuspend @@ -400,7 +400,7 @@ private slots: void handleSleepButtonEvent(); //! handle event for press s2disk button and call action void handleS2DiskButtonEvent(); - + //! handle changes of the session state void handleSessionState (bool state); @@ -438,13 +438,13 @@ public: kpowersave( bool force_acpi_check = false, bool trace_func = false); //! default destructor virtual ~kpowersave(); - -k_dcop: + +k_dcop: //! dcop function to lock the screen bool lockScreen(); - //! dcop function to set a scheme + //! dcop function to set a scheme bool do_setScheme( QString ); - //! dcop function to set CPU Freq policy + //! dcop function to set CPU Freq policy bool do_setCPUFreqPolicy( QString ); //! dcop function to send 'suspend to disk' command to powersaved bool do_suspendToDisk(); @@ -470,16 +470,16 @@ k_dcop: //! dcop funtion to get the current brightness level int brightnessGet(); - //! dcop function to return the name of the current scheme + //! dcop function to return the name of the current scheme QString currentScheme (); //! dcop function to return the current cpufreqpolicy QString currentCPUFreqPolicy(); - + //! dcop function to return the supported sleeping states QStringList allowed_sleepingStates(); //! dcop function to return the schemes QStringList listSchemes(); - //! dcop function to return the supported CPU + //! dcop function to return the supported CPU QStringList listCPUFreqPolicies(); };