summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-24 13:34:36 +0100
committerJonathan Bauer2011-03-24 13:34:36 +0100
commit1d78a746edc496e42ecdbaf340f850ee5f390fe2 (patch)
treef08ee016b10039742ef49648358875a982aebcb9 /src/fbgui.cpp
parentcomments.. (diff)
downloadfbgui-1d78a746edc496e42ecdbaf340f850ee5f390fe2.tar.gz
fbgui-1d78a746edc496e42ecdbaf340f850ee5f390fe2.tar.xz
fbgui-1d78a746edc496e42ecdbaf340f850ee5f390fe2.zip
more
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp129
1 files changed, 72 insertions, 57 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 0840d54..4d8f9d1 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -26,20 +26,8 @@ fbgui::fbgui()
sil->getInfoAboutNetworkInterface();
sil->getInfoAboutClassNet();
- // start basic console debug log
- qxtLog->disableLoggerEngine("DEFAULT");
- qxtLog->enableLogLevels(QxtLogger::DebugLevel);
- if (debugMode == 0 || debugMode == 1){
- qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std);
- qxtLog->initLoggerEngine("std_logger");
- qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel);
- qxtLog->debug() << "Initializing fbgui...";
- }
-
- // setup layout of the gui: debug split or browser
- _webView = new QWebView(this);
- if (debugMode == 1) setupDebugSplit();
- else setCentralWidget(_webView);
+ setupBasicDebug();
+ setupLayout();
createActions();
// initialize javascript interface
@@ -54,14 +42,16 @@ fbgui::fbgui()
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(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()));
- // load filler page & start watching for fileToTriggerURL
+ // show filler page
_webView->load(QUrl("qrc:/html/loadAbout.html"));
+ // start watching for fileToTriggerURL
watchForTrigger();
// set properties
@@ -71,6 +61,39 @@ fbgui::fbgui()
showFullScreen();
}
//-------------------------------------------------------------------------------------------
+// Layout / actions setup
+//-------------------------------------------------------------------------------------------
+void fbgui::setupLayout()
+{
+ // setup layout of the gui: debug split or browser
+ _webView = new QWebView(this);
+ if (debugMode == 1){
+ _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);
+ // display browser and debug in a splitter
+ _splitter = new QSplitter(Qt::Vertical, this);
+ _splitter->addWidget(_webView);
+ _splitter->addWidget(_debugConsole);
+ // 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()));
+ setCentralWidget(_splitter);
+ }
+ else
+ setCentralWidget(_webView);
+}
+//-------------------------------------------------------------------------------------------
void fbgui::createActions()
{
// CTRL + X to kill the gui
@@ -110,10 +133,12 @@ void fbgui::watchForTrigger()
}
else {
// watch the path where trigger file is expected
- qxtLog->debug() << "[watcher] Watching " << fi.absolutePath() << " for file: " << fi.fileName();
+ qxtLog->debug() << "[watcher] Watching " << fi.absolutePath()
+ << " for file: " << fi.fileName();
QStringList pathToWatch(fi.absolutePath());
_watcher = new QFileSystemWatcher(pathToWatch, this);
- QObject::connect(_watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(checkForTrigger(const QString&)));
+ QObject::connect(_watcher, SIGNAL(directoryChanged(const QString&)),
+ this, SLOT(checkForTrigger(const QString&)));
}
}
//-------------------------------------------------------------------------------------------
@@ -131,9 +156,23 @@ void fbgui::checkForTrigger(const QString& dirname)
qxtLog->debug() << "[watcher] weird file!";
}
//-------------------------------------------------------------------------------------------
-// preparing URL loading
+// Preparations for URL load
//-------------------------------------------------------------------------------------------
-void fbgui::loadURL(){
+bool fbgui::checkHost() const
+{
+ QHostInfo hostInfo = QHostInfo::fromName(baseURL.host());
+ if (hostInfo.error() != QHostInfo::NoError){
+ qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << "failed. Exiting...";
+ return false;
+ }
+ else{
+ qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << " succeeded.";
+ return true;
+ }
+}
+//-------------------------------------------------------------------------------------------
+void fbgui::loadURL()
+{
// load if host is valid
if (checkHost()){
qxtLog->debug() << "[gui] Loading URL...";
@@ -147,20 +186,8 @@ void fbgui::loadURL(){
_watcher->disconnect(this);
}
//-------------------------------------------------------------------------------------------
-bool fbgui::checkHost() const
+QByteArray fbgui::generatePOSTData()
{
- QHostInfo hostInfo = QHostInfo::fromName(baseURL.host());
- if (hostInfo.error() != QHostInfo::NoError){
- qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << "failed. Exiting...";
- return false;
- }
- else{
- qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << " succeeded.";
- return true;
- }
-}
-//-------------------------------------------------------------------------------------------
-QByteArray fbgui::generatePOSTData(){
qxtLog->debug() << "[gui] Generating POST data...";
// hash testing
SysInfo si;
@@ -190,34 +217,22 @@ QByteArray fbgui::generatePOSTData(){
return postData;
}
//-------------------------------------------------------------------------------------------
-// setup debug console widget
+// Debug setup / control
//-------------------------------------------------------------------------------------------
-void fbgui::setupDebugSplit()
+void fbgui::setupBasicDebug()
{
- _debugConsole = new QTextEdit(this);
- _debugConsole->setWindowFlags(Qt::FramelessWindowHint);
- 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);
- // display browser and debug in a splitter
- _splitter = new QSplitter(Qt::Vertical, this);
- _splitter->addWidget(_webView);
- _splitter->addWidget(_debugConsole);
- // CTRL + D toggles debug window
- _toggleDebug = new QAction(tr("&toggleDebug"), this);
- _toggleDebug->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
- addAction(_toggleDebug);
- connect(_toggleDebug, SIGNAL(triggered()), this, SLOT(toggleDebug()));
- //_webView->load(QUrl("qrc:/html/loadAbout.html"));
- setCentralWidget(_splitter);
+ // start basic console debug log
+ if (debugMode == 0 || debugMode == 1){
+ qxtLog->disableLoggerEngine("DEFAULT");
+ qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std);
+ qxtLog->initLoggerEngine("std_logger");
+ qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel);
+ qxtLog->enableLogLevels(QxtLogger::DebugLevel);
+ qxtLog->debug() << "Initializing fbgui...";
+ }
}
//-------------------------------------------------------------------------------------------
-void fbgui::toggleDebug()
+void fbgui::toggleDebugConsole()
{
if (_debugConsole->isVisible())
_debugConsole->hide();