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

Diff of /infoscreen/webview.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 512 by torben, Tue Dec 15 13:53:02 2009 UTC revision 535 by torben, Fri Jan 8 09:20:37 2010 UTC
# Line 6  Line 6 
6    
7    
8  MyWebView::MyWebView(QWidget* parent) : QWebView(parent) {                MyWebView::MyWebView(QWidget* parent) : QWebView(parent) {              
9          connect(this, SIGNAL( loadFinished(bool) ), this, SLOT( onChange(bool) ) );      connect(this, SIGNAL( loadFinished(bool) ), this, SLOT( onChange(bool) ) );
10    
11          QWebSettings* settings = QWebSettings::globalSettings();      QWebSettings* settings = QWebSettings::globalSettings();
12          settings->setAttribute( QWebSettings::JavascriptEnabled, true);      settings->setAttribute( QWebSettings::JavascriptEnabled, true);
13          settings->setAttribute( QWebSettings::PluginsEnabled, true);      settings->setAttribute( QWebSettings::PluginsEnabled, true);
14    
15    
16    
17          QTimer* timer = new QTimer(this);      QTimer* timer = new QTimer(this);
18          connect(timer, SIGNAL(timeout()), this, SLOT(onTimer()));      connect(timer, SIGNAL(timeout()), this, SLOT(onTimer()));
19          timer->start(1000);      timer->start(1000);
20            
21  }  }
22    
23  void MyWebView::start() {  void MyWebView::start(QString url, QString screenid) {
24          try {        try {
25                  this->load( QUrl( generateUrl() ) );          this->load( QUrl( generateUrl(url, screenid) ) );
26          } catch (std::exception& e) {      } catch (std::exception& e) {
27                  showError(e.what() );          showError(e.what() );
28          }      }
29    
30  }  }
31    
32  void MyWebView::showError(const char* msg) {  void MyWebView::showError(const char* msg) {
33          QString str("<html><body><center><h1>");      QString str("<html><body><center><h1>");
34          str.append(msg).append("</h1></center></body></html>");      str.append(msg).append("</h1></center></body></html>");
35          this->setHtml( str );      this->setHtml( str );
36  }  }
37    
38  QString MyWebView::generateUrl() {  QString MyWebView::generateUrl(QString url, QString screenid) {
39          QDesktopWidget* desktop = QApplication::desktop();      QDesktopWidget* desktop = QApplication::desktop();
40          QRect rect = desktop->screenGeometry();      QRect rect = desktop->screenGeometry();
   
41    
         QString width, height;  
         width.setNum( rect.width() );  
         height.setNum( rect.height() );  
42    
43                        QString width, height;
44          QSettings settings("Caddi", "infoscreen");      width.setNum( rect.width() );
45          qDebug() << "Settings: " << settings.fileName();      height.setNum( rect.height() );
46    
         QString url = settings.value("url").toString();  
         QString screenid = settings.value("screenid").toString();  
47    
48          if (url.length() == 0) {      if (url.length() == 0) {
49                  throw std::runtime_error("No url in config file");          throw std::runtime_error("No url in config file");
50          }      }
51    
52          url.append("?screen_id=").append(screenid);      url.append("?screen_id=").append(screenid);
53          url.append("&width=").append(width);      url.append("&width=").append(width);
54          url.append("&height=").append(height);      url.append("&height=").append(height);
55    
56    
57          qDebug() << "URL:" << url;      qDebug() << "URL:" << url;
58    
59    
60          return url;      return url;
61  }  }
62    
63  //public slots:  //public slots:

Legend:
Removed from v.512  
changed lines
  Added in v.535

  ViewVC Help
Powered by ViewVC 1.1.20