Skip to content

Commit

Permalink
Mac add missing Qt framework
Browse files Browse the repository at this point in the history
  • Loading branch information
MizPlusPlus committed May 7, 2018
1 parent 7b9f15d commit 1f7eb77
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 42 deletions.
2 changes: 1 addition & 1 deletion OSCRouter.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion OSCRouter/EosPlatform_Mac.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electronic Theatre Controls, Inc., http://www.etcconnect.com
// Copyright (c) 2018 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -41,7 +41,10 @@ EosPlatform_Mac::~EosPlatform_Mac()
bool EosPlatform_Mac::Initialize(std::string &error)
{
if(m_Platform == 0)
{
m_Platform = Bridge_CreatePlatform(error);
Bridge_InitQtPlugins();
}

return (m_Platform != 0);
}
Expand Down
2 changes: 1 addition & 1 deletion OSCRouter/EosPlatform_Mac.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electronic Theatre Controls, Inc., http://www.etcconnect.com
// Copyright (c) 2018 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion OSCRouter/EosPlatform_Mac_Bridge.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electronic Theatre Controls, Inc., http://www.etcconnect.com
// Copyright (c) 2018 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,6 +29,7 @@ void* Bridge_CreatePlatform(std::string &error);
void Bridge_DestroyPlatform(void *platform);
void* Bridge_BeginActivity(const std::string &reason, std::string &error);
void Bridge_EndActivity(void *activity);
void Bridge_InitQtPlugins();

////////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion OSCRouter/EosPlatform_Mac_Native.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electronic Theatre Controls, Inc., http://www.etcconnect.com
// Copyright (c) 2018 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 19 additions & 1 deletion OSCRouter/EosPlatform_Mac_Native.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electronic Theatre Controls, Inc., http://www.etcconnect.com
// Copyright (c) 2018 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -20,6 +20,10 @@

#import "EosPlatform_Mac_Native.h"
#import "EosPlatform_Mac_Bridge.h"
#import <QtWidgets/QApplication>
#import <QtCore/QDir>
#import <QtCore/QUrl>


////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -112,3 +116,17 @@ + (void)EndActivity:(id)activity
@end

////////////////////////////////////////////////////////////////////////////////

void Bridge_InitQtPlugins()
{
// only load plugins from our bundle
CFURLRef url = (CFURLRef)CFAutorelease((CFURLRef)CFBundleCopyBundleURL(CFBundleGetMainBundle()));
if(url != nil)
{
QDir dir( QUrl::fromCFURL(url).path() );
if( dir.cd("Contents/Plugins") )
QApplication::setLibraryPaths(QStringList() << dir.canonicalPath());
}
}

////////////////////////////////////////////////////////////////////////////////
36 changes: 10 additions & 26 deletions OSCRouter/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

////////////////////////////////////////////////////////////////////////////////

#define APP_VERSION "0.10"
#define APP_VERSION "0.11"
#define SETTING_LOG_DEPTH "LogDepth"
#define SETTING_FILE_DEPTH "FileDepth"
#define SETTING_LAST_FILE "LastFile"
Expand Down Expand Up @@ -1290,6 +1290,8 @@ void RoutingTable::LoadLineFromFile(const QString &line, Router::ROUTES &routes)
bool RoutingTable::SaveToFile(const QString &path) const
{
bool success = true;

QDir().mkpath( QFileInfo(path).absolutePath() );

QFile f(path);
if( f.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text) )
Expand Down Expand Up @@ -1490,7 +1492,7 @@ void RoutingTable::resizeEvent(QResizeEvent *event)

////////////////////////////////////////////////////////////////////////////////

MainWindow::MainWindow(QWidget* parent/*=0*/, Qt::WindowFlags f/*=0*/)
MainWindow::MainWindow(EosPlatform *platform, QWidget* parent/*=0*/, Qt::WindowFlags f/*=0*/)
: QWidget(parent, f)
, m_Settings("ETC", "OSCRouter")
, m_LogDepth(200)
Expand All @@ -1499,6 +1501,7 @@ MainWindow::MainWindow(QWidget* parent/*=0*/, Qt::WindowFlags f/*=0*/)
, m_RouterThread(0)
, m_FileLineCount(0)
, m_ReconnectDelay(5000)
, m_pPlatform(platform)
{
#ifdef WIN32
QIcon icon;
Expand Down Expand Up @@ -1535,18 +1538,6 @@ MainWindow::MainWindow(QWidget* parent/*=0*/, Qt::WindowFlags f/*=0*/)
m_Settings.setValue(SETTING_DISABLE_SYSTEM_IDLE, static_cast<int>(m_DisableSystemIdle?1:0));

InitLogFile();

m_Platform = EosPlatform::Create();
if( m_Platform )
{
std::string error;
if( !m_Platform->Initialize(error) )
{
m_Log.AddError("platform initialization failed");
delete m_Platform;
m_Platform = 0;
}
}

QGridLayout *layout = new QGridLayout(this);

Expand Down Expand Up @@ -1614,12 +1605,6 @@ MainWindow::MainWindow(QWidget* parent/*=0*/, Qt::WindowFlags f/*=0*/)

MainWindow::~MainWindow()
{
if( m_Platform )
{
delete m_Platform;
m_Platform = 0;
}

Shutdown();
ShutdownLogFile();
}
Expand Down Expand Up @@ -1742,10 +1727,10 @@ void MainWindow::Shutdown()
delete m_RouterThread;
m_RouterThread = 0;

if(m_Platform && m_DisableSystemIdle)
if(m_pPlatform && m_DisableSystemIdle)
{
std::string error;
if( m_Platform->SetSystemIdleAllowed(true,"routing stopped",error) )
if( m_pPlatform->SetSystemIdleAllowed(true,"routing stopped",error) )
{
m_Log.AddInfo("routing stopped, system idle allowed");
}
Expand Down Expand Up @@ -1774,10 +1759,10 @@ bool MainWindow::BuildRoutes()

if( !routes.empty() )
{
if(m_Platform && m_DisableSystemIdle)
if(m_pPlatform && m_DisableSystemIdle)
{
std::string error;
if( m_Platform->SetSystemIdleAllowed(false,"routing started",error) )
if( m_pPlatform->SetSystemIdleAllowed(false,"routing started",error) )
{
m_Log.AddInfo("routing started, system idle disabled");
}
Expand Down Expand Up @@ -2074,8 +2059,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
QString path;
GetPersistentSavePath(path);
m_RoutingTable->SaveToFile(path);

QWidget::closeEvent(event);
QApplication::exit(0);
}

////////////////////////////////////////////////////////////////////////////////
4 changes: 2 additions & 2 deletions OSCRouter/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class MainWindow
Q_OBJECT

public:
MainWindow(QWidget *parent=0, Qt::WindowFlags f=0);
MainWindow(EosPlatform *platform, QWidget *parent=0, Qt::WindowFlags f=0);
virtual ~MainWindow();

virtual QSize sizeHint() const {return QSize(900,500);}
Expand All @@ -390,7 +390,7 @@ private slots:
ItemStateTable m_ItemStateTable;
QListWidget *m_LogWidget;
QSettings m_Settings;
EosPlatform *m_Platform;
EosPlatform *m_pPlatform;
int m_LogDepth;
int m_FileDepth;
int m_FileLineCount;
Expand Down
25 changes: 17 additions & 8 deletions OSCRouter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "EosTimer.h"
#include "QtInclude.h"
#include "MainWindow.h"
#include "EosPlatform.h"

// must be last include
#include "LeakWatcher.h"
Expand All @@ -40,15 +41,20 @@ int main(int argc, char* argv[])
#endif

EosTimer::Init();

EosPlatform *platform = EosPlatform::Create();
if( platform )
{
std::string error;
if( !platform->Initialize(error) )
{
printf("platform initialization failed\n");
delete platform;
platform = 0;
}
}

QApplication app(argc, argv);

#ifndef WIN32
QDir dir( app.applicationDirPath() );
dir.cdUp();
dir.cd("Plugins");
app.setLibraryPaths( QStringList(dir.canonicalPath()) );
#endif

app.setDesktopSettingsAware(false);
app.setStyle( QStyleFactory::create("Fusion") );
Expand All @@ -71,10 +77,13 @@ int main(int argc, char* argv[])
pal.setColor(QPalette::Disabled, QPalette::ButtonText, MUTED_COLOR);
app.setPalette(pal);

MainWindow *mainWindow = new MainWindow();
MainWindow *mainWindow = new MainWindow(platform);
mainWindow->show();
int result = app.exec();
delete mainWindow;

if(platform)
delete platform;

return result;
}
Expand Down

0 comments on commit 1f7eb77

Please sign in to comment.