1 |
#include <QApplication> |
#include <QApplication> |
2 |
#include <QtWebKit> |
#include "mainview.h" |
3 |
#include <QDesktopWidget> |
#include <QtDebug> |
|
#include <iostream> |
|
4 |
|
|
|
class MyWebView : public QWebView |
|
|
{ |
|
|
public: |
|
|
MyWebView(QWidget* parent) : QWebView(parent) { |
|
|
this->setWindowState( Qt::WindowFullScreen ); |
|
|
qApp->setOverrideCursor( QCursor( Qt::BlankCursor) ); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
virtual void show() { |
|
|
QWebView::show(); |
|
|
|
|
|
this->load( QUrl( generateUrl() ) ); |
|
|
} |
|
|
|
|
|
QString generateUrl() { |
|
|
QDesktopWidget* desktop = QApplication::desktop(); |
|
|
QRect rect = desktop->screenGeometry(); |
|
|
|
|
|
QString width; |
|
|
width.setNum( rect.width() ); |
|
|
|
|
|
QString height; |
|
|
height.setNum( rect.height() ); |
|
|
|
|
|
|
|
|
QSettings settings("Caddi", "infoscreen"); |
|
|
QString url = settings.value("url").toString(); |
|
|
QString screenid = settings.value("screenid").toString(); |
|
|
|
|
|
url.append("?screen_id=").append(screenid); |
|
|
url.append("&width=").append(width); |
|
|
url.append("&height=").append(height); |
|
5 |
|
|
6 |
|
//TODO: write messages to log file |
7 |
|
void myMessageOutput(QtMsgType type, const char *msg) |
8 |
|
{ |
9 |
|
switch (type) { |
10 |
|
case QtDebugMsg: |
11 |
|
fprintf(stderr, "Debug: %s\n", msg); |
12 |
|
break; |
13 |
|
case QtWarningMsg: |
14 |
|
fprintf(stderr, "Warning: %s\n", msg); |
15 |
|
break; |
16 |
|
case QtCriticalMsg: |
17 |
|
fprintf(stderr, "Critical: %s\n", msg); |
18 |
|
break; |
19 |
|
case QtFatalMsg: |
20 |
|
fprintf(stderr, "Fatal: %s\n", msg); |
21 |
|
abort(); |
22 |
|
} |
23 |
|
} |
24 |
|
|
|
std::cout << url.toAscii().data() << std::endl; |
|
|
|
|
|
return url; |
|
|
} |
|
|
|
|
|
}; |
|
25 |
|
|
26 |
|
|
27 |
int main(int argc, char** argv) { |
int main(int argc, char** argv) { |
|
QApplication app(argc,argv); |
|
28 |
|
|
29 |
|
qInstallMsgHandler(myMessageOutput); |
30 |
|
qDebug() << "--------------------------------------------------------------------------------------------"; |
31 |
|
|
32 |
QWebSettings* settings = QWebSettings::globalSettings(); |
QApplication app(argc,argv); |
33 |
settings->setAttribute( QWebSettings::JavascriptEnabled, true); |
app.setApplicationName("infoscreen"); |
|
settings->setAttribute( QWebSettings::PluginsEnabled, true); |
|
34 |
|
|
35 |
MyWebView web(0); |
MainView main(0); |
36 |
web.show(); |
main.show(); |
37 |
|
|
|
|
|
38 |
return app.exec(); |
return app.exec(); |
39 |
} |
} |