From 39aa4ad2dff9cc05a44a664e25b9a12ee3bb2092 Mon Sep 17 00:00:00 2001 From: rti Date: Sun, 12 Dec 2010 19:10:58 +0100 Subject: [PATCH] Fixed: #1190 Run Georges Editor Qt on Mac OS X --- .../object_viewer_widget/src/CMakeLists.txt | 2 +- .../src/object_viewer_widget.h | 16 ++-- .../georges_editor_qt/src/CMakeLists.txt | 11 +++ .../georges_editor_qt/src/modules.cpp | 83 ++++++++++++------- .../src/objectviewer_dialog.h | 1 - 5 files changed, 76 insertions(+), 37 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt b/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt index 34797d45e..645c2f4cb 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt @@ -17,7 +17,7 @@ QT4_WRAP_CPP( OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR} ) SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) -ADD_LIBRARY(object_viewer_widget_qt SHARED +ADD_LIBRARY(object_viewer_widget_qt MODULE ${OBJECT_VIEWER_WIDGET_SRC} ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h index 4f8d68e58..8e3fb8be6 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h +++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h @@ -63,6 +63,8 @@ namespace NLQT CObjectViewerWidget(QWidget *parent = 0); virtual ~CObjectViewerWidget(); + virtual QPaintEngine* paintEngine() const { return NULL; } + void setNelContext(NLMISC::INelContext &nelContext); static CObjectViewerWidget &objViewWid() { return *_objectViewerWidget; } @@ -159,13 +161,13 @@ namespace NLQT virtual QString name() const {return ("ObjectViewerWidget");} - protected: -#if defined(NL_OS_WINDOWS) - virtual bool winEvent(MSG * message, long * result); -#elif defined(NL_OS_MAC) - virtual bool macEvent(EventHandlerCallRef caller, EventRef event); -#elif defined(NL_OS_UNIX) - virtual bool x11Event(XEvent *event); + protected: +#if defined(NL_OS_WINDOWS) + virtual bool winEvent(MSG * message, long * result); +#elif defined(NL_OS_MAC) + virtual bool macEvent(EventHandlerCallRef caller, EventRef event); +#elif defined(NL_OS_UNIX) + virtual bool x11Event(XEvent *event); #endif private Q_SLOTS: diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt index a6fb0b3da..f24f2570b 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt @@ -24,6 +24,17 @@ SOURCE_GROUP(QtResources FILES ${GEORGES_EDITOR_UIS} ${GEORGES_EDITOR_RCS}) SOURCE_GROUP(QtGeneratedUiHdr FILES ${GEORGES_EDITOR_UI_HDRS}) SOURCE_GROUP(QtGeneratedMocSrc FILES ${GEORGES_EDITOR_MOC_SRCS}) +if(APPLE) + SET(MACOSX_BUNDLE_INFO_STRING "Georges Editor Qt") + SET(MACOSX_BUNDLE_ICON_FILE "georges_logo.icns") + SET(MACOSX_BUNDLE_GUI_IDENTIFIER "") + SET(MACOSX_BUNDLE_LONG_VERSION_STRING ${NL_VERSION}) + SET(MACOSX_BUNDLE_BUNDLE_NAME "Georges Editor Qt") + SET(MACOSX_BUNDLE_SHORT_VERSION_STRING "0.9") + SET(MACOSX_BUNDLE_BUNDLE_VERSION "0.9") + SET(MACOSX_BUNDLE_COPYRIGHT "Winchgate and The Ryzom Core Community") +ENDIF(APPLE) + ADD_EXECUTABLE(georges_editor_qt WIN32 MACOSX_BUNDLE ${GEORGES_EDITOR_SRC} ${GEORGES_EDITOR_MOC_SRCS} ${GEORGES_EDITOR_RC_SRCS} ${GEORGES_EDITOR_UI_HDRS}) TARGET_LINK_LIBRARIES(georges_editor_qt diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp index 90c7c4a53..aa651becd 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.cpp @@ -1,5 +1,5 @@ /* -Georges Editor Qt +Georges Editor Qt Copyright (C) 2010 Adrian Jaekel This program is free software: you can redistribute it and/or modify @@ -23,6 +23,8 @@ along with this program. If not, see . #include #include +#include + NLQT::CConfiguration *Modules::_configuration = NULL; NLQT::IObjectViewer *Modules::_objViewerInterface = NULL; NLQT::CMainWindow *Modules::_mainWindow = NULL; @@ -47,30 +49,55 @@ void Modules::release() delete _configuration; _configuration = NULL; } -bool Modules::loadPlugin() -{ - QDir pluginsDir(qApp->applicationDirPath()); - /*#if defined(Q_OS_WIN) - if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") - pluginsDir.cdUp(); - #elif defined(Q_OS_MAC) - if (pluginsDir.dirName() == "MacOS") { - pluginsDir.cdUp(); - pluginsDir.cdUp(); - pluginsDir.cdUp(); - } - #endif*/ - //pluginsDir.cd("plugins"); - //Q_FOREACH (QString fileName, pluginsDir.entryList(QDir::Files)) { - QPluginLoader pluginLoader(pluginsDir.absoluteFilePath("object_viewer_widget_qt.dll")); - QObject *plugin = pluginLoader.instance(); - if (plugin) - { - _objViewerInterface = qobject_cast(plugin); - if (_objViewerInterface) - return true; - } - //} - - return false; -} \ No newline at end of file +bool Modules::loadPlugin() +{ +#if defined(Q_OS_WIN) + QString pluginPath = qApp->applicationDirPath(); + QString pluginFilename = "object_viewer_widget_qt.dll"; +#elif defined(Q_OS_MAC) + QString pluginPath = qApp->applicationDirPath() + "/../PlugIns/"; + QString pluginFilename = "libobject_viewer_widget_qt.so"; +#else // LINUX + QString pluginPath = qApp->applicationDirPath(); + QString pluginFilename = "libobject_viewer_widget_qt.so"; +#endif + + // if(!QFile::exists(pluginPath + pluginFilename)) + // { + // nlwarning("Cannot find %s in %s, fallback to working dir", + // pluginFilename.toStdString().c_str(), pluginPath.toStdString().c_str()); + // + // pluginPath = ""; + // + // Q_FOREACH (QString path, qApp->libraryPaths()) + // nlwarning("libraryPaths %s", path.toStdString().c_str()); + // } + + QDir pluginsDir(pluginPath); + QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(pluginFilename)); + + QObject *plugin = pluginLoader.instance(); + if (plugin) + { + _objViewerInterface = qobject_cast(plugin); + if (_objViewerInterface) + { + nlinfo("Loaded %s", + pluginsDir.absoluteFilePath(pluginFilename).toStdString().c_str()); + return true; + } + else + { + nlwarning("Loaded %s, but cannot cast to NLQT::IObjectViewer*", + pluginFilename.toStdString().c_str()); + } + } + else + { + nlwarning("Cannot get plugin instance for %s (searched in %s)", + pluginFilename.toStdString().c_str(), + (qApp->applicationDirPath() + pluginPath).toStdString().c_str()); + } + + return false; +} diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h index dadee1d8a..f890eaca2 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h @@ -59,7 +59,6 @@ namespace NLQT ~CObjectViewerDialog(); virtual void setVisible(bool visible); - virtual QPaintEngine* paintEngine() const { return NULL; } QAction *createSaveScreenshotAction(QObject *parent); QAction *createSetBackgroundColor(QObject *parent);