blob: e9ae7d4461affad2502007f35ee6d6bc66c0c233 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include "fbgui.h"
#include "javascriptinterface.h"
#include "sysinfo.h"
//-------------------------------------------------------------------------------------------------------
JavascriptInterface::JavascriptInterface(QWebFrame *parent){
qxtLog->debug() << "Initializing javascript interface...";
_parent = parent;
}
//-------------------------------------------------------------------------------------------------------
JavascriptInterface::~JavascriptInterface() {}
//-------------------------------------------------------------------------------------------------------
const QString JavascriptInterface::getSysInfo(const QString& info){
SysInfo si;
return si.getInfo(info);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::attachToDOM(){
_parent->addToJavaScriptWindowObject(QString("fbgui"), this);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::notify(const QString& msg){
qxtLog->debug() << "Notifying: " << msg;
QString code = QString("notify('\%1')").arg(msg);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::getSession(const QString& session){
qxtLog->debug() << "Received session id: " << session;
sessionID = session;
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::startDownload(const QString& filename){
// ignore if empty filename
if (filename.isEmpty()){
_parent->evaluateJavaScript("alert(\"No filename!\")");
return;
}
emit requestFile(filename);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::downloadInfo(const QString& filename, const double& filesize){
QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(filesize);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::updateProgressBar(const int& percent, const double& speed, const QString& unit){
if (percent == 0) return;
QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(speed).arg(unit);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::setCallbackOnDlQueueFinished(QString& jsFunction){
_callBackOnDownloadsFinished = jsFunction;
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::callbackOnDlQueueFinished(){
QString code = QString("\%1").arg(_callBackOnDownloadsFinished);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
void JavascriptInterface::quit(){
emit quitFbgui();
}
|