19 |
{ |
{ |
20 |
this->resize(400,400); |
this->resize(400,400); |
21 |
this->setWindowState( Qt::WindowFullScreen ); |
this->setWindowState( Qt::WindowFullScreen ); |
22 |
|
this->grabKeyboard(); |
23 |
|
|
24 |
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
25 |
|
|
30 |
web->setVisible( false); |
web->setVisible( false); |
31 |
|
|
32 |
picture = new PictureView(this); |
picture = new PictureView(this); |
33 |
picture->setVisible( true ); |
picture->setVisible( false ); |
34 |
|
|
35 |
video = new VideoView(this); |
video = new VideoView(this); |
36 |
video->setVisible(false); |
video->setVisible(false); |
52 |
|
|
53 |
} |
} |
54 |
|
|
55 |
|
void MainView::keyPressEvent ( QKeyEvent* event ) |
56 |
|
{ |
57 |
|
Q_UNUSED(event); |
58 |
|
qApp->quit(); |
59 |
|
} |
60 |
|
|
61 |
void MainView::onTimer() |
void MainView::onTimer() |
62 |
{ |
{ |
72 |
{ |
{ |
73 |
const int TIMEOUT = 30*60*1000; // 30 minutter |
const int TIMEOUT = 30*60*1000; // 30 minutter |
74 |
if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) { |
if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) { |
75 |
qDebug() << "reread"; |
|
76 |
xmlHandler.readXml( "http://infoscreen.sundhedhorsens.dk/infoscreen/screen_xml.php?screen_id=1" ); |
xmlHandler.readXml( "http://infoscreen.sundhedhorsens.dk/infoscreen/screen_xml.php?screen_id=1" ); |
77 |
|
|
78 |
lastXml = QTime::currentTime(); |
lastXml = QTime::currentTime(); |
94 |
|
|
95 |
if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) { |
if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) { |
96 |
|
|
97 |
|
QTime now = QTime::currentTime(); |
98 |
if (lastScreenSwitch.isNull()) |
if (lastScreenSwitch.isNull()) |
99 |
currentItemIdx = 0; |
currentItemIdx = -1; |
100 |
else |
|
101 |
currentItemIdx = (currentItemIdx+1) % screenItems.size(); |
bool found = false; |
102 |
currentItem = screenItems.at(currentItemIdx); |
int tries = 0; |
103 |
picture->loadFromUrl( currentItem.url ); |
|
104 |
|
if (screenItems.size() > 0) { //only try if we have a any screens |
105 |
|
while (found == false && tries <= screenItems.size()) { //find next with valid display time |
106 |
|
tries++; |
107 |
|
currentItemIdx = (currentItemIdx+1) % screenItems.size(); |
108 |
|
currentItem = screenItems.at(currentItemIdx); |
109 |
|
|
110 |
|
if (currentItem.start <= now && now <= currentItem.stop ) |
111 |
|
found = true; |
112 |
|
} |
113 |
|
} |
114 |
|
|
115 |
|
if (found) { |
116 |
|
|
117 |
|
if (currentItem.module == "info_image") { |
118 |
|
ensureVisible(picture); |
119 |
|
|
120 |
|
picture->loadFromUrl( currentItem.url ); |
121 |
|
|
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
} else { |
126 |
|
qDebug() << "no screen"; |
127 |
|
hideAll(); |
128 |
|
} |
129 |
lastScreenSwitch = QTime::currentTime(); |
lastScreenSwitch = QTime::currentTime(); |
130 |
|
|
131 |
} |
} |
132 |
} |
} |
133 |
|
|
134 |
|
void MainView::ensureVisible(QWidget* widget) |
135 |
|
{ |
136 |
|
if (! widget->isVisible()) { |
137 |
|
hideAll(); |
138 |
|
widget->setVisible(true); |
139 |
|
} |
140 |
|
} |
141 |
|
|
142 |
|
void MainView::hideAll() |
143 |
|
{ |
144 |
|
render->setVisible( false ); |
145 |
|
web->setVisible( false); |
146 |
|
picture->setVisible( false ); |
147 |
|
video->setVisible(false); |
148 |
|
} |