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

  ViewVC Help
Powered by ViewVC 1.1.20