--- infoscreen/MyWebView.cpp 2009/12/12 17:48:23 508 +++ infoscreen/webview.cpp 2010/06/24 09:44:57 884 @@ -1,81 +1,54 @@ #include #include -#include #include -#include "MyWebView.h" +#include "webview.h" -MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { -// this->setWindowState( Qt::WindowFullScreen ); - qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); - - connect(this, SIGNAL( loadStarted() ), this, SLOT( test() ) ); - - QTimer* timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); - timer->start(1000); +WebView::WebView(QWidget* parent) : QWebView(parent) { + + QWebSettings* settings = QWebSettings::globalSettings(); + settings->setAttribute( QWebSettings::JavascriptEnabled, true); + settings->setAttribute( QWebSettings::PluginsEnabled, true); } -void MyWebView::show() { - QWebView::show(); - try { - this->load( QUrl( generateUrl() ) ); - } catch (std::exception& e) { - showError(e.what() ); - } +void WebView::start(QString url, QString screenid) { + try { + this->load( QUrl( generateUrl(url, screenid) ) ); + } catch (std::exception& e) { + showError(e.what() ); + } } -void MyWebView::showError(const char* msg) { - QString str("

"); - str.append(msg).append("

"); - this->setHtml( str ); +void WebView::showError(const char* msg) { + QString str("

"); + str.append(msg).append("

"); + this->setHtml( str ); } -QString MyWebView::generateUrl() { - QDesktopWidget* desktop = QApplication::desktop(); - QRect rect = desktop->screenGeometry(); - - QString width; - width.setNum( rect.width() ); - - QString height; - height.setNum( rect.height() ); - - - QSettings settings("Caddi", "infoscreen"); - std::cout << settings.fileName().toAscii().data() << std::endl; - QString url = settings.value("url").toString(); - QString screenid = settings.value("screenid").toString(); - - if (url.length() == 0) { - throw std::runtime_error("No url in config file"); - } - - url.append("?screen_id=").append(screenid); - url.append("&width=").append(width); - url.append("&height=").append(height); +QString WebView::generateUrl(QString url, QString screenid) { + QDesktopWidget* desktop = QApplication::desktop(); + QRect rect = desktop->screenGeometry(); - std::cout << url.toAscii().data() << std::endl; + QString width, height; + width.setNum( rect.width() ); + height.setNum( rect.height() ); - return url; -} -//public slots: -void MyWebView::test() { - std::cout << "test" << std::endl; -} + if (url.length() == 0) { + throw std::runtime_error("No url in config file"); + } + + url.append("?screen_id=").append(screenid); + url.append("&width=").append(width); + url.append("&height=").append(height); -void MyWebView::onTimer() { - static int count = 0; - count++; - - if (count == 10) { - system("xset dpms force off"); - } - - std::cout << "timer" << std::endl; + qDebug() << "URL:" << url; + + + return url; } +