summaryrefslogtreecommitdiffstats
path: root/src/tdepowersave.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-08-29 20:50:54 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-08-29 20:50:54 -0500
commitba6b20795df0c7a3344ca2a77042e8eee7ac744c (patch)
treeaebb713b0742f9ac8fa2fcd9c9c2856e38b023cf /src/tdepowersave.cpp
parentf5d1ba39dc125e663103d5bfb0dffdd6cdfba989 (diff)
downloadtdepowersave-ba6b20795df0c7a3344ca2a77042e8eee7ac744c.tar.gz
tdepowersave-ba6b20795df0c7a3344ca2a77042e8eee7ac744c.zip
Completely disable autosuspend functions if system does not support suspend
This relates to Bug 1615
Diffstat (limited to 'src/tdepowersave.cpp')
-rw-r--r--src/tdepowersave.cpp103
1 files changed, 74 insertions, 29 deletions
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index 2958d72..b54b990 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -859,38 +859,61 @@ bool tdepowersave::do_standby(){
void tdepowersave::do_autosuspendWarn() {
kdDebugFuncIn(trace);
- if (settings->autoSuspendCountdown && (settings->autoSuspendCountdownTimeout > 0)) {
- // we have to display the warn dialog
- if(!contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) {
- TQString message;
-
- countdown = new countDownDialog(settings->autoSuspendCountdownTimeout);
+ // Verify that the desired suspend action is allowed before displaying the dialog
+ SuspendStates suspend = hwinfo->getSuspendSupport();
+ bool allowed = false;
+ if(settings->autoInactiveAction == "Suspend to Disk") {
+ if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Suspend to RAM") {
+ if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Standby") {
+ if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
+ allowed = true;
+ }
+ }
- if(settings->autoInactiveAction == "Suspend to Disk") {
- countdown->setPixmap("suspend2disk");
- } else if (settings->autoInactiveAction == "Suspend to RAM") {
- countdown->setPixmap("suspend2ram");
- } else if (settings->autoInactiveAction == "Standby") {
- countdown->setPixmap("standby");
- } else {
- countdown->setPixmap("tdepowersave");
- }
+ if (allowed) {
+ if (settings->autoSuspendCountdown && (settings->autoSuspendCountdownTimeout > 0)) {
+ // we have to display the warn dialog
+ if(!contextMenu()->isItemChecked(AUTOSUSPEND_MENU_ID)) {
+ TQString message;
+
+ countdown = new countDownDialog(settings->autoSuspendCountdownTimeout);
+
+ if(settings->autoInactiveAction == "Suspend to Disk") {
+ countdown->setPixmap("suspend2disk");
+ } else if (settings->autoInactiveAction == "Suspend to RAM") {
+ countdown->setPixmap("suspend2ram");
+ } else if (settings->autoInactiveAction == "Standby") {
+ countdown->setPixmap("standby");
+ } else {
+ countdown->setPixmap("tdepowersave");
+ }
- // 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 "
- "expires.").arg(i18n("Autosuspend")) + "\n\n" +
- i18n("The computer autosuspend in: ");
+ // 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 "
+ "expires.").arg(i18n("Autosuspend")) + "\n\n" +
+ i18n("The computer autosuspend in: ");
- countdown->setMessageText(message);
+ countdown->setMessageText(message);
- connect(countdown, TQT_SIGNAL(dialogClosed(bool)), this, TQT_SLOT(do_autosuspend(bool)));
- countdown->showDialog();
+ connect(countdown, TQT_SIGNAL(dialogClosed(bool)), this, TQT_SLOT(do_autosuspend(bool)));
+ countdown->showDialog();
+ }
+ }
+ else {
+ // call directly autosuspend
+ do_autosuspend(false);
}
- } else {
- // call directly autosuspend
- do_autosuspend(false);
}
+
kdDebugFuncOut(trace);
}
@@ -1701,7 +1724,8 @@ void tdepowersave::setSchemeSettings(){
// --> set autosuspend settings
if(settings->autoSuspend) {
setAutoSuspend(false);
- } else {
+ }
+ else {
this->contextMenu()->setItemVisible(AUTOSUSPEND_MENU_ID, false);
this->contextMenu()->setItemChecked(AUTOSUSPEND_MENU_ID, false);
this->contextMenu()->setItemVisible(AUTOSUSPEND_SEPARATOR_MENU_ID, false);
@@ -1803,6 +1827,28 @@ void tdepowersave::setSchemeSettings(){
void tdepowersave::setAutoSuspend( bool resumed ){
if (trace) kdDebug() << funcinfo << "IN: " << "resumed? " << resumed << endl;
+ // Verify that the desired suspend action is allowed before enabling autosuspend
+ SuspendStates suspend = hwinfo->getSuspendSupport();
+ bool allowed = false;
+ if(settings->autoInactiveAction == "Suspend to Disk") {
+ if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Suspend to RAM") {
+ if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ else if (settings->autoInactiveAction == "Standby") {
+ if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
+ allowed = true;
+ }
+ }
+ if (!allowed) {
+ settings->autoSuspend = false;
+ }
+
if(settings->autoInactiveActionAfter > 0 && settings->autoSuspend) {
int autoInactiveActionAfter = 0;
@@ -1814,8 +1860,7 @@ void tdepowersave::setAutoSuspend( bool resumed ){
autoSuspend->stop();
delete autoSuspend;
autoSuspend = new autosuspend();
- connect(autoSuspend, TQT_SIGNAL(inactivityTimeExpired()), this,
- TQT_SLOT(do_autosuspendWarn()));
+ connect(autoSuspend, TQT_SIGNAL(inactivityTimeExpired()), this, TQT_SLOT(do_autosuspendWarn()));
}
if (settings->autoSuspendCountdown && (settings->autoSuspendCountdownTimeout > 0)) {