/[projects]/infoscreen/mainview.cpp
ViewVC logotype

Diff of /infoscreen/mainview.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 872 by torben, Tue Jun 22 07:24:14 2010 UTC revision 902 by torben, Fri Jun 25 07:17:40 2010 UTC
# Line 1  Line 1 
1  #include "MainView.h"  #include "mainview.h"
2  #include <QApplication>  #include <QApplication>
3  #include <QPushButton>  #include <QPushButton>
4  #include <QLabel>  #include <QLabel>
# Line 10  Line 10 
10  #include <QSettings>  #include <QSettings>
11  #include <QMessageBox>  #include <QMessageBox>
12    
13  #include "MyWebView.h"  #include "webview.h"
14  #include "clientsiderender.h"  #include "clientsiderender.h"
15  #include "pictureview.h"  #include "pictureview.h"
16  #include "videoview.h"  #include "videoview.h"
17    #include "clockoverlay.h"
18  #include "httpwrapper.h"  #include "httpwrapper.h"
19    #include "screenmanager.h"
20    
21    
22    
# Line 28  MainView::MainView(QWidget* parent) Line 29  MainView::MainView(QWidget* parent)
29          xmlUrl = url + "?screen_id=" + screenid;          xmlUrl = url + "?screen_id=" + screenid;
30          qDebug() << "Starting XML mode";          qDebug() << "Starting XML mode";
31          qDebug() << "xmlUrl" << xmlUrl;          qDebug() << "xmlUrl" << xmlUrl;
32            qDebug() << "xmlInterval" << xmlInterval/(60*1000);
33      }      }
34    
35      if (currentMode == ModeSimpleWeb){      if (currentMode == ModeSimpleWeb){
# Line 49  MainView::MainView(QWidget* parent) Line 51  MainView::MainView(QWidget* parent)
51    
52      render = new ClientSideRender(this);      render = new ClientSideRender(this);
53    
54      web = new MyWebView(this);      web = new WebView(this);
55    
56      picture = new PictureView(this);      picture = new PictureView(this);
57    
# Line 66  MainView::MainView(QWidget* parent) Line 68  MainView::MainView(QWidget* parent)
68      layout->setContentsMargins(0,0,0,0);      layout->setContentsMargins(0,0,0,0);
69      setLayout(layout);      setLayout(layout);
70    
71        if (showClock == true) {
72            clockOverlay = new ClockOverlay(this);
73            clockOverlay->move(10,10);
74            clockOverlay->resize(150,75);
75        }
76    
77        
78    
79      if (currentMode == ModeSimpleWeb) {      if (currentMode == ModeSimpleWeb) {
80          web->setVisible(true);          web->setVisible(true);
81          web->start(url,screenid);          web->start(url,screenid);
82      }      }
83    
84      if (currentMode == ModeXml || currentMode == ModeLocal) {      if (enableScreenManager) {
85          qDebug() << "Starting timer...";          screenManager = new ScreenManager(screenManagerOn, screenManagerOff);
86          timer = new QTimer(this);      } else {
87          connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));          qDebug() << "ScreenManager is disabled";
         timer->start(100);  
88      }      }
89    
90    
91        qDebug() << "Starting timer...";
92        timer = new QTimer(this);
93        connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));
94        timer->start(100);
95  }  }
96    
97  void MainView::loadSettings()  void MainView::loadSettings()
# Line 98  void MainView::loadSettings() Line 113  void MainView::loadSettings()
113          exit(1);          exit(1);
114      }      }
115    
116        enableScreenManager = settings->value("enablescreenmanager").toBool();
117        if (enableScreenManager) {
118            screenManagerOn = settings->value("screenmanager_on").toTime();
119            screenManagerOff = settings->value("screenmanager_off").toTime();
120        }
121    
122        showClock = settings->value("showclock").toBool();
123    
124        xmlInterval = settings->value("xmlinterval", 30).toInt();
125        xmlInterval = (xmlInterval * 60 * 1000); //convert to milliseconds
126    
127    
128      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {
129          url = settings->value("url").toString();          url = settings->value("url").toString();
# Line 135  void MainView::keyPressEvent ( QKeyEvent Line 161  void MainView::keyPressEvent ( QKeyEvent
161    
162  void MainView::onTimer()  void MainView::onTimer()
163  {  {
164      screenManager.timerTick();      if (enableScreenManager == true) {
165            screenManager->timerTick();
166        }
167    
168      if (currentMode == ModeXml) {      if (currentMode == ModeXml) {
169          readXml();          readXml();
170      }      }
171    
172      switchScreens();      if (currentMode == ModeXml || currentMode == ModeLocal) {
173            switchScreens();
174        }
175        if (showClock == true) {
176            clockOverlay->timerTick();
177        }
178  }  }
179    
180    
# Line 195  void MainView::readLocalFiles() Line 228  void MainView::readLocalFiles()
228    
229  bool MainView::readXml()  bool MainView::readXml()
230  {  {
231      const int TIMEOUT = 30*60*1000; // 30 minutter      if ( lastXml.isNull() || lastXml.elapsed() > xmlInterval) {
232      if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) {          qDebug() << "Reading XML";
233    
234    
235          bool res = xmlHandler.readXml( xmlUrl );          bool res = xmlHandler.readXml( xmlUrl );
# Line 222  void MainView::switchScreens() Line 255  void MainView::switchScreens()
255      }      }
256    
257      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {
   
258          QTime now = QTime::currentTime();          QTime now = QTime::currentTime();
259          if (lastScreenSwitch.isNull())          if (lastScreenSwitch.isNull())
260              currentItemIdx = -1;              currentItemIdx = -1;
# Line 269  void MainView::switchScreens() Line 301  void MainView::switchScreens()
301              }              }
302    
303          } else {          } else {
             qDebug() << "no screen";  
304              errorInfoScreen("Der er ingen information at vise");              errorInfoScreen("Der er ingen information at vise");
305                currentItem = ScreenItem();
306                currentItem.runtime = 60; //switch screens again in 1 minute
307          }          }
308          lastScreenSwitch = QTime::currentTime();          lastScreenSwitch = QTime::currentTime();
309    
# Line 279  void MainView::switchScreens() Line 312  void MainView::switchScreens()
312    
313  void MainView::errorInfoScreen(QString msg)  void MainView::errorInfoScreen(QString msg)
314  {  {
315          ensureVisible(web);      ensureVisible(web);
316          web->setHtml("<html>\      QString html("<html><body text='#505050' bgcolor='#000000'>");
317                  <body text='#505050' bgcolor='#000000'>\      html.append("<table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>")
318          <table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>" + msg+ "</h1></td></tr></table>\          .append(msg)
319                  </body></html>");          .append("</h1></td></tr></table></body></html>");
320        web->setHtml(html);
321  }  }
322    
323  void MainView::ensureVisible(QWidget* widget)  void MainView::ensureVisible(QWidget* widget)

Legend:
Removed from v.872  
changed lines
  Added in v.902

  ViewVC Help
Powered by ViewVC 1.1.20