--- infoscreen/MyWebView.cpp 2009/12/14 13:38:55 511 +++ infoscreen/MyWebView.cpp 2009/12/15 13:53:02 512 @@ -1,24 +1,26 @@ #include #include -#include #include #include "MyWebView.h" -MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { -// this->setWindowState( Qt::WindowFullScreen ); - qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); - - connect(this, SIGNAL( loadStarted() ), this, SLOT( test() ) ); +MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { + connect(this, SIGNAL( loadFinished(bool) ), this, SLOT( onChange(bool) ) ); + + QWebSettings* settings = QWebSettings::globalSettings(); + settings->setAttribute( QWebSettings::JavascriptEnabled, true); + settings->setAttribute( QWebSettings::PluginsEnabled, true); + + QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); timer->start(1000); + } -void MyWebView::show() { - QWebView::show(); +void MyWebView::start() { try { this->load( QUrl( generateUrl() ) ); } catch (std::exception& e) { @@ -35,17 +37,17 @@ QString MyWebView::generateUrl() { QDesktopWidget* desktop = QApplication::desktop(); - QRect rect = desktop->screenGeometry(); - - QString width; - width.setNum( rect.width() ); + QRect rect = desktop->screenGeometry(); - QString height; - height.setNum( rect.height() ); + + QString width, height; + width.setNum( rect.width() ); + height.setNum( rect.height() ); QSettings settings("Caddi", "infoscreen"); - std::cout << settings.fileName().toAscii().data() << std::endl; + qDebug() << "Settings: " << settings.fileName(); + QString url = settings.value("url").toString(); QString screenid = settings.value("screenid").toString(); @@ -58,24 +60,17 @@ url.append("&height=").append(height); - std::cout << url.toAscii().data() << std::endl; + qDebug() << "URL:" << url; + return url; } //public slots: -void MyWebView::test() { - std::cout << "test" << std::endl; +void MyWebView::onChange(bool success) { + //qDebug() << "html" << this->page()->mainFrame()->toHtml(); } void MyWebView::onTimer() { - static int count = 0; - count++; - - if (count == 10) { - system("xset dpms force off"); - } - - std::cout << "timer" << std::endl; }