/[projects]/infoscreen/MyWebView.cpp
ViewVC logotype

Contents of /infoscreen/MyWebView.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 506 - (show annotations) (download)
Fri Dec 11 21:47:49 2009 UTC (14 years, 5 months ago) by torben
File size: 1496 byte(s)
Restructured to multifile project

1 #include <QApplication>
2 #include <QtWebKit>
3 #include <QDesktopWidget>
4 #include <iostream>
5 #include <stdexcept>
6
7 #include "MyWebView.h"
8
9
10 MyWebView::MyWebView(QWidget* parent) : QWebView(parent) {
11 // this->setWindowState( Qt::WindowFullScreen );
12 qApp->setOverrideCursor( QCursor( Qt::BlankCursor) );
13
14 connect(this, SIGNAL( loadStarted() ), this, SLOT( test() ) );
15 }
16
17 void MyWebView::show() {
18 QWebView::show();
19 try {
20 this->load( QUrl( generateUrl() ) );
21 } catch (std::exception& e) {
22 showError(e.what() );
23 }
24
25 }
26
27 void MyWebView::showError(const char* msg) {
28 QString str("<html><body><center><h1>");
29 str.append(msg).append("</h1></center></body></html>");
30 this->setHtml( str );
31 }
32
33 QString MyWebView::generateUrl() {
34 QDesktopWidget* desktop = QApplication::desktop();
35 QRect rect = desktop->screenGeometry();
36
37 QString width;
38 width.setNum( rect.width() );
39
40 QString height;
41 height.setNum( rect.height() );
42
43
44 QSettings settings("Caddi", "infoscreen");
45 std::cout << settings.fileName().toAscii().data() << std::endl;
46 QString url = settings.value("url").toString();
47 QString screenid = settings.value("screenid").toString();
48
49 if (url.length() == 0) {
50 throw std::runtime_error("No url in config file");
51 }
52
53 url.append("?screen_id=").append(screenid);
54 url.append("&width=").append(width);
55 url.append("&height=").append(height);
56
57
58 std::cout << url.toAscii().data() << std::endl;
59
60 return url;
61 }
62
63 //public slots:
64 void MyWebView::test() {
65 std::cout << "test" << std::endl;
66 }

  ViewVC Help
Powered by ViewVC 1.1.20