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"); |
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 { |
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 |
|
|
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 |
|
|
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 |
|
|
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 |
|
errorInfoScreen("Unknown module: " + currentItem.module ); |
172 |
|
|
173 |
} else { |
} else { |
174 |
qDebug() << "no screen"; |
qDebug() << "no screen"; |
175 |
hideAll(); |
errorInfoScreen("Der er ingen information at vise"); |
176 |
} |
} |
177 |
lastScreenSwitch = QTime::currentTime(); |
lastScreenSwitch = QTime::currentTime(); |
178 |
|
|
179 |
} |
} |
180 |
} |
} |
181 |
|
|
182 |
|
void MainView::errorInfoScreen(QString msg) |
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>" + msg+ "</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()) { |