29 |
web->setVisible( false); |
web->setVisible( false); |
30 |
|
|
31 |
picture = new PictureView(this); |
picture = new PictureView(this); |
32 |
picture->setVisible( true ); |
picture->setVisible( false ); |
33 |
|
|
34 |
video = new VideoView(this); |
video = new VideoView(this); |
35 |
video->setVisible(false); |
video->setVisible(false); |
66 |
{ |
{ |
67 |
const int TIMEOUT = 30*60*1000; // 30 minutter |
const int TIMEOUT = 30*60*1000; // 30 minutter |
68 |
if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) { |
if ( lastXml.isNull() || lastXml.elapsed() > TIMEOUT) { |
69 |
qDebug() << "reread"; |
|
70 |
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" ); |
71 |
|
|
72 |
lastXml = QTime::currentTime(); |
lastXml = QTime::currentTime(); |
88 |
|
|
89 |
if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) { |
if (lastScreenSwitch.isNull() || lastScreenSwitch.elapsed() > (currentItem.runtime*1000)) { |
90 |
|
|
91 |
|
QTime now = QTime::currentTime(); |
92 |
if (lastScreenSwitch.isNull()) |
if (lastScreenSwitch.isNull()) |
93 |
currentItemIdx = 0; |
currentItemIdx = -1; |
94 |
else |
|
95 |
currentItemIdx = (currentItemIdx+1) % screenItems.size(); |
bool found = false; |
96 |
currentItem = screenItems.at(currentItemIdx); |
int tries = 0; |
97 |
picture->loadFromUrl( currentItem.url ); |
|
98 |
|
if (screenItems.size() > 0) { //only try if we have a any screens |
99 |
|
while (found == false && tries <= screenItems.size()) { //find next with valid display time |
100 |
|
tries++; |
101 |
|
currentItemIdx = (currentItemIdx+1) % screenItems.size(); |
102 |
|
currentItem = screenItems.at(currentItemIdx); |
103 |
|
|
104 |
|
if (currentItem.start <= now && now <= currentItem.stop ) |
105 |
|
found = true; |
106 |
|
} |
107 |
|
} |
108 |
|
|
109 |
|
if (found) { |
110 |
|
|
111 |
|
if (currentItem.module == "info_image") { |
112 |
|
ensureVisible(picture); |
113 |
|
|
114 |
|
picture->loadFromUrl( currentItem.url ); |
115 |
|
|
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
} else { |
120 |
|
qDebug() << "no screen"; |
121 |
|
hideAll(); |
122 |
|
} |
123 |
lastScreenSwitch = QTime::currentTime(); |
lastScreenSwitch = QTime::currentTime(); |
124 |
|
|
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
void MainView::ensureVisible(QWidget* widget) |
129 |
|
{ |
130 |
|
if (! widget->isVisible()) { |
131 |
|
hideAll(); |
132 |
|
widget->setVisible(true); |
133 |
} |
} |
134 |
} |
} |
135 |
|
|
136 |
|
void MainView::hideAll() |
137 |
|
{ |
138 |
|
render->setVisible( false ); |
139 |
|
web->setVisible( false); |
140 |
|
picture->setVisible( false ); |
141 |
|
video->setVisible(false); |
142 |
|
} |