1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Put macOS specific functions to MacUtils namespace

This commit is contained in:
vit9696 2017-12-12 20:20:48 +03:00
parent d57bd62add
commit d7fa5b6b6b
5 changed files with 71 additions and 65 deletions

View File

@ -33,9 +33,12 @@
#include <QSize> #include <QSize>
#include <objc/objc.h> #include <objc/objc.h>
namespace MacUtils
{
QPixmap pixmapForExtension(const QString &ext, const QSize &size); QPixmap pixmapForExtension(const QString &ext, const QSize &size);
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...)); void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...));
void displayNotification(const QString &title, const QString &message); void displayNotification(const QString &title, const QString &message);
void openFiles(const QSet<QString> &pathsList); void openFiles(const QSet<QString> &pathsList);
}
#endif // MACUTILITIES_H #endif // MACUTILITIES_H

View File

@ -33,6 +33,8 @@
#include <objc/message.h> #include <objc/message.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
namespace MacUtils
{
QPixmap pixmapForExtension(const QString &ext, const QSize &size) QPixmap pixmapForExtension(const QString &ext, const QSize &size)
{ {
@autoreleasepool { @autoreleasepool {
@ -94,3 +96,4 @@ void openFiles(const QSet<QString> &pathsList)
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs]; [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs];
} }
} }
}

View File

@ -1298,7 +1298,7 @@ static bool dockClickHandler(id self, SEL cmd, ...)
void MainWindow::setupDockClickHandler() void MainWindow::setupDockClickHandler()
{ {
dockMainWindowHandle = this; dockMainWindowHandle = this;
overrideDockClickHandler(dockClickHandler); MacUtils::overrideDockClickHandler(dockClickHandler);
} }
#endif #endif
@ -1557,7 +1557,7 @@ void MainWindow::showNotificationBaloon(QString title, QString msg) const
if (!reply.isError()) if (!reply.isError())
return; return;
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
displayNotification(title, msg); MacUtils::displayNotification(title, msg);
#else #else
if (m_systrayIcon && QSystemTrayIcon::supportsMessages()) if (m_systrayIcon && QSystemTrayIcon::supportsMessages())
m_systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON); m_systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);

View File

@ -150,7 +150,7 @@ namespace
{ {
QPixmap pixmapForExtension(const QString &ext) const override QPixmap pixmapForExtension(const QString &ext) const override
{ {
return ::pixmapForExtension(ext, QSize(32, 32)); return MacUtils::pixmapForExtension(ext, QSize(32, 32));
} }
}; };
#else #else

View File

@ -559,7 +559,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
QString path = torrent->contentPath(true); QString path = torrent->contentPath(true);
pathsList.insert(path); pathsList.insert(path);
} }
openFiles(pathsList); MacUtils::openFiles(pathsList);
#else #else
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) { foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
QString path = torrent->contentPath(true); QString path = torrent->contentPath(true);