Skip to content

Commit

Permalink
Add lots of stupid code and subclassing QApplication just to support …
Browse files Browse the repository at this point in the history
…file opening in PropellerIDE, because Mac.
  • Loading branch information
bweir committed Apr 24, 2016
1 parent 28651b4 commit 526e2ff
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Makefile*
src/propelleride/propelleride
src/terminal/propterm
build/

.DS_Store
30 changes: 30 additions & 0 deletions src/propelleride/application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "application.h"

#include <QFileOpenEvent>
#include <QDebug>

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;
}
22 changes: 22 additions & 0 deletions src/propelleride/application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <QApplication>

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);

};
11 changes: 11 additions & 0 deletions src/propelleride/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#include <QtGlobal>

#ifdef Q_OS_MAC
#include "application.h"
#else
#include <QApplication>
#endif

#include <QDebug>
#include <QMessageBox>
#include <QStyleFactory>
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions src/propelleride/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/propelleride/propelleride.pro
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SOURCES += \
preferences.cpp \
logging.cpp \

HEADERS += \
HEADERS += \
buildmanager.h \
clickable.h \
colorchooser.h \
Expand All @@ -52,6 +52,11 @@ HEADERS += \
templates/Singleton.h \
logging.h \

macx {
SOURCES += application.cpp
HEADERS += application.h
}

OTHER_FILES +=

FORMS += \
Expand Down

0 comments on commit 526e2ff

Please sign in to comment.