Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djg/9eb6edec00999a05da072e0f28f927b6 to your computer and use it in GitHub Desktop.
Save djg/9eb6edec00999a05da072e0f28f927b6 to your computer and use it in GitHub Desktop.
OpenSCAD: Fix compilation on OSX with cmake
From 518dd61cfbdcaa4c8815f15ae484552125134d4b Mon Sep 17 00:00:00 2001
From: Dan Glastonbury <dglastonbury@mozilla.com>
Date: Thu, 18 May 2017 10:14:47 +1000
Subject: [PATCH] Fix compilation on osx with cmake.
---
CMakeLists.txt | 7 ++++++-
cmake/Modules/FindQt5QScintilla.cmake | 2 +-
src/AboutDialog.cc | 9 +++++++++
src/AboutDialog.h | 8 +-------
src/EventFilter.cc | 27 +++++++++++++++++++++++++++
src/EventFilter.h | 23 ++---------------------
src/{mainwin.cc => MainWindow.cc} | 0
7 files changed, 46 insertions(+), 30 deletions(-)
create mode 100644 src/AboutDialog.cc
create mode 100644 src/EventFilter.cc
rename src/{mainwin.cc => MainWindow.cc} (100%)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 018012e..9da4376 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -152,7 +152,7 @@ endif()
#
if(APPLE)
message(STATUS "Offscreen OpenGL Context - using Apple CGL")
- set(PLATFORM_SOURCES src/PlatformUtils-mac.mm src/OffscreenContextCGL.mm src/imageutils-macosx.cc src/CocoaUtils.mm src/AppleEvents.cc src/EventFilter.cc)
+ set(PLATFORM_SOURCES src/PlatformUtils-mac.mm src/OffscreenContextCGL.mm src/imageutils-macosx.cc src/CocoaUtils.mm src/AppleEvents.cc)
find_library(COCOA_LIBRARY Cocoa)
set(PLATFORM_LIBS ${COCOA_LIBRARY})
elseif(UNIX)
@@ -325,6 +325,7 @@ set(GUI_SOURCES
src/ProgressWidget.cc
src/AutoUpdater.cc
src/QGLView.cc
+ src/QSettingsCached.cc
src/Dock.cc
src/UIUtils.cc
src/scadlexer.cpp
@@ -350,6 +351,10 @@ set(GUI_SOURCES
src/parameter/parametervirtualwidget.cpp
)
+if(APPLE)
+ LIST(APPEND GUI_SOURCES src/EventFilter.cc)
+endif()
+
if(NULLGL)
message(STATUS "NULLGL is set. Overriding previous OpenGL(TM) settings")
set(OFFSCREEN_SOURCES
diff --git a/cmake/Modules/FindQt5QScintilla.cmake b/cmake/Modules/FindQt5QScintilla.cmake
index 986deb4..16eb644 100644
--- a/cmake/Modules/FindQt5QScintilla.cmake
+++ b/cmake/Modules/FindQt5QScintilla.cmake
@@ -80,7 +80,7 @@ endif ()
find_library ( QT5QSCINTILLA_LIBRARY
- NAMES qt5scintilla2 qscintilla2-qt5 qscintilla2
+ NAMES qt5scintilla2 qscintilla2-qt5 qscintilla2 qscintilla2_qt5
HINTS ${Qt5Widgets_LIBRARIES}
)
diff --git a/src/AboutDialog.cc b/src/AboutDialog.cc
new file mode 100644
index 0000000..076fc74
--- /dev/null
+++ b/src/AboutDialog.cc
@@ -0,0 +1,9 @@
+#include "AboutDialog.h"
+
+AboutDialog::AboutDialog(QWidget *) {
+ setupUi(this);
+ this->setWindowTitle( QString(_("About OpenSCAD")) + " " + openscad_shortversionnumber.c_str());
+ QString tmp = this->aboutText->toHtml();
+ tmp.replace("__VERSION__", openscad_detailedversionnumber.c_str());
+ this->aboutText->setHtml(tmp);
+}
diff --git a/src/AboutDialog.h b/src/AboutDialog.h
index 6c718a3..430b1f2 100644
--- a/src/AboutDialog.h
+++ b/src/AboutDialog.h
@@ -8,13 +8,7 @@ class AboutDialog : public QDialog, public Ui::AboutDialog
{
Q_OBJECT;
public:
- AboutDialog(QWidget *) {
- setupUi(this);
- this->setWindowTitle( QString(_("About OpenSCAD")) + " " + openscad_shortversionnumber.c_str());
- QString tmp = this->aboutText->toHtml();
- tmp.replace("__VERSION__", openscad_detailedversionnumber.c_str());
- this->aboutText->setHtml(tmp);
- }
+ AboutDialog(QWidget *);
public slots:
void on_okPushButton_clicked() { accept(); }
diff --git a/src/EventFilter.cc b/src/EventFilter.cc
new file mode 100644
index 0000000..455a4a0
--- /dev/null
+++ b/src/EventFilter.cc
@@ -0,0 +1,27 @@
+#include "EventFilter.h"
+
+EventFilter::EventFilter(QObject *parent)
+ : QObject(parent)
+{}
+
+bool EventFilter::eventFilter(QObject *obj, QEvent *event) {
+ // Handle Apple event for opening files, only available on OS X
+ if (event->type() == QEvent::FileOpen) {
+ QFileOpenEvent *foe = static_cast<QFileOpenEvent *>(event);
+ const QString &filename = foe->file();
+ if (LaunchingScreen *ls = LaunchingScreen::getDialog()) {
+ // We need to invoke the method since, apparently, we receive
+ // this event in another thread.
+ QMetaObject::invokeMethod(ls, "openFile", Qt::QueuedConnection,
+ Q_ARG(QString, filename));
+ }
+ else {
+ scadApp->requestOpenFile(filename);
+ }
+ return true;
+ } else {
+ // standard event processing
+ return QObject::eventFilter(obj, event);
+ }
+}
+
diff --git a/src/EventFilter.h b/src/EventFilter.h
index 379e152..2098c71 100644
--- a/src/EventFilter.h
+++ b/src/EventFilter.h
@@ -10,26 +10,7 @@ class EventFilter : public QObject
Q_OBJECT;
public:
- EventFilter(QObject *parent) : QObject(parent) {}
+ EventFilter(QObject *parent);
protected:
- bool eventFilter(QObject *obj, QEvent *event) {
- // Handle Apple event for opening files, only available on OS X
- if (event->type() == QEvent::FileOpen) {
- QFileOpenEvent *foe = static_cast<QFileOpenEvent *>(event);
- const QString &filename = foe->file();
- if (LaunchingScreen *ls = LaunchingScreen::getDialog()) {
- // We need to invoke the method since, apparently, we receive
- // this event in another thread.
- QMetaObject::invokeMethod(ls, "openFile", Qt::QueuedConnection,
- Q_ARG(QString, filename));
- }
- else {
- scadApp->requestOpenFile(filename);
- }
- return true;
- } else {
- // standard event processing
- return QObject::eventFilter(obj, event);
- }
- }
+ bool eventFilter(QObject *obj, QEvent *event);
};
diff --git a/src/mainwin.cc b/src/MainWindow.cc
similarity index 100%
rename from src/mainwin.cc
rename to src/MainWindow.cc
--
2.10.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment