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 <objc/objc.h>
namespace MacUtils
{
QPixmap pixmapForExtension(const QString &ext, const QSize &size);
void overrideDockClickHandler(bool (*dockClickHandler)(id, SEL, ...));
void displayNotification(const QString &title, const QString &message);
void openFiles(const QSet<QString> &pathsList);
}
#endif // MACUTILITIES_H

View File

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

View File

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

View File

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

View File

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