Make Okular inhibit sleep and screen power management when in Presentation mode

REVIEW:103713
This commit is contained in:
Dario Freddi 2012-01-18 01:04:06 +01:00
parent 2c9122192d
commit 1a31dffca9
3 changed files with 15 additions and 2 deletions

View file

@ -189,7 +189,7 @@ qt4_add_dbus_interfaces(okularpart_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpe
kde4_add_plugin(okularpart ${okularpart_SRCS})
target_link_libraries(okularpart okularcore ${KDE4_KPARTS_LIBS} ${KDE4_KPRINTUTILS_LIBS} ${MATH_LIB} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_PHONON_LIBRARY})
target_link_libraries(okularpart okularcore ${KDE4_KPARTS_LIBS} ${KDE4_KPRINTUTILS_LIBS} ${MATH_LIB} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_PHONON_LIBRARY} ${KDE4_SOLID_LIBRARY})
install(TARGETS okularpart DESTINATION ${PLUGIN_INSTALL_DIR})

View file

@ -41,6 +41,8 @@
#include <kshortcut.h>
#include <kdialog.h>
#include <Solid/PowerManagement>
// system includes
#include <stdlib.h>
#include <math.h>
@ -1391,14 +1393,19 @@ void PresentationWidget::applyNewScreenSize( const QSize & oldSize )
void PresentationWidget::inhibitScreenSaver()
{
QString reason = i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" );
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.ScreenSaver", "/ScreenSaver",
"org.freedesktop.ScreenSaver", "Inhibit" );
message << QString( "Okular" );
message << i18nc( "Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a presentation" );
message << reason;
QDBusReply<uint> reply = QDBusConnection::sessionBus().call( message );
if ( reply.isValid() )
m_screenSaverCookie = reply.value();
// Inhibit screen and sleep
m_screenInhibitCookie = Solid::PowerManagement::beginSuppressingScreenPowerManagement(reason);
m_sleepInhibitCookie = Solid::PowerManagement::beginSuppressingSleep(reason);
}
void PresentationWidget::allowScreenSaver()
@ -1410,6 +1417,10 @@ void PresentationWidget::allowScreenSaver()
message << (uint)m_screenSaverCookie;
QDBusConnection::sessionBus().send( message );
}
// Remove cookies
Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_screenInhibitCookie);
Solid::PowerManagement::stopSuppressingSleep(m_sleepInhibitCookie);
}
void PresentationWidget::showTopBar( bool show )

View file

@ -105,6 +105,8 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
QRect m_drawingRect;
int m_screen;
int m_screenSaverCookie;
int m_screenInhibitCookie;
int m_sleepInhibitCookie;
// transition related
QTimer * m_transitionTimer;