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
This commit is contained in:
@@ -119,4 +119,7 @@ add_files(
|
||||
qt/window/QtSplashScreen.h
|
||||
qt/window/QtStartScreen.cpp
|
||||
qt/window/QtStartScreen.h
|
||||
|
||||
qt/QtApplication.cpp
|
||||
qt/QtApplication.h
|
||||
)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "qt/QtApplication.h"
|
||||
|
||||
#include <QFileOpenEvent>
|
||||
|
||||
#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<QFileOpenEvent*>(event);
|
||||
|
||||
FilePath path(fileEvent->file().toStdString());
|
||||
|
||||
if (path.exists() && path.extension() == ".coatiproject")
|
||||
{
|
||||
MessageLoadProject(path.str(), false).dispatch();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QApplication::event(event);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef QT_APPLICATION_H
|
||||
#define QT_APPLICATION_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
class QtApplication
|
||||
: public QApplication
|
||||
{
|
||||
public:
|
||||
QtApplication(int& argc, char** argv);
|
||||
|
||||
bool event(QEvent *event);
|
||||
};
|
||||
|
||||
#endif // QT_APPLICATION_H
|
||||
@@ -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));
|
||||
|
||||
@@ -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<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
QtThreadedFunctor<> m_hideStartScreenFunctor;
|
||||
QtThreadedFunctor<const std::string&> m_setTitleFunctor;
|
||||
QtThreadedFunctor<> m_activateWindowFunctor;
|
||||
QtThreadedFunctor<> m_updateRecentProjectMenuFunctor;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -62,8 +62,6 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(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();
|
||||
|
||||
@@ -63,6 +63,7 @@ protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
};
|
||||
|
||||
|
||||
class QtMainWindow
|
||||
: public QMainWindow
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user