From 3cbafa64562cbe0e68aa23db1629a9cb83455c1b Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 2 Feb 2016 13:20:05 +0100 Subject: [PATCH] logic: file associations for Mac and opening project files via Mac OS * hide start screen when opening with project file * added project icon file to bundle and file type association to plist * listen for file open events from double click or drag and drop * fixed crashes in window handling --- bin/app/data/gui/icon/project_256_256.png | Bin 0 -> 6833 bytes setup/MacOSX/Info.plist.in | 15 ++++++++ setup/MacOSX/bundle_install.sh.in | 28 ++++++++++++--- src/app/LicenseChecker.h | 33 ++++++++++++++++-- src/app/main.cpp | 23 ++++++------ src/lib/Application.cpp | 12 +++++-- src/lib/Application.h | 2 ++ src/lib/CMakeLists.txt | 1 + .../messaging/type/MessageEnteredLicense.h | 21 +++++++++++ src/lib_gui/CMakeLists.txt | 3 ++ src/lib_gui/qt/QtApplication.cpp | 30 ++++++++++++++++ src/lib_gui/qt/QtApplication.h | 15 ++++++++ src/lib_gui/qt/view/QtMainView.cpp | 10 ++++-- src/lib_gui/qt/view/QtMainView.h | 2 ++ src/lib_gui/qt/window/QtLicense.cpp | 5 ++- src/lib_gui/qt/window/QtMainWindow.cpp | 8 ++--- src/lib_gui/qt/window/QtMainWindow.h | 1 + src/trial/main.cpp | 14 +++----- 18 files changed, 183 insertions(+), 40 deletions(-) create mode 100644 bin/app/data/gui/icon/project_256_256.png create mode 100644 src/lib/utility/messaging/type/MessageEnteredLicense.h create mode 100644 src/lib_gui/qt/QtApplication.cpp create mode 100644 src/lib_gui/qt/QtApplication.h diff --git a/bin/app/data/gui/icon/project_256_256.png b/bin/app/data/gui/icon/project_256_256.png new file mode 100644 index 0000000000000000000000000000000000000000..d67260017ef17075e34eb28442e06eba708767c4 GIT binary patch literal 6833 zcmai3cQ}>d-@l*Z92_ew5qC-p}{`?$7uBKG*#`&$Tsg&{CbD0szpetEuV$0Fjmupd=>| z6SqQJ5@GkaX5gXgYU|;B-^~UnS-V==pwyl3+u7*Y+_(05)MXwP0m$n1Drm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4>yY7cJo8EiSlzIBa3V-j)?_Z*<)*B_)`^EQM1FkWRadN0ypdkZA zYPMf8hr$gDS(S{{)8W&}OAnpcrnU`XAeR39WHnFM1K1iu{EhGe1XRVhRahXu>vps* za-I>?<_)xIuOayUxv3Ci*si1mbPaR@Z2V8Ys^G~g)i06HQ%zwA5%M!(8gvQoQQj{!?3tI;-5h!Am>GFpqkJ^tjjcZ9QPnx{Quhj9 zS%1WF==egzLWjS&CQVP&;gz9T%KEFU@>o&P&p7?atb6GQRSwb*h(-Cl9FxCLq>_+V z?iU|{zv8)+lMksSl<;JN!p^V0n+Um#P_~!}n3oTCg2uNUmqV;0JrXoLA5KbOn6Yj} zX*`9AF+7I!Sn4Wt#Y0vC3#{QfTZh!g7v(I6W~_(f?`r!%^^5sCN44;9M2Y;~TtPjX7f2>k5&XK0^4c4rTPeW2r z4ZZxOJ8Z`?;9d_HqL`tLV~0~e?K#FTXh4~lYV_+Y3Wzjq4>Ukh7eDgYMHV{(0>6K C#ysi( literal 0 HcmV?d00001 diff --git a/setup/MacOSX/Info.plist.in b/setup/MacOSX/Info.plist.in index b9a19f4f..e38dbb53 100644 --- a/setup/MacOSX/Info.plist.in +++ b/setup/MacOSX/Info.plist.in @@ -40,5 +40,20 @@ icon LSMinimumSystemVersion 10.9 + CFBundleDocumentTypes + + + CFBundleTypeRole + Editor + CFBundleTypeName + Coati Project + CFBundleTypeExtensions + + coatiproject + + CFBundleTypeIconFile + project + + diff --git a/setup/MacOSX/bundle_install.sh.in b/setup/MacOSX/bundle_install.sh.in index 2e2ab74f..d5d8c953 100755 --- a/setup/MacOSX/bundle_install.sh.in +++ b/setup/MacOSX/bundle_install.sh.in @@ -102,9 +102,9 @@ do echo "lib" $LIB_PATH $LIB_NAME done -echo -e $INFO "Fixing lib dependencies" -install_name_tool -change libboost_system.dylib @executable_path/../lib/libboost_system.dylib $DYNLIB_DIR/libboost_filesystem.dylib -otool -L $DYNLIB_DIR/libboost_filesystem.dylib +# echo -e $INFO "Fixing lib dependencies" +# install_name_tool -change libboost_system.dylib @executable_path/../lib/libboost_system.dylib $DYNLIB_DIR/libboost_filesystem.dylib +# otool -L $DYNLIB_DIR/libboost_filesystem.dylib echo -e $INFO "Copying Plugins" @@ -160,7 +160,7 @@ echo -e $INFO "App dependencies" otool -L $APP_PATH echo -e $INFO "Create icon" -ICON=../data/gui/installer/logo_1024_1024.png +ICON=../data/gui/icon/logo_1024_1024.png ICON_SET=$RES_DIR/icon.iconset mkdir -p $ICON_SET @@ -177,6 +177,26 @@ convert $ICON -resize 1024x1024 $ICON_SET/icon_512x512@2x.png iconutil -c icns -o $RES_DIR/icon.icns $ICON_SET +echo -e $INFO "Create project icon" +ICON=../data/gui/icon/project_256_256.png +ICON_SET=$RES_DIR/project.iconset + +mkdir -p $ICON_SET +convert $ICON -resize 16x16 $ICON_SET/icon_16x16.png +convert $ICON -resize 32x32 $ICON_SET/icon_16x16@2x.png +convert $ICON -resize 32x32 $ICON_SET/icon_32x32.png +convert $ICON -resize 64x64 $ICON_SET/icon_32x32@2x.png +convert $ICON -resize 64x64 $ICON_SET/icon_64x64.png +convert $ICON -resize 128x128 $ICON_SET/icon_64x64@2x.png +convert $ICON -resize 128x128 $ICON_SET/icon_128x128.png +convert $ICON -resize 256x256 $ICON_SET/icon_128x128@2x.png +convert $ICON -resize 256x256 $ICON_SET/icon_256x256.png +convert $ICON -resize 512x512 $ICON_SET/icon_256x256@2x.png +convert $ICON -resize 512x512 $ICON_SET/icon_512x512.png +convert $ICON -resize 1024x1024 $ICON_SET/icon_512x512@2x.png + +iconutil -c icns -o $RES_DIR/project.icns $ICON_SET + echo -e $INFO "Obfuscate binary" # upx -1 $APP_PATH upx --best $APP_PATH diff --git a/src/app/LicenseChecker.h b/src/app/LicenseChecker.h index 551b18fc..7a1b8c49 100644 --- a/src/app/LicenseChecker.h +++ b/src/app/LicenseChecker.h @@ -2,6 +2,7 @@ #define LICENSE_CHECKER_H #include "utility/messaging/MessageListener.h" +#include "utility/messaging/type/MessageEnteredLicense.h" #include "utility/messaging/type/MessageLoadProject.h" #include "utility/messaging/type/MessageStatus.h" @@ -12,25 +13,49 @@ #include "utility/AppPath.h" class LicenseChecker - : public MessageListener + : public MessageListener + , public MessageListener { public: + LicenseChecker() + : m_forcedLicenseEntering(false) + { + } + inline void setApp(Application* app) { m_app = app; - if (!checkLicenseString()) + if (!m_forcedLicenseEntering && !checkLicenseString()) { m_app->showLicenseScreen(); + m_forcedLicenseEntering = true; } } private: + void handleMessage(MessageEnteredLicense* message) + { + m_forcedLicenseEntering = false; + + if (m_resendMessage) + { + m_resendMessage->dispatch(); + m_resendMessage.reset(); + } + } + void handleMessage(MessageLoadProject* message) { if (!checkLicenseString()) { + m_resendMessage = std::make_shared(*message); message->cancel(); - m_app->showLicenseScreen(); + + if (!m_forcedLicenseEntering) + { + m_app->showLicenseScreen(); + m_forcedLicenseEntering = true; + } } } @@ -77,6 +102,8 @@ private: } Application* m_app; + std::shared_ptr m_resendMessage; + bool m_forcedLicenseEntering; }; #endif // LICENSE_CHECKER_H diff --git a/src/app/main.cpp b/src/app/main.cpp index 91f8588c..a14a086f 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -1,25 +1,22 @@ -#include - -#include - +#include "utility/AppPath.h" #include "utility/logging/ConsoleLogger.h" #include "utility/logging/FileLogger.h" #include "utility/logging/LogManager.h" +#include "utility/ResourcePaths.h" #include "utility/Version.h" #include "Application.h" #include "includes.h" // defines 'void setup(int argc, char *argv[])' #include "LicenseChecker.h" #include "qt/commandline/QtCommandLineParser.h" -#include "qt/window/QtMainWindow.h" -#include "qt/window/QtSplashScreen.h" #include "qt/network/QtNetworkFactory.h" +#include "qt/QtApplication.h" #include "qt/utility/utilityQt.h" #include "qt/view/QtViewFactory.h" +#include "qt/window/QtMainWindow.h" +#include "qt/window/QtSplashScreen.h" #include "version.h" -#include "utility/AppPath.h" -#include "utility/ResourcePaths.h" void init() { @@ -40,14 +37,10 @@ int main(int argc, char *argv[]) Version version = Version::fromString(GIT_VERSION_NUMBER); setup(argc, argv); - QApplication qtApp(argc, argv); + QtApplication qtApp(argc, argv); QApplication::setApplicationName("Coati"); QApplication::setApplicationVersion(version.toDisplayString().c_str()); - QtCommandLineParser commandLineParser; - commandLineParser.setup(); - commandLineParser.process(qtApp); - qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps); QPixmap whitePixmap(500, 500); @@ -60,6 +53,10 @@ int main(int argc, char *argv[]) init(); + QtCommandLineParser commandLineParser; + commandLineParser.setup(); + commandLineParser.process(qtApp); + QtViewFactory viewFactory; QtNetworkFactory networkFactory; diff --git a/src/lib/Application.cpp b/src/lib/Application.cpp index 833bf2ab..2b1b8d71 100644 --- a/src/lib/Application.cpp +++ b/src/lib/Application.cpp @@ -46,6 +46,8 @@ std::shared_ptr Application::create( ptr->m_ideCommunicationController = networkFactory->createIDECommunicationController(ptr->m_storageCache.get()); + ptr->startMessagingAndScheduling(); + return ptr; } @@ -59,9 +61,6 @@ void Application::loadSettings() Application::Application() { - TaskScheduler::getInstance()->startSchedulerLoopThreaded(); - MessageQueue::getInstance()->setSendMessagesAsTasks(true); - MessageQueue::getInstance()->startMessageLoopThreaded(); } Application::~Application() @@ -161,6 +160,13 @@ void Application::handleMessage(MessageSaveProject* message) saveProject(message->projectSettingsFilePath); } +void Application::startMessagingAndScheduling() +{ + TaskScheduler::getInstance()->startSchedulerLoopThreaded(); + MessageQueue::getInstance()->setSendMessagesAsTasks(true); + MessageQueue::getInstance()->startMessageLoopThreaded(); +} + void Application::updateRecentProjects(const FilePath& projectSettingsFilePath) { ApplicationSettings* appSettings = ApplicationSettings::getInstance().get(); diff --git a/src/lib/Application.h b/src/lib/Application.h index 8235d8d3..dc572c5f 100644 --- a/src/lib/Application.h +++ b/src/lib/Application.h @@ -48,6 +48,8 @@ private: virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageSaveProject* message); + void startMessagingAndScheduling(); + void updateRecentProjects(const FilePath& projectSettingsFilePath); std::shared_ptr m_project; diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2fe989d0..6106f6a8 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -223,6 +223,7 @@ add_files( utility/messaging/type/MessageChangeFileView.h utility/messaging/type/MessageClearErrorCount.h utility/messaging/type/MessageDeactivateEdge.h + utility/messaging/type/MessageEnteredLicense.h utility/messaging/type/MessageFind.h utility/messaging/type/MessageFinishedParsing.h utility/messaging/type/MessageFlushUpdates.h diff --git a/src/lib/utility/messaging/type/MessageEnteredLicense.h b/src/lib/utility/messaging/type/MessageEnteredLicense.h new file mode 100644 index 00000000..6e538d39 --- /dev/null +++ b/src/lib/utility/messaging/type/MessageEnteredLicense.h @@ -0,0 +1,21 @@ +#ifndef MESSAGE_ENTERED_LICENSE_H +#define MESSAGE_ENTERED_LICENSE_H + +#include "utility/messaging/Message.h" + +class MessageEnteredLicense + : public Message +{ +public: + MessageEnteredLicense() + { + setSendAsTask(false); + } + + static const std::string getStaticType() + { + return "MessageEnteredLicense"; + } +}; + +#endif // MESSAGE_ENTERED_LICENSE_H diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index 8acd35ef..d3f52204 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -119,4 +119,7 @@ add_files( qt/window/QtSplashScreen.h qt/window/QtStartScreen.cpp qt/window/QtStartScreen.h + + qt/QtApplication.cpp + qt/QtApplication.h ) diff --git a/src/lib_gui/qt/QtApplication.cpp b/src/lib_gui/qt/QtApplication.cpp new file mode 100644 index 00000000..821117cd --- /dev/null +++ b/src/lib_gui/qt/QtApplication.cpp @@ -0,0 +1,30 @@ +#include "qt/QtApplication.h" + +#include + +#include "utility/file/FilePath.h" +#include "utility/messaging/type/MessageLoadProject.h" + +QtApplication::QtApplication(int& argc, char** argv) + : QApplication(argc, argv) +{ +} + +// responds to FileOpenEvent specific for Mac +bool QtApplication::event(QEvent *event) +{ + if (event->type() == QEvent::FileOpen) + { + QFileOpenEvent* fileEvent = dynamic_cast(event); + + FilePath path(fileEvent->file().toStdString()); + + if (path.exists() && path.extension() == ".coatiproject") + { + MessageLoadProject(path.str(), false).dispatch(); + return true; + } + } + + return QApplication::event(event); +} diff --git a/src/lib_gui/qt/QtApplication.h b/src/lib_gui/qt/QtApplication.h new file mode 100644 index 00000000..b0c53123 --- /dev/null +++ b/src/lib_gui/qt/QtApplication.h @@ -0,0 +1,15 @@ +#ifndef QT_APPLICATION_H +#define QT_APPLICATION_H + +#include + +class QtApplication + : public QApplication +{ +public: + QtApplication(int& argc, char** argv); + + bool event(QEvent *event); +}; + +#endif // QT_APPLICATION_H diff --git a/src/lib_gui/qt/view/QtMainView.cpp b/src/lib_gui/qt/view/QtMainView.cpp index ca20595f..7105922e 100644 --- a/src/lib_gui/qt/view/QtMainView.cpp +++ b/src/lib_gui/qt/view/QtMainView.cpp @@ -5,7 +5,8 @@ #include "qt/window/QtMainWindow.h" QtMainView::QtMainView() - : m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1)) + : m_hideStartScreenFunctor(std::bind(&QtMainView::doHideStartScreen, this)) + , m_setTitleFunctor(std::bind(&QtMainView::doSetTitle, this, std::placeholders::_1)) , m_activateWindowFunctor(std::bind(&QtMainView::doActivateWindow, this)) , m_updateRecentProjectMenuFunctor(std::bind(&QtMainView::doUpdateRecentProjectMenu, this)) , m_showLicenseScreenFunctor(std::bind(&QtMainView::doShowLicenseScreen, this)) @@ -69,7 +70,7 @@ void QtMainView::setStatusBar(QStatusBar* statusbar) void QtMainView::hideStartScreen() { - m_window->clearWindows(); + m_hideStartScreenFunctor(); } void QtMainView::setTitle(const std::string& title) @@ -97,6 +98,11 @@ void QtMainView::doUpdateRecentProjectMenu() m_window->updateRecentProjectMenu(); } +void QtMainView::doHideStartScreen() +{ + m_window->clearWindows(); +} + void QtMainView::doSetTitle(const std::string& title) { m_window->setWindowTitle(QString::fromStdString(title)); diff --git a/src/lib_gui/qt/view/QtMainView.h b/src/lib_gui/qt/view/QtMainView.h index 1549e025..9864c24c 100644 --- a/src/lib_gui/qt/view/QtMainView.h +++ b/src/lib_gui/qt/view/QtMainView.h @@ -40,6 +40,7 @@ public: virtual void showLicenseScreen(); private: + void doHideStartScreen(); void doSetTitle(const std::string& title); void doActivateWindow(); void doUpdateRecentProjectMenu(); @@ -48,6 +49,7 @@ private: std::shared_ptr m_window; std::vector m_views; + QtThreadedFunctor<> m_hideStartScreenFunctor; QtThreadedFunctor m_setTitleFunctor; QtThreadedFunctor<> m_activateWindowFunctor; QtThreadedFunctor<> m_updateRecentProjectMenuFunctor; diff --git a/src/lib_gui/qt/window/QtLicense.cpp b/src/lib_gui/qt/window/QtLicense.cpp index 467d4ae9..9457f11c 100644 --- a/src/lib_gui/qt/window/QtLicense.cpp +++ b/src/lib_gui/qt/window/QtLicense.cpp @@ -12,8 +12,9 @@ #include "PublicKey.h" #include "qt/utility/utilityQt.h" #include "settings/ApplicationSettings.h" -#include "utility/file/FilePath.h" #include "utility/AppPath.h" +#include "utility/file/FilePath.h" +#include "utility/messaging/type/MessageEnteredLicense.h" #include "utility/ResourcePaths.h" QtLicense::QtLicense(QWidget *parent) @@ -152,6 +153,8 @@ void QtLicense::handleUpdateButtonPress() FilePath p(appLocation); appSettings->setLicenseCheck(license.hashLocation(p.absolute().str())); appSettings->save(); + + MessageEnteredLicense().dispatch(); } else { diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index cc7b1b38..87b753af 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -62,8 +62,6 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event) { QMouseEvent* mouseEvent = dynamic_cast(event); - - if (mouseEvent->button() == m_backButton) { MessageUndo().dispatch(); @@ -82,7 +80,6 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event) MouseWheelFilter::MouseWheelFilter(QObject* parent) : QObject(parent) { - } bool MouseWheelFilter::eventFilter(QObject* obj, QEvent* event) @@ -106,6 +103,7 @@ bool MouseWheelFilter::eventFilter(QObject* obj, QEvent* event) return QObject::eventFilter(obj, event); } + QtMainWindow::QtMainWindow() : m_showDockWidgetTitleBars(true) { @@ -300,9 +298,9 @@ void QtMainWindow::popWindow() void QtMainWindow::clearWindows() { - if (m_windowStack.size()) + for (QWidget* window : m_windowStack) { - m_windowStack.back()->hide(); + window->hide(); } m_windowStack.clear(); diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h index 869af972..e93042b3 100644 --- a/src/lib_gui/qt/window/QtMainWindow.h +++ b/src/lib_gui/qt/window/QtMainWindow.h @@ -63,6 +63,7 @@ protected: bool eventFilter(QObject* obj, QEvent* event); }; + class QtMainWindow : public QMainWindow { diff --git a/src/trial/main.cpp b/src/trial/main.cpp index 4b6daddd..10ed0da5 100644 --- a/src/trial/main.cpp +++ b/src/trial/main.cpp @@ -1,24 +1,20 @@ -#include - -#include - +#include "utility/AppPath.h" #include "utility/logging/ConsoleLogger.h" #include "utility/logging/FileLogger.h" #include "utility/logging/LogManager.h" -#include "utility/AppPath.h" #include "utility/ResourcePaths.h" #include "utility/Version.h" #include "Application.h" #include "includes.h" // defines 'void setup(int argc, char *argv[])' -#include "qt/window/QtMainWindow.h" -#include "qt/window/QtSplashScreen.h" #include "qt/network/QtNetworkFactory.h" +#include "qt/QtApplication.h" #include "qt/utility/utilityQt.h" #include "qt/view/QtViewFactory.h" +#include "qt/window/QtMainWindow.h" +#include "qt/window/QtSplashScreen.h" #include "version.h" -#include "component/controller/helper/NetworkProtocolHelper.h" // remove when done void init() { @@ -39,7 +35,7 @@ int main(int argc, char *argv[]) Version version = Version::fromString(GIT_VERSION_NUMBER); setup(argc, argv); - QApplication qtApp(argc, argv); + QtApplication qtApp(argc, argv); qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);