1 |
#include <QApplication> |
#include <QApplication> |
2 |
#include <QDesktopWidget> |
#include <QDesktopWidget> |
3 |
|
#include <QtDebug> |
4 |
|
|
5 |
|
|
6 |
#include <stdexcept> |
#include <stdexcept> |
7 |
|
|
8 |
#include "MyWebView.h" |
#include "webview.h" |
9 |
|
|
10 |
|
|
11 |
MyWebView::MyWebView(QWidget* parent) : QWebView(parent) { |
WebView::WebView(QWidget* parent) : QWebView(parent) { |
12 |
|
|
13 |
QWebSettings* settings = QWebSettings::globalSettings(); |
QWebSettings* settings = QWebSettings::globalSettings(); |
14 |
settings->setAttribute( QWebSettings::JavascriptEnabled, true); |
settings->setAttribute( QWebSettings::JavascriptEnabled, true); |
15 |
settings->setAttribute( QWebSettings::PluginsEnabled, true); |
settings->setAttribute( QWebSettings::PluginsEnabled, true); |
16 |
} |
} |
17 |
|
|
18 |
void MyWebView::start(QString url, QString screenid) { |
void WebView::start(QString& url, QString& screenid) { |
19 |
try { |
try { |
20 |
this->load( QUrl( generateUrl(url, screenid) ) ); |
this->load( QUrl( generateUrl(url, screenid) ) ); |
21 |
} catch (std::exception& e) { |
} catch (std::exception& e) { |
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 url, QString screenid) { |
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 |
|
|