diff --git a/.gitignore b/.gitignore index 0a2e4b8..c1a3698 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ Makefile* src/propelleride/propelleride src/terminal/propterm build/ + +.DS_Store diff --git a/src/propelleride/application.cpp b/src/propelleride/application.cpp new file mode 100644 index 0000000..f667b70 --- /dev/null +++ b/src/propelleride/application.cpp @@ -0,0 +1,30 @@ +#include "application.h" + +#include +#include + +Application::Application(int &argc, char **argv) : QApplication(argc,argv) +{ +} + +Application::~Application() +{ +} + +bool Application::event(QEvent *event) +{ + switch(event->type()) + { + case QEvent::FileOpen: + loadFile( ((QFileOpenEvent *)event)->file() ); + emit fileOpened( ((QFileOpenEvent *)event)->file() ); + return true; + default: + return QApplication::event(event); + } +} + +void Application::loadFile(const QString & filename) +{ + qDebug() << "File Name:" << filename; +} diff --git a/src/propelleride/application.h b/src/propelleride/application.h new file mode 100644 index 0000000..c3f0ea9 --- /dev/null +++ b/src/propelleride/application.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class Application : public QApplication +{ + Q_OBJECT + +public: + Application(int &argc, char** argv); + ~Application(); + +protected: + bool event(QEvent *); + +private: + void loadFile(const QString & filename); + +signals: + void fileOpened(const QString & filename); + +}; diff --git a/src/propelleride/main.cpp b/src/propelleride/main.cpp index 1f958a0..9d156fc 100644 --- a/src/propelleride/main.cpp +++ b/src/propelleride/main.cpp @@ -1,4 +1,11 @@ +#include + +#ifdef Q_OS_MAC +#include "application.h" +#else #include +#endif + #include #include #include @@ -55,7 +62,11 @@ int main(int argc, char *argv[]) qInstallMessageHandler(messageHandler); #endif +#ifdef Q_OS_MAC + Application app(argc, argv); +#else QApplication app(argc, argv); +#endif QCoreApplication::setOrganizationName("Parallax"); QCoreApplication::setOrganizationDomain("www.parallax.com"); diff --git a/src/propelleride/mainwindow.cpp b/src/propelleride/mainwindow.cpp index 233a076..43a4524 100644 --- a/src/propelleride/mainwindow.cpp +++ b/src/propelleride/mainwindow.cpp @@ -45,6 +45,11 @@ MainWindow::MainWindow(QWidget *parent) QSplitterHandle *hndl = ui.splitter->handle(1); hndl->setEnabled(false); + +#ifdef Q_OS_MAC + connect(qApp, SIGNAL(fileOpened(const QString &)), ui.editorTabs, SLOT(openFile(const QString &))); +#endif + connect(ui.editorTabs, SIGNAL(fileUpdated(int)), this, SLOT(setProject())); // File Menu diff --git a/src/propelleride/propelleride.pro b/src/propelleride/propelleride.pro index 82f1e9b..e44d9be 100644 --- a/src/propelleride/propelleride.pro +++ b/src/propelleride/propelleride.pro @@ -34,7 +34,7 @@ SOURCES += \ preferences.cpp \ logging.cpp \ -HEADERS += \ +HEADERS += \ buildmanager.h \ clickable.h \ colorchooser.h \ @@ -52,6 +52,11 @@ HEADERS += \ templates/Singleton.h \ logging.h \ +macx { + SOURCES += application.cpp + HEADERS += application.h +} + OTHER_FILES += FORMS += \