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

Annotation of /infoscreen/webview.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 541 - (hide annotations) (download)
Sat Jan 9 16:12:33 2010 UTC (14 years, 4 months ago) by torben
Original Path: infoscreen/MyWebView.cpp
File size: 1277 byte(s)
more unused code
1 torben 506 #include <QApplication>
2     #include <QDesktopWidget>
3     #include <stdexcept>
4    
5     #include "MyWebView.h"
6    
7    
8 torben 512 MyWebView::MyWebView(QWidget* parent) : QWebView(parent) {
9 torben 507
10 torben 534 QWebSettings* settings = QWebSettings::globalSettings();
11     settings->setAttribute( QWebSettings::JavascriptEnabled, true);
12     settings->setAttribute( QWebSettings::PluginsEnabled, true);
13 torben 506 }
14    
15 torben 535 void MyWebView::start(QString url, QString screenid) {
16 torben 534 try {
17 torben 535 this->load( QUrl( generateUrl(url, screenid) ) );
18 torben 534 } catch (std::exception& e) {
19     showError(e.what() );
20     }
21 torben 506
22     }
23    
24     void MyWebView::showError(const char* msg) {
25 torben 534 QString str("<html><body><center><h1>");
26     str.append(msg).append("</h1></center></body></html>");
27     this->setHtml( str );
28 torben 506 }
29    
30 torben 535 QString MyWebView::generateUrl(QString url, QString screenid) {
31 torben 534 QDesktopWidget* desktop = QApplication::desktop();
32     QRect rect = desktop->screenGeometry();
33 torben 506
34    
35 torben 534 QString width, height;
36     width.setNum( rect.width() );
37     height.setNum( rect.height() );
38 torben 512
39    
40 torben 534 if (url.length() == 0) {
41     throw std::runtime_error("No url in config file");
42     }
43 torben 506
44 torben 534 url.append("?screen_id=").append(screenid);
45     url.append("&width=").append(width);
46     url.append("&height=").append(height);
47 torben 506
48    
49 torben 534 qDebug() << "URL:" << url;
50 torben 512
51 torben 534
52     return url;
53 torben 506 }

  ViewVC Help
Powered by ViewVC 1.1.20