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

Annotation of /infoscreen/webview.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.20