mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
parent
f0c3bf4332
commit
a87040f770
@ -504,6 +504,8 @@ if(APPLE)
|
||||
list(APPEND HEADERS ui/macsystemtrayicon.h)
|
||||
list(APPEND HEADERS widgets/maclineedit.h)
|
||||
list(APPEND SOURCES widgets/maclineedit.mm)
|
||||
list(APPEND SOURCES ui/macscreensaver.cpp)
|
||||
list(APPEND HEADERS ui/macscreensaver.h)
|
||||
include_directories(${GROWL}/Headers)
|
||||
else(APPLE)
|
||||
if(WIN32)
|
||||
|
23
src/ui/macscreensaver.cpp
Normal file
23
src/ui/macscreensaver.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "macscreensaver.h"
|
||||
|
||||
#include <CoreServices/CoreServices.h>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
MacScreensaver::MacScreensaver() {
|
||||
timer_.setInterval(30000);
|
||||
connect(&timer_, SIGNAL(timeout()), SLOT(Timeout()));
|
||||
}
|
||||
|
||||
void MacScreensaver::Timeout() {
|
||||
UpdateSystemActivity(OverallAct);
|
||||
}
|
||||
|
||||
void MacScreensaver::Inhibit() {
|
||||
timer_.start(30000);
|
||||
Timeout();
|
||||
}
|
||||
|
||||
void MacScreensaver::Uninhibit() {
|
||||
timer_.stop();
|
||||
}
|
23
src/ui/macscreensaver.h
Normal file
23
src/ui/macscreensaver.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef MACSCREENSAVER_H
|
||||
#define MACSCREENSAVER_H
|
||||
|
||||
#include "screensaver.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
class MacScreensaver : public QObject, public Screensaver {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MacScreensaver();
|
||||
|
||||
void Inhibit();
|
||||
void Uninhibit();
|
||||
|
||||
private slots:
|
||||
void Timeout();
|
||||
|
||||
private:
|
||||
QTimer timer_;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,20 +1,30 @@
|
||||
#include "screensaver.h"
|
||||
|
||||
#include "gnomescreensaver.h"
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include "gnomescreensaver.h"
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include "macscreensaver.h"
|
||||
#endif
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
Screensaver* Screensaver::screensaver_ = 0;
|
||||
|
||||
Screensaver* Screensaver::GetScreensaver() {
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (!screensaver_) {
|
||||
#ifdef Q_WS_X11
|
||||
#if defined(Q_WS_X11)
|
||||
if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.gnome.ScreenSaver")) {
|
||||
screensaver_ = new GnomeScreensaver();
|
||||
}
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
screensaver_ = new MacScreensaver();
|
||||
#endif
|
||||
}
|
||||
return screensaver_;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
class Screensaver {
|
||||
public:
|
||||
virtual ~Screensaver() {}
|
||||
|
||||
virtual void Inhibit() = 0;
|
||||
virtual void Uninhibit() = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user