mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-13 01:57: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
|
@ -43,13 +43,13 @@
|
|||
#endif
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#ifndef Q_OS_WIN
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
|
@ -60,8 +60,12 @@
|
|||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QDesktopServices>
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace libtorrent;
|
||||
|
@ -125,9 +129,9 @@ bool fsutils::smartRemoveEmptyFolderTree(const QString& dir_path)
|
|||
return true;
|
||||
|
||||
// Remove Files created by the OS
|
||||
#if defined Q_WS_MAC
|
||||
#if defined Q_OS_MAC
|
||||
fsutils::forceRemove(dir_path + QLatin1String("/.DS_Store"));
|
||||
#elif defined Q_WS_WIN
|
||||
#elif defined Q_OS_WIN
|
||||
fsutils::forceRemove(dir_path + QLatin1String("/Thumbs.db"));
|
||||
#endif
|
||||
|
||||
|
@ -283,7 +287,7 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
|
|||
}
|
||||
Q_ASSERT(dir_path.exists());
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#ifndef Q_OS_WIN
|
||||
unsigned long long available;
|
||||
struct statfs stats;
|
||||
const QString statfs_path = dir_path.path()+"/.";
|
||||
|
@ -338,7 +342,7 @@ QString fsutils::branchPath(const QString& file_path, QString* removed)
|
|||
|
||||
bool fsutils::sameFileNames(const QString &first, const QString &second)
|
||||
{
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
#if defined(Q_OS_UNIX) || defined(Q_WS_QWS)
|
||||
return QString::compare(first, second, Qt::CaseSensitive) == 0;
|
||||
#else
|
||||
return QString::compare(first, second, Qt::CaseInsensitive) == 0;
|
||||
|
@ -364,14 +368,14 @@ QString fsutils::expandPathAbs(const QString& path) {
|
|||
|
||||
QString fsutils::QDesktopServicesDataLocation() {
|
||||
QString result;
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
LPWSTR path=new WCHAR[256];
|
||||
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
||||
result = fsutils::fromNativePath(QString::fromWCharArray(path));
|
||||
if (!QCoreApplication::applicationName().isEmpty())
|
||||
result += QLatin1String("/") + qApp->applicationName();
|
||||
#else
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
FSRef ref;
|
||||
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
|
||||
if (err)
|
||||
|
@ -397,10 +401,10 @@ QString fsutils::QDesktopServicesDataLocation() {
|
|||
|
||||
QString fsutils::QDesktopServicesCacheLocation() {
|
||||
QString result;
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
||||
result = QDesktopServicesDataLocation() + QLatin1String("cache");
|
||||
#else
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
||||
FSRef ref;
|
||||
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
|
||||
|
@ -424,16 +428,21 @@ QString fsutils::QDesktopServicesCacheLocation() {
|
|||
}
|
||||
|
||||
QString fsutils::QDesktopServicesDownloadLocation() {
|
||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
||||
// as long as it stays WinXP like we do the same on OS/2
|
||||
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
||||
// instead of hardcoding "Downloads"
|
||||
// Unfortunately, this would break compatibility with WinXP
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
||||
QCoreApplication::translate("fsutils", "Downloads"));
|
||||
#else
|
||||
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(
|
||||
QCoreApplication::translate("fsutils", "Downloads"));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||
QString save_path;
|
||||
// Default save path on Linux
|
||||
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
||||
|
@ -468,7 +477,7 @@ QString fsutils::QDesktopServicesDownloadLocation() {
|
|||
return save_path;
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
// TODO: How to support this on Mac OS X?
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue