mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-13 05:01:30 +00:00
Make Okular inhibit sleep and screen power management when in Presentation mode
REVIEW:103713
This commit is contained in:
parent
2c9122192d
commit
1a31dffca9
|
@ -189,7 +189,7 @@ qt4_add_dbus_interfaces(okularpart_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpe
|
||||||
|
|
||||||
kde4_add_plugin(okularpart ${okularpart_SRCS})
|
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})
|
install(TARGETS okularpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include <kshortcut.h>
|
#include <kshortcut.h>
|
||||||
#include <kdialog.h>
|
#include <kdialog.h>
|
||||||
|
|
||||||
|
#include <Solid/PowerManagement>
|
||||||
|
|
||||||
// system includes
|
// system includes
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -1391,14 +1393,19 @@ void PresentationWidget::applyNewScreenSize( const QSize & oldSize )
|
||||||
|
|
||||||
void PresentationWidget::inhibitScreenSaver()
|
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",
|
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.ScreenSaver", "/ScreenSaver",
|
||||||
"org.freedesktop.ScreenSaver", "Inhibit" );
|
"org.freedesktop.ScreenSaver", "Inhibit" );
|
||||||
message << QString( "Okular" );
|
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 );
|
QDBusReply<uint> reply = QDBusConnection::sessionBus().call( message );
|
||||||
if ( reply.isValid() )
|
if ( reply.isValid() )
|
||||||
m_screenSaverCookie = reply.value();
|
m_screenSaverCookie = reply.value();
|
||||||
|
|
||||||
|
// Inhibit screen and sleep
|
||||||
|
m_screenInhibitCookie = Solid::PowerManagement::beginSuppressingScreenPowerManagement(reason);
|
||||||
|
m_sleepInhibitCookie = Solid::PowerManagement::beginSuppressingSleep(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresentationWidget::allowScreenSaver()
|
void PresentationWidget::allowScreenSaver()
|
||||||
|
@ -1410,6 +1417,10 @@ void PresentationWidget::allowScreenSaver()
|
||||||
message << (uint)m_screenSaverCookie;
|
message << (uint)m_screenSaverCookie;
|
||||||
QDBusConnection::sessionBus().send( message );
|
QDBusConnection::sessionBus().send( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove cookies
|
||||||
|
Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_screenInhibitCookie);
|
||||||
|
Solid::PowerManagement::stopSuppressingSleep(m_sleepInhibitCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresentationWidget::showTopBar( bool show )
|
void PresentationWidget::showTopBar( bool show )
|
||||||
|
|
|
@ -105,6 +105,8 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
|
||||||
QRect m_drawingRect;
|
QRect m_drawingRect;
|
||||||
int m_screen;
|
int m_screen;
|
||||||
int m_screenSaverCookie;
|
int m_screenSaverCookie;
|
||||||
|
int m_screenInhibitCookie;
|
||||||
|
int m_sleepInhibitCookie;
|
||||||
|
|
||||||
// transition related
|
// transition related
|
||||||
QTimer * m_transitionTimer;
|
QTimer * m_transitionTimer;
|
||||||
|
|
Loading…
Reference in a new issue