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

Diff of /infoscreen/mainview.cpp

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

revision 535 by torben, Fri Jan 8 09:20:37 2010 UTC revision 539 by torben, Sat Jan 9 12:25:07 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    
114          lastXml = QTime::currentTime();          lastXml = QTime::currentTime();
115    
# Line 123  bool MainView::readXml() Line 127  bool MainView::readXml()
127    
128  void MainView::switchScreens()  void MainView::switchScreens()
129  {  {
130        if (video->isVisible() && video->isPlaying() ) {
131            return; //wait until current clip has finished
132        }
133    
134      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {      if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) {
135    
# Line 152  void MainView::switchScreens() Line 159  void MainView::switchScreens()
159                  picture->loadFromUrl( currentItem.url );                  picture->loadFromUrl( currentItem.url );
160    
161              }              }
162                if (currentItem.module == "info_web") {
163                    ensureVisible(web);
164                    web->load(currentItem.url);
165                }
166                if (currentItem.module == "info_video") {
167                    ensureVisible(video);
168                    video->loadUrl(currentItem.url);
169                }
170    
171    
172          } else {          } else {
173              qDebug() << "no screen";              qDebug() << "no screen";
174              hideAll();                          noInfoScreen();
175          }          }
176          lastScreenSwitch = QTime::currentTime();          lastScreenSwitch = QTime::currentTime();
177    
178      }      }
179  }  }
180    
181    void MainView::noInfoScreen()
182    {
183            ensureVisible(web);
184            web->setHtml("<html>\
185                    <body text='#505050' bgcolor='#000000'>\
186                    <table width='100%' height='100%'><tr><td align='center' valign='middel'><h1>Der er ingen information at vise</h1></td></tr></table>\
187                    </body></html>");
188    }
189    
190  void MainView::ensureVisible(QWidget* widget)  void MainView::ensureVisible(QWidget* widget)
191  {  {
192      if (! widget->isVisible()) {      if (! widget->isVisible()) {

Legend:
Removed from v.535  
changed lines
  Added in v.539

  ViewVC Help
Powered by ViewVC 1.1.20