diff options
-rw-r--r-- | src/Dialog.cpp | 33 | ||||
-rw-r--r-- | src/Dialog.h | 3 | ||||
-rw-r--r-- | src/Globals.cpp | 1 | ||||
-rw-r--r-- | src/JavaScriptInterface.cpp | 191 | ||||
-rw-r--r-- | src/main.cpp | 40 |
5 files changed, 139 insertions, 129 deletions
diff --git a/src/Dialog.cpp b/src/Dialog.cpp index bc6a5a3..afe34bd 100644 --- a/src/Dialog.cpp +++ b/src/Dialog.cpp @@ -15,18 +15,17 @@ #include <QtGui> #include <QSizeGrip> -//#include <QSettings> +#include <QSettings> #include <QRect> #include <QWebView> #include <VSession.h> -//#include "QChooserTreeView.h" -//#include "QWebViewCustom.h" #include "JavaScriptInterface.h" -#include "Dialog.h" #include "Globals.h" +#include "Dialog.h" + void Dialog::setTheme() { @@ -34,14 +33,9 @@ Dialog::setTheme() } void -Dialog::showSettingsPVS() +Dialog::addItems(const QList<Session *> entries) { - -} - -void -Dialog::addItems(const QList<Session *> entries) { - jsi->addItems(entries); + jsi->addItems(entries); } void @@ -78,9 +72,11 @@ Dialog::Dialog(QWidget *parent) : #endif #if QT_VERSION >= 0x040700 - QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true); + QWebSettings::globalSettings()->setAttribute( + QWebSettings::LocalContentCanAccessFileUrls, true); #endif - QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); + QWebSettings::globalSettings()->setAttribute( + QWebSettings::LocalContentCanAccessRemoteUrls, true); //QWebSettings::globalSettings()->setAttribute(, true); webView->setUrl(QUrl("qrc:/html/index.html")); @@ -90,13 +86,8 @@ Dialog::Dialog(QWidget *parent) : setLayout(layout); jsi = new JavaScriptInterface(webView); - QObject::connect( - webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), - jsi, SLOT(attachToDOM()) - ); - QObject::connect( - jsi, SIGNAL(hideMainWindow()), - this, SLOT(hide()) - ); + QObject::connect(webView->page()->mainFrame(), + SIGNAL(javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM())); + QObject::connect(jsi, SIGNAL(hideMainWindow()), this, SLOT(hide())); } diff --git a/src/Dialog.h b/src/Dialog.h index 56786d3..2df9240 100644 --- a/src/Dialog.h +++ b/src/Dialog.h @@ -40,7 +40,6 @@ class Dialog : public QDialog public: explicit Dialog(QWidget *parent = 0); void setTheme(); - void showSettingsPVS(); void center(); void addItems(const QList<Session *> entries); @@ -49,7 +48,7 @@ class Dialog : public QDialog void createLayout(); QString readStyle(const QString &filename); - QVBoxLayout *layout; + QVBoxLayout *layout; JavaScriptInterface *jsi; diff --git a/src/Globals.cpp b/src/Globals.cpp index 9100ebb..5df8942 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -33,7 +33,6 @@ const QString globalConfFile(etcPath + "/emuchooser.conf"); const QString userConfFile(userPath + "/emuchooser.conf"); const QString previousSessionFile(userPath + "/emuchooser_prev_session"); -bool debugMode = false; bool pvsEnabled = false; QString pool; diff --git a/src/JavaScriptInterface.cpp b/src/JavaScriptInterface.cpp index dcae24b..dbb6e2e 100644 --- a/src/JavaScriptInterface.cpp +++ b/src/JavaScriptInterface.cpp @@ -15,129 +15,146 @@ #include <XSession.h> #include <XSessionHandler.h> +JavaScriptInterface::JavaScriptInterface(QWebView* parent) +{ + // TODO Auto-generated constructor stub - -JavaScriptInterface::JavaScriptInterface(QWebView* parent) { - // TODO Auto-generated constructor stub - - index = 1; - m_dom = parent->page()->mainFrame(); + index = 1; + m_dom = parent->page()->mainFrame(); } -JavaScriptInterface::~JavaScriptInterface() { - // TODO Auto-generated destructor stub +JavaScriptInterface::~JavaScriptInterface() +{ + // TODO Auto-generated destructor stub } -void JavaScriptInterface::addItems(const QList<Session *> entries) { - int i; - for(i=0; i<entries.size(); i++) { - m_data.insert(index + i, entries.at(i)); +void +JavaScriptInterface::addItems(const QList<Session *> entries) +{ + int i; + for (i = 0; i < entries.size(); i++) + { + m_data.insert(index + i, entries.at(i)); } - index = index + i; + index = index + i; } - -void JavaScriptInterface::attachToDOM() { - m_dom->addToJavaScriptWindowObject(QString("emuchooser"), this); +void +JavaScriptInterface::attachToDOM() +{ + m_dom->addToJavaScriptWindowObject(QString("emuchooser"), this); } -QVariantList JavaScriptInterface::getList() { - QVariantMap elem; - QVariantList list; +QVariantList +JavaScriptInterface::getList() +{ + QVariantMap elem; + QVariantList list; // qDebug() << "getList was called"; - QHashIterator<int, Session *> i(m_data); - while (i.hasNext()) { - i.next(); - elem.insert("title", i.value()->shortDescription()); - elem.insert("icon", i.value()->icon()); - elem.insert("id", i.key()); - list << elem; - elem.clear(); - } - - return list; + QHashIterator<int, Session *> i(m_data); + while (i.hasNext()) + { + i.next(); + elem.insert("title", i.value()->shortDescription()); + elem.insert("icon", i.value()->icon()); + elem.insert("id", i.key()); + list << elem; + elem.clear(); + } + + return list; } -QString JavaScriptInterface::getDetails(int id) { +QString +JavaScriptInterface::getDetails(int id) +{ // qDebug() << "getDetails was called"; - QString tpl, ret; - QFile file(":/html/detail"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return QString(); + QString tpl, ret; + QFile file(":/html/detail"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); - while (!file.atEnd()) { - QByteArray line = file.readLine(); - tpl.append(line); + while (!file.atEnd()) + { + QByteArray line = file.readLine(); + tpl.append(line); } + ret = + tpl.arg(m_data.value(id)->title()).arg(m_data.value(id)->screenshot()).arg( + m_data.value(id)->author()).arg(m_data.value(id)->creationDate()).arg( + m_data.value(id)->changeDate()).arg(m_data.value(id)->os()).arg( + m_data.value(id)->emulator()).arg(m_data.value(id)->description()); - ret = tpl.arg(m_data.value(id)->title()) - .arg(m_data.value(id)->screenshot()) - .arg(m_data.value(id)->author()) - .arg(m_data.value(id)->creationDate()) - .arg(m_data.value(id)->changeDate()) - .arg(m_data.value(id)->os()) - .arg(m_data.value(id)->emulator()) - .arg(m_data.value(id)->description()); - - return ret; + return ret; } - - -QString JavaScriptInterface::getFoo() { +QString +JavaScriptInterface::getFoo() +{ // qDebug() << "getFoo was called"; - return QString("foobar"); + return QString("foobar"); } -QString JavaScriptInterface::getAbout() { +QString +JavaScriptInterface::getAbout() +{ // qDebug() << "getAbout was called"; - QString ret; - QFile file(":/html/about"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return QString(); - - while (!file.atEnd()) { - QByteArray line = file.readLine(); - ret.append(line); + QString ret; + QFile file(":/html/about"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + + while (!file.atEnd()) + { + QByteArray line = file.readLine(); + ret.append(line); } - return ret; + return ret; } -QString JavaScriptInterface::getHelp() { +QString +JavaScriptInterface::getHelp() +{ // qDebug() << "getHelp was called"; - QString ret; - QFile file(":/html/help"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return QString(); - - while (!file.atEnd()) { - QByteArray line = file.readLine(); - ret.append(line); + QString ret; + QFile file(":/html/help"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + + while (!file.atEnd()) + { + QByteArray line = file.readLine(); + ret.append(line); } - return ret; + return ret; } -QString JavaScriptInterface::getWelcome() { +QString +JavaScriptInterface::getWelcome() +{ // qDebug() << "getWelcome was called"; - QString ret; - QFile file(":/html/welcome"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return QString(); - - while (!file.atEnd()) { - QByteArray line = file.readLine(); - ret.append(line); + QString ret; + QFile file(":/html/welcome"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + + while (!file.atEnd()) + { + QByteArray line = file.readLine(); + ret.append(line); } - return ret; + return ret; } -void JavaScriptInterface::run(int id) { - qDebug() << "start system: " << m_data.value(id)->title(); - emit hideMainWindow(); - m_data.value(id)->run(); +void +JavaScriptInterface::run(int id) +{ + qDebug() << "start system: " << m_data.value(id)->title(); + emit + hideMainWindow(); + m_data.value(id)->run(); } - diff --git a/src/main.cpp b/src/main.cpp index 839aa43..58c0584 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,25 +26,29 @@ #include "Globals.h" #include "Dialog.h" -bool myLessThan(Session* a, Session* b) { - return *a < *b; +bool +myLessThan(Session* a, Session* b) +{ + return *a < *b; } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { - QApplication a(argc, argv); + QApplication a(argc, argv); - VSessionHandler *vh = new VSessionHandler; - vh->setConfPath(etcPath); - vh->setFilterScript(filterScript + ".disabled"); - vh->setRunVmScript(runVmScript); + VSessionHandler *vh = new VSessionHandler; + vh->setConfPath(etcPath); + vh->setFilterScript(filterScript + ".disabled"); + vh->setRunVmScript(runVmScript); - /* read session files */ - QList<Session*> vsessions(vh->readXmlDir(vSessionPath)); + /* read session files */ + QList<Session*> vsessions(vh->readXmlDir(vSessionPath)); - Dialog *w = new Dialog; + Dialog *w = new Dialog; - if (vsessions.size()) { + if (vsessions.size()) + { // if (!(QFile::permissions(runVmScript) & QFile::ExeUser)) { // std::cerr << a.translate( // "Console", @@ -53,13 +57,13 @@ int main(int argc, char *argv[]) // << std::endl; // return EXIT_FAILURE; // } - qSort(vsessions.begin(), vsessions.end(), myLessThan); - w->addItems(vsessions); + qSort(vsessions.begin(), vsessions.end(), myLessThan); + w->addItems(vsessions); } - w->center(); - w->show(); + w->center(); + w->show(); - a.setActiveWindow(w); - return a.exec(); + a.setActiveWindow(w); + return a.exec(); } |