QTfrontend/HWApplication.cpp
changeset 8716 e09633d10f16
parent 8715 70a586fc76fd
child 8722 2dead6b84bca
equal deleted inserted replaced
8715:70a586fc76fd 8716:e09633d10f16
    48 }
    48 }
    49 
    49 
    50 bool HWApplication::event(QEvent *event)
    50 bool HWApplication::event(QEvent *event)
    51 {
    51 {
    52     QFileOpenEvent *openEvent;
    52     QFileOpenEvent *openEvent;
    53     QString scheme, path;
    53     QString scheme, path, address;
    54 
    54 
    55     if (event->type() == QEvent::FileOpen) {
    55     if (event->type() == QEvent::FileOpen) {
    56         openEvent = (QFileOpenEvent *)event;
    56         openEvent = (QFileOpenEvent *)event;
    57         scheme = openEvent->url().scheme();
    57         scheme = openEvent->url().scheme();
    58         path = openEvent->url().path();
    58         path = openEvent->url().path();
       
    59         address = openEvent->url().host();
    59 
    60 
    60         QFile file(path);
    61         QFile file(path);
    61         if (scheme == "file" && file.exists()) {
    62         if (scheme == "file" && file.exists()) {
    62             form->PlayDemoQuick(openEvent->file());
    63             form->PlayDemoQuick(openEvent->file());
       
    64             return true;
       
    65         } else if (scheme == "hwplay") {
       
    66             int port = openEvent->url().port(NETGAME_DEFAULT_PORT);
       
    67             form->NetConnectQuick(address, (quint16) port);
    63             return true;
    68             return true;
    64         } else {
    69         } else {
    65             const QString errmsg = tr("Not yet implemented").arg(path);
    70             const QString errmsg = tr("Not yet implemented").arg(path);
    66             MessageDialog::ShowErrorMessage(errmsg, form);
    71             MessageDialog::ShowErrorMessage(errmsg, form);
    67             return false;
    72             return false;
    68         }
    73         }
    69      }
    74     }
    70 
    75 
    71     return QApplication::event(event);
    76     return QApplication::event(event);
    72 }
    77 }
    73 
    78 
    74 
    79