Fix macos build

This commit is contained in:
Jonas Kvinge
2018-07-01 22:26:46 +02:00
parent c4e75dea65
commit ada7325a04
51 changed files with 453 additions and 399 deletions

View File

@@ -74,7 +74,7 @@ class ApplicationImpl {
player_([=]() { return new Player(app, app); }),
enginedevice_([=]() { return new EngineDevice(app); }),
device_manager_([=]() { return new DeviceManager(app, app); }),
collection_([=]() { return new Collection(app, app); }),
collection_([=]() { return new SCollection(app, app); }),
playlist_backend_([=]() {
PlaylistBackend *backend = new PlaylistBackend(app, app);
app->MoveToThread(backend, database_->thread());
@@ -107,7 +107,7 @@ class ApplicationImpl {
Lazy<Player> player_;
Lazy<EngineDevice> enginedevice_;
Lazy<DeviceManager> device_manager_;
Lazy<Collection> collection_;
Lazy<SCollection> collection_;
Lazy<PlaylistBackend> playlist_backend_;
Lazy<PlaylistManager> playlist_manager_;
Lazy<CoverProviders> cover_providers_;
@@ -183,7 +183,7 @@ DeviceManager *Application::device_manager() const {
return p_->device_manager_.get();
}
Collection *Application::collection() const { return p_->collection_.get(); }
SCollection *Application::collection() const { return p_->collection_.get(); }
CollectionBackend *Application::collection_backend() const {
return collection()->backend();

View File

@@ -40,7 +40,7 @@ class Database;
class EngineDevice;
class Player;
class Appearance;
class Collection;
class SCollection;
class CollectionBackend;
class CollectionModel;
class PlaylistBackend;
@@ -67,15 +67,15 @@ class Application : public QObject {
EngineDevice *enginedevice() const;
DeviceManager *device_manager() const;
Collection *collection() const;
SCollection *collection() const;
PlaylistBackend *playlist_backend() const;
PlaylistManager *playlist_manager() const;
CoverProviders *cover_providers() const;
AlbumCoverLoader *album_cover_loader() const;
CurrentArtLoader *current_art_loader() const;
CollectionBackend *collection_backend() const;
CollectionModel *collection_model() const;

View File

@@ -90,7 +90,7 @@ CommandlineOptions::CommandlineOptions(int argc, char* *argv)
toggle_pretty_osd_(false),
log_levels_(logging::kDefaultLogLevels) {
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
// Remove -psn_xxx option that Mac passes when opened from Finder.
RemoveArg("-psn", 1);
#endif

View File

@@ -25,7 +25,7 @@
#include "filesystemwatcherinterface.h"
#include "qtfslistener.h"
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
#include "macfslistener.h"
#endif
@@ -34,7 +34,7 @@ FileSystemWatcherInterface::FileSystemWatcherInterface(QObject *parent)
FileSystemWatcherInterface *FileSystemWatcherInterface::Create(QObject *parent) {
FileSystemWatcherInterface *ret;
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
ret = new MacFSListener(parent);
#else
ret = new QtFSListener(parent);

View File

@@ -1,7 +1,7 @@
#import <AppKit/NSApplication.h>
#include "config.h"
#include "macglobalshortcutbackend.h"
#include "globalshortcuts/macglobalshortcutbackend.h"
class PlatformInterface;
@class SPMediaKeyTap;

View File

@@ -43,18 +43,18 @@
#include "config.h"
#include "globalshortcuts.h"
#include "mac_delegate.h"
#include "mac_startup.h"
#include "mac_utilities.h"
#include "macglobalshortcutbackend.h"
#include "utilities.h"
#include "core/logging.h"
#include "scoped_cftyperef.h"
#include "scoped_nsautorelease_pool.h"
#include "core/logging.h"
#include "core/scoped_nsautorelease_pool.h"
#include "globalshortcuts/globalshortcuts.h"
#include "globalshortcuts/macglobalshortcutbackend.h"
#ifdef HAVE_SPARKLE
#import <Sparkle/SUUpdater.h>
# import <Sparkle/SUUpdater.h>
#endif
#include <QApplication>

View File

@@ -90,7 +90,7 @@ class MacSystemTrayIconPrivate {
// This must be called after our custom NSApplicationDelegate has been set.
[(AppDelegate*)([NSApp delegate]) setDockMenu:dock_menu_];
ClearPlaying();
ClearNowPlaying();
}
void AddMenuItem(QAction* action) {
@@ -120,8 +120,8 @@ class MacSystemTrayIconPrivate {
[dock_menu_ addItem:separator];
}
void ShowPlaying(const QString& artist, const QString& title) {
ClearPlaying(); // Makes sure the order is consistent.
void ShowNowPlaying(const QString& artist, const QString& title) {
ClearNowPlaying(); // Makes sure the order is consistent.
[now_playing_artist_ setTitle:
[[NSString alloc] initWithUTF8String: artist.toUtf8().constData()]];
[now_playing_title_ setTitle:
@@ -131,7 +131,7 @@ class MacSystemTrayIconPrivate {
artist.isEmpty() && title.isEmpty() ? HideItem(now_playing_) : ShowItem(now_playing_);
}
void ClearPlaying() {
void ClearNowPlaying() {
// Hiding doesn't seem to work in the dock menu.
HideItem(now_playing_);
HideItem(now_playing_artist_);
@@ -200,10 +200,10 @@ void MacSystemTrayIcon::ActionChanged() {
p_->ActionChanged(action);
}
void MacSystemTrayIcon::ClearPlaying() {
p_->ClearPlaying();
void MacSystemTrayIcon::ClearNowPlaying() {
p_->ClearNowPlaying();
}
void MacSystemTrayIcon::SetPlaying(const Song& song, const QString& image_path) {
p_->ShowPlaying(song.artist(), song.PrettyTitle());
void MacSystemTrayIcon::SetNowPlaying(const Song& song, const QString& image_path) {
p_->ShowNowPlaying(song.artist(), song.PrettyTitle());
}

View File

@@ -31,6 +31,7 @@
#include <QtGlobal>
#include <QObject>
#include <QCoreApplication>
#include <QStandardPaths>
#include <QFileDevice>
#include <QIODevice>
#include <QByteArray>
@@ -48,7 +49,7 @@
# include <unistd.h>
#endif
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
# include <sys/resource.h>
# include <sys/sysctl.h>
#endif
@@ -90,13 +91,13 @@
int main(int argc, char* argv[]) {
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
// Do Mac specific startup to get media keys working.
// This must go before QApplication initialisation.
mac::MacMain();
#endif
#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN)
#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS)
QCoreApplication::setApplicationName("Strawberry");
QCoreApplication::setOrganizationName("Strawberry");
#else
@@ -142,7 +143,7 @@ int main(int argc, char* argv[]) {
}
}
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
// Must happen after QCoreApplication::setOrganizationName().
setenv("XDG_CONFIG_HOME", QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).toLocal8Bit().constData(), 1);
#endif
@@ -159,8 +160,8 @@ int main(int argc, char* argv[]) {
QtSingleApplication a(argc, argv);
#ifdef Q_OS_DARWIN
QCoreApplication::setCollectionPaths(QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns");
#ifdef Q_OS_MACOS
QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns");
#endif
a.setQuitOnLastWindowClosed(false);
@@ -170,7 +171,7 @@ int main(int argc, char* argv[]) {
return 0;
}
#ifndef Q_OS_DARWIN
#ifndef Q_OS_MACOS
// Gnome on Ubuntu has menu icons disabled by default. I think that's a bad idea, and makes some menus in Strawberry look confusing.
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
#else
@@ -217,9 +218,9 @@ int main(int argc, char* argv[]) {
// Window
MainWindow w(&app, tray_icon.get(), &osd, options);
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
mac::EnableFullScreen(w);
#endif // Q_OS_DARWIN
#endif // Q_OS_MACOS
#ifdef HAVE_GIO
ScanGIOModulePath();
#endif

View File

@@ -84,7 +84,7 @@
#include "dialogs/trackselectiondialog.h"
#include "dialogs/edittagdialog.h"
#ifdef HAVE_GSTREAMER
#include "dialogs/organisedialog.h"
# include "dialogs/organisedialog.h"
#endif
#include "widgets/fancytabwidget.h"
#include "widgets/playingwidget.h"
@@ -127,13 +127,13 @@
#include "settings/playlistsettingspage.h"
#include "settings/settingsdialog.h"
#ifdef Q_OS_DARWIN
#include "ui/macsystemtrayicon.h"
#ifdef Q_OS_MACOS
# include "core/macsystemtrayicon.h"
#endif
#ifdef Q_OS_DARWIN
// Non exported mac-specific function.
void qt_mac_set_dock_menu(QMenu*);
#ifdef Q_OS_MACOS
// Non exported mac-specific function.
void qt_mac_set_dock_menu(QMenu*);
#endif
const char *MainWindow::kSettingsGroup = "MainWindow";
@@ -203,7 +203,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
// Initialise the UI
ui_->setupUi(this);
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
ui_->menu_help->menuAction()->setVisible(false);
#endif
@@ -511,7 +511,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
playlist_menu_->addAction(ui_->action_remove_duplicates);
playlist_menu_->addAction(ui_->action_remove_unavailable);
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
ui_->action_shuffle->setShortcut(QKeySequence());
#endif
@@ -525,7 +525,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), playlist_copy_to_device_, SLOT(setDisabled(bool)));
#endif
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
mac::SetApplicationHandler(this);
#endif
// Tray icon
@@ -542,7 +542,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
// Windows 7 thumbbar buttons
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr); // spacer
#if (defined(Q_OS_DARWIN) && defined(HAVE_SPARKLE))
#if (defined(Q_OS_MACOS) && defined(HAVE_SPARKLE))
// Add check for updates item to application menu.
QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates..."));
check_updates->setMenuRole(QAction::ApplicationSpecificRole);
@@ -661,7 +661,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
ui_->playlist->view()->ReloadSettings();
#ifndef Q_OS_DARWIN
#ifndef Q_OS_MACOS
QSettings settings;
settings.beginGroup(BehaviourSettingsPage::kSettingsGroup);
StartupBehaviour behaviour = StartupBehaviour(settings.value("startupbehaviour", Startup_Remember).toInt());
@@ -682,7 +682,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
settings_.setValue("hidden", false);
show();
}
#else // Q_OS_DARWIN
#else // Q_OS_MACOS
// Always show mainwindow on startup on OS X.
show();
#endif
@@ -711,7 +711,7 @@ void MainWindow::ReloadSettings() {
QSettings settings;
#ifndef Q_OS_DARWIN
#ifndef Q_OS_MACOS
settings.beginGroup(BehaviourSettingsPage::kSettingsGroup);
bool showtrayicon = settings.value("showtrayicon", true).toBool();
@@ -1694,7 +1694,7 @@ bool MainWindow::LoadUrl(const QString &url) {
}
void MainWindow::CheckForUpdates() {
#if defined(Q_OS_DARWIN)
#if defined(Q_OS_MACOS)
mac::CheckForUpdates();
#endif
}

View File

@@ -29,7 +29,7 @@
#include "screensaver.h"
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
#include "macscreensaver.h"
#endif
@@ -51,7 +51,7 @@ Screensaver *Screensaver::GetScreensaver() {
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kKdeService)) {
screensaver_ = new DBusScreensaver(kKdeService, kKdePath, kKdeInterface);
}
#elif defined(Q_OS_DARWIN)
#elif defined(Q_OS_MACOS)
screensaver_ = new MacScreensaver();
#endif
}

View File

@@ -87,7 +87,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget) {
ReplaceColor(&contents, "Link", p, QPalette::Link);
ReplaceColor(&contents, "LinkVisited", p, QPalette::LinkVisited);
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
contents.replace("darwin", "*");
#endif

View File

@@ -30,8 +30,11 @@
#include <QRect>
#include <QVector>
#include "qtsystemtrayicon.h"
#include "systemtrayicon.h"
#include "qtsystemtrayicon.h"
#ifdef Q_OS_MACOS
# include "macsystemtrayicon.h"
#endif
SystemTrayIcon::SystemTrayIcon(QObject *parent)
: QObject(parent),
@@ -103,7 +106,7 @@ void SystemTrayIcon::SetStopped() {
}
SystemTrayIcon* SystemTrayIcon::CreateSystemTrayIcon(QObject *parent) {
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
return new MacSystemTrayIcon(parent);
#else
return new QtSystemTrayIcon(parent);

View File

@@ -59,26 +59,27 @@
#include <QtDebug>
#ifdef Q_OS_LINUX
#include <unistd.h>
#include <sys/syscall.h>
# include <unistd.h>
# include <sys/syscall.h>
#endif
#ifdef Q_OS_DARWIN
#include <sys/resource.h>
#ifdef Q_OS_MACOS
# include <sys/resource.h>
# include <sys/sysctl.h>
# include <sys/param.h>
#endif
#if defined(Q_OS_UNIX)
#include <sys/statvfs.h>
#elif defined(Q_OS_WIN32)
#include <windows.h>
# include <sys/statvfs.h>
#elif defined(Q_OS_WIN)
# include <windows.h>
#endif
#ifdef Q_OS_DARWIN
#include <QProcess>
#include "CoreServices/CoreServices.h"
#include "IOKit/ps/IOPSKeys.h"
#include "IOKit/ps/IOPowerSources.h"
#elif defined(Q_OS_WIN32)
#ifdef Q_OS_MACOS
# include <QProcess>
# include "CoreServices/CoreServices.h"
# include "IOKit/ps/IOPSKeys.h"
# include "IOKit/ps/IOPowerSources.h"
#elif defined(Q_OS_WIN)
#include <QProcess>
#endif
@@ -89,10 +90,10 @@
#include "timeconstants.h"
#include "application.h"
#ifdef Q_OS_DARWIN
#include "mac_startup.h"
#include "mac_utilities.h"
#include "scoped_cftyperef.h"
#ifdef Q_OS_MACOS
# include "mac_startup.h"
# include "mac_utilities.h"
# include "scoped_cftyperef.h"
#endif
namespace Utilities {
@@ -361,7 +362,7 @@ QString ColorToRgba(const QColor &c) {
}
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
qint32 GetMacVersion() {
SInt32 minor_version;
@@ -374,7 +375,7 @@ qint32 GetMacVersion() {
void RevealFileInFinder(QString const &path) {
QProcess::execute("/usr/bin/open", QStringList() << "-R" << path);
}
#endif // Q_OS_DARWIN
#endif // Q_OS_MACOS
#ifdef Q_OS_WIN
void ShowFileInExplorer(QString const &path) {
@@ -398,7 +399,7 @@ void OpenInFileBrowser(const QList<QUrl> &urls) {
if (dirs.contains(directory)) continue;
dirs.insert(directory);
qLog(Debug) << path;
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
// Revealing multiple files in the finder only opens one window, so it also makes sense to reveal at most one per directory
RevealFileInFinder(path);
#elif defined(Q_OS_WIN32)
@@ -642,7 +643,7 @@ int SetThreadIOPriority(IoPriority priority) {
#ifdef Q_OS_LINUX
return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(), 4 | priority << IOPRIO_CLASS_SHIFT);
#elif defined(Q_OS_DARWIN)
#elif defined(Q_OS_MACOS)
return setpriority(PRIO_DARWIN_THREAD, 0, priority == IOPRIO_CLASS_IDLE ? PRIO_DARWIN_BG : 0);
#else
return 0;
@@ -752,7 +753,7 @@ void SetEnv(const char *key, const QString &value) {
void IncreaseFDLimit() {
#ifdef Q_OS_DARWIN
#ifdef Q_OS_MACOS
// Bump the soft limit for the number of file descriptors from the default of 256 to the maximum (usually 10240).
struct rlimit limit;
getrlimit(RLIMIT_NOFILE, &limit);