# HG changeset patch # User koda # Date 1362879145 -3600 # Node ID 8d0a150d42c2cb58289034d38980b0769fc102bf # Parent 191bd86f97a183e9e5470bf9d40cdc0d80cd99b9 cleanup file loading, this codepath can be used to load url schemes diff -r 191bd86f97a1 -r 8d0a150d42c2 QTfrontend/HWApplication.cpp --- a/QTfrontend/HWApplication.cpp Sun Mar 10 01:27:48 2013 +0100 +++ b/QTfrontend/HWApplication.cpp Sun Mar 10 02:32:25 2013 +0100 @@ -20,6 +20,8 @@ #include #include "hwform.h" +#include "MessageDialog.h" + #if !defined(Q_WS_WIN) void terminateFrontend(int signal) @@ -35,23 +37,35 @@ #if !defined(Q_WS_WIN) signal(SIGINT, &terminateFrontend); #endif +#if 0 + qDebug("%s called with", argv[0]); + for (int i = 1; i < argc; i++) + qDebug("%d: %s", i, argv[i]); +#endif } bool HWApplication::event(QEvent *event) { QFileOpenEvent *openEvent; + QString scheme, path; - switch (event->type()) - { - case QEvent::FileOpen: - openEvent = (QFileOpenEvent *)event; - if (form) form->PlayDemoQuick(openEvent->file()); + if (event->type() == QEvent::FileOpen) { + openEvent = (QFileOpenEvent *)event; + scheme = openEvent->url().scheme(); + path = openEvent->url().path(); + + QFile file(path); + if (scheme == "file" && file.exists()) { + form->PlayDemoQuick(openEvent->file()); return true; - break; - default: - return QApplication::event(event); - break; - } + } else { + const QString errmsg = tr("Not yet implemented").arg(path); + MessageDialog::ShowErrorMessage(errmsg, form); + return false; + } + } + + return QApplication::event(event); }