From b219655ac299609e02658109b0de96422016134b Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 17 Nov 2015 13:50:48 +0100 Subject: [PATCH] removed redundant OBCocoa files / namespace; moved functions to UBPlatformUtils, which serves the same purpose --- src/core/OBCocoa.h | 11 ----------- src/core/OBCocoa.mm | 24 ------------------------ src/core/UBApplication.cpp | 6 +----- src/core/core.pri | 6 ------ src/frameworks/UBPlatformUtils.h | 1 + src/frameworks/UBPlatformUtils_linux.cpp | 5 +++++ src/frameworks/UBPlatformUtils_mac.mm | 14 ++++++++++++++ src/frameworks/UBPlatformUtils_win.cpp | 4 ++++ 8 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 src/core/OBCocoa.h delete mode 100644 src/core/OBCocoa.mm diff --git a/src/core/OBCocoa.h b/src/core/OBCocoa.h deleted file mode 100644 index f646d434..00000000 --- a/src/core/OBCocoa.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - OBCocoa.h - - Header file permitting access to Mac OSX / Cocoa specific functions - -*/ - - -namespace OBCocoa { - void setFrontProcess(); -} diff --git a/src/core/OBCocoa.mm b/src/core/OBCocoa.mm deleted file mode 100644 index 53c01e2f..00000000 --- a/src/core/OBCocoa.mm +++ /dev/null @@ -1,24 +0,0 @@ -#include "OBCocoa.h" -#include "UBApplicationController.h" - -#include -#import - -namespace OBCocoa { - -/** - * @brief Activate the current application - */ -void setFrontProcess() -{ - NSRunningApplication* app = [NSRunningApplication currentApplication]; - - // activate the application, forcing focus on it - [app activateWithOptions: NSApplicationActivateIgnoringOtherApps]; - - // other option:NSApplicationActivateAllWindows. This won't steal focus from another app, e.g - // if the user is doing something else while waiting for OpenBoard to load -} - - -} // namespace OBCocoa diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index c24ffbbb..24558e59 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -33,10 +33,6 @@ #include #include -#if defined(Q_OS_OSX) - #include "OBCocoa.h" -#endif - #include "frameworks/UBPlatformUtils.h" #include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBStringUtils.h" @@ -564,7 +560,7 @@ bool UBApplication::eventFilter(QObject *obj, QEvent *event) { QFileOpenEvent *fileToOpenEvent = static_cast(event); - OBCocoa::setFrontProcess(); + UBPlatformUtils::setFrontProcess(); applicationController->importFile(fileToOpenEvent->file()); } diff --git a/src/core/core.pri b/src/core/core.pri index 92825ee3..a60978ad 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -34,9 +34,3 @@ SOURCES += src/core/main.cpp \ src/core/UBOpenSankoreImporter.cpp \ src/core/UBTextTools.cpp \ src/core/UBPersistenceWorker.cpp - - -macx { - HEADERS += src/core/OBCocoa.h - OBJECTIVE_SOURCES += src/core/OBCocoa.mm -} diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h index c7b99bc1..e0b3f4ff 100644 --- a/src/frameworks/UBPlatformUtils.h +++ b/src/frameworks/UBPlatformUtils.h @@ -203,6 +203,7 @@ public: static UBKeyboardLocale** getKeyboardLayouts(int& nCount); static QString urlFromClipboard(); static QStringList availableTranslations(); + static void setFrontProcess(); #ifdef Q_OS_OSX static void SetMacLocaleByIdentifier(const QString& id); diff --git a/src/frameworks/UBPlatformUtils_linux.cpp b/src/frameworks/UBPlatformUtils_linux.cpp index 73e901a0..17011217 100644 --- a/src/frameworks/UBPlatformUtils_linux.cpp +++ b/src/frameworks/UBPlatformUtils_linux.cpp @@ -429,3 +429,8 @@ QString UBPlatformUtils::urlFromClipboard() return qsRet; } + + +void UBPlatformUtils::setFrontProcess() +{ +} diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm index d4685fe5..b2623080 100644 --- a/src/frameworks/UBPlatformUtils_mac.mm +++ b/src/frameworks/UBPlatformUtils_mac.mm @@ -557,3 +557,17 @@ void UBPlatformUtils::SetMacLocaleByIdentifier(const QString& id) } [pool drain]; } + +/** + * @brief Activate the current application + */ +void UBPlatformUtils::setFrontProcess() +{ + NSRunningApplication* app = [NSRunningApplication currentApplication]; + + // activate the application, forcing focus on it + [app activateWithOptions: NSApplicationActivateIgnoringOtherApps]; + + // other option:NSApplicationActivateAllWindows. This won't steal focus from another app, e.g + // if the user is doing something else while waiting for OpenBoard to load +} diff --git a/src/frameworks/UBPlatformUtils_win.cpp b/src/frameworks/UBPlatformUtils_win.cpp index 1d46586a..ed698a39 100644 --- a/src/frameworks/UBPlatformUtils_win.cpp +++ b/src/frameworks/UBPlatformUtils_win.cpp @@ -424,3 +424,7 @@ QString UBPlatformUtils::urlFromClipboard() // Not implemented yet return qsRet; } + +void UBPlatformUtils::setFrontProcess() +{ +}