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) { |
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); |
13 |
} |
} |
14 |
|
|
15 |
void MyWebView::start(QString url, QString screenid) { |
void WebView::start(QString& url, QString& screenid) { |
16 |
try { |
try { |
17 |
this->load( QUrl( generateUrl(url, screenid) ) ); |
this->load( QUrl( generateUrl(url, screenid) ) ); |
18 |
} catch (std::exception& e) { |
} catch (std::exception& e) { |
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 url, QString screenid) { |
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 |
|
|