Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Dragon
Commits
0b3bcc92
Commit
0b3bcc92
authored
Dec 20, 2016
by
Anthony Fieroni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inhibit powersave
REVIEW:129651 Signed-off-by:
Anthony Fieroni
<
bvbfan@abv.bg
>
parent
ccac1eb4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
19 deletions
+36
-19
CMakeLists.txt
CMakeLists.txt
+1
-0
src/app/CMakeLists.txt
src/app/CMakeLists.txt
+2
-0
src/app/mainWindow.cpp
src/app/mainWindow.cpp
+33
-19
No files found.
CMakeLists.txt
View file @
0b3bcc92
...
...
@@ -44,6 +44,7 @@ find_package(KF5 REQUIRED
WidgetsAddons
WindowSystem
XmlGui
Notifications
)
find_package
(
Phonon4Qt5 4.6.60 REQUIRED NO_MODULE
)
...
...
src/app/CMakeLists.txt
View file @
0b3bcc92
...
...
@@ -44,6 +44,7 @@ target_link_libraries(dragon
KF5::DBusAddons
KF5::JobWidgets
KF5::WindowSystem
KF5::Notifications
${
PHONON_LIBRARY
}
)
...
...
@@ -70,6 +71,7 @@ target_link_libraries(dragonpart
KF5::XmlGui
KF5::JobWidgets
KF5::WindowSystem
KF5::Notifications
${
PHONON_LIBRARY
}
)
...
...
src/app/mainWindow.cpp
View file @
0b3bcc92
...
...
@@ -41,8 +41,12 @@
#include <QMenu>
#include <QMenuBar>
#include <QStatusBar>
#include <QDBusReply>
#include <QDBusInterface>
#include <QDBusUnixFileDescriptor>
//#include <KNotificationRestrictions> // kf5 FIXME
#include <KAboutData>
#include <KNotificationRestrictions>
#include <KSqueezedTextLabel>
#include <KToggleFullScreenAction>
#include <KToolBar>
...
...
@@ -61,9 +65,6 @@
#include <Solid/Device>
#include <Solid/OpticalDisc>
#if 0 // kf5 FIXME port to new Solid::Power API
#include <solid/powermanagement.h>
#endif
#include "actions.h"
#include "discSelectionDialog.h"
...
...
@@ -817,36 +818,49 @@ MainWindow::keyPressEvent( QKeyEvent *e )
void
MainWindow
::
inhibitPowerSave
()
{
#if 0 // kf5 FIXME port to new Solid::Power API
if (m_stopSleepCookie == -1)
m_stopSleepCookie = Solid::PowerManagement::beginSuppressingSleep(QLatin1String( "watching a film" ));
if (m_stopScreenPowerMgmtCookie == -1 && TheStream::hasVideo())
m_stopScreenPowerMgmtCookie = Solid::PowerManagement::beginSuppressingScreenPowerManagement(QLatin1String( "watching a film" ));
if
(
m_stopSleepCookie
==
-
1
)
{
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.login1"
),
QStringLiteral
(
"/org/freedesktop/login1"
),
QStringLiteral
(
"org.freedesktop.login1.Manager"
),
QDBusConnection
::
systemBus
());
if
(
iface
.
isValid
())
{
QDBusReply
<
QDBusUnixFileDescriptor
>
reply
;
if
(
TheStream
::
hasVideo
())
{
reply
=
iface
.
call
(
QStringLiteral
(
"Inhibit"
),
QStringLiteral
(
"sleep:idle"
),
KAboutData
::
applicationData
().
componentName
(),
QStringLiteral
(
"playing a video"
),
QStringLiteral
(
"block"
));
}
else
{
reply
=
iface
.
call
(
QStringLiteral
(
"Inhibit"
),
QStringLiteral
(
"sleep"
),
KAboutData
::
applicationData
().
componentName
(),
QStringLiteral
(
"playing an audio"
),
QStringLiteral
(
"block"
));
}
if
(
reply
.
isValid
())
{
m_stopSleepCookie
=
reply
.
value
().
fileDescriptor
();
}
}
}
// TODO: inhibit screen sleep. No viable API found.
// https://git.reviewboard.kde.org/r/129651
if
(
!
m_stopScreenSaver
&&
TheStream
::
hasVideo
())
m_stopScreenSaver
=
new
KNotificationRestrictions
(
KNotificationRestrictions
::
ScreenSaver
);
#endif
}
void
MainWindow
::
releasePowerSave
()
{
#if 0 // kf5 FIXME port to new Solid::Power API
//stop supressing sleep
if
(
m_stopSleepCookie
!=
-
1
)
{
Solid::PowerManagement::stopSuppressingSleep
(m_stopSleepCookie);
::
close
(
m_stopSleepCookie
);
m_stopSleepCookie
=
-
1
;
}
//stop supressing screen power management
if (m_stopScreenPowerMgmtCookie != -1) {
Solid::PowerManagement::stopSuppressingScreenPowerManagement(m_stopScreenPowerMgmtCookie);
m_stopScreenPowerMgmtCookie = -1;
}
//stop disabling screensaver
delete
m_stopScreenSaver
;
// It is always 0, I have been careful.
m_stopScreenSaver
=
0
;
#endif
}
QMenu
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment