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

Diff of /infoscreen/mainview.cpp

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

revision 873 by torben, Tue Jun 22 20:29:40 2010 UTC revision 2103 by torben, Tue Feb 4 14:16:40 2014 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>
5  #include <QStackedLayout>  #include <QStackedLayout>
6  #include <QSvgWidget>  #include <QSvgWidget>
7    
8    #include <QDir>
9  #include <QTimer>  #include <QTimer>
10  #include <QKeyEvent>  #include <QKeyEvent>
11  #include <QSettings>  #include <QSettings>
12  #include <QMessageBox>  #include <QMessageBox>
13    
14  #include "MyWebView.h"  #include "webview.h"
15  #include "clientsiderender.h"  #include "clientsiderender.h"
16  #include "pictureview.h"  #include "pictureview.h"
17  #include "videoview.h"  #include "videoview.h"
18    #include "clockoverlay.h"
19  #include "httpwrapper.h"  #include "httpwrapper.h"
20    #include "screenmanager.h"
21    
22    
23    
# Line 28  MainView::MainView(QWidget* parent) Line 30  MainView::MainView(QWidget* parent)
30          xmlUrl = url + "?screen_id=" + screenid;          xmlUrl = url + "?screen_id=" + screenid;
31          qDebug() << "Starting XML mode";          qDebug() << "Starting XML mode";
32          qDebug() << "xmlUrl" << xmlUrl;          qDebug() << "xmlUrl" << xmlUrl;
33            qDebug() << "xmlInterval" << xmlInterval/(60*1000);
34      }      }
35    
36      if (currentMode == ModeSimpleWeb){      if (currentMode == ModeSimpleWeb){
# Line 41  MainView::MainView(QWidget* parent) Line 44  MainView::MainView(QWidget* parent)
44          readLocalFiles();          readLocalFiles();
45      }      }
46    
47      this->resize(400,400);      this->resize(640,480);
48      this->setWindowState( Qt::WindowFullScreen );      this->setWindowState( Qt::WindowFullScreen );
49      this->grabKeyboard();      this->grabKeyboard();
50    
# Line 49  MainView::MainView(QWidget* parent) Line 52  MainView::MainView(QWidget* parent)
52    
53      render = new ClientSideRender(this);      render = new ClientSideRender(this);
54    
55      web = new MyWebView(this);      web = new WebView(this);
56    
57      picture = new PictureView(this);      picture = new PictureView(this);
58    
# Line 66  MainView::MainView(QWidget* parent) Line 69  MainView::MainView(QWidget* parent)
69      layout->setContentsMargins(0,0,0,0);      layout->setContentsMargins(0,0,0,0);
70      setLayout(layout);      setLayout(layout);
71    
72        if (showClock == true) {
73            clockOverlay = new ClockOverlay(this);
74            clockOverlay->move(10,10);
75            clockOverlay->resize(150,75);
76        }
77    
78        
79    
80      if (currentMode == ModeSimpleWeb) {      if (currentMode == ModeSimpleWeb) {
81          web->setVisible(true);          web->setVisible(true);
82          web->start(url,screenid);          web->start(url,screenid);
83      }      }
84    
85        if (enableScreenManager) {
86            screenManager = new ScreenManager(screenManagerOn, screenManagerOff);
87        } else {
88            qDebug() << "ScreenManager is disabled";
89        }
90    
91    
92      qDebug() << "Starting timer...";      qDebug() << "Starting timer...";
93      timer = new QTimer(this);      timer = new QTimer(this);
# Line 97  void MainView::loadSettings() Line 114  void MainView::loadSettings()
114          exit(1);          exit(1);
115      }      }
116    
117        enableScreenManager = settings->value("enablescreenmanager").toBool();
118        if (enableScreenManager) {
119            screenManagerOn = settings->value("screenmanager_on").toTime();
120            screenManagerOff = settings->value("screenmanager_off").toTime();
121        }
122    
123        showClock = settings->value("showclock").toBool();
124    
125        xmlInterval = settings->value("xmlinterval", 30).toInt();
126        xmlInterval = (xmlInterval * 60 * 1000); //convert to milliseconds
127    
128    
129      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {      if (currentMode == ModeSimpleWeb || currentMode == ModeXml) {
130          url = settings->value("url").toString();          url = settings->value("url").toString();
# Line 130  void MainView::keyPressEvent ( QKeyEvent Line 158  void MainView::keyPressEvent ( QKeyEvent
158      if (key == ' ' || key == Qt::Key_Return || key == Qt::Key_Enter) {      if (key == ' ' || key == Qt::Key_Return || key == Qt::Key_Enter) {
159          close();          close();
160      }      }
161    
162        if (key == 'f' || key == 'F') {
163            Qt::WindowStates current = this->windowState();
164            if (current == Qt::WindowFullScreen) {
165                this->setWindowState(Qt::WindowActive);
166            } else {
167                this->setWindowState(Qt::WindowFullScreen);
168            }
169        }
170    
171  }    }  
172    
173  void MainView::onTimer()  void MainView::onTimer()
174  {  {
175      qDebug() << "onTimer()";      if (enableScreenManager == true) {
176      screenManager.timerTick();          screenManager->timerTick();
177        }
178    
179      if (currentMode == ModeXml) {      if (currentMode == ModeXml) {
180          readXml();          readXml();
# Line 144  void MainView::onTimer() Line 183  void MainView::onTimer()
183      if (currentMode == ModeXml || currentMode == ModeLocal) {      if (currentMode == ModeXml || currentMode == ModeLocal) {
184          switchScreens();          switchScreens();
185      }      }
186        if (showClock == true) {
187            clockOverlay->timerTick();
188        }
189  }  }
190    
191    
# Line 197  void MainView::readLocalFiles() Line 239  void MainView::readLocalFiles()
239    
240  bool MainView::readXml()  bool MainView::readXml()
241  {  {
242      const int TIMEOUT = 30*60*1000; // 30 minutter      if ( lastXml.isNull() || lastXml.elapsed() > xmlInterval) {
243      if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) {          qDebug() << "Reading XML";
244    
245    
246          bool res = xmlHandler.readXml( xmlUrl );          bool res = xmlHandler.readXml( xmlUrl );
# Line 224  void MainView::switchScreens() Line 266  void MainView::switchScreens()
266      }      }
267    
268      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {
   
269          QTime now = QTime::currentTime();          QTime now = QTime::currentTime();
270          if (lastScreenSwitch.isNull())          if (lastScreenSwitch.isNull())
271              currentItemIdx = -1;              currentItemIdx = -1;
# Line 271  void MainView::switchScreens() Line 312  void MainView::switchScreens()
312              }              }
313    
314          } else {          } else {
             qDebug() << "no screen";  
315              errorInfoScreen("Der er ingen information at vise");              errorInfoScreen("Der er ingen information at vise");
316                currentItem = ScreenItem();
317                currentItem.runtime = 60; //switch screens again in 1 minute
318          }          }
319          lastScreenSwitch = QTime::currentTime();          lastScreenSwitch = QTime::currentTime();
320    
# Line 281  void MainView::switchScreens() Line 323  void MainView::switchScreens()
323    
324  void MainView::errorInfoScreen(QString msg)  void MainView::errorInfoScreen(QString msg)
325  {  {
326          ensureVisible(web);      ensureVisible(web);
327          web->setHtml("<html>\      QString html("<html><body text='#505050' bgcolor='#000000'>");
328                  <body text='#505050' bgcolor='#000000'>\      html.append("<table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>")
329          <table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>" + msg+ "</h1></td></tr></table>\          .append(msg)
330                  </body></html>");          .append("</h1></td></tr></table></body></html>");
331        web->setHtml(html);
332  }  }
333    
334  void MainView::ensureVisible(QWidget* widget)  void MainView::ensureVisible(QWidget* widget)

Legend:
Removed from v.873  
changed lines
  Added in v.2103

  ViewVC Help
Powered by ViewVC 1.1.20