diff --git a/CMakeLists.txt b/CMakeLists.txt index d36898400..f6014dff6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -689,7 +689,10 @@ if (APPLE) set(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO}) set(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE}) - set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") + set(OPENMW_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") + + set(OPENCS_APP "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/OpenCS.app") + set(PLUGINS "") set(ABSOLUTE_PLUGINS "") @@ -750,7 +753,8 @@ if (APPLE) cmake_policy(SET CMP0009 OLD) set(BU_CHMOD_BUNDLE_ITEMS ON) include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") + fixup_bundle(\"${OPENMW_APP}\" \"${PLUGINS}\" \"${DIRS}\") + fixup_bundle(\"${OPENCS_APP}\" \"\" \"${DIRS}\") " COMPONENT Runtime) include(CPack) endif (APPLE) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 5df2d364c..8abdf0019 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -4,10 +4,12 @@ #include #include -#ifdef __APPLE__ +#ifdef MAC_OS_X_VERSION_MIN_REQUIRED +#undef MAC_OS_X_VERSION_MIN_REQUIRED // We need to do this because of Qt: https://bugreports.qt-project.org/browse/QTBUG-22154 #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -#endif +#endif // MAC_OS_X_VERSION_MIN_REQUIRED + #include #include diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index eb8ad8507..156bbf65b 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -3,10 +3,12 @@ #include #include -#ifdef __APPLE__ +#ifdef MAC_OS_X_VERSION_MIN_REQUIRED +#undef MAC_OS_X_VERSION_MIN_REQUIRED // We need to do this because of Qt: https://bugreports.qt-project.org/browse/QTBUG-22154 #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -#endif +#endif // MAC_OS_X_VERSION_MIN_REQUIRED + #include #include "maindialog.hpp" diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index ec1ecb65e..1197e2014 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -152,13 +152,36 @@ qt4_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +if(APPLE) + set (OPENCS_MAC_ICON ${CMAKE_SOURCE_DIR}/files/mac/opencs.icns) +else() + set (OPENCS_MAC_ICON "") +endif(APPLE) + add_executable(opencs + MACOSX_BUNDLE ${OPENCS_SRC} ${OPENCS_UI_HDR} ${OPENCS_MOC_SRC} ${OPENCS_RES_SRC} + ${OPENCS_MAC_ICON} ) +if(APPLE) + set_target_properties(opencs PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}" + OUTPUT_NAME "OpenCS" + MACOSX_BUNDLE_ICON_FILE "opencs.icns" + MACOSX_BUNDLE_BUNDLE_NAME "OpenCS" + MACOSX_BUNDLE_GUI_IDENTIFIER "org.openmw.opencs" + MACOSX_BUNDLE_SHORT_VERSION_STRING ${OPENMW_VERSION} + MACOSX_BUNDLE_BUNDLE_VERSION ${OPENMW_VERSION} + ) + + set_source_files_properties(${OPENCS_MAC_ICON} PROPERTIES + MACOSX_PACKAGE_LOCATION Resources) +endif(APPLE) + target_link_libraries(opencs ${Boost_LIBRARIES} ${QT_LIBRARIES} @@ -169,3 +192,6 @@ if(DPKG_PROGRAM) INSTALL(TARGETS opencs RUNTIME DESTINATION games COMPONENT opencs) endif() +if(APPLE) + INSTALL(TARGETS opencs BUNDLE DESTINATION OpenMW COMPONENT BUNDLE) +endif() diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 449dd229e..341bdc780 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -9,6 +9,10 @@ #include +#ifdef Q_OS_MAC +#include +#endif + class Application : public QApplication { private: @@ -43,6 +47,25 @@ int main(int argc, char *argv[]) Application mApplication (argc, argv); +#ifdef Q_OS_MAC + QDir dir(QCoreApplication::applicationDirPath()); + if (dir.dirName() == "MacOS") { + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); + } + QDir::setCurrent(dir.absolutePath()); + + // force Qt to load only LOCAL plugins, don't touch system Qt installation + QDir pluginsPath(QCoreApplication::applicationDirPath()); + pluginsPath.cdUp(); + pluginsPath.cd("Plugins"); + + QStringList libraryPaths; + libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath(); + mApplication.setLibraryPaths(libraryPaths); +#endif + mApplication.setWindowIcon (QIcon (":./opencs.png")); CS::Editor editor; diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 590a19439..27f4f498a 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2245,29 +2245,39 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, co mData.setDescription (""); mData.setAuthor (""); } -/// \todo un-outcomment the else, once loading an existing content file works properly again. + + bool filtersFound = false; + + if (boost::filesystem::exists (mProjectPath)) + { + filtersFound = true; + } else { - if (boost::filesystem::exists (mProjectPath)) + boost::filesystem::path locCustomFiltersPath (configuration.getUserPath()); + locCustomFiltersPath /= "defaultfilters"; + + if (boost::filesystem::exists(locCustomFiltersPath)) { - getData().loadFile (mProjectPath, false, true); + boost::filesystem::copy_file (locCustomFiltersPath, mProjectPath); + filtersFound = true; } else { - boost::filesystem::path locCustomFiltersPath (configuration.getUserPath()); - locCustomFiltersPath /= "defaultfilters"; - if (boost::filesystem::exists(locCustomFiltersPath)) + boost::filesystem::path filters(mResDir); + filters /= "defaultfilters"; + + if (boost::filesystem::exists(filters)) { - boost::filesystem::copy_file (locCustomFiltersPath, mProjectPath); - } else { - boost::filesystem::path filters(mResDir); - filters /= "defaultfilters"; boost::filesystem::copy_file(filters, mProjectPath); + filtersFound = true; } - getData().loadFile (mProjectPath, false, true); } } + if (filtersFound) + getData().loadFile (mProjectPath, false, true); + addOptionalGmsts(); addOptionalGlobals(); diff --git a/files/mac/opencs.icns b/files/mac/opencs.icns new file mode 100644 index 000000000..98812f871 Binary files /dev/null and b/files/mac/opencs.icns differ