From 627bcf0ee7e209ed59394dcec85b2cfacd8ada4b Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 22 Sep 2011 16:47:47 +0200 Subject: added some more js functions. abortBootDialog() and chooseInterfaceDialog() --- LogReceiver/ndgui.cpp | 80 ++++++++++++++++----------------------------------- 1 file changed, 25 insertions(+), 55 deletions(-) (limited to 'LogReceiver/ndgui.cpp') diff --git a/LogReceiver/ndgui.cpp b/LogReceiver/ndgui.cpp index ccd67da..0394926 100644 --- a/LogReceiver/ndgui.cpp +++ b/LogReceiver/ndgui.cpp @@ -6,10 +6,10 @@ ndgui::ndgui(QMainWindow *parent) : connect(&logReceiver, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &))); connect(&logReceiver, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&))); //connect(&logReceiver, SIGNAL(connectionEstablished(interfaceconfiguration*)), this, SLOT(handleConnectionEstablished(interfaceconfiguration*))); - //connect(&logReceiver, SIGNAL(abortBoot(QString)), this, SLOT(handleAbortBoot(QString))); + connect(&logReceiver, SIGNAL(abortBoot(QString)), this, SLOT(abortBoot(const QString))); connect(&logReceiver, SIGNAL(updateStatusLabel(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &))); //connect(&logReceiver, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished())); - connect(&logReceiver, SIGNAL(continueBoot(QString)), this, SLOT(continueBoot(QString))); + connect(&logReceiver, SIGNAL(continueBoot(QString, bool)), this, SLOT(continueBoot(QString, bool))); _started = false; @@ -48,74 +48,33 @@ void ndgui::handleConnectionEstablished(interfaceconfiguration *ifConf) { finalUsableIntefacesMap.insert(ifConf->getInterface(), ifConf); } -void ndgui::handleAbortBoot(QString msg) { - qDebug() << "abort boot. reason:" << msg; - showAbortBootDialog(); -} - - void ndgui::handleAllProcessesFinished() { qDebug() << "all Processes finished"; - - if (finalUsableIntefacesMap.size() > 0) { - showChooseInterfaceDialog(); + if(finalUsableIntefacesMap.size() > 0) { + // chooseInterfaceDialog(); } else { - showAbortBootDialog(); + abortBoot("No usable interfaces found!"); } } -void ndgui::showAbortBootDialog() { - aBD = new AbortBootDialog(this); - connect(aBD, SIGNAL(showLogSignal()), this, SLOT(showLog())); - connect(aBD, SIGNAL(restartSignal()), this, SLOT(restartSystem())); - connect(aBD, SIGNAL(shutDownSignal()), this, SLOT(shutDownSystem())); - aBD->setModal(true); - aBD->show(); -} - -void ndgui::showChooseInterfaceDialog() { - QStringList list(finalUsableIntefacesMap.keys()); - cID = new ChooseInterfaceDialog(list, this); - connect(cID, SIGNAL(continueSignal(QString)), this, - SLOT(continueBoot(QString))); - connect(cID, SIGNAL(restartSignal()), this, SLOT(restartSystem())); - connect(cID, SIGNAL(shutDownSignal()), this, SLOT(shutDownSystem())); - cID->setModal(true); - cID->show(); -} - void ndgui::restartSystem() { - if (qobject_cast (QObject::sender()) > 0) { - qDebug() << "received Signal restart abd"; - aBD->closeDialog(); - } else if (qobject_cast (QObject::sender()) > 0) { - qDebug() << "received Signal restart cid"; - cID->close(); - } else { - qDebug() << "unknown sender" << QObject::sender(); - } - } void ndgui::shutDownSystem() { - if (qobject_cast (QObject::sender()) > 0) { - aBD->closeDialog(); - } else if (qobject_cast (QObject::sender()) > 0) { +} - cID->close(); +void ndgui::continueBoot(QString ifName, bool userChoice) { + if (!userChoice) { + QString text = "continue with interface: " + ifName; + qDebug() << text << "no user choice"; + _webView->load(QUrl("qrc:html/continueBoot.html")); } else { - qDebug() << "unknown sender" << QObject::sender(); + QString text = "continue with interface: " + ifName; + qDebug() << text << "with user choice"; + _webView->load(QUrl("qrc:html/continueBoot.html")); } - -} - -void ndgui::continueBoot(QString ifName) { - QString text = "continue with interface: " + ifName; - qDebug() << text; - _webView->load(QUrl("qrc:html/continueBoot.html")); - //cID->close(); } void ndgui::showLog() { @@ -166,6 +125,17 @@ void ndgui::loadJQuery() { // dieser code muss später in die javascriptInterface klasse der fbgui eingefügt werden // tausche dazu ndgui zu javascriptinterface // und _webView->page()->mainFrame() zu _parent + +void ndgui::abortBoot(const QString msg) { + QString code = QString("abortBootDialog('\%1')").arg(msg); + _webView->page()->mainFrame()->evaluateJavaScript(code); +} + +void ndgui::chooseInterfaceDialog(const QString msg) { + QString code = QString("chooseInterfaceDialog('\%1')").arg(msg); + _webView->page()->mainFrame()->evaluateJavaScript(code); +} + void ndgui::updateStatus(const QString &status) { if (status == "") return; -- cgit v1.2.3-55-g7522