summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
blob: ac078e04a37760760591648f0cd365225d0a6c3b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "fbgui.h"
#include "DownloadManager.h"
#include "javascriptInterface.h"

#include <iostream>
#include <QUrl>
#include <QDir>
#include <QtWebKit>
#include <QApplication>

// Note: Absolute paths. binPath empty init, set in main() after QApplication instanciated.
QString binPath("");
QString downloadPath(binPath + "/downloads");
QUrl baseURL(DEFAULT_URL);
bool debug = false;

fbgui::fbgui(QApplication *parent)
{
	if (debug) qDebug() << "Application dir path: " << QApplication::applicationDirPath();
	/* Browser init. */
	QWebView* webView = new QWebView(this);
	webView->load(baseURL);

	/* Init JavaScript interface */
	javascriptInterface* jsi = new javascriptInterface(webView->page()->mainFrame());
	// this still looks bad..
	QObject::connect(jsi, SIGNAL(signalQuitAll()), this, SLOT(close()));
	QObject::connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
						  jsi, SLOT(attachToDOM()));

	/* Init Download Manager */
	DownloadManager* dm = new DownloadManager();
	QObject::connect(jsi, SIGNAL(requestFile(QString&)), dm, SLOT(downloadFile(QString&)));
	QObject::connect(dm, SIGNAL(updateProgress(int)), jsi, SLOT(updateProgressBar(int)));

	setWindowFlags(Qt::SplashScreen);
	showFullScreen();
	setCentralWidget(webView);

}