mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 05:08:05 -06:00
Fix functions and macros using to support both Qt4 and Qt5.
This commit is contained in:
committed by
sledgehammer999
parent
763d8a392f
commit
ce3aac5f9d
@@ -30,22 +30,22 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
#include "powermanagement_x11.h"
|
||||
#endif
|
||||
#include "powermanagement.h"
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
PowerManagement::PowerManagement(QObject *parent) : QObject(parent), m_busy(false)
|
||||
{
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
m_inhibitor = new PowerManagementInhibitor(this);
|
||||
#endif
|
||||
}
|
||||
@@ -65,11 +65,11 @@ void PowerManagement::setBusy()
|
||||
if (m_busy) return;
|
||||
m_busy = true;
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
||||
#elif defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#elif (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
m_inhibitor->RequestBusy();
|
||||
#elif defined(Q_WS_MAC)
|
||||
#elif defined(Q_OS_MAC)
|
||||
IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID);
|
||||
if (success != kIOReturnSuccess) m_busy = false;
|
||||
#endif
|
||||
@@ -80,11 +80,11 @@ void PowerManagement::setIdle()
|
||||
if (!m_busy) return;
|
||||
m_busy = false;
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
#elif defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#elif (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
m_inhibitor->RequestIdle();
|
||||
#elif defined(Q_WS_MAC)
|
||||
#elif defined(Q_OS_MAC)
|
||||
IOPMAssertionRelease(m_assertionID);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
// Require Mac OS X >= 10.5
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
// Require DBus
|
||||
class PowerManagementInhibitor;
|
||||
#endif
|
||||
@@ -59,10 +59,10 @@ private:
|
||||
void setBusy();
|
||||
void setIdle();
|
||||
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
PowerManagementInhibitor *m_inhibitor;
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
IOPMAssertionID m_assertionID;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user