summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp112
1 files changed, 60 insertions, 52 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 9e3dba5..021a9e3 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -3,7 +3,6 @@
#include "loggerengine.h"
#include "downloadmanager.h"
#include "javascriptinterface.h"
-#include "sysinfolibsysfs.h"
#include <iostream>
#include <QThread>
@@ -34,59 +33,71 @@ int debugMode = -1;
* @see DownloadManager
*/
fbgui::fbgui() {
+}
+fbgui::~fbgui() {
+ dmThread.quit();
+}
- // test for libsys function
- //SysInfo si;
- //qxtLog->debug() << si.getInfo("mbserial");
- //si.getInfo("usb");
- setupLayout();
- createActions();
- // initialize javascript interface
- JavascriptInterface* jsi = new JavascriptInterface(
- _webView->page()->mainFrame());
- QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close()));
- QObject::connect(jsi, SIGNAL(shutDownClient()), this,
- SLOT(performShutDown()));
- QObject::connect(_webView->page()->mainFrame(), SIGNAL(
- javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM()));
+/**
+ * init function.
+ */
+void fbgui::init() {
+ // start fbgui
+ qxtLog->debug() << "Initializing fbgui...";
- // initialize download manager
- DownloadManager* dm = new DownloadManager();
- QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)), jsi,
- SLOT(downloadInfo(const QString&, const double&)));
- QObject::connect(dm, SIGNAL(notify(const QString&)), jsi, SLOT(notify(const QString&)));
- QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm,
- SLOT(downloadFile(const QString&)));
- QObject::connect(dm, SIGNAL(updateProgress(const int&, const double&, const QString&)), jsi,
- SLOT(updateProgressBar(const int&, const double&, const QString&)));
- QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(
- callbackOnFinished()));
- QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem()));
+ setupLayout();
+ createActions();
- // move download manager to its own thread
- dm->moveToThread(&dmThread);
- dmThread.start();
+ // initialize javascript interface
+ JavascriptInterface* jsi = new JavascriptInterface(
+ _webView->page()->mainFrame());
+ QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close()));
+ QObject::connect(jsi, SIGNAL(shutDownClient()), this,
+ SLOT(performShutDown()));
+ QObject::connect(_webView->page()->mainFrame(), SIGNAL(
+ javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM()));
- // show "waiting for internet" page until triggered.
- if (debugMode > -1) {
- _webView->load(QUrl("qrc:/html/preload-debug.html"));
- } else {
- _webView->load(QUrl("qrc:/html/preload.html"));
- }
+ // initialize download manager
+ DownloadManager* dm = new DownloadManager();
+ QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)),
+ jsi, SLOT(downloadInfo(const QString&, const double&)));
+ QObject::connect(dm, SIGNAL(notify(const QString&)), jsi,
+ SLOT(notify(const QString&)));
+ QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm,
+ SLOT(downloadFile(const QString&)));
+ QObject::connect(
+ dm,
+ SIGNAL(updateProgress(const int&, const double&, const QString&)),
+ jsi,
+ SLOT(updateProgressBar(const int&, const double&, const QString&)));
+ QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(
+ callbackOnFinished()));
+ QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem()));
- // start watching for fileToTriggerURL
- watchForTrigger();
+ // move download manager to its own thread
+ dm->moveToThread(&dmThread);
+ dmThread.start();
- // set properties
- setWindowTitle("fbgui");
- setAttribute(Qt::WA_QuitOnClose, true);
- setWindowFlags(Qt::FramelessWindowHint);
- showFullScreen();
-}
-fbgui::~fbgui() {
- dmThread.quit();
+ // show "waiting for internet" page until triggered.
+ if (debugMode > -1) {
+ _webView->load(QUrl("qrc:/html/preload-debug.html"));
+ } else {
+ _webView->load(QUrl("qrc:/html/preload.html"));
+ }
+
+ // watcher is not needed anymore since we guarantee internet connection with the networkDiscovery.
+ // start watching for fileToTriggerURL
+ //watchForTrigger();
+ loadURL();
+
+ // set properties
+ setWindowTitle("fbgui");
+ setAttribute(Qt::WA_QuitOnClose, true);
+ setWindowFlags(Qt::FramelessWindowHint);
+// showFullScreen();
+ this->show();
}
//-------------------------------------------------------------------------------------------
// Layout / actions setup
@@ -220,7 +231,7 @@ void fbgui::loadURL() {
QNetworkRequest req(baseURL);
// show cursor again since user is about to interact.
- QWSServer::instance()->setCursorVisible(true);
+ //QWSServer::instance()->setCursorVisible(true);
QObject::connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadURLDone(bool)));
_webView->load(req, QNetworkAccessManager::PostOperation, postData);
}
@@ -262,7 +273,8 @@ QByteArray fbgui::generatePOSTData() {
if (!mbserial.isEmpty())
data.append(mbserial);
else {
- qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending to base hash data.";
+ qxtLog->debug()
+ << "[gui] Mainboard serial was empty. Not appending to base hash data.";
}
qxtLog->debug() << "[post] Hashing: " << data;
// generate MD5 hash of data
@@ -478,7 +490,3 @@ void fbgui::createDebugConsole() {
void fbgui::toggleDebugConsole() {
(_debugConsole->isVisible()) ? _debugConsole->hide() : _debugConsole->show();
}
-//-------------------------------------------------------------------------------------------
-//
-
-//-------------------------------------------------------------------------------------------