Revert "Add an option to inhibit suspend while playing"

This commit is contained in:
John Maguire 2016-01-08 15:09:07 +00:00
parent 70070ee0bf
commit c9b0bb2044
20 changed files with 194 additions and 443 deletions

View File

@ -344,7 +344,6 @@ set(SOURCES
ui/globalshortcutgrabber.cpp
ui/globalshortcutssettingspage.cpp
ui/iconloader.cpp
ui/idlehandler.cpp
ui/mainwindow.cpp
ui/networkproxysettingspage.cpp
ui/networkremotesettingspage.cpp
@ -353,6 +352,7 @@ set(SOURCES
ui/organiseerrordialog.cpp
ui/playbacksettingspage.cpp
ui/qtsystemtrayicon.cpp
ui/screensaver.cpp
ui/settingsdialog.cpp
ui/settingspage.cpp
ui/standarditemiconloader.cpp
@ -863,7 +863,7 @@ optional_source(APPLE
engines/osxdevicefinder.cpp
networkremote/bonjour.mm
ui/globalshortcutgrabber.mm
ui/macidlehandler.cpp
ui/macscreensaver.cpp
ui/macsystemtrayicon.mm
widgets/osd_mac.mm
HEADERS
@ -878,7 +878,7 @@ optional_source(WIN32
SOURCES
engines/directsounddevicefinder.cpp
networkremote/tinysvcmdns.cpp
ui/windowsidlehandler.cpp
ui/windowsscreensaver.cpp
widgets/osd_win.cpp
INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/3rdparty/tinysvcmdns
@ -984,7 +984,7 @@ optional_source(HAVE_DBUS
core/mpris1.cpp
core/mpris2.cpp
networkremote/avahi.cpp
ui/dbusidlehandler.cpp
ui/dbusscreensaver.cpp
HEADERS
core/mpris.h
core/mpris1.h

View File

@ -1,78 +0,0 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dbusidlehandler.h"
#include <QCoreApplication>
#include <QDBusInterface>
#include <QDBusReply>
#include <stdint.h>
#include "core/logging.h"
DBusIdleHandler::DBusIdleHandler(const QString& service, const QString& path,
const QString& interface)
: service_(service), path_(path), interface_(interface) {}
void DBusIdleHandler::Inhibit(const char* reason) {
QDBusInterface iface(service_, path_,
interface_, QDBusConnection::sessionBus());
QDBusReply<quint32> reply;
if (service_ == IdleHandler::kGnomePowermanagerService) {
reply =
iface.call("Inhibit", QCoreApplication::applicationName(),
quint32(0), QObject::tr(reason),
quint32(Inhibit_Suspend));
} else {
reply =
iface.call("Inhibit", QCoreApplication::applicationName(),
QObject::tr("reason"));
}
if (reply.isValid()) {
cookie_ = reply.value();
} else {
qLog(Warning) << "Failed to inhibit screensaver/suspend dbus service: "
<< service_ << " path: " << path_ << " interface: "
<< interface_;
}
}
void DBusIdleHandler::Uninhibit() {
QDBusInterface iface(service_, path_,
interface_, QDBusConnection::sessionBus());
if (service_ == IdleHandler::kGnomePowermanagerService) {
iface.call("Uninhibit", cookie_);
} else {
iface.call("UnInhibit", cookie_);
}
}
bool DBusIdleHandler::Isinhibited() {
QDBusInterface iface(service_, path_,
interface_, QDBusConnection::sessionBus());
QDBusReply<bool> reply;
if (service_ == IdleHandler::kGnomePowermanagerService) {
reply = iface.call("IsInhibited", quint32(Inhibit_Suspend));
} else {
reply = iface.call("HasInhibit");
}
return reply;
}

View File

@ -0,0 +1,43 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dbusscreensaver.h"
#include <QCoreApplication>
#include <QDBusInterface>
#include <QDBusReply>
DBusScreensaver::DBusScreensaver(const QString& service, const QString& path,
const QString& interface)
: service_(service), path_(path), interface_(interface) {}
void DBusScreensaver::Inhibit() {
QDBusInterface gnome_screensaver("org.gnome.ScreenSaver", "/",
"org.gnome.ScreenSaver");
QDBusReply<quint32> reply =
gnome_screensaver.call("Inhibit", QCoreApplication::applicationName(),
QObject::tr("Visualizations"));
if (reply.isValid()) {
cookie_ = reply.value();
}
}
void DBusScreensaver::Uninhibit() {
QDBusInterface gnome_screensaver("org.gnome.ScreenSaver", "/",
"org.gnome.ScreenSaver");
gnome_screensaver.call("UnInhibit", cookie_);
}

View File

@ -1,6 +1,5 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,28 +15,22 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DBUSIDLEHANDLER_H
#define DBUSIDLEHANDLER_H
#ifndef DBUSSCREENSAVER_H
#define DBUSSCREENSAVER_H
#include "idlehandler.h"
#include "screensaver.h"
#include <QString>
class DBusIdleHandler : public IdleHandler {
class DBusScreensaver : public Screensaver {
public:
DBusIdleHandler(const QString& service, const QString& path,
DBusScreensaver(const QString& service, const QString& path,
const QString& interface);
void Inhibit(const char* reason) override;
void Uninhibit() override;
bool Isinhibited() override;
void Inhibit();
void Uninhibit();
private:
enum GnomeIdleHandlerFlags {
Inhibit_Suspend = 4,
Inhibit_Mark_Idle = 8
};
QString service_;
QString path_;
QString interface_;
@ -45,4 +38,4 @@ class DBusIdleHandler : public IdleHandler {
quint32 cookie_;
};
#endif // DBUSIDLEHANDLER_H
#endif

View File

@ -1,134 +0,0 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "idlehandler.h"
#include "core/logging.h"
#include <QtGlobal>
#ifdef HAVE_DBUS
#include "dbusidlehandler.h"
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#endif
#ifdef Q_OS_DARWIN
#include "macidlehandler.h"
#endif
#ifdef Q_OS_WIN32
#include "windowsidlehandler.h"
#endif
// Services
const char* IdleHandler::kGnomeScreensaverService
= "org.gnome.ScreenSaver";
const char* IdleHandler::kFreedesktopScreensaverService
= "org.freedesktop.ScreenSaver";
const char* IdleHandler::kGnomePowermanagerService
= "org.gnome.SessionManager";
const char* IdleHandler::kFreedesktopPowermanagerService
= "org.freedesktop.PowerManagement";
namespace {
// Gnome Screensaver
const char* kGnomeScreensaverPath
= "/";
const char* kGnomeScreensaverInterface
= "org.gnome.ScreenSaver";
// Freedesktop screensaver
const char* kFreedesktopScreensaverPath
= "/ScreenSaver";
const char* kFreedesktopScreensaverInterface
= "org.freedesktop.ScreenSaver";
// Gnome powermanager
const char* kGnomePowermanagerPath
= "/org/gnome/SessionManager";
const char* kGnomePowermanagerInterface
= "org.gnome.SessionManager";
// Freedesktop powermanager
const char* kFreedesktopPowermanagerPath
= "/org/freedesktop/PowerManagement/Inhibit";
const char* kFreedesktopPowermanagerInterface
= "org.freedesktop.PowerManagement.Inhibit";
}
IdleHandler* IdleHandler::screensaver_ = 0;
IdleHandler* IdleHandler::suspend_ = 0;
IdleHandler::Inhibitor IdleHandler::inbtr_;
IdleHandler* IdleHandler::GetScreensaver() {
inbtr_ = Screensaver;
if (!screensaver_) {
#if defined(HAVE_DBUS)
// For gnome
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kGnomeScreensaverService)) {
screensaver_ = new DBusIdleHandler(kGnomeScreensaverService,
kGnomeScreensaverPath,
kGnomeScreensaverInterface);
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kFreedesktopScreensaverService)) /* For KDE, XFCE & others */ {
screensaver_ = new DBusIdleHandler(kFreedesktopScreensaverService,
kFreedesktopScreensaverPath,
kFreedesktopScreensaverInterface);
} else {
qLog(Warning) << "no supported dbus screensaver service available";
}
#elif defined(Q_OS_DARWIN)
screensaver_ = new MacIdleHandler();
#elif defined(Q_OS_WIN32)
screensaver_ = new WindowsIdleHandler();
#endif
}
return screensaver_;
}
IdleHandler* IdleHandler::GetSuspend() {
inbtr_ = Suspend;
if (!suspend_) {
#if defined(HAVE_DBUS)
// For gnome
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kGnomePowermanagerService)) {
suspend_ = new DBusIdleHandler(kGnomePowermanagerService,
kGnomePowermanagerPath,
kGnomePowermanagerInterface);
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kFreedesktopPowermanagerService)) /* For KDE, XFCE & others */ {
suspend_ = new DBusIdleHandler(kFreedesktopPowermanagerService,
kFreedesktopPowermanagerPath,
kFreedesktopPowermanagerInterface);
} else {
qLog(Warning) << "no supported dbus powermanager service available";
}
#elif defined(Q_OS_DARWIN)
suspend_ = new MacIdleHandler();
#elif defined(Q_OS_WIN32)
suspend_ = new WindowsIdleHandler();
#endif
}
return suspend_;
}

View File

@ -1,6 +1,5 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,40 +15,20 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "macidlehandler.h"
#include "macscreensaver.h"
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <QtDebug>
#include "core/logging.h"
#include "core/utilities.h"
MacIdleHandler::MacIdleHandler() : assertion_id_(0),
is_inhibit_(false) {}
MacScreensaver::MacScreensaver() : assertion_id_(0) {}
void MacIdleHandler::Inhibit(const char* reason) {
IOReturn reply = IOPMAssertionCreateWithName(
void MacScreensaver::Inhibit() {
IOPMAssertionCreateWithName(
kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn,
CFSTR(reason), &assertion_id_);
if (reply == kIOReturnSuccess) {
is_inhibit_ = true;
} else {
qLog(Warning) << "Failed to inhibit screensaver/suspend";
}
CFSTR("Showing full-screen Clementine visualisations"), &assertion_id_);
}
void MacIdleHandler::Uninhibit() {
IOReturn reply = IOPMAssertionRelease(assertion_id_);
if (reply == kIOReturnSuccess) {
is_inhibit_ = false;
} else {
qLog(Warning) << "Failed to uninhibit screensaver/suspend";
}
}
bool MacIdleHandler::Isinhibited() {
return is_inhibit_;
}
void MacScreensaver::Uninhibit() { IOPMAssertionRelease(assertion_id_); }

View File

@ -1,6 +1,5 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,24 +15,22 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MACIDLEHANDLER_H
#define MACIDLEHANDLER_H
#ifndef MACSCREENSAVER_H
#define MACSCREENSAVER_H
#include "idlehandler.h"
#include "screensaver.h"
#include <IOKit/pwr_mgt/IOPMLib.h>
class MacIdleHandler : public IdleHandler {
class MacScreensaver : public Screensaver {
public:
MacIdleHandler();
MacScreensaver();
void Inhibit(const char* reason) override;
void Uninhibit() override;
bool Isinhibited() override;
void Inhibit();
void Uninhibit();
private:
IOPMAssertionID assertion_id_;
bool is_inhibit_;
};
#endif // MACIDLEHANDLER_H
#endif

View File

@ -195,9 +195,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
saved_playback_state_(Engine::Empty),
doubleclick_addmode_(AddBehaviour_Append),
doubleclick_playmode_(PlayBehaviour_IfStopped),
menu_playmode_(PlayBehaviour_IfStopped),
idlehandler_(IdleHandler::GetSuspend()),
is_suspend_inhibited_(false) {
menu_playmode_(PlayBehaviour_IfStopped) {
qLog(Debug) << "Starting";
connect(app, SIGNAL(ErrorAdded(QString)), SLOT(ShowErrorDialog(QString)));
@ -1011,12 +1009,6 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
new WiimotedevShortcuts(osd_, this, app_->player()));
#endif
settings_.endGroup();
settings_.beginGroup(Engine::Base::kSettingsGroup);
inhibit_suspend_while_playing_status_ =
settings_.value("InhibitSuspendWhilePlaying", false).toBool();
CheckFullRescanRevisions();
LoadPlaybackStatus();
@ -1090,7 +1082,6 @@ void MainWindow::MediaStopped() {
ui_->track_slider->SetStopped();
tray_icon_->SetProgress(0);
tray_icon_->SetStopped();
HandleInhibitSuspendWhilePlaying(false);
}
void MainWindow::MediaPaused() {
@ -1106,7 +1097,6 @@ void MainWindow::MediaPaused() {
track_slider_timer_->stop();
tray_icon_->SetPaused();
HandleInhibitSuspendWhilePlaying(false);
}
void MainWindow::MediaPlaying() {
@ -1136,7 +1126,6 @@ void MainWindow::MediaPlaying() {
track_position_timer_->start();
track_slider_timer_->start();
UpdateTrackPosition();
HandleInhibitSuspendWhilePlaying(true);
}
void MainWindow::VolumeChanged(int volume) {
@ -2468,11 +2457,6 @@ void MainWindow::EnsureSettingsDialogCreated() {
SLOT(SetWiimotedevInterfaceActived(bool)));
#endif
// Handle suspend status
connect(settings_dialog_.get(),
SIGNAL(InhibitSuspendWhilePlaying(bool)),
SLOT(InhibitSuspendWhilePlaying(bool)));
// Allows custom notification preview
connect(settings_dialog_.get(),
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)),
@ -2854,21 +2838,3 @@ void MainWindow::keyPressEvent(QKeyEvent* event) {
QMainWindow::keyPressEvent(event);
}
}
void MainWindow::InhibitSuspendWhilePlaying(bool status) {
inhibit_suspend_while_playing_status_ = status;
HandleInhibitSuspendWhilePlaying(status);
}
void MainWindow::HandleInhibitSuspendWhilePlaying(bool status) {
if (idlehandler_) {
if (inhibit_suspend_while_playing_status_ &&
!is_suspend_inhibited_ && status) {
idlehandler_->Inhibit("Clementine is playing");
is_suspend_inhibited_ = idlehandler_->Isinhibited();
} else if (is_suspend_inhibited_ && !status){
idlehandler_->Uninhibit();
is_suspend_inhibited_ = idlehandler_->Isinhibited();
}
}
}

View File

@ -30,7 +30,6 @@
#include "engines/engine_fwd.h"
#include "library/librarymodel.h"
#include "playlist/playlistitem.h"
#include "ui/idlehandler.h"
#include "ui/settingsdialog.h"
class About;
@ -65,7 +64,6 @@ class PlaylistBackend;
class PlaylistListContainer;
class PlaylistManager;
class QueueManager;
class IdleHandler;
class InternetItem;
class InternetModel;
class InternetViewContainer;
@ -280,9 +278,6 @@ signals:
void ShowConsole();
void InhibitSuspendWhilePlaying(bool status);
void HandleInhibitSuspendWhilePlaying(bool status);
private:
void ConnectInfoView(SongInfoBase* view);
@ -378,9 +373,6 @@ signals:
PlayBehaviour menu_playmode_;
BackgroundStreams* background_streams_;
IdleHandler* idlehandler_;
bool inhibit_suspend_while_playing_status_;
bool is_suspend_inhibited_;
};
#endif // MAINWINDOW_H

View File

@ -87,8 +87,6 @@ void PlaybackSettingsPage::Load() {
s.value("FadeoutPauseEnabled", false).toBool());
ui_->fading_pause_duration->setValue(
s.value("FadeoutPauseDuration", 250).toInt());
ui_->inhibit_suspend_while_playing->setChecked(
s.value("InhibitSuspendWhilePlaying", false).toBool());
s.endGroup();
s.beginGroup(GstEngine::kSettingsGroup);
@ -136,8 +134,6 @@ void PlaybackSettingsPage::Save() {
s.setValue("NoCrossfadeSameAlbum", ui_->fading_samealbum->isChecked());
s.setValue("FadeoutPauseEnabled", ui_->fadeout_pause->isChecked());
s.setValue("FadeoutPauseDuration", ui_->fading_pause_duration->value());
s.setValue("InhibitSuspendWhilePlaying",
ui_->inhibit_suspend_while_playing->isChecked());
s.endGroup();
GstEngine::OutputDetails details =
@ -158,10 +154,6 @@ void PlaybackSettingsPage::Save() {
ui_->sample_rate->itemData(ui_->sample_rate->currentIndex()).toInt());
s.setValue("bufferminfill", ui_->buffer_min_fill->value());
s.endGroup();
//Emit inhibit suspend while playing signal
emit InhibitSuspendWhilePlaying(
ui_->inhibit_suspend_while_playing->isChecked());
}
void PlaybackSettingsPage::RgPreampChanged(int value) {

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>596</width>
<height>754</height>
<height>667</height>
</rect>
</property>
<property name="windowTitle">
@ -25,7 +25,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="fading_groupBox">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Fading</string>
</property>
@ -168,25 +168,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="power_management_groupBox">
<property name="title">
<string>System Power Management Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="inhibit_suspend_while_playing">
<property name="toolTip">
<string>If enabled, Clementine will prevent the system from automatically suspending if it is playing a track</string>
</property>
<property name="text">
<string>Inhibit automatic suspend if playing</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="replaygain_group">
<property name="title">

66
src/ui/screensaver.cpp Normal file
View File

@ -0,0 +1,66 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "screensaver.h"
#include <QtGlobal>
#ifdef HAVE_DBUS
#include "dbusscreensaver.h"
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#endif
#ifdef Q_OS_DARWIN
#include "macscreensaver.h"
#endif
#ifdef Q_OS_WIN32
#include "windowsscreensaver.h"
#endif
#include <QtDebug>
const char* Screensaver::kGnomeService = "org.gnome.ScreenSaver";
const char* Screensaver::kGnomePath = "/";
const char* Screensaver::kGnomeInterface = "org.gnome.ScreenSaver";
const char* Screensaver::kKdeService = "org.kde.ScreenSaver";
const char* Screensaver::kKdePath = "/ScreenSaver/";
const char* Screensaver::kKdeInterface = "org.freedesktop.ScreenSaver";
Screensaver* Screensaver::screensaver_ = 0;
Screensaver* Screensaver::GetScreensaver() {
if (!screensaver_) {
#if defined(HAVE_DBUS)
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kGnomeService)) {
screensaver_ =
new DBusScreensaver(kGnomeService, kGnomePath, kGnomeInterface);
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
kKdeService)) {
screensaver_ = new DBusScreensaver(kKdeService, kKdePath, kKdeInterface);
}
#elif defined(Q_OS_DARWIN)
screensaver_ = new MacScreensaver();
#elif defined(Q_OS_WIN32)
screensaver_ = new WindowsScreensaver();
#endif
}
return screensaver_;
}

View File

@ -1,6 +1,5 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,35 +15,28 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDLEHANDLER_H
#define IDLEHANDLER_H
#ifndef SCREENSAVER_H
#define SCREENSAVER_H
class IdleHandler {
class Screensaver {
public:
virtual ~IdleHandler() {}
virtual ~Screensaver() {}
virtual void Inhibit(const char* reason) = 0;
static const char* kGnomeService;
static const char* kGnomePath;
static const char* kGnomeInterface;
static const char* kKdeService;
static const char* kKdePath;
static const char* kKdeInterface;
virtual void Inhibit() = 0;
virtual void Uninhibit() = 0;
virtual bool Isinhibited() = 0;
static IdleHandler* GetScreensaver();
static IdleHandler* GetSuspend();
enum Inhibitor
{
Screensaver = 0,
Suspend = 1
};
static Inhibitor inbtr_;
static const char* kGnomeScreensaverService;
static const char* kFreedesktopScreensaverService;
static const char* kGnomePowermanagerService;
static const char* kFreedesktopPowermanagerService;
static Screensaver* GetScreensaver();
private:
static IdleHandler* screensaver_;
static IdleHandler* suspend_;
static Screensaver* screensaver_;
};
#endif // IDLEHANDLER_H
#endif

View File

@ -245,8 +245,6 @@ void SettingsDialog::AddPage(Page id, SettingsPage* page,
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
connect(page, SIGNAL(SetWiimotedevInterfaceActived(bool)),
SIGNAL(SetWiimotedevInterfaceActived(bool)));
connect(page, SIGNAL(InhibitSuspendWhilePlaying(bool)),
SIGNAL(InhibitSuspendWhilePlaying(bool)));
// Create the list item
QTreeWidgetItem* item = new QTreeWidgetItem;

View File

@ -119,7 +119,6 @@ class SettingsDialog : public QDialog {
signals:
void NotificationPreview(OSD::Behaviour, QString, QString);
void SetWiimotedevInterfaceActived(bool);
void InhibitSuspendWhilePlaying(bool);
private slots:
void CurrentItemChanged(QTreeWidgetItem* item);

View File

@ -45,7 +45,6 @@ class SettingsPage : public QWidget {
signals:
void NotificationPreview(OSD::Behaviour, QString, QString);
void SetWiimotedevInterfaceActived(bool);
void InhibitSuspendWhilePlaying(bool);
private:
SettingsDialog* dialog_;

View File

@ -1,61 +0,0 @@
/* This file is part of Clementine.
Copyright 2015, John Maguire <john.maguire@gmail.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "windowsidlehandler.h"
#include "core/logging.h"
// TODO: use PowerCreateRequest on Win7+
WindowsIdleHandler::WindowsIdleHandler() : previous_state_(0),
is_inhibit_(false) {}
void WindowsIdleHandler::Inhibit(const char*) {
switch (IdleHandler::inbtr_) {
case IdleHandler::Screensaver :
// resetting the display idle timer.
previous_state_ =
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
break;
case IdleHandler::Suspend :
// resetting the system idle timer.
previous_state_ =
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
break;
}
if (previous_state_! = 0) {
is_inhibit_ = true;
} else {
qLog(Warning) << "Failed to inhibit screensaver/suspend";
}
}
void WindowsIdleHandler::Uninhibit() {
previous_state_ =
SetThreadExecutionState(ES_CONTINUOUS | previous_state_);
if (previous_state_! = 0) {
is_inhibit_ = false;
} else {
qLog(Warning) << "Failed to uninhibit screensaver/suspend";
}
}
bool WindowsIdleHandler::Isinhibited() {
return is_inhibit_;
}

View File

@ -0,0 +1,30 @@
/* This file is part of Clementine.
Copyright 2015, John Maguire <john.maguire@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "windowsscreensaver.h"
WindowsScreensaver::WindowsScreensaver() : previous_state_(0) {}
void WindowsScreensaver::Inhibit() {
// TODO: use PowerCreateRequest on Win7+
previous_state_ =
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
}
void WindowsScreensaver::Uninhibit() {
SetThreadExecutionState(ES_CONTINUOUS | previous_state_);
}

View File

@ -1,6 +1,5 @@
/* This file is part of Clementine.
Copyright 2015, John Maguire <john.maguire@gmail.com>
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,24 +14,22 @@
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WINDOWSIDLEHANDLER_H
#define WINDOWSIDLEHANDLER_H
#ifndef WINDOWSSCREENSAVER_H
#define WINDOWSSCREENSAVER_H
#include "idlehandler.h"
#include "screensaver.h"
#include <windows.h>
class WindowsIdleHandler : public IdleHandler {
class WindowsScreensaver : public Screensaver {
public:
WindowsIdleHandler();
WindowsScreensaver();
void Inhibit(const char*) override;
void Inhibit() override;
void Uninhibit() override;
bool Isinhibited() override;
private:
EXECUTION_STATE previous_state_;
bool is_inhibit_;
};
#endif // WINDOWSIDLEHANDLER_H
#endif // WINDOWSSCREENSAVER_H

View File

@ -22,7 +22,7 @@
#include "visualisationselector.h"
#include "engines/gstengine.h"
#include "ui/iconloader.h"
#include "ui/idlehandler.h"
#include "ui/screensaver.h"
#include <QGLWidget>
#include <QGraphicsProxyWidget>
@ -265,9 +265,9 @@ void VisualisationContainer::keyReleaseEvent(QKeyEvent* event) {
void VisualisationContainer::ToggleFullscreen() {
setWindowState(windowState() ^ Qt::WindowFullScreen);
IdleHandler* screensaver = IdleHandler::GetScreensaver();
Screensaver* screensaver = Screensaver::GetScreensaver();
if (screensaver)
isFullScreen() ? screensaver->Inhibit("Visualisation") : screensaver->Uninhibit();
isFullScreen() ? screensaver->Inhibit() : screensaver->Uninhibit();
}
void VisualisationContainer::SetFps(int fps) {