diff options
| author | Jonathan Bauer | 2011-03-20 19:37:58 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-20 19:37:58 +0100 |
| commit | 3e76f5ca4439ae87f436080b840dba180fb842d3 (patch) | |
| tree | f02a320058973ec60fa85a84491ce222c513aefd /src/javascriptInterface.cpp | |
| parent | debug console dummy only shown if debug mode active (diff) | |
| download | fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.tar.gz fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.tar.xz fbgui-3e76f5ca4439ae87f436080b840dba180fb842d3.zip | |
debug console now powered by qxt, custom engines, updated debug msgs. Download manager now uses notify(message) to send error/status to the javascript interface, checks for download errors (still some missing)
Diffstat (limited to 'src/javascriptInterface.cpp')
| -rw-r--r-- | src/javascriptInterface.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/javascriptInterface.cpp b/src/javascriptInterface.cpp index c4dd61b..1a9b470 100644 --- a/src/javascriptInterface.cpp +++ b/src/javascriptInterface.cpp @@ -5,26 +5,23 @@ //------------------------------------------------------------------------------------------------------- javascriptInterface::javascriptInterface(QWebFrame *parent) { + qxtLog->debug() << "Initializing javascript interface..."; //TODO: check for better way to use evaluateJavaScript() _parent = parent; } //------------------------------------------------------------------------------------------------------- javascriptInterface::~javascriptInterface() {} //------------------------------------------------------------------------------------------------------- -QString javascriptInterface::getSysInfo(QString info) -{ +QString javascriptInterface::getSysInfo(QString info){ sysInfo si; - if (debug) qDebug() << "Requested info: " << info << endl; return si.getInfo(info); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::attachToDOM() -{ +void javascriptInterface::attachToDOM(){ _parent->addToJavaScriptWindowObject(QString("fbgui"), this); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::startDownload(QString filename) -{ +void javascriptInterface::startDownload(QString filename){ /* ignore if empty filename */ if (filename.isEmpty()){ _parent->evaluateJavaScript("alert(\"No filename!\")"); @@ -33,33 +30,33 @@ void javascriptInterface::startDownload(QString filename) emit requestFile(filename); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::downloadInfo(QString filename, double filesize) -{ +void javascriptInterface::downloadInfo(QString filename, double filesize){ QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(filesize); _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::updateProgressBar(int percent, double speed, QString unit) -{ +void javascriptInterface::notify(QString msg){ + + QString code = QString("notify('\%1')").arg(msg); + _parent->evaluateJavaScript(code); + return; +} +//------------------------------------------------------------------------------------------------------- +void javascriptInterface::updateProgressBar(int percent, double speed, QString unit){ if (percent == 0) return; QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(speed).arg(unit); - if (debug) qDebug() << "To JS: " << code; _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::setCallbackOnDlQueueFinished(QString jsFunction) -{ +void javascriptInterface::setCallbackOnDlQueueFinished(QString jsFunction){ callBackOnDownloadsFinished = jsFunction; } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::callbackOnDlQueueFinished() -{ +void javascriptInterface::callbackOnDlQueueFinished(){ QString code = QString("\%1").arg(callBackOnDownloadsFinished); _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void javascriptInterface::quit() -{ - if (debug) qDebug() << "Quit signal."; +void javascriptInterface::quit(){ emit quitFbgui(); } |
