From 46da51f8701747376999dcca8f034e41eeb206e0 Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 29 Sep 2011 14:24:48 +0200 Subject: did some refactoring. added a user choice screen which is shown 2 seconds before the magic begins. (press F5 to get a choice) --- LogReceiver/ndgui.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'LogReceiver/ndgui.cpp') diff --git a/LogReceiver/ndgui.cpp b/LogReceiver/ndgui.cpp index cb2a2f9..be01224 100644 --- a/LogReceiver/ndgui.cpp +++ b/LogReceiver/ndgui.cpp @@ -3,6 +3,11 @@ ndgui::ndgui(QMainWindow *parent) : QMainWindow(parent) { + _started = false; + _userChoice = false; + + createAction(); + connect(&networkDiscovery, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &))); connect(&networkDiscovery, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&))); connect(&networkDiscovery, SIGNAL(connectionEstablished(QString)), this, SLOT(handleConnectionEstablished(QString))); @@ -11,34 +16,53 @@ ndgui::ndgui(QMainWindow *parent) : connect(&networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished())); connect(&networkDiscovery, SIGNAL(continueBoot(QString, int)), this, SLOT(continueBoot(QString, int))); - _started = false; - _manualConfInterfaces = "[\"NO INTERFACE\"]"; + _webView = new QWebView(this); connect(_webView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared()), this, SLOT(attachToDOM())); - connect(_webView, SIGNAL(loadFinished(bool)), this, - SLOT(startNetworkDiscovery())); - - - setCentralWidget(_webView); - _webView->load(QUrl("qrc:html/networkdiscovery.html")); - _webView->show(); setWindowTitle(tr("NetD")); setAttribute(Qt::WA_QuitOnClose, true); setWindowFlags(Qt::FramelessWindowHint); + _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html")); + _webView->show(); + + QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover())); + } ndgui::~ndgui() { } +void ndgui::createAction() { + _allowUserChoice = new QAction(tr("&quit"), this); + _allowUserChoice->setShortcut(QKeySequence(Qt::Key_F5)); + connect(_allowUserChoice, SIGNAL(triggered()), this, SLOT(setUserChoiceTrue())); + this->addAction(_allowUserChoice); +} + +void ndgui::setUserChoiceTrue() { + _userChoice = true; +} + +void ndgui::prepareNetworkDiscover() { + connect(_webView, SIGNAL(loadFinished(bool)), this, + SLOT(startNetworkDiscovery())); + this->removeAction(_allowUserChoice); + + _webView->load(QUrl("qrc:html/networkdiscovery.html")); + _webView->show(); +} + void ndgui::startNetworkDiscovery(){ + + disconnect(_webView,SIGNAL(loadFinished(bool)), this, SLOT(startNetworkDiscovery())); if(!_started) { _started = true; - networkDiscovery.initAndRun("209.85.148.105", true,"/var/tmp/qt_c_socket_custom"); + networkDiscovery.initAndRun("209.85.148.105", _userChoice,"/var/tmp/qt_c_socket_custom"); } else { qDebug() << "NetworkDiscovery already started"; -- cgit v1.2.3-55-g7522