Skip to content

Commit

Permalink
Merge pull request #11195 from Chocobo1/mac
Browse files Browse the repository at this point in the history
Replace deprecated macro
  • Loading branch information
Chocobo1 committed Sep 7, 2019
2 parents ee8b99f + 17e4902 commit d2c21ce
Show file tree
Hide file tree
Showing 37 changed files with 161 additions and 159 deletions.
2 changes: 1 addition & 1 deletion CODING_GUIDELINES.md
Expand Up @@ -306,7 +306,7 @@ Example:
#include <QString>
#include <QUrl>
#ifdef Q_OS_MAC // conditional
#ifdef Q_OS_MACOS // conditional
#include <QFont>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -47,7 +47,7 @@ list(APPEND CMAKE_AUTORCC_OPTIONS -compress 9 -threshold 5)
if (APPLE)
# Workaround CMake bug (autogen does not pass required parameters to moc)
# Relevant issue: https://gitlab.kitware.com/cmake/cmake/issues/18041
list(APPEND CMAKE_AUTOMOC_MOC_OPTIONS -DQ_OS_MAC -DQ_OS_DARWIN)
list(APPEND CMAKE_AUTOMOC_MOC_OPTIONS -DQ_OS_MACOS -DQ_OS_DARWIN)
endif ()

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
10 changes: 6 additions & 4 deletions src/app/application.cpp
Expand Up @@ -56,9 +56,9 @@
#include <QSessionManager>
#include <QSharedMemory>
#endif // Q_OS_WIN
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include <QFileOpenEvent>
#endif // Q_OS_MAC
#endif // Q_OS_MACOS
#endif

#include "base/bittorrent/session.h"
Expand Down Expand Up @@ -121,7 +121,9 @@ namespace
const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
const int DEFAULT_FILELOG_SIZE = 65 * 1024; // 65KiB

#if !defined(DISABLE_GUI)
const int PIXMAP_CACHE_SIZE = 64 * 1024 * 1024; // 64MiB
#endif
}

Application::Application(const QString &id, int &argc, char **argv)
Expand Down Expand Up @@ -586,7 +588,7 @@ bool Application::isRunning()
}

#ifndef DISABLE_GUI
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
bool Application::event(QEvent *ev)
{
if (ev->type() == QEvent::FileOpen) {
Expand All @@ -605,7 +607,7 @@ bool Application::event(QEvent *ev)
return BaseApplication::event(ev);
}
}
#endif // Q_OS_MAC
#endif // Q_OS_MACOS
#endif // DISABLE_GUI

void Application::initializeTranslation()
Expand Down
2 changes: 1 addition & 1 deletion src/app/application.h
Expand Up @@ -105,7 +105,7 @@ class Application : public BaseApplication

protected:
#ifndef DISABLE_GUI
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
bool event(QEvent *) override;
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Expand Up @@ -221,7 +221,7 @@ int main(int argc, char *argv[])
#endif
#endif // Q_OS_WIN

#if defined(Q_OS_MAC)
#if defined(Q_OS_MACOS)
// Since Apple made difficult for users to set PATH, we set here for convenience.
// Users are supposed to install Homebrew Python for search function.
// For more info see issue #5571.
Expand Down
2 changes: 1 addition & 1 deletion src/base/filesystemwatcher.cpp
Expand Up @@ -30,7 +30,7 @@

#include <QtGlobal>

#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
#if defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
#include <cstring>
#include <sys/mount.h>
#include <sys/param.h>
Expand Down
16 changes: 8 additions & 8 deletions src/base/preferences.cpp
Expand Up @@ -29,7 +29,7 @@

#include "preferences.h"

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include <CoreServices/CoreServices.h>
#endif
#ifdef Q_OS_WIN
Expand Down Expand Up @@ -188,7 +188,7 @@ void Preferences::setHideZeroComboValues(const int n)

// In Mac OS X the dock is sufficient for our needs so we disable the sys tray functionality.
// See extensive discussion in https://github.com/qbittorrent/qBittorrent/pull/3018
#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
bool Preferences::systrayIntegration() const
{
return value("Preferences/General/SystrayEnabled", true).toBool();
Expand Down Expand Up @@ -238,7 +238,7 @@ void Preferences::setCloseToTrayNotified(const bool b)
{
setValue("Preferences/General/CloseToTrayNotified", b);
}
#endif // Q_OS_MAC
#endif // Q_OS_MACOS

bool Preferences::isToolbarDisplayed() const
{
Expand Down Expand Up @@ -884,7 +884,7 @@ void Preferences::resolvePeerHostNames(const bool resolve)
setValue("Preferences/Connection/ResolvePeerHostNames", resolve);
}

#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
bool Preferences::useSystemIconTheme() const
{
return value("Preferences/Advanced/useSystemIconTheme", true).toBool();
Expand Down Expand Up @@ -988,7 +988,7 @@ void Preferences::setMagnetLinkAssoc(const bool set)
}
#endif // Q_OS_WIN

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
namespace
{
const CFStringRef torrentExtension = CFSTR("torrent");
Expand Down Expand Up @@ -1042,7 +1042,7 @@ void Preferences::setMagnetLinkAssoc()
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
}
#endif // Q_OS_MAC
#endif // Q_OS_MACOS

int Preferences::getTrackerPort() const
{
Expand All @@ -1054,7 +1054,7 @@ void Preferences::setTrackerPort(const int port)
setValue("Preferences/Advanced/trackerPort", port);
}

#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
bool Preferences::isUpdateCheckEnabled() const
{
return value("Preferences/Advanced/updateCheck", true).toBool();
Expand Down Expand Up @@ -1096,7 +1096,7 @@ void Preferences::setConfirmRemoveAllTags(const bool enabled)
setValue("Preferences/Advanced/confirmRemoveAllTags", enabled);
}

#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
TrayIcon::Style Preferences::trayIconStyle() const
{
return TrayIcon::Style(value("Preferences/Advanced/TrayIconStyle", TrayIcon::NORMAL).toInt());
Expand Down
10 changes: 5 additions & 5 deletions src/base/preferences.h
Expand Up @@ -254,7 +254,7 @@ class Preferences : public QObject
void resolvePeerCountries(bool resolve);
bool resolvePeerHostNames() const;
void resolvePeerHostNames(bool resolve);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
bool useSystemIconTheme() const;
void useSystemIconTheme(bool enabled);
#endif
Expand All @@ -268,15 +268,15 @@ class Preferences : public QObject
static void setTorrentFileAssoc(bool set);
static void setMagnetLinkAssoc(bool set);
#endif
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
static bool isTorrentFileAssocSet();
static bool isMagnetLinkAssocSet();
static void setTorrentFileAssoc();
static void setMagnetLinkAssoc();
#endif
int getTrackerPort() const;
void setTrackerPort(int port);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
bool isUpdateCheckEnabled() const;
void setUpdateCheckEnabled(bool enabled);
#endif
Expand All @@ -286,7 +286,7 @@ class Preferences : public QObject
void setConfirmTorrentRecheck(bool enabled);
bool confirmRemoveAllTags() const;
void setConfirmRemoveAllTags(bool enabled);
#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
bool systrayIntegration() const;
void setSystrayIntegration(bool enabled);
bool minimizeToTrayNotified() const;
Expand All @@ -299,7 +299,7 @@ class Preferences : public QObject
void setCloseToTrayNotified(bool b);
TrayIcon::Style trayIconStyle() const;
void setTrayIconStyle(TrayIcon::Style style);
#endif // Q_OS_MAC
#endif // Q_OS_MACOS

// Stuff that don't appear in the Options GUI but are saved
// in the same file.
Expand Down
6 changes: 3 additions & 3 deletions src/base/private/profile_p.cpp
Expand Up @@ -73,7 +73,7 @@ QString Private::DefaultProfile::configLocation() const

QString Private::DefaultProfile::dataLocation() const
{
#if defined(Q_OS_WIN) || defined (Q_OS_MAC)
#if defined(Q_OS_WIN) || defined (Q_OS_MACOS)
return locationWithConfigurationName(QStandardPaths::AppLocalDataLocation);
#else
// on Linux gods know why qBittorrent creates 'data' subdirectory in ~/.local/share/
Expand All @@ -89,7 +89,7 @@ QString Private::DefaultProfile::downloadLocation() const

SettingsPtr Private::DefaultProfile::applicationSettings(const QString &name) const
{
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
return SettingsPtr(new QSettings(QSettings::IniFormat, QSettings::UserScope, profileName(), name));
#else
return SettingsPtr(new QSettings(profileName(), name));
Expand Down Expand Up @@ -135,7 +135,7 @@ QString Private::CustomProfile::downloadLocation() const
SettingsPtr Private::CustomProfile::applicationSettings(const QString &name) const
{
// here we force QSettings::IniFormat format always because we need it to be portable across platforms
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
constexpr const char *CONF_FILE_EXTENSION = ".ini";
#else
constexpr const char *CONF_FILE_EXTENSION = ".conf";
Expand Down
4 changes: 2 additions & 2 deletions src/base/utils/fs.cpp
Expand Up @@ -39,7 +39,7 @@

#if defined(Q_OS_WIN)
#include <Windows.h>
#elif defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
#elif defined(Q_OS_MACOS) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(Q_OS_HAIKU)
Expand Down Expand Up @@ -321,7 +321,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
return false;

return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE);
#elif defined(Q_OS_MAC) || defined(Q_OS_OPENBSD)
#elif defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD)
QString file = path;
if (!file.endsWith('/'))
file += '/';
Expand Down
6 changes: 3 additions & 3 deletions src/base/utils/misc.cpp
Expand Up @@ -36,7 +36,7 @@
#include <unistd.h>
#endif

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
#endif
Expand All @@ -51,7 +51,7 @@
#include <QSet>
#include <QSysInfo>

#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
#include <QDBusInterface>
#endif

Expand Down Expand Up @@ -139,7 +139,7 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
tkp.Privileges[0].Attributes = 0;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);

#elif defined(Q_OS_MAC)
#elif defined(Q_OS_MACOS)
AEEventID EventToSend;
if (action != ShutdownDialogAction::Shutdown)
EventToSend = kAESleep;
Expand Down
6 changes: 3 additions & 3 deletions src/base/utils/string.cpp
Expand Up @@ -35,7 +35,7 @@
#include <QLocale>
#include <QRegExp>
#include <QtGlobal>
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include <QThreadStorage>
#endif

Expand Down Expand Up @@ -139,7 +139,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con
// provide a single `NaturalCompare` instance for easy use
// https://doc.qt.io/qt-5/threads-reentrancy.html
if (caseSensitivity == Qt::CaseSensitive) {
#ifdef Q_OS_MAC // workaround for Apple xcode: https://stackoverflow.com/a/29929949
#ifdef Q_OS_MACOS // workaround for Apple xcode: https://stackoverflow.com/a/29929949
static QThreadStorage<NaturalCompare> nCmp;
if (!nCmp.hasLocalData())
nCmp.setLocalData(NaturalCompare(Qt::CaseSensitive));
Expand All @@ -150,7 +150,7 @@ int Utils::String::naturalCompare(const QString &left, const QString &right, con
#endif
}

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
static QThreadStorage<NaturalCompare> nCmp;
if (!nCmp.hasLocalData())
nCmp.setLocalData(NaturalCompare(Qt::CaseInsensitive));
Expand Down
6 changes: 3 additions & 3 deletions src/gui/advancedsettings.cpp
Expand Up @@ -80,7 +80,7 @@ enum AdvSettingsRows
DOWNLOAD_TRACKER_FAVICON,
SAVE_PATH_HISTORY_LENGTH,
ENABLE_SPEED_WIDGET,
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
USE_ICON_THEME,
#endif

Expand Down Expand Up @@ -233,7 +233,7 @@ void AdvancedSettings::saveAdvancedSettings()
session->setSeedChokingAlgorithm(static_cast<BitTorrent::SeedChokingAlgorithm>(m_comboBoxSeedChokingAlgorithm.currentIndex()));

// Icon theme
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
pref->useSystemIconTheme(m_checkBoxUseIconTheme.isChecked());
#endif
pref->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck.isChecked());
Expand Down Expand Up @@ -515,7 +515,7 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(SEED_CHOKING_ALGORITHM, (tr("Upload choking algorithm") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", "(?)"))
, &m_comboBoxSeedChokingAlgorithm);

#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
m_checkBoxUseIconTheme.setChecked(pref->useSystemIconTheme());
addRow(USE_ICON_THEME, tr("Use system icon theme"), &m_checkBoxUseIconTheme);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/gui/advancedsettings.h
Expand Up @@ -69,7 +69,7 @@ private slots:
QLineEdit m_lineEditAnnounceIP;

// OS dependent settings
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
QCheckBox m_checkBoxUseIconTheme;
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion src/gui/categoryfilterwidget.cpp
Expand Up @@ -69,7 +69,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
setUniformRowHeights(true);
setHeaderHidden(true);
setIconSize(Utils::Gui::smallIconSize());
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
setAttribute(Qt::WA_MacShowFocusRect, false);
#endif
m_defaultIndentation = indentation();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/executionlogwidget.cpp
Expand Up @@ -44,7 +44,7 @@ ExecutionLogWidget::ExecutionLogWidget(QWidget *parent, const Log::MsgTypes &typ
{
m_ui->setupUi(this);

#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
m_ui->tabConsole->setTabIcon(0, UIThemeManager::instance()->getIcon("view-calendar-journal"));
m_ui->tabConsole->setTabIcon(1, UIThemeManager::instance()->getIcon("view-filter"));
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/gui/hidabletabwidget.cpp
Expand Up @@ -30,7 +30,7 @@

#include <QTabBar>

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include <QPaintEvent>
#include <QStyle>
#endif
Expand All @@ -53,7 +53,7 @@ void HidableTabWidget::tabRemoved(const int index)
tabBar()->setVisible(count() != 1);
}

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
void HidableTabWidget::paintEvent(QPaintEvent *event)
{
// Hide the pane for macintosh style
Expand Down
4 changes: 2 additions & 2 deletions src/gui/hidabletabwidget.h
Expand Up @@ -31,7 +31,7 @@

#include <QTabWidget>

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
class QPaintEvent;
#endif

Expand All @@ -44,7 +44,7 @@ class HidableTabWidget : public QTabWidget
void tabInserted(int index) override;
void tabRemoved(int index) override;

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
void paintEvent(QPaintEvent *event) override;
#endif
};
Expand Down

0 comments on commit d2c21ce

Please sign in to comment.