#include #include #include #include "webview.h" WebView::WebView(QWidget* parent) : QWebView(parent) { QWebSettings* settings = QWebSettings::globalSettings(); settings->setAttribute( QWebSettings::JavascriptEnabled, true); settings->setAttribute( QWebSettings::PluginsEnabled, true); } void WebView::start(QString& url, QString& screenid) { try { this->load( QUrl( generateUrl(url, screenid) ) ); } catch (std::exception& e) { showError(e.what() ); } } void WebView::showError(const char* msg) { QString str("

"); str.append(msg).append("

"); this->setHtml( str ); } QString WebView::generateUrl(QString& url, QString& screenid) { QDesktopWidget* desktop = QApplication::desktop(); QRect rect = desktop->screenGeometry(); QString width, height; width.setNum( rect.width() ); height.setNum( rect.height() ); if (url.length() == 0) { throw std::runtime_error("No url in config file"); } url.append("?screen_id=").append(screenid); url.append("&width=").append(width); url.append("&height=").append(height); qDebug() << "URL:" << url; return url; }