diff options
author | Jonathan Bauer | 2012-02-01 15:31:48 +0100 |
---|---|---|
committer | Jonathan Bauer | 2012-02-01 15:31:48 +0100 |
commit | 1fe9c90f77990e740c205a5113340583146536e8 (patch) | |
tree | 834545bffba0be9fe8895fdf3bc90f91f285b120 /src/fbgui/ndgui.cpp | |
parent | new abstract class agui for common gui functions, new console class for debug... (diff) | |
download | fbgui-1fe9c90f77990e740c205a5113340583146536e8.tar.gz fbgui-1fe9c90f77990e740c205a5113340583146536e8.tar.xz fbgui-1fe9c90f77990e740c205a5113340583146536e8.zip |
adapted existing classes to reflect changes
Diffstat (limited to 'src/fbgui/ndgui.cpp')
-rw-r--r-- | src/fbgui/ndgui.cpp | 153 |
1 files changed, 17 insertions, 136 deletions
diff --git a/src/fbgui/ndgui.cpp b/src/fbgui/ndgui.cpp index 4e0b3f6..34a3f2d 100644 --- a/src/fbgui/ndgui.cpp +++ b/src/fbgui/ndgui.cpp @@ -30,8 +30,8 @@ QString gPathToDhcpExe(""); /** * constructor */ -ndgui::ndgui(QMainWindow *parent) : - QMainWindow(parent) { +ndgui::ndgui() : + agui() { } @@ -41,11 +41,11 @@ ndgui::ndgui(QMainWindow *parent) : */ ndgui::~ndgui() { - delete _debugConsole; - delete _toggleDebugConsole; + //delete _debugConsole; + //delete _toggleDebugConsole; delete _allowUserChoice; delete _tryAgain; - delete _webView; + //delete _webView; delete _networkDiscovery; } @@ -57,13 +57,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 +91,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 +119,6 @@ void ndgui::createAction() { this->addAction(_tryAgain); } - - /** * @brief set userChoice true * @@ -300,43 +222,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 * @@ -358,7 +243,6 @@ void ndgui::continueBoot(QString ifName) { } - /** * @brief continue the boot sequence without further checking if the connection is still possible. */ @@ -369,7 +253,6 @@ void ndgui::continueBootWithoutCheck(QString ifName) { } - /** * @brief read the log file. Log File will be presented inside of a dialog. */ @@ -379,7 +262,6 @@ QString ndgui::readLogFile() { } - /** * @brief starts the whole application again. */ @@ -387,13 +269,13 @@ void ndgui::tryAgain() { LOG4CXX_DEBUG(ndLogger, " try again "); _networkDiscovery->prepareTryAgain(); if(debugMode > -1) { - delete _splitter; - delete _debugConsole; - delete _toggleDebugConsole; + //delete _splitter; + //delete _debugConsole; + //delete _toggleDebugConsole; } delete _allowUserChoice; delete _tryAgain; - delete _webView; + //delete _webView; delete _networkDiscovery; init(); @@ -401,7 +283,6 @@ void ndgui::tryAgain() { } - /*test html gui version*/ /** |