diff options
-rw-r--r-- | quacker/main.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/quacker/main.cpp b/quacker/main.cpp index 964f9b2..213297f 100644 --- a/quacker/main.cpp +++ b/quacker/main.cpp @@ -17,13 +17,53 @@ */ #include <QApplication> +#include <QFileOpenEvent> #include "quacker.h" +class QuackerApplication : public QApplication +{ +public: + QuackerApplication(int& argc, char** argv) + : QApplication(argc, argv) + , m_TopLevel(NULL) + { + // empty + }; + + virtual bool event(QEvent* event) + { + switch(event->type()) + { + case QEvent::FileOpen: + { + QFileOpenEvent* fileOpenEvent = static_cast<QFileOpenEvent*>(event); + if (m_TopLevel && !fileOpenEvent->file().isEmpty()) + { + m_TopLevel->openFile(fileOpenEvent->file()); + return true; + } + } + // no break + default: + return QApplication::event(event); + } + } + + void setTopLevel(TopLevel* topLevel) + { + m_TopLevel = topLevel; + } + +private: + TopLevel* m_TopLevel; +}; + int main(int argc, char **argv) { - QApplication a(argc, argv); + QuackerApplication a(argc, argv); TopLevel topLevel; + a.setTopLevel(&topLevel); topLevel.show(); return a.exec(); } |