summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-08 10:51:47 +0100
committerJonathan Bauer2011-03-08 10:51:47 +0100
commite70ac1752845a57696ad827032d746db752aa9f0 (patch)
tree45f8ba5ebbf20212ffcb47add439ed419e205c08 /src
parent.. (diff)
downloadfbgui-e70ac1752845a57696ad827032d746db752aa9f0.tar.gz
fbgui-e70ac1752845a57696ad827032d746db752aa9f0.tar.xz
fbgui-e70ac1752845a57696ad827032d746db752aa9f0.zip
renamed JSObject to a more appropriate name..
Diffstat (limited to 'src')
-rw-r--r--src/fbgui.cpp12
-rw-r--r--src/fbgui.pro4
-rw-r--r--src/javascriptInterface.cpp (renamed from src/JSObject.cpp)18
-rw-r--r--src/javascriptInterface.h (renamed from src/JSObject.h)12
-rw-r--r--src/main.cpp98
5 files changed, 71 insertions, 73 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 6311b86..da72c21 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -1,6 +1,6 @@
#include "fbgui.h"
#include "DownloadManager.h"
-#include "JSObject.h"
+#include "javascriptInterface.h"
#include <iostream>
#include <QUrl>
@@ -19,16 +19,16 @@ fbgui::fbgui(QApplication *parent)
webView->load(baseURL);
/* Init JavaScript interface */
- JSObject* jso = new JSObject(webView->page()->mainFrame());
+ javascriptInterface* jsi = new javascriptInterface(webView->page()->mainFrame());
// this still looks bad..
- QObject::connect(jso, SIGNAL(signalQuitAll()), this, SLOT(close()));
+ QObject::connect(jsi, SIGNAL(signalQuitAll()), this, SLOT(close()));
QObject::connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
- jso, SLOT(attachToDOM()));
+ jsi, 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)));
+ QObject::connect(jsi, SIGNAL(requestFile(QString&)), dm, SLOT(downloadFile(QString&)));
+ QObject::connect(dm, SIGNAL(updateProgress(int)), jsi, SLOT(updateProgressBar(int)));
setWindowFlags(Qt::SplashScreen);
showFullScreen();
diff --git a/src/fbgui.pro b/src/fbgui.pro
index 4c065de..ad6c6fd 100644
--- a/src/fbgui.pro
+++ b/src/fbgui.pro
@@ -7,12 +7,12 @@ QT += core \
webkit \
network
HEADERS += fbgui.h \
- JSObject.h \
+ javascriptInterface.h \
DownloadManager.h \
sysInfo.h
SOURCES += main.cpp \
fbgui.cpp \
- JSObject.cpp \
+ javascriptInterface.cpp \
DownloadManager.cpp \
sysInfo.cpp
FORMS +=
diff --git a/src/JSObject.cpp b/src/javascriptInterface.cpp
index 11f91c6..98efdb7 100644
--- a/src/JSObject.cpp
+++ b/src/javascriptInterface.cpp
@@ -1,24 +1,24 @@
/*
- * jsObject.cpp
+ * jsObject.cpp javascriptInterface
*
* Created on: Feb 1, 2011
* Author: niklas
*/
#include "fbgui.h"
-#include "JSObject.h"
+#include "javascriptInterface.h"
#include "sysInfo.h"
//-------------------------------------------------------------------------------------------------------
-JSObject::JSObject(QWebFrame *parent) {
+javascriptInterface::javascriptInterface(QWebFrame *parent) {
// check for better way to use evaluateJavaScript()
_parent = parent;
}
//-------------------------------------------------------------------------------------------------------
-JSObject::~JSObject() {}
+javascriptInterface::~javascriptInterface() {}
//-------------------------------------------------------------------------------------------------------
/* TEST */
-QString JSObject::getSysInfo(QString info)
+QString javascriptInterface::getSysInfo(QString info)
{
sysInfo si;
if (debug) qDebug() << "Requested info: " << info;
@@ -34,13 +34,13 @@ QString JSObject::getSysInfo(QString info)
return "no value";
}
//-------------------------------------------------------------------------------------------------------
-void JSObject::attachToDOM()
+void javascriptInterface::attachToDOM()
{
// Attaches itself to the DOM
_parent->addToJavaScriptWindowObject(QString("jsObject"), this);
}
//-------------------------------------------------------------------------------------------------------
-void JSObject::startDownload(QString filename)
+void javascriptInterface::startDownload(QString filename)
{
/* return if no filename in input field */
if (filename.isEmpty())
@@ -53,7 +53,7 @@ void JSObject::startDownload(QString filename)
}
//-------------------------------------------------------------------------------------------------------
-void JSObject::updateProgressBar(int i)
+void javascriptInterface::updateProgressBar(int i)
{
if (i == 0)
return;
@@ -62,7 +62,7 @@ void JSObject::updateProgressBar(int i)
}
//-------------------------------------------------------------------------------------------------------
-void JSObject::quitAll()
+void javascriptInterface::quitAll()
{
if (debug) qDebug() << "Quit signal.";
emit signalQuitAll();
diff --git a/src/JSObject.h b/src/javascriptInterface.h
index f11ddf1..21f994a 100644
--- a/src/JSObject.h
+++ b/src/javascriptInterface.h
@@ -7,21 +7,21 @@
* Those javascript functions are writen in a seperate file: jsFunktions.js
*/
-#ifndef JSOBJECT_H_
-#define JSOBJECT_H_
+#ifndef JAVASCRIPTINTERFACE_H_
+#define JAVASCRIPTINTERFACE_H_
#include "fbgui.h"
-class JSObject : public QObject{
+class javascriptInterface : public QObject{
Q_OBJECT
private:
QWebFrame* _parent;
public:
- JSObject(QWebFrame* parent);
- virtual ~JSObject();
+ javascriptInterface(QWebFrame* parent);
+ virtual ~javascriptInterface();
signals:
void requestFile(QString& filename);
@@ -35,4 +35,4 @@ public slots:
void quitAll();
};
-#endif /* JSOBJECT_H_ */
+#endif /* JAVASCRIPTINTERFACE_H_ */
diff --git a/src/main.cpp b/src/main.cpp
index 2897403..ac545d8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,12 +15,14 @@ void printHelp()
qout << "-u <URL>, --url=<URL> " << QObject::tr("Set which URL to load.") << endl;
qout << "-d, --debug " << QObject::tr("Activate debug mode.") << endl;
qout << "-h, --help " << QObject::tr("Prints usage information.") << endl;
+ qout.flush();
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
{
- debug = false;
- QApplication app(argc, argv, QApplication::GuiServer);
+ debug = false;
+ QApplication app(argc, argv, QApplication::GuiServer);
app.setOrganizationName("team_projekt_2011");
app.setApplicationName("prebootGUI");
app.setObjectName("test");
@@ -33,24 +35,24 @@ int main(int argc, char *argv[])
/* Parse cmdline argus. */
QMap<QString, QString> clo;
- int longIndex = 0;
- static const char *optString = "u:hDd";
- static const struct option longOpts[] =
- {
- {"url", required_argument, NULL, 'u'},
- {"downloadtodir", required_argument, NULL, 'd'},
- {"debug", no_argument, NULL, 'D'},
- {"help", no_argument, NULL, 'h'}
- };
- int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- while (opt != -1)
- {
- switch(opt)
- {
- case 'u':
- clo.insert("url", optarg);
- break;
- case 'd':
+ int longIndex = 0;
+ static const char *optString = "u:hDd";
+ static const struct option longOpts[] =
+ {
+ {"url", required_argument, NULL, 'u'},
+ {"downloadtodir", required_argument, NULL, 'd'},
+ {"debug", no_argument, NULL, 'D'},
+ {"help", no_argument, NULL, 'h'}
+ };
+ int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ while (opt != -1)
+ {
+ switch(opt)
+ {
+ case 'u':
+ clo.insert("url", optarg);
+ break;
+ case 'd':
clo.insert("downloadDir", optarg);
break;
case 'D':
@@ -59,39 +61,35 @@ int main(int argc, char *argv[])
case 'h':
clo.insert("help", "help");
break;
- }
- opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
- }
- // Print help
- if (clo.contains("help")){
- printHelp();
- exit(EXIT_SUCCESS);
}
- // Debug mode
- if (clo.contains("debug")){
- debug = true;
- qDebug() << "Debug mode activated.";
- }
- else
- debug = false;
- // Read the config file, for now hardcoded expected name.
- QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat);
- confFileSettings.setIniCodec("UTF-8");
+ opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
+ }
+ // Print help
+ if (clo.contains("help"))
+ printHelp();
+ // Debug mode
+ if (clo.contains("debug"))
+ debug = true;
+ else
+ debug = false;
+ // Read the config file, for now hardcoded expected name.
+ QSettings confFileSettings(app.applicationDirPath() + "/fbgui.conf", QSettings::IniFormat);
+ confFileSettings.setIniCodec("UTF-8");
- if (clo.contains("url"))
- baseURL = QUrl(clo.value("url"));
- else if (confFileSettings.contains("default/url"))
- baseURL = confFileSettings.value("default/url").toUrl();
- else
- baseURL = DEFAULT_URL;
+ if (clo.contains("url"))
+ baseURL = QUrl(clo.value("url"));
+ else if (confFileSettings.contains("default/url"))
+ baseURL = confFileSettings.value("default/url").toUrl();
+ else
+ baseURL = DEFAULT_URL;
- if (clo.contains("downloadDir"))
- downloadDirectory = QDir(clo.value("downloadDir"));
- else if (confFileSettings.contains("default/downloadDirectory"))
- downloadDirectory = QDir(confFileSettings.value("default/downloadDirectory").toString());
- else
- downloadDirectory = QDir(".");
- // Start fbgui.
+ if (clo.contains("downloadDir"))
+ downloadDirectory = QDir(clo.value("downloadDir"));
+ else if (confFileSettings.contains("default/downloadDirectory"))
+ downloadDirectory = QDir(confFileSettings.value("default/downloadDirectory").toString());
+ else
+ downloadDirectory = QDir(".");
+ // Start fbgui.
fbgui gui(&app);
gui.show();
return app.exec();