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

Diff of /infoscreen/mainview.cpp

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

revision 870 by torben, Mon Jun 21 13:53:17 2010 UTC revision 886 by torben, Thu Jun 24 12:14:33 2010 UTC
# 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){
36          qDebug() << "Starting plain browser mode";          qDebug() << "Starting plain browser mode";
         web->setVisible(true);  
         web->start(url,screenid);  
37      }      }
38    
39      if (currentMode == ModeLocal ) {      if (currentMode == ModeLocal ) {
# Line 51  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 68  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        clockOverlay = new ClockOverlay(this);
72        clockOverlay->move(10,10);
73        clockOverlay->resize(150,75);
74    
75      if (currentMode == ModeXml || currentMode == ModeLocal) {      
76          qDebug() << "Starting timer...";  
77          timer = new QTimer(this);      if (currentMode == ModeSimpleWeb) {
78          connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));          web->setVisible(true);
79          timer->start(100);          web->start(url,screenid);
80        }
81    
82        if (enableScreenManager) {
83            screenManager = new ScreenManager(screenManagerOn, screenManagerOff);
84        } else {
85            qDebug() << "ScreenManager is disabled";
86      }      }
87    
88    
89        qDebug() << "Starting timer...";
90        timer = new QTimer(this);
91        connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));
92        timer->start(100);
93  }  }
94    
95  void MainView::loadSettings()  void MainView::loadSettings()
# Line 96  void MainView::loadSettings() Line 111  void MainView::loadSettings()
111          exit(1);          exit(1);
112      }      }
113    
114        enableScreenManager = settings->value("enablescreenmanager").toBool();
115        if (enableScreenManager) {
116            screenManagerOn = settings->value("screenmanager_on").toTime();
117            screenManagerOff = settings->value("screenmanager_off").toTime();
118        }
119    
120        xmlInterval = settings->value("xmlinterval", 30).toInt();
121        xmlInterval = (xmlInterval * 60 * 1000); //convert to milliseconds
122    
123    
124      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {
125          url = settings->value("url").toString();          url = settings->value("url").toString();
# Line 133  void MainView::keyPressEvent ( QKeyEvent Line 157  void MainView::keyPressEvent ( QKeyEvent
157    
158  void MainView::onTimer()  void MainView::onTimer()
159  {  {
160      screenManager.timerTick();      if (enableScreenManager == true) {
161            screenManager->timerTick();
162        }
163    
164      if (currentMode == ModeXml) {      if (currentMode == ModeXml) {
165          readXml();          readXml();
166      }      }
167    
168      switchScreens();      if (currentMode == ModeXml || currentMode == ModeLocal) {
169            switchScreens();
170        }
171        clockOverlay->timerTick();
172  }  }
173    
174    
# Line 193  void MainView::readLocalFiles() Line 222  void MainView::readLocalFiles()
222    
223  bool MainView::readXml()  bool MainView::readXml()
224  {  {
225      const int TIMEOUT = 30*60*1000; // 30 minutter      if ( lastXml.isNull() || lastXml.elapsed() > xmlInterval) {
226      if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) {          qDebug() << "Reading XML";
227    
228    
229          bool res = xmlHandler.readXml( xmlUrl );          bool res = xmlHandler.readXml( xmlUrl );
# Line 220  void MainView::switchScreens() Line 249  void MainView::switchScreens()
249      }      }
250    
251      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {
   
252          QTime now = QTime::currentTime();          QTime now = QTime::currentTime();
253          if (lastScreenSwitch.isNull())          if (lastScreenSwitch.isNull())
254              currentItemIdx = -1;              currentItemIdx = -1;
# Line 267  void MainView::switchScreens() Line 295  void MainView::switchScreens()
295              }              }
296    
297          } else {          } else {
             qDebug() << "no screen";  
298              errorInfoScreen("Der er ingen information at vise");              errorInfoScreen("Der er ingen information at vise");
299                currentItem = ScreenItem();
300                currentItem.runtime = 60; //switch screens again in 1 minute
301          }          }
302          lastScreenSwitch = QTime::currentTime();          lastScreenSwitch = QTime::currentTime();
303    

Legend:
Removed from v.870  
changed lines
  Added in v.886

  ViewVC Help
Powered by ViewVC 1.1.20