mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
Fix functions and macros using to support both Qt4 and Qt5.
This commit is contained in:
parent
763d8a392f
commit
ce3aac5f9d
51 changed files with 260 additions and 181 deletions
16
src/misc.cpp
16
src/misc.cpp
|
@ -49,7 +49,7 @@
|
|||
#include <QDesktopWidget>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <PowrProf.h>
|
||||
const int UNLEN = 256;
|
||||
|
@ -58,13 +58,13 @@ const int UNLEN = 256;
|
|||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ static struct { const char *source; const char *comment; } units[] = {
|
|||
|
||||
#ifndef DISABLE_GUI
|
||||
void misc::shutdownComputer(bool sleep) {
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
// Use dbus to power off / suspend the system
|
||||
if (sleep) {
|
||||
// Some recent systems use systemd's logind
|
||||
|
@ -126,7 +126,7 @@ void misc::shutdownComputer(bool sleep) {
|
|||
halIface.call("Shutdown");
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
AEEventID EventToSend;
|
||||
if (sleep)
|
||||
EventToSend = kAESleep;
|
||||
|
@ -167,7 +167,7 @@ void misc::shutdownComputer(bool sleep) {
|
|||
|
||||
AEDisposeDesc(&eventReply);
|
||||
#endif
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
HANDLE hToken; // handle to process token
|
||||
TOKEN_PRIVILEGES tkp; // pointer to token structure
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
||||
|
@ -367,7 +367,7 @@ QString misc::magnetUriToHash(const QString& magnet_uri) {
|
|||
const QString found = regHex.cap(1);
|
||||
qDebug() << Q_FUNC_INFO << "regex found: " << found;
|
||||
if (found.length() == 40) {
|
||||
const sha1_hash sha1(QByteArray::fromHex(found.toAscii()).constData());
|
||||
const sha1_hash sha1(QByteArray::fromHex(found.toLatin1()).constData());
|
||||
qDebug("magnetUriToHash (Hex): hash: %s", qPrintable(misc::toQString(sha1)));
|
||||
return misc::toQString(sha1);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ QString misc::userFriendlyDuration(qlonglong seconds) {
|
|||
|
||||
QString misc::getUserIDString() {
|
||||
QString uid = "0";
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
char buffer[UNLEN+1] = {0};
|
||||
DWORD buffer_len = UNLEN + 1;
|
||||
if (!GetUserNameA(buffer, &buffer_len))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue