2 |
#include <QApplication> |
#include <QApplication> |
3 |
#include <QPushButton> |
#include <QPushButton> |
4 |
#include <QLabel> |
#include <QLabel> |
5 |
#include <QVBoxLayout> |
#include <QStackedLayout> |
6 |
|
#include <QSvgWidget> |
7 |
|
|
8 |
#include <QTimer> |
#include <QTimer> |
9 |
#include <QKeyEvent> |
#include <QKeyEvent> |
16 |
#include "videoview.h" |
#include "videoview.h" |
17 |
|
|
18 |
#include "httpwrapper.h" |
#include "httpwrapper.h" |
19 |
|
#include "screenmanager.h" |
20 |
|
|
21 |
|
|
22 |
|
|
23 |
MainView::MainView(QWidget* parent) |
MainView::MainView(QWidget* parent) |
33 |
|
|
34 |
if (currentMode == ModeSimpleWeb){ |
if (currentMode == ModeSimpleWeb){ |
35 |
qDebug() << "Starting plain browser mode"; |
qDebug() << "Starting plain browser mode"; |
|
web->setVisible(true); |
|
|
web->start(url,screenid); |
|
36 |
} |
} |
37 |
|
|
38 |
if (currentMode == ModeLocal ) { |
if (currentMode == ModeLocal ) { |
49 |
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
50 |
|
|
51 |
render = new ClientSideRender(this); |
render = new ClientSideRender(this); |
|
render->setVisible( false ); |
|
52 |
|
|
53 |
web = new MyWebView(this); |
web = new MyWebView(this); |
|
web->setVisible( false); |
|
54 |
|
|
55 |
picture = new PictureView(this); |
picture = new PictureView(this); |
|
picture->setVisible( false ); |
|
56 |
|
|
57 |
video = new VideoView(this); |
video = new VideoView(this); |
|
video->setVisible(false); |
|
58 |
|
|
59 |
QVBoxLayout* layout = new QVBoxLayout(); |
svg = new QSvgWidget(this); |
60 |
layout->addWidget(web,1); |
|
61 |
layout->addWidget(render,1); |
layout = new QStackedLayout(); |
62 |
layout->addWidget(picture,1); |
layout->addWidget(web); |
63 |
layout->addWidget(video,1); |
layout->addWidget(render); |
64 |
layout->addStretch(); |
layout->addWidget(picture); |
65 |
|
layout->addWidget(video); |
66 |
|
layout->addWidget(svg); |
67 |
layout->setContentsMargins(0,0,0,0); |
layout->setContentsMargins(0,0,0,0); |
68 |
setLayout(layout); |
setLayout(layout); |
69 |
|
|
70 |
|
if (currentMode == ModeSimpleWeb) { |
71 |
|
web->setVisible(true); |
72 |
|
web->start(url,screenid); |
73 |
|
} |
74 |
|
|
75 |
if (currentMode == ModeXml || currentMode == ModeLocal) { |
if (enableScreenManager) { |
76 |
qDebug() << "Starting timer..."; |
screenManager = new ScreenManager(); |
77 |
timer = new QTimer(this); |
} else { |
78 |
connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() )); |
qDebug() << "ScreenManager is disabled"; |
|
timer->start(100); |
|
79 |
} |
} |
80 |
|
|
81 |
|
|
82 |
|
qDebug() << "Starting timer..."; |
83 |
|
timer = new QTimer(this); |
84 |
|
connect(timer, SIGNAL(timeout() ), this, SLOT(onTimer() )); |
85 |
|
timer->start(100); |
86 |
} |
} |
87 |
|
|
88 |
void MainView::loadSettings() |
void MainView::loadSettings() |
104 |
exit(1); |
exit(1); |
105 |
} |
} |
106 |
|
|
107 |
|
enableScreenManager = settings->value("enableScreenManager").toBool(); |
108 |
|
|
109 |
|
|
110 |
if (currentMode == ModeSimpleWeb || currentMode == ModeXml) { |
if (currentMode == ModeSimpleWeb || currentMode == ModeXml) { |
111 |
url = settings->value("url").toString(); |
url = settings->value("url").toString(); |
143 |
|
|
144 |
void MainView::onTimer() |
void MainView::onTimer() |
145 |
{ |
{ |
146 |
screenManager.timerTick(); |
if (enableScreenManager == true) { |
147 |
|
screenManager->timerTick(); |
148 |
|
} |
149 |
|
|
150 |
if (currentMode == ModeXml) { |
if (currentMode == ModeXml) { |
151 |
readXml(); |
readXml(); |
152 |
} |
} |
153 |
|
|
154 |
switchScreens(); |
if (currentMode == ModeXml || currentMode == ModeLocal) { |
155 |
|
switchScreens(); |
156 |
|
} |
157 |
} |
} |
158 |
|
|
159 |
|
|
185 |
item.runtime = 10; |
item.runtime = 10; |
186 |
} |
} |
187 |
|
|
188 |
|
if (ext == "svg") { |
189 |
|
item.module = ModuleSvg; |
190 |
|
item.runtime = 10; |
191 |
|
} |
192 |
|
|
193 |
|
if (ext == "htm" || ext == "html") { |
194 |
|
item.module = ModuleWeb; |
195 |
|
item.runtime = 10; |
196 |
|
} |
197 |
|
|
198 |
if (item.module != ModuleUnknown) { //no need to enqueue unknown modules |
if (item.module != ModuleUnknown) { //no need to enqueue unknown modules |
199 |
screenItems.push_back( item ); |
screenItems.push_back( item ); |
200 |
} |
} |
258 |
} |
} |
259 |
|
|
260 |
if (found) { |
if (found) { |
261 |
|
switch(currentItem.module) { |
262 |
if (currentItem.module == ModuleImage) { |
case ModuleImage: |
263 |
ensureVisible(picture); |
ensureVisible(picture); |
|
|
|
264 |
picture->loadFromUrl( currentItem.url ); |
picture->loadFromUrl( currentItem.url ); |
265 |
|
break; |
266 |
} else if (currentItem.module == ModuleWeb) { |
case ModuleWeb: |
267 |
ensureVisible(web); |
ensureVisible(web); |
268 |
web->load(currentItem.url); |
web->load(currentItem.url); |
269 |
} else if (currentItem.module == ModuleVideo) { |
break; |
270 |
|
case ModuleVideo: |
271 |
ensureVisible(video); |
ensureVisible(video); |
272 |
video->loadUrl(currentItem.url); |
video->loadUrl(currentItem.url); |
273 |
} else { |
break; |
274 |
|
case ModuleSvg: |
275 |
|
ensureVisible(svg); |
276 |
|
svg->load(currentItem.url); |
277 |
|
break; |
278 |
|
default: |
279 |
// ModuleUnknown - what should we do?? |
// ModuleUnknown - what should we do?? |
280 |
|
break; |
281 |
} |
} |
282 |
|
|
283 |
} else { |
} else { |
|
qDebug() << "no screen"; |
|
284 |
errorInfoScreen("Der er ingen information at vise"); |
errorInfoScreen("Der er ingen information at vise"); |
285 |
} |
} |
286 |
lastScreenSwitch = QTime::currentTime(); |
lastScreenSwitch = QTime::currentTime(); |
299 |
|
|
300 |
void MainView::ensureVisible(QWidget* widget) |
void MainView::ensureVisible(QWidget* widget) |
301 |
{ |
{ |
302 |
if (! widget->isVisible()) { |
layout->setCurrentWidget(widget); |
|
hideAll(); |
|
|
widget->setVisible(true); |
|
|
} |
|
303 |
} |
} |
304 |
|
|
|
void MainView::hideAll() |
|
|
{ |
|
|
render->setVisible( false ); |
|
|
web->setVisible( false); |
|
|
picture->setVisible( false ); |
|
|
video->setVisible(false); |
|
|
} |
|