summaryrefslogtreecommitdiffstats
path: root/src/fbgui/ndgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbgui/ndgui.cpp')
-rw-r--r--src/fbgui/ndgui.cpp156
1 files changed, 14 insertions, 142 deletions
diff --git a/src/fbgui/ndgui.cpp b/src/fbgui/ndgui.cpp
index 4e0b3f6..a95d884 100644
--- a/src/fbgui/ndgui.cpp
+++ b/src/fbgui/ndgui.cpp
@@ -11,7 +11,6 @@
#include "ndgui.h"
-
#include <log4cxx/logger.h>
#include "qlog4cxx.h"
@@ -24,14 +23,14 @@ QString gServerIp("");
bool gAutoUp = true;
QString gSocketServerPath("");
QString gPathToDhcpExe("");
-
+QString interfaceName("");
/**
* constructor
*/
-ndgui::ndgui(QMainWindow *parent) :
- QMainWindow(parent) {
+ndgui::ndgui() :
+ agui() {
}
@@ -41,11 +40,8 @@ ndgui::ndgui(QMainWindow *parent) :
*/
ndgui::~ndgui() {
- delete _debugConsole;
- delete _toggleDebugConsole;
delete _allowUserChoice;
delete _tryAgain;
- delete _webView;
delete _networkDiscovery;
}
@@ -57,13 +53,14 @@ ndgui::~ndgui() {
*/
void ndgui::init() {
+ LOG4CXX_DEBUG(ndLogger, "Initializing ndgui...");
+
_started = false;
_userChoice = false;
_ifNameList.clear();
_manConfList.clear();
- setupLayout();
- createAction();
+ addActions();
_networkDiscovery = new NetworkDiscovery();
connect(_networkDiscovery, SIGNAL(addInterface(const QString &)), this,
@@ -90,101 +87,24 @@ void ndgui::init() {
javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(startSingleShot()));
- setWindowTitle(tr("NetD"));
- setAttribute(Qt::WA_QuitOnClose, true);
- setWindowFlags(Qt::FramelessWindowHint);
- showFullScreen();
if (debugMode > -1) {
_webView->load(QUrl("qrc:html/networkdiscovery_debug.html"));
} else {
_webView->load(QUrl("qrc:html/networkdiscovery.html"));
-
}
- _webView->show();
-}
-
-
-
-/**
- * @brief 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);
- _webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu
-
- 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 {
- _webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
- setCentralWidget(_webView);
- }
-}
-
-
-
-/**
- * @brief 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()));
-}
-
-
-
-/**
- * @brief 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();
+ setWindowTitle(tr("NetD"));
+ showFullScreen();
}
-
/**
- * @brief Create actions
+ * @brief Add actions
*
- * creates an action which you can trigger with the F5 and F9 Button.
+ * Add actions which you can trigger with the F5 and F9 Button.
*/
-void ndgui::createAction() {
+void ndgui::addActions() {
_allowUserChoice = new QAction(tr("&userChoice"), this);
_allowUserChoice->setShortcut(QKeySequence(Qt::Key_F5));
connect(_allowUserChoice, SIGNAL(triggered()), this, SLOT(setUserChoiceTrue()));
@@ -195,8 +115,6 @@ void ndgui::createAction() {
this->addAction(_tryAgain);
}
-
-
/**
* @brief set userChoice true
*
@@ -259,8 +177,6 @@ void ndgui::handleConnectionEstablished(QString ifName) {
_ifNameList.append(ifName);
}
-
-
/**
* @brief determines if we continue the boot sequence or if we show the chooseInterface or abortBoot dialog
*
@@ -300,43 +216,6 @@ void ndgui::handleAllProcessesFinished() {
}
-
-/**
- * @brief restart the system
- *
- * this method will restart the system.
- * triggered through a button click in the gui.
- */
-void ndgui::restartSystem() {
- QFile file("/proc/sysrq-trigger");
- if (file.open(QIODevice::WriteOnly)) {
- file.write("b");
- file.close();
- } else {
- LOG4CXX_DEBUG(ndLogger, "Could not open /proc/sysrq-trigger");
- }
-}
-
-
-
-/**
- * @brief shut down the system
- *
- * this method will restart the system.
- * triggered through a button click in the gui.
- */
-void ndgui::shutDownSystem() {
- QFile file("/proc/sysrq-trigger");
- if (file.open(QIODevice::WriteOnly)) {
- file.write("o");
- file.close();
- } else {
- LOG4CXX_DEBUG(ndLogger, "Could not open /proc/sysrq-trigger");
- }
-}
-
-
-
/**
* @brief continue the boot sequence
*
@@ -348,6 +227,7 @@ void ndgui::shutDownSystem() {
void ndgui::continueBoot(QString ifName) {
if (_networkDiscovery->checkConnectivity(ifName)) {
LOG4CXX_DEBUG(ndLogger, " continue with interface: " << ifName);
+ interfaceName = ifName;
emit initFbgui();
this->close();
} else {
@@ -358,18 +238,17 @@ void ndgui::continueBoot(QString ifName) {
}
-
/**
* @brief continue the boot sequence without further checking if the connection is still possible.
*/
void ndgui::continueBootWithoutCheck(QString ifName) {
LOG4CXX_DEBUG(ndLogger, " continue with interface: " << ifName);
+ interfaceName = ifName;
emit initFbgui();
this->close();
}
-
/**
* @brief read the log file. Log File will be presented inside of a dialog.
*/
@@ -379,21 +258,15 @@ QString ndgui::readLogFile() {
}
-
/**
* @brief starts the whole application again.
*/
void ndgui::tryAgain() {
LOG4CXX_DEBUG(ndLogger, " try again ");
_networkDiscovery->prepareTryAgain();
- if(debugMode > -1) {
- delete _splitter;
- delete _debugConsole;
- delete _toggleDebugConsole;
- }
delete _allowUserChoice;
delete _tryAgain;
- delete _webView;
+ //delete _webView;
delete _networkDiscovery;
init();
@@ -401,7 +274,6 @@ void ndgui::tryAgain() {
}
-
/*test html gui version*/
/**