diff options
author | Jonathan Bauer | 2011-04-18 02:13:18 +0200 |
---|---|---|
committer | Jonathan Bauer | 2011-04-18 02:13:18 +0200 |
commit | e512c756586d5509ac11759bae40f7911fe0f948 (patch) | |
tree | 65873adce9fa6401026b1b4c89f12a1e8868e3c2 /src/javascriptinterface.cpp | |
parent | cursor hidden by QWSServer, added loading animation for preload page, started... (diff) | |
download | fbgui-e512c756586d5509ac11759bae40f7911fe0f948.tar.gz fbgui-e512c756586d5509ac11759bae40f7911fe0f948.tar.xz fbgui-e512c756586d5509ac11759bae40f7911fe0f948.zip |
uniformed formatting...
Diffstat (limited to 'src/javascriptinterface.cpp')
-rw-r--r-- | src/javascriptinterface.cpp | 95 |
1 files changed, 49 insertions, 46 deletions
diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp index 634b478..ea25855 100644 --- a/src/javascriptinterface.cpp +++ b/src/javascriptinterface.cpp @@ -2,7 +2,6 @@ #include "javascriptinterface.h" #include "sysinfo.h" - //------------------------------------------------------------------------------------------------------- // Initialisation //------------------------------------------------------------------------------------------------------- @@ -12,15 +11,16 @@ * @param parent * Is of type QWebFrame. */ -JavascriptInterface::JavascriptInterface(QWebFrame *parent){ - qxtLog->debug() << "Initializing javascript interface..."; - _parent = parent; +JavascriptInterface::JavascriptInterface(QWebFrame *parent) { + qxtLog->debug() << "Initializing javascript interface..."; + _parent = parent; } //------------------------------------------------------------------------------------------------------- /** * An empty destructor. */ -JavascriptInterface::~JavascriptInterface() { /* destructor dummy */ } +JavascriptInterface::~JavascriptInterface() { /* destructor dummy */ +} //------------------------------------------------------------------------------------------------------- /** * Attaches an instance of this class to the DOM of the HTML page. @@ -32,9 +32,9 @@ JavascriptInterface::~JavascriptInterface() { /* destructor dummy */ } * * @see JavascriptInterface::loadJQuery() */ -void JavascriptInterface::attachToDOM(){ - _parent->addToJavaScriptWindowObject(QString("fbgui"), this); - loadJQuery(); +void JavascriptInterface::attachToDOM() { + _parent->addToJavaScriptWindowObject(QString("fbgui"), this); + loadJQuery(); } //------------------------------------------------------------------------------------------------------- /** @@ -48,7 +48,7 @@ void JavascriptInterface::attachToDOM(){ * * @see JavascriptInterface::attachToDOM() */ -void JavascriptInterface::loadJQuery(){ +void JavascriptInterface::loadJQuery() { QString js; QString pathToJsDir(DEFAULT_QRC_HTML_DIR); pathToJsDir.append("/js"); @@ -57,24 +57,22 @@ void JavascriptInterface::loadJQuery(){ QFileInfoList fiList = qrcJSDir.entryInfoList(); QFileInfo fi; foreach(fi, fiList) - { - if(fi.suffix() == "js") { - //qDebug()<< fi.fileName(); - //qxtLog->debug() << fi.fileName(); - if(fi.fileName()!="test.js") - { - QFile file; - file.setFileName(pathToJsDir + "/" + fi.fileName()); - file.open(QIODevice::ReadOnly); - js = file.readAll(); - file.close(); + if (fi.suffix() == "js") { + //qDebug()<< fi.fileName(); + //qxtLog->debug() << fi.fileName(); + if (fi.fileName() != "test.js") { + QFile file; + file.setFileName(pathToJsDir + "/" + fi.fileName()); + file.open(QIODevice::ReadOnly); + js = file.readAll(); + file.close(); - _parent->evaluateJavaScript(js); - //qxtLog->debug() << "evaluated " + fi.fileName(); + _parent->evaluateJavaScript(js); + //qxtLog->debug() << "evaluated " + fi.fileName(); + } } } - } } //------------------------------------------------------------------------------------------------------- // Javascript functions for webpage @@ -86,13 +84,13 @@ void JavascriptInterface::loadJQuery(){ * Can be called from inside a JavaScript function of the HTML page. * Emits the JavascriptInterface::requestFile(const QString) signal. */ -void JavascriptInterface::startDownload(const QString& filename){ - // ignore if empty filename - if (filename.isEmpty()){ - _parent->evaluateJavaScript("alert(\"No filename!\")"); - return; - } - emit requestFile(filename); +void JavascriptInterface::startDownload(const QString& filename) { + // ignore if empty filename + if (filename.isEmpty()) { + _parent->evaluateJavaScript("alert(\"No filename!\")"); + return; + } + emit requestFile(filename); } //------------------------------------------------------------------------------------------------------- /** @@ -103,7 +101,7 @@ void JavascriptInterface::startDownload(const QString& filename){ * * @todo add some more informations */ -void JavascriptInterface::setCallbackOnFinished(const QString& function){ +void JavascriptInterface::setCallbackOnFinished(const QString& function) { qxtLog->debug() << "[jsi] Callback set: " << function; _callbackOnDownloadsFinished = QString(function); } @@ -128,7 +126,7 @@ void JavascriptInterface::setCallbackOnFinished(const QString& function){ * * @see SysInfo::getInfo(const QString& infoName) */ -const QString JavascriptInterface::getSysInfo(const QString& info){ +const QString JavascriptInterface::getSysInfo(const QString& info) { SysInfo si; return si.getInfo(info); } @@ -140,7 +138,7 @@ const QString JavascriptInterface::getSysInfo(const QString& info){ * Can be called from inside a JavaScript function of the HTML page. * Emits JavascriptInterface::quitFbgui() signal */ -void JavascriptInterface::quit(){ +void JavascriptInterface::quit() { emit quitFbgui(); } //------------------------------------------------------------------------------------------------------- @@ -153,9 +151,11 @@ void JavascriptInterface::quit(){ * * @todo add some more informations */ -void JavascriptInterface::downloadInfo(const QString& filename, const double& filesize){ - QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(filesize); - _parent->evaluateJavaScript(code); +void JavascriptInterface::downloadInfo(const QString& filename, + const double& filesize) { + QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg( + filesize); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- /** @@ -166,10 +166,13 @@ void JavascriptInterface::downloadInfo(const QString& filename, const double& fi * * @todo add some more informations */ -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::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); } //------------------------------------------------------------------------------------------------------- /** @@ -177,7 +180,7 @@ void JavascriptInterface::updateProgressBar(const int& percent, const double& sp * * @todo add some more informations. */ -void JavascriptInterface::notify(const QString& msg){ +void JavascriptInterface::notify(const QString& msg) { qxtLog->debug() << "[jsi] Notifying: " << msg; QString code = QString("notify('\%1')").arg(msg); _parent->evaluateJavaScript(code); @@ -186,9 +189,9 @@ void JavascriptInterface::notify(const QString& msg){ /** * @todo add some more informations */ -void JavascriptInterface::callbackOnFinished(){ - QString code = QString("\%1").arg(_callbackOnDownloadsFinished); - _parent->evaluateJavaScript(code); +void JavascriptInterface::callbackOnFinished() { + QString code = QString("\%1").arg(_callbackOnDownloadsFinished); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- @@ -206,9 +209,9 @@ void JavascriptInterface::callbackOnFinished(){ * @see bool fbgui::checkHost() * @see void fbgui::loadURL() */ -void JavascriptInterface::trigger(){ +void JavascriptInterface::trigger() { QFile file(fileToTriggerURL); - if (file.open(QIODevice::WriteOnly)){ + if (file.open(QIODevice::WriteOnly)) { file.write("data\n"); qxtLog->debug() << "[jsi] *trigger watcher*"; } |