From e942d5d431346439533910bf649b10ec17463c03 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 25 Oct 2011 18:57:40 +0200 Subject: fixed some bugs. show log screen is now bigger and opens a scrollbar automatically. debug screens added. fixed continue in debug mode, added progress indicator for all screens. --- src/ndgui.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 6 deletions(-) (limited to 'src/ndgui.cpp') diff --git a/src/ndgui.cpp b/src/ndgui.cpp index 05ceac1..145cd78 100644 --- a/src/ndgui.cpp +++ b/src/ndgui.cpp @@ -17,6 +17,7 @@ ndgui::ndgui(QMainWindow *parent) : _userChoice = false; _tryAgain = false; + setupLayout(); createAction(); connect(&networkDiscovery, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &))); @@ -27,16 +28,22 @@ ndgui::ndgui(QMainWindow *parent) : connect(&networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished())); connect(&networkDiscovery, SIGNAL(continueBoot(QString, int)), this, SLOT(continueBoot(QString, int))); - _webView = new QWebView(this); + connect(_webView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared()), this, SLOT(attachToDOM())); - setCentralWidget(_webView); + setWindowTitle(tr("NetD")); setAttribute(Qt::WA_QuitOnClose, true); setWindowFlags(Qt::FramelessWindowHint); showFullScreen(); - _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html")); + if (debugMode > -1) { + _webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html")); + } + else { + _webView->load(QUrl("prc:html/networkdiscovery_userchoice.html")); + } + _webView->show(); qxtLog->debug() << _tag << "start singel shot"; @@ -52,6 +59,74 @@ ndgui::~ndgui() { +/** + * This method sets the used Layout. + * + * This method sets the used Layout. Possible layout are: + * - browser mode: only the browser is visible + * - debug mode: the screen is divided into the browser and a debug + * out console + */ +void ndgui::setupLayout() { + // setup layout of the gui: debug split or browser + _webView = new QWebView(this); + if (debugMode == 1) { + // split main window in browser & debug console + createDebugConsole(); + _splitter = new QSplitter(Qt::Vertical, this); + _splitter->addWidget(_webView); + _splitter->addWidget(_debugConsole); + setCentralWidget(_splitter); + } else + setCentralWidget(_webView); +} + + + +/** + * This method creates a debug console as a widget. + * + * It is basicly a QTextEdit widget as provided by QT's Framework. + * An action to toggle this widget is implemented (CTRL + D). + * + * @see fbgui::toggleDebugConsole() + */ +void ndgui::createDebugConsole() { + // create the debug console widget + _debugConsole = new QTextEdit(this); + _debugConsole->setWindowFlags(Qt::FramelessWindowHint); + // fanciness + QPalette pal; + pal.setColor(QPalette::Base, Qt::black); + _debugConsole->setPalette(pal); + _debugConsole->setTextColor(Qt::white); + // enable custom logger engine + qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); + //qxtLog->initLoggerEngine("fb_logger"); + qxtLog->setMinimumLevel("fb_logger", QxtLogger::DebugLevel); + // CTRL + D toggles debug window + _toggleDebugConsole = new QAction(tr("&toggleDebug"), this); + _toggleDebugConsole->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); + addAction(_toggleDebugConsole); + connect(_toggleDebugConsole, SIGNAL(triggered()), this, SLOT( + toggleDebugConsole())); +} + + + +/** + * This method toggles the debug console. + * + * Toggle the visibility of the debug console if the action _toggleDebugConsole is triggered. + * + * @see fbgui::createDebugConsole() + */ +void ndgui::toggleDebugConsole() { + (_debugConsole->isVisible()) ? _debugConsole->hide() : _debugConsole->show(); +} + + + /** * creates an action which you can trigger with the F5 Button during the first * seconds. @@ -87,7 +162,13 @@ void ndgui::prepareNetworkDiscover() { SLOT(startNetworkDiscovery())); this->removeAction(_allowUserChoice); - _webView->load(QUrl("qrc:html/networkdiscovery.html")); + if (debugMode > -1) { + _webView->load(QUrl("qrc:html/networkdiscovery_debug.html")); + } + else { + _webView->load(QUrl("qrc:html/networkdiscovery.html")); + } + _webView->show(); } @@ -106,7 +187,7 @@ void ndgui::startNetworkDiscovery(){ _started = true; QStringList l; l << "-d"; - networkDiscovery.initAndRun("209.85.148.105", _userChoice, true, "/var/tmp/logfile","/var/tmp/qt_c_socket_custom", DEFAULT_PATHTODHCPCDEXE, &l); + networkDiscovery.initAndRun("209.85.148.105", _userChoice, true, logFilePath,"/var/tmp/qt_c_socket_custom", DEFAULT_PATHTODHCPCDEXE, &l); } else { _tryAgain = false; networkDiscovery.tryAgain(); @@ -204,6 +285,7 @@ void ndgui::continueBoot(QString ifName, int userChoice) { } if (networkDiscovery.checkConnectivityViaTcp()) { emit initFbgui(); + this->close(); } else { abortBoot("Interface was suddenly made unusable "); } @@ -229,7 +311,12 @@ void ndgui::tryAgain() { _ifNameList.clear(); _manConfList.clear(); createAction(); - _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html")); + if (debugMode > -1) { + _webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html")); + } + else { + _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html")); + } _webView->show(); QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover())); -- cgit v1.2.3-55-g7522