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

Diff of /infoscreen/MainView.cpp

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

revision 536 by torben, Fri Jan 8 09:20:37 2010 UTC revision 537 by torben, Fri Jan 8 21:53:23 2010 UTC
# Line 18  Line 18 
18    
19    
20  MainView::MainView(QWidget* parent)  MainView::MainView(QWidget* parent)
21      : QWidget(parent)      : QWidget(parent), timer(0)
22  {  {
23    
24      settings = new QSettings("Caddi", "infoscreen");      settings = new QSettings("Caddi", "infoscreen");
# Line 69  MainView::MainView(QWidget* parent) Line 69  MainView::MainView(QWidget* parent)
69          qDebug() << "Starting XML mode";          qDebug() << "Starting XML mode";
70          qDebug() << "xmlUrl" << xmlUrl;          qDebug() << "xmlUrl" << xmlUrl;
71    
72          QTimer* timer = new QTimer(this);          timer = new QTimer(this);
73          connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));          connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() ));
74          timer->start(100);          timer->start(100);
75      } else {      } else {
# Line 77  MainView::MainView(QWidget* parent) Line 77  MainView::MainView(QWidget* parent)
77          web->setVisible(true);          web->setVisible(true);
78          web->start(url,screenid);          web->start(url,screenid);
79      }      }
80    }
81    
82    void MainView::closeEvent ( QCloseEvent * event )
83    {
84        Q_UNUSED(event);
85        exit(0); //force application shutdown
86  }  }
87    
88  void MainView::keyPressEvent ( QKeyEvent* event )  void MainView::keyPressEvent ( QKeyEvent* event )
89  {  {
90      int key = event->key();      int key = event->key();
91      if (key == ' ' || key == Qt::Key_Return || key == Qt::Key_Enter) {      if (key == ' ' || key == Qt::Key_Return || key == Qt::Key_Enter) {
92          qApp->quit();          close();
93      }      }
94  }    }  
95    
# Line 105  bool MainView::readXml() Line 109  bool MainView::readXml()
109      if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) {      if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) {
110    
111    
112          xmlHandler.readXml( xmlUrl );          bool res = xmlHandler.readXml( xmlUrl );
113                    if (res == false)
114    
115          lastXml = QTime::currentTime();          lastXml = QTime::currentTime();
116    
# Line 123  bool MainView::readXml() Line 128  bool MainView::readXml()
128    
129  void MainView::switchScreens()  void MainView::switchScreens()
130  {  {
131        if (video->isVisible() && video->isPlaying() ) {
132            return; //wait until current clip has finished
133        }
134    
135      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {
136    
# Line 152  void MainView::switchScreens() Line 160  void MainView::switchScreens()
160                  picture->loadFromUrl( currentItem.url );                  picture->loadFromUrl( currentItem.url );
161    
162              }              }
163                if (currentItem.module == "info_web") {
164                    ensureVisible(web);
165                    web->load(currentItem.url);
166                }
167                if (currentItem.module == "info_video") {
168                    ensureVisible(video);
169                    video->loadUrl(currentItem.url);
170                }
171    
172    
173          } else {          } else {
174              qDebug() << "no screen";              qDebug() << "no screen";
175              hideAll();                          noInfoScreen();
176          }          }
177          lastScreenSwitch = QTime::currentTime();          lastScreenSwitch = QTime::currentTime();
178    
179      }      }
180  }  }
181    
182    void MainView::noInfoScreen()
183    {
184            ensureVisible(web);
185            web->setHtml("<html>\
186                    <body text='#505050' bgcolor='#000000'>\
187                    <table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>Der er ingen information at vise</h1></td></tr></table>\
188                    </body></html>");
189    }
190    
191  void MainView::ensureVisible(QWidget* widget)  void MainView::ensureVisible(QWidget* widget)
192  {  {
193      if (! widget->isVisible()) {      if (! widget->isVisible()) {

Legend:
Removed from v.536  
changed lines
  Added in v.537

  ViewVC Help
Powered by ViewVC 1.1.20