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

Diff of /infoscreen/webview.cpp

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20