--- infoscreen/MainView.cpp 2010/01/07 19:42:12 534 +++ infoscreen/MainView.cpp 2010/01/08 21:53:23 537 @@ -6,6 +6,8 @@ #include #include +#include +#include #include "MyWebView.h" #include "clientsiderender.h" @@ -16,8 +18,22 @@ MainView::MainView(QWidget* parent) - : QWidget(parent) + : QWidget(parent), timer(0) { + + settings = new QSettings("Caddi", "infoscreen"); + url = settings->value("url").toString(); + bool xmlMode = settings->value("xml").toBool(); + screenid = settings->value("screenid").toString(); + + if (url == "" || screenid == "") { + QMessageBox::warning(this,"infoscreen","Could not find url or screenid in config file " + settings->fileName()); + + exit(1); //Normal qApp->exit() doesn't terminate the init sequence so use std C exit function + } + + + this->resize(400,400); this->setWindowState( Qt::WindowFullScreen ); this->grabKeyboard(); @@ -47,17 +63,33 @@ - QTimer* timer = new QTimer(this); - connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() )); - timer->start(100); + if (xmlMode == true) { + xmlUrl = url + "?screen_id=" + screenid; + qDebug() << "Starting XML mode"; + qDebug() << "xmlUrl" << xmlUrl; + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() )); + timer->start(100); + } else { + qDebug() << "Starting plain browser mode"; + web->setVisible(true); + web->start(url,screenid); + } +} + +void MainView::closeEvent ( QCloseEvent * event ) +{ + Q_UNUSED(event); + exit(0); //force application shutdown } void MainView::keyPressEvent ( QKeyEvent* event ) { int key = event->key(); if (key == ' ' || key == Qt::Key_Return || key == Qt::Key_Enter) { - qApp->quit(); + close(); } } @@ -76,7 +108,9 @@ const int TIMEOUT = 30*60*1000; // 30 minutter if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) { - xmlHandler.readXml( "http://infoscreen.sundhedhorsens.dk/infoscreen/screen_xml.php?screen_id=1" ); + + bool res = xmlHandler.readXml( xmlUrl ); + if (res == false) lastXml = QTime::currentTime(); @@ -94,6 +128,9 @@ void MainView::switchScreens() { + if (video->isVisible() && video->isPlaying() ) { + return; //wait until current clip has finished + } if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) { @@ -123,17 +160,34 @@ picture->loadFromUrl( currentItem.url ); } + if (currentItem.module == "info_web") { + ensureVisible(web); + web->load(currentItem.url); + } + if (currentItem.module == "info_video") { + ensureVisible(video); + video->loadUrl(currentItem.url); + } } else { qDebug() << "no screen"; - hideAll(); + noInfoScreen(); } lastScreenSwitch = QTime::currentTime(); } } +void MainView::noInfoScreen() +{ + ensureVisible(web); + web->setHtml("\ + \ +

Der er ingen information at vise

\ + "); +} + void MainView::ensureVisible(QWidget* widget) { if (! widget->isVisible()) {