summaryrefslogblamecommitdiffstats
path: root/src/fbgui.cpp
blob: 6311b86a4d648b09fff4e00b082e2a5c82543873 (plain) (tree)
1
2
3
4
5
6
7
8
9
                  

                            
 
                   
               
               

                       
 



                                       
                                  
 
                           

                                               
 

                                                                   
                                 
                                                                            

                                                                                               




                                                                                               
 





                                         
                      
 
#include "fbgui.h"
#include "DownloadManager.h"
#include "JSObject.h"

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

QUrl baseURL(DEFAULT_URL);
QDir downloadDirectory("./downloads/");
bool debug = false;

fbgui::fbgui(QApplication *parent)
{
	/* Browser init. */
	QWebView* webView = new QWebView(this);
	webView->load(baseURL);

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

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

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

}
void fbgui::quit(){
	this->close();
}