QTfrontend/HWApplication.cpp
changeset 8710 8d0a150d42c2
parent 8708 6354b01d5500
child 8712 ba98ab1f26b6
equal deleted inserted replaced
8709:191bd86f97a1 8710:8d0a150d42c2
    18 
    18 
    19 #include "HWApplication.h"
    19 #include "HWApplication.h"
    20 #include <QFileOpenEvent>
    20 #include <QFileOpenEvent>
    21 
    21 
    22 #include "hwform.h"
    22 #include "hwform.h"
       
    23 #include "MessageDialog.h"
       
    24 
    23 
    25 
    24 #if !defined(Q_WS_WIN)
    26 #if !defined(Q_WS_WIN)
    25 void terminateFrontend(int signal)
    27 void terminateFrontend(int signal)
    26 {
    28 {
    27     Q_UNUSED(signal);
    29     Q_UNUSED(signal);
    33     QApplication(argc, argv)
    35     QApplication(argc, argv)
    34 {
    36 {
    35 #if !defined(Q_WS_WIN)
    37 #if !defined(Q_WS_WIN)
    36     signal(SIGINT, &terminateFrontend);
    38     signal(SIGINT, &terminateFrontend);
    37 #endif
    39 #endif
       
    40 #if 0
       
    41     qDebug("%s called with", argv[0]);
       
    42     for (int i = 1; i < argc; i++)
       
    43         qDebug("%d: %s", i, argv[i]);
       
    44 #endif
    38 }
    45 }
    39 
    46 
    40 bool HWApplication::event(QEvent *event)
    47 bool HWApplication::event(QEvent *event)
    41 {
    48 {
    42     QFileOpenEvent *openEvent;
    49     QFileOpenEvent *openEvent;
       
    50     QString scheme, path;
    43 
    51 
    44     switch (event->type())
    52     if (event->type() == QEvent::FileOpen) {
    45     {
    53         openEvent = (QFileOpenEvent *)event;
    46         case QEvent::FileOpen:
    54         scheme = openEvent->url().scheme();
    47             openEvent = (QFileOpenEvent *)event;
    55         path = openEvent->url().path();
    48             if (form) form->PlayDemoQuick(openEvent->file());
    56 
       
    57         QFile file(path);
       
    58         if (scheme == "file" && file.exists()) {
       
    59             form->PlayDemoQuick(openEvent->file());
    49             return true;
    60             return true;
    50             break;
    61         } else {
    51         default:
    62             const QString errmsg = tr("Not yet implemented").arg(path);
    52             return QApplication::event(event);
    63             MessageDialog::ShowErrorMessage(errmsg, form);
    53             break;
    64             return false;
    54     }
    65         }
       
    66      }
       
    67 
       
    68     return QApplication::event(event);
    55 }
    69 }
    56 
    70 
    57 
    71