QTfrontend/HWApplication.cpp
changeset 8722 2dead6b84bca
parent 8716 e09633d10f16
child 8777 cce79a042cfc
equal deleted inserted replaced
8721:4cc2b2cd4184 8722:2dead6b84bca
    43 #if 0
    43 #if 0
    44     qDebug("%s called with", argv[0]);
    44     qDebug("%s called with", argv[0]);
    45     for (int i = 1; i < argc; i++)
    45     for (int i = 1; i < argc; i++)
    46         qDebug("%d: %s", i, argv[i]);
    46         qDebug("%d: %s", i, argv[i]);
    47 #endif
    47 #endif
       
    48     // on Windows, sending an event right away leads to a segfault
       
    49     // so we use urlString to save the data and send the event just before the app.exec()
       
    50     urlString = NULL;
       
    51     if (argc > 1) {
       
    52         urlString = new QString(argv[1]);
       
    53         if (urlString->contains("//", Qt::CaseInsensitive) == false) {
       
    54             delete urlString;
       
    55             urlString = NULL;
       
    56         }
       
    57     }
       
    58 }
       
    59 
       
    60 void HWApplication::fakeEvent()
       
    61 {
       
    62     QUrl parsedUrl(*urlString);
       
    63     delete urlString;
       
    64     urlString = NULL;
       
    65     QFileOpenEvent *openEvent = new QFileOpenEvent(parsedUrl);
       
    66     QCoreApplication::sendEvent(QCoreApplication::instance(), openEvent);
    48 }
    67 }
    49 
    68 
    50 bool HWApplication::event(QEvent *event)
    69 bool HWApplication::event(QEvent *event)
    51 {
    70 {
    52     QFileOpenEvent *openEvent;
    71     QFileOpenEvent *openEvent;
    58         path = openEvent->url().path();
    77         path = openEvent->url().path();
    59         address = openEvent->url().host();
    78         address = openEvent->url().host();
    60 
    79 
    61         QFile file(path);
    80         QFile file(path);
    62         if (scheme == "file" && file.exists()) {
    81         if (scheme == "file" && file.exists()) {
    63             form->PlayDemoQuick(openEvent->file());
    82             form->PlayDemoQuick(path);
    64             return true;
    83             return true;
    65         } else if (scheme == "hwplay") {
    84         } else if (scheme == "hwplay") {
    66             int port = openEvent->url().port(NETGAME_DEFAULT_PORT);
    85             int port = openEvent->url().port(NETGAME_DEFAULT_PORT);
    67             form->NetConnectQuick(address, (quint16) port);
    86             form->NetConnectQuick(address, (quint16) port);
    68             return true;
    87             return true;
    69         } else {
    88         } else {
    70             const QString errmsg = tr("Not yet implemented").arg(path);
    89             const QString errmsg = tr("Scheme '%1' not supported").arg(scheme);
    71             MessageDialog::ShowErrorMessage(errmsg, form);
    90             MessageDialog::ShowErrorMessage(errmsg, form);
    72             return false;
    91             return false;
    73         }
    92         }
    74     }
    93     }
    75 
    94