Skip to content

Commit

Permalink
make mac work
Browse files Browse the repository at this point in the history
  • Loading branch information
fireph committed Aug 14, 2018
1 parent 8f99c75 commit b9ffcc9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
5 changes: 3 additions & 2 deletions ObsSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ void ObsSettingsDialog::selectApp()
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFiles);
QStringList filters;
#ifdef WIN32
#ifdef Q_OS_WIN
dialog.setDirectory("C:\\Program Files (x86)");
filters << "Exe files (*.exe)";
#elif __APPLE__
#endif
#ifdef Q_OS_OSX
dialog.setDirectory("/Applications");
filters << "App files (*.app)";
#endif
Expand Down
9 changes: 5 additions & 4 deletions ObsUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "ObsUtils.hpp"

#ifdef Q_OS_OSX
#include <libproc.h>
#include "ObsUtilsOSX.hpp"
#endif

#include "ObsUtils.hpp"

namespace ObsUtils
{

Expand All @@ -13,8 +13,9 @@ namespace ObsUtils
std::set<std::string> appsOpen;
#ifdef Q_OS_WIN
EnumWindows(EnumWindowsProcOpenApps, reinterpret_cast<LPARAM>(&appsOpen));
#elif Q_OS_OSX
std::set<std::string> appsOpen = ObsUtilsOSX::getOpenApps();
#endif
#ifdef Q_OS_OSX
ObsUtilsOSX::setOpenApps(&appsOpen);
#endif
for (const auto &appToWatch : appsToWatch)
{
Expand Down
2 changes: 1 addition & 1 deletion ObsUtilsOSX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ObsUtilsOSX
{
std::set<std::string> getOpenApps();
void setOpenApps(std::set<std::string>* appsOpen);
void showDockIcon();
void hideDockIcon();
}
Expand Down
13 changes: 3 additions & 10 deletions ObsUtilsOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@
namespace ObsUtilsOSX
{

std::set<std::string> getOpenApps()
void setOpenApps(std::set<std::string>* appsOpen)
{
std::set<std::string> appsOpen;
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSArray *apps = [workspace runningApplications];

for (NSRunningApplication *a in apps) {
if (a.bundleURL != nil) {
NSString *path = [a.bundleURL.absoluteString stringByRemovingPercentEncoding];
std::string filePath([path cStringUsingEncoding:NSUTF8StringEncoding]);
if (filePath.compare(filePath.size() - 1, 1, "/") == 0) {
filePath = filePath.substr(0, filePath.size() - 1);
}
filePath = filePath.substr(filePath.find_last_of("/") + 1);
appsOpen.emplace(filePath);
std::string filename([a.bundleURL.lastPathComponent cStringUsingEncoding:NSUTF8StringEncoding]);
appsOpen->emplace(filename);
}
}
return appsOpen;
}

void showDockIcon()
Expand Down
2 changes: 1 addition & 1 deletion obsautorecord.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MOC_DIR = $$DESTDIR/.moc
RCC_DIR = $$DESTDIR/.qrc
UI_DIR = $$DESTDIR/.ui

VERSION = 1.0.0.0
VERSION = 2.0.1
QMAKE_TARGET_COMPANY = "Frederick Meyer"
QMAKE_TARGET_PRODUCT = "OBS Auto Record"
QMAKE_TARGET_DESCRIPTION = "OBS Auto Record"
Expand Down

0 comments on commit b9ffcc9

Please sign in to comment.