[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [dragon] src/app: make sure power saving is resumed when quitting the app
From: Harald Sitter <sitter () kde ! org>
Date: 2012-05-31 22:24:27
Message-ID: 20120531222427.DEC47A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit ac92ddb3c2fe7ecc4009d0f2f1ec33843949ea2e by Harald Sitter.
Committed on 01/06/2012 at 00:24.
Pushed by sitter into branch 'master'.
make sure power saving is resumed when quitting the app
BUG: 290587
M +26 -0 src/app/mainWindow.cpp
M +3 -0 src/app/mainWindow.h
M +2 -19 src/app/stateChange.cpp
http://commits.kde.org/dragon/ac92ddb3c2fe7ecc4009d0f2f1ec33843949ea2e
diff --git a/src/app/mainWindow.cpp b/src/app/mainWindow.cpp
index 3197986..b0e92b9 100644
--- a/src/app/mainWindow.cpp
+++ b/src/app/mainWindow.cpp
@@ -255,6 +255,7 @@ MainWindow::init()
MainWindow::~MainWindow()
{
hide(); //so we appear to have quit, and then sound fades out below
+ releasePowerSave();
delete videoWindow(); //fades out sound in dtor
}
@@ -780,6 +781,31 @@ MainWindow::keyPressEvent( QKeyEvent *e )
#undef seek
}
+void
+MainWindow::inhibitPowerSave()
+{
+ m_stopSleepCookie = Solid::PowerManagement::beginSuppressingSleep(QLatin1String( \
"watching a film" )); + m_stopScreenPowerMgmtCookie = \
Solid::PowerManagement::beginSuppressingScreenPowerManagement(QLatin1String( \
"watching a film" )); + if (!m_stopScreenSaver)
+ m_stopScreenSaver = new \
KNotificationRestrictions(KNotificationRestrictions::ScreenSaver); +}
+
+void
+MainWindow::releasePowerSave()
+{
+ //stop supressing sleep
+ if (m_stopSleepCookie != -1)
+ Solid::PowerManagement::stopSuppressingSleep(m_stopSleepCookie);
+
+ //stop supressing screen power management
+ if (m_stopScreenPowerMgmtCookie != -1)
+ Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_stopScreenPowerMgmtCookie);
+
+ //stop disabling screensaver
+ delete m_stopScreenSaver; // It is always 0, I have been careful.
+ m_stopScreenSaver = 0;
+}
+
QMenu*
MainWindow::menu( const char *name )
{
diff --git a/src/app/mainWindow.h b/src/app/mainWindow.h
index f581374..502758d 100644
--- a/src/app/mainWindow.h
+++ b/src/app/mainWindow.h
@@ -111,6 +111,9 @@ namespace Dragon
virtual void dropEvent( QDropEvent* );
virtual void keyPressEvent( QKeyEvent* );
+ void inhibitPowerSave();
+ void releasePowerSave();
+
// virtual void saveProperties( KConfig* );
// virtual void readProperties( KConfig* );
diff --git a/src/app/stateChange.cpp b/src/app/stateChange.cpp
index f54b75c..3593f86 100644
--- a/src/app/stateChange.cpp
+++ b/src/app/stateChange.cpp
@@ -118,26 +118,9 @@ MainWindow::engineStateChanged( Phonon::State state, \
Phonon::State oldstate )
/// turn off screensaver
if( state == Phonon::PlayingState )
- {
- m_stopSleepCookie = \
Solid::PowerManagement::beginSuppressingSleep(QLatin1String( \
"watching a film" ));
- m_stopScreenPowerMgmtCookie = \
Solid::PowerManagement::beginSuppressingScreenPowerManagement(QLatin1String( \
"watching a film" ));
- if (!m_stopScreenSaver)
- m_stopScreenSaver = new \
KNotificationRestrictions(KNotificationRestrictions::ScreenSaver);
- }
+ inhibitPowerSave();
else if( Phonon::StoppedState || !TheStream::hasMedia() )
- {
- //stop supressing sleep
- if (m_stopSleepCookie != -1)
- Solid::PowerManagement::stopSuppressingSleep(m_stopSleepCookie);
-
- //stop supressing screen power management
- if (m_stopScreenPowerMgmtCookie != -1)
- Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_stopScreenPowerMgmtCookie);
-
- //stop disabling screensaver
- delete m_stopScreenSaver; // It is always 0, I have been careful.
- m_stopScreenSaver = 0;
- }
+ releasePowerSave();
updateTitleBarText();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic