1
0
Fork 0

[UI+Backend] Hopefuly make disabling screensaver better and added per theme colours.

This commit is contained in:
NamedKitten 2018-12-01 12:10:52 +00:00
parent ea40440d72
commit 2b05c3184d
21 changed files with 126 additions and 100 deletions

View file

@ -109,7 +109,7 @@ DirectMpvPlayerBackend::DirectMpvPlayerBackend(QQuickItem* parent)
mpv_observe_property(mpv, 0, "sub-text", MPV_FORMAT_STRING); mpv_observe_property(mpv, 0, "sub-text", MPV_FORMAT_STRING);
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NONE); mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE); mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE);
mpv_set_wakeup_callback(mpv, wakeup, this); mpv_set_wakeup_callback(mpv, wakeup, this);
@ -541,7 +541,6 @@ DirectMpvPlayerBackend::handle_mpv_event(mpv_event* event)
if (prop->format == MPV_FORMAT_DOUBLE) { if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *(double*)prop->data; double time = *(double*)prop->data;
emit durationChanged(time); emit durationChanged(time);
Utils::ResetScreensaver();
} }
} else if (strcmp(prop->name, "mute") == 0 || } else if (strcmp(prop->name, "mute") == 0 ||
strcmp(prop->name, "volume") == 0) { strcmp(prop->name, "volume") == 0) {
@ -578,10 +577,14 @@ DirectMpvPlayerBackend::handle_mpv_event(mpv_event* event)
emit playlistPositionChanged(pos); emit playlistPositionChanged(pos);
} }
} else if (strcmp(prop->name, "pause") == 0) { } else if (strcmp(prop->name, "pause") == 0) {
if (getProperty("pause").toBool()) { mpv_node* nod = (mpv_node*)prop->data;
if (mpv::qt::node_to_variant(nod).toBool()) {
emit playStatusChanged(Enums::PlayStatus::Paused); emit playStatusChanged(Enums::PlayStatus::Paused);
Utils::SetScreensaver(window()->winId(), true);
} else { } else {
emit playStatusChanged(Enums::PlayStatus::Playing); emit playStatusChanged(Enums::PlayStatus::Playing);
Utils::SetScreensaver(window()->winId(), true);
} }
} else if (strcmp(prop->name, "track-list") == 0) { } else if (strcmp(prop->name, "track-list") == 0) {
mpv_node* nod = (mpv_node*)prop->data; mpv_node* nod = (mpv_node*)prop->data;

View file

@ -159,7 +159,7 @@ MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent)
mpv_observe_property(mpv, 0, "sub-text", MPV_FORMAT_STRING); mpv_observe_property(mpv, 0, "sub-text", MPV_FORMAT_STRING);
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NODE);
mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE); mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NODE);
mpv_set_wakeup_callback(mpv, wakeup, this); mpv_set_wakeup_callback(mpv, wakeup, this);
@ -519,7 +519,6 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
if (prop->format == MPV_FORMAT_DOUBLE) { if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *(double*)prop->data; double time = *(double*)prop->data;
emit durationChanged(time); emit durationChanged(time);
Utils::ResetScreensaver();
} }
} else if (strcmp(prop->name, "mute") == 0 || } else if (strcmp(prop->name, "mute") == 0 ||
strcmp(prop->name, "volume") == 0) { strcmp(prop->name, "volume") == 0) {
@ -558,11 +557,12 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
} }
} else if (strcmp(prop->name, "pause") == 0) { } else if (strcmp(prop->name, "pause") == 0) {
mpv_node* nod = (mpv_node*)prop->data; mpv_node* nod = (mpv_node*)prop->data;
qDebug() << mpv::qt::node_to_variant(nod); if (mpv::qt::node_to_variant(nod).toBool()) {
if (getProperty("pause").toBool()) {
emit playStatusChanged(Enums::PlayStatus::Paused); emit playStatusChanged(Enums::PlayStatus::Paused);
Utils::SetScreensaver(window()->winId(), true);
} else { } else {
emit playStatusChanged(Enums::PlayStatus::Playing); emit playStatusChanged(Enums::PlayStatus::Playing);
Utils::SetScreensaver(window()->winId(), false);
} }
} else if (strcmp(prop->name, "track-list") == 0) { } else if (strcmp(prop->name, "track-list") == 0) {
mpv_node* nod = (mpv_node*)prop->data; mpv_node* nod = (mpv_node*)prop->data;

View file

@ -81,7 +81,8 @@ Item {
opacity: 1 opacity: 1
background: Rectangle { background: Rectangle {
id: subsBackground id: subsBackground
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
width: subsContainer.childrenRect.width width: subsContainer.childrenRect.width
height: subsContainer.childrenRect.height height: subsContainer.childrenRect.height
} }
@ -106,7 +107,8 @@ Item {
anchors.right: parent.right anchors.right: parent.right
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
visible: controlsOverlay.controlsShowing visible: controlsOverlay.controlsShowing
} }

View file

@ -6,7 +6,8 @@ Menu {
background: Rectangle { background: Rectangle {
implicitWidth: parent.width implicitWidth: parent.width
implicitHeight: 10 implicitHeight: 10
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
} }
delegate: CustomMenuItem { delegate: CustomMenuItem {
} }

View file

@ -6,7 +6,8 @@ import player 1.0
Rectangle { Rectangle {
id: chapterMarker id: chapterMarker
property int time: 0 property int time: 0
color: appearance.chapterMarkerColor color: getAppearanceValueForTheme(appearance.themeName,
"chapterMarkerColor")
Connections { Connections {
target: player target: player
enabled: true enabled: true

View file

@ -166,7 +166,8 @@ MenuBar {
background: Rectangle { background: Rectangle {
width: parent.width width: parent.width
implicitHeight: 10 implicitHeight: 10
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
} }
CustomMenu { CustomMenu {

View file

@ -40,7 +40,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
BackwardButton { BackwardButton {
id: backwardButton id: backwardButton
@ -63,7 +62,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
PlaylistNextButton { PlaylistNextButton {
id: playlistNextButton id: playlistNextButton
@ -72,7 +70,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
FullscreenButton { FullscreenButton {
@ -82,7 +79,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
SettingsButton { SettingsButton {
id: settingsButton id: settingsButton
@ -91,6 +87,5 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
} }

View file

@ -10,7 +10,7 @@ import player 1.0
Button { Button {
id: backwardButton id: backwardButton
icon.source: "icons/" + appearance.themeName + "/backward.svg" icon.source: "icons/" + appearance.themeName + "/backward.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.Seek, "-10") player.playerCommand(Enums.Commands.Seek, "-10")

View file

@ -10,7 +10,7 @@ import player 1.0
Button { Button {
id: forwardButton id: forwardButton
icon.source: "icons/" + appearance.themeName + "/forward.svg" icon.source: "icons/" + appearance.themeName + "/forward.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.Seek, "10") player.playerCommand(Enums.Commands.Seek, "10")

View file

@ -9,9 +9,8 @@ import player 1.0
Button { Button {
id: fullscreenButton id: fullscreenButton
//icon.name: "fullscreen"
icon.source: "icons/" + appearance.themeName + "/fullscreen.svg" icon.source: "icons/" + appearance.themeName + "/fullscreen.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
display: AbstractButton.IconOnly display: AbstractButton.IconOnly

View file

@ -10,7 +10,7 @@ import player 1.0
Button { Button {
id: playPauseButton id: playPauseButton
icon.source: "icons/" + appearance.themeName + "/pause.svg" icon.source: "icons/" + appearance.themeName + "/pause.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.TogglePlayPause) player.playerCommand(Enums.Commands.TogglePlayPause)

View file

@ -11,7 +11,7 @@ Button {
id: playlistNextButton id: playlistNextButton
//icon.name: "next" //icon.name: "next"
icon.source: "icons/" + appearance.themeName + "/next.svg" icon.source: "icons/" + appearance.themeName + "/next.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.NextPlaylistItem) player.playerCommand(Enums.Commands.NextPlaylistItem)

View file

@ -11,7 +11,7 @@ Button {
id: playlistPrevButton id: playlistPrevButton
objectName: "playlistPrevButton" objectName: "playlistPrevButton"
icon.source: "icons/" + appearance.themeName + "/prev.svg" icon.source: "icons/" + appearance.themeName + "/prev.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
visible: appearance.themeName == "Youtube" ? false : true visible: appearance.themeName == "Youtube" ? false : true
onClicked: { onClicked: {

View file

@ -11,7 +11,7 @@ Button {
id: settingsButton id: settingsButton
//icon.name: "settings" //icon.name: "settings"
icon.source: "icons/" + appearance.themeName + "/settings.svg" icon.source: "icons/" + appearance.themeName + "/settings.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {

View file

@ -75,13 +75,15 @@ Slider {
width: progressBar.availableWidth width: progressBar.availableWidth
height: progressBar.getProgressBarHeight( height: progressBar.getProgressBarHeight(
fun.nyanCat, mouseAreaProgressBar.containsMouse) fun.nyanCat, mouseAreaProgressBar.containsMouse)
color: appearance.progressBackgroundColor color: getAppearanceValueForTheme(appearance.themeName,
"progressBackgroundColor")
Rectangle { Rectangle {
x: (mouseAreaProgressBar.mouseX - hoverProgressLabel.width / 2) x: (mouseAreaProgressBar.mouseX - hoverProgressLabel.width / 2)
y: progressBackground.y - 20 - hoverProgressLabel.height y: progressBackground.y - 20 - hoverProgressLabel.height
visible: mouseAreaProgressBar.containsMouse visible: mouseAreaProgressBar.containsMouse
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
height: hoverProgressLabel.height height: hoverProgressLabel.height
width: hoverProgressLabel.width width: hoverProgressLabel.width
z: 80 z: 80
@ -105,7 +107,8 @@ Slider {
Rectangle { Rectangle {
width: cachedLength.visualPosition * parent.width width: cachedLength.visualPosition * parent.width
height: parent.height height: parent.height
color: appearance.progressCachedColor color: getAppearanceValueForTheme(appearance.themeName,
"progressCachedColor")
} }
} }
z: 40 z: 40
@ -124,7 +127,6 @@ Slider {
onChaptersChanged: function (chapters) { onChaptersChanged: function (chapters) {
for (var i = 0, len = chapters.length; i < len; i++) { for (var i = 0, len = chapters.length; i < len; i++) {
var component = Qt.createComponent("ChapterMarker.qml") var component = Qt.createComponent("ChapterMarker.qml")
var marker = component.createObject(chapterMarkers, { var marker = component.createObject(chapterMarkers, {
time: chapters[i]["time"] time: chapters[i]["time"]
}) })
@ -139,7 +141,8 @@ Slider {
anchors.left: progressBackground.left anchors.left: progressBackground.left
width: progressBar.visualPosition * parent.width width: progressBar.visualPosition * parent.width
height: parent.height height: parent.height
color: appearance.progressSliderColor color: getAppearanceValueForTheme(appearance.themeName,
"progressSliderColor")
Image { Image {
visible: fun.nyanCat visible: fun.nyanCat
id: rainbow id: rainbow
@ -161,7 +164,8 @@ Slider {
implicitHeight: radius implicitHeight: radius
implicitWidth: radius implicitWidth: radius
radius: 12 + (progressBackground.height / 2) radius: 12 + (progressBackground.height / 2)
color: fun.nyanCat ? "transparent" : appearance.progressSliderColor color: fun.nyanCat ? "transparent" : getAppearanceValueForTheme(
appearance.themeName, "progressSliderColor")
visible: getHandleVisibility(appearance.themeName, visible: getHandleVisibility(appearance.themeName,
mouseAreaProgressBar.containsMouse) mouseAreaProgressBar.containsMouse)
AnimatedImage { AnimatedImage {

View file

@ -11,7 +11,7 @@ Button {
id: volumeButton id: volumeButton
objectName: "volumeButton" objectName: "volumeButton"
icon.source: "icons/" + appearance.themeName + "/volume-up.svg" icon.source: "icons/" + appearance.themeName + "/volume-up.svg"
icon.color: appearance.buttonColor icon.color: getAppearanceValueForTheme(appearance.themeName, "buttonColor")
display: AbstractButton.IconOnly display: AbstractButton.IconOnly
onClicked: { onClicked: {
player.playerCommand(Enums.Commands.ToggleMute) player.playerCommand(Enums.Commands.ToggleMute)

View file

@ -48,11 +48,13 @@ Slider {
implicitHeight: appearance.themeName == "Niconico" ? layout.height / 8 : layout.height / 10 implicitHeight: appearance.themeName == "Niconico" ? layout.height / 8 : layout.height / 10
width: volumeBar.availableWidth width: volumeBar.availableWidth
height: implicitHeight height: implicitHeight
color: appearance.progressBackgroundColor color: getAppearanceValueForTheme(appearance.themeName,
"progressBackgroundColor")
Rectangle { Rectangle {
width: volumeBar.visualPosition * parent.width width: volumeBar.visualPosition * parent.width
height: parent.height height: parent.height
color: appearance.volumeSliderBackground color: getAppearanceValueForTheme(appearance.themeName,
"volumeSliderBackground")
} }
} }
} }

View file

@ -29,7 +29,6 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
icon.height: parent.height / 2 icon.height: parent.height / 2
icon.width: parent.height / 2 icon.width: parent.height / 2
} }
PlaylistNextButton { PlaylistNextButton {
id: playlistNextButton id: playlistNextButton

View file

@ -20,6 +20,14 @@ Window {
property bool onTop: false property bool onTop: false
function getAppearanceValueForTheme(themeName, name) {
if (themeName == "YouTube") {
return youTubeAppearance[name]
} else if (themeName == "Niconico") {
return nicoNicoAppearance[name]
}
}
Translator { Translator {
id: translate id: translate
} }
@ -38,6 +46,12 @@ Window {
property bool useMpvSubs: false property bool useMpvSubs: false
property string themeName: "YouTube" property string themeName: "YouTube"
property string fontName: "Roboto" property string fontName: "Roboto"
property double scaleFactor: 1.0
}
Settings {
id: youTubeAppearance
category: "Appearance"
property string mainBackground: "#9C000000" property string mainBackground: "#9C000000"
property string progressBackgroundColor: "#3CFFFFFF" property string progressBackgroundColor: "#3CFFFFFF"
property string progressCachedColor: "white" property string progressCachedColor: "white"
@ -45,7 +59,18 @@ Window {
property string progressSliderColor: "red" property string progressSliderColor: "red"
property string chapterMarkerColor: "#fc0" property string chapterMarkerColor: "#fc0"
property string volumeSliderBackground: "white" property string volumeSliderBackground: "white"
property double scaleFactor: 1.0 }
Settings {
id: nicoNicoAppearance
category: "Appearance"
property string mainBackground: "#9C000000"
property string progressBackgroundColor: "#444"
property string progressCachedColor: "white"
property string buttonColor: "white"
property string progressSliderColor: "#007cff"
property string chapterMarkerColor: "#fc0"
property string volumeSliderBackground: "#0077cff"
} }
Settings { Settings {
@ -93,6 +118,7 @@ Window {
property string decreaseVolume: "/" property string decreaseVolume: "/"
property string mute: "m" property string mute: "m"
property string increaseScale: "Ctrl+Shift+=" property string increaseScale: "Ctrl+Shift+="
property string resetScale: "Ctrl+Shift+0"
property string decreaseScale: "Ctrl+Shift+-" property string decreaseScale: "Ctrl+Shift+-"
property string customKeybind0: "" property string customKeybind0: ""
property string customKeybind0Command: "" property string customKeybind0Command: ""
@ -137,6 +163,26 @@ Window {
width: parent.width width: parent.width
height: parent.height height: parent.height
z: 1 z: 1
Action {
onTriggered: {
appearance.scaleFactor += 0.1
}
shortcut: keybinds.increaseScale
}
Action {
onTriggered: {
appearance.scaleFactor = 1
}
shortcut: keybinds.resetScale
}
Action {
onTriggered: {
appearance.scaleFactor -= 0.1
}
shortcut: keybinds.decreaseScale
}
function startPlayer() { function startPlayer() {
var args = Qt.application.arguments var args = Qt.application.arguments
var len = Qt.application.arguments.length var len = Qt.application.arguments.length
@ -240,19 +286,6 @@ Window {
} }
} }
Action {
onTriggered: {
appearance.scaleFactor += 0.1
}
shortcut: appearance.increaseScale
}
Action {
onTriggered: {
appearance.scaleFactor -= 0.1
}
shortcut: appearance.decreaseScale
}
MouseArea { MouseArea {
id: mouseAreaPlayer id: mouseAreaPlayer
z: 1000 z: 1000
@ -268,7 +301,7 @@ Window {
anchors.topMargin: 0 anchors.topMargin: 0
hoverEnabled: true hoverEnabled: true
onDoubleClicked: { onDoubleClicked: {
playTimer.stop() player.playerCommand(Enums.Commands.TogglePlayPause)
toggleFullscreen() toggleFullscreen()
} }
Action { Action {
@ -279,18 +312,9 @@ Window {
} }
shortcut: "Esc" shortcut: "Esc"
} }
Timer {
id: playTimer
interval: 200
running: false
repeat: false
onTriggered: {
player.playerCommand(Enums.Commands.TogglePlayPause)
}
}
onClicked: { onClicked: {
if (appearance.clickToPause) { if (appearance.clickToPause) {
playTimer.start() player.playerCommand(Enums.Commands.TogglePlayPause)
} }
} }
Timer { Timer {
@ -321,7 +345,8 @@ Window {
anchors.top: parent.top anchors.top: parent.top
visible: controlsOverlay.controlsShowing visible: controlsOverlay.controlsShowing
color: appearance.mainBackground color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text { Text {
id: titleLabel id: titleLabel

View file

@ -14,9 +14,6 @@
#include <QX11Info> #include <QX11Info>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/dpms.h>
#include <X11/keysym.h>
#endif #endif
#endif #endif
@ -65,36 +62,53 @@ createTimestamp(int seconds)
} }
} }
#ifdef __linux__ void
SetScreensaver(WId wid, bool on)
{
QProcess xdgScreensaver;
xdgScreensaver.setProcessChannelMode(QProcess::ForwardedChannels);
if (on) {
xdgScreensaver.start("xdg-screensaver",
QStringList() << "resume" << QString::number(wid));
} else {
xdgScreensaver.start("xdg-screensaver",
QStringList() << "suspend" << QString::number(wid));
}
xdgScreensaver.waitForFinished();
}
void void
SetDPMS(bool on) SetDPMS(bool on)
{ {
#ifdef __linux__
if (getPlatformName() != "xcb") { if (getPlatformName() != "xcb") {
return; return;
} }
#ifdef ENABLE_X11 QProcess xsetProcess;
Display* dpy = QX11Info::display(); xsetProcess.setProcessChannelMode(QProcess::ForwardedChannels);
if (on) { if (on) {
DPMSEnable(dpy);
qDebug() << "Enabled DPMS."; qDebug() << "Enabled DPMS.";
xsetProcess.start("xset",
QStringList() << "s"
<< "on"
<< "+dpms");
} else { } else {
DPMSDisable(dpy);
qDebug() << "Disabled DPMS."; qDebug() << "Disabled DPMS.";
xsetProcess.start("xset",
QStringList() << "s"
<< "off"
<< "-dpms");
} }
#endif xsetProcess.waitForFinished();
} #else
void qDebug() << "Can't set DPMS for platform: " << getPlatformName();
ResetScreensaver()
{
#ifdef ENABLE_X11
Display* display = QX11Info::display();
XResetScreenSaver(display);
#endif #endif
} }
void void
AlwaysOnTop(WId wid, bool on) AlwaysOnTop(WId wid, bool on)
{ {
#ifdef __linux__
#ifdef ENABLE_X11 #ifdef ENABLE_X11
Display* display = QX11Info::display(); Display* display = QX11Info::display();
XEvent event; XEvent event;
@ -118,27 +132,8 @@ AlwaysOnTop(WId wid, bool on)
SubstructureRedirectMask | SubstructureNotifyMask, SubstructureRedirectMask | SubstructureNotifyMask,
&event); &event);
#endif #endif
}
#else #else
void
AlwaysOnTop(WId wid, bool on)
{
qDebug() << "Can't set on top for platform: " << getPlatformName(); qDebug() << "Can't set on top for platform: " << getPlatformName();
}
void
SetDPMS(bool on)
{
qDebug() << "Can't set DPMS for platform: " << getPlatformName();
}
void
ResetScreensaver()
{
qDebug() << "Can't reset screensaver for: " << getPlatformName();
}
#endif #endif
} }
}

View file

@ -10,13 +10,13 @@ Q_NAMESPACE
void void
SetDPMS(bool on); SetDPMS(bool on);
void void
SetScreensaver(WId wid, bool on);
void
AlwaysOnTop(WId wid, bool on); AlwaysOnTop(WId wid, bool on);
void void
updateAppImage(); updateAppImage();
QString QString
createTimestamp(int seconds); createTimestamp(int seconds);
void
ResetScreensaver();
} }
class UtilsClass : public QObject class UtilsClass : public QObject
@ -30,7 +30,6 @@ public slots:
{ {
return Utils::createTimestamp(seconds); return Utils::createTimestamp(seconds);
}; };
void ResetScreensaver() { Utils::ResetScreensaver(); };
}; };
#endif #endif