-
Notifications
You must be signed in to change notification settings - Fork 2
/
webtabcontents.cpp
58 lines (47 loc) · 1.71 KB
/
webtabcontents.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "webtabcontents.h"
#include "ui_webtabcontents.h"
//#incude "QTextBrowser"
WebTabContents::WebTabContents(QWidget *parent) :
QWidget(parent),
ui(new Ui::WebTabContents)
{
this->setObjectName("webtab");
ui->setupUi(this);
webview = new WebViewRS();
//QTextBrowser
this->ui->verticalLayout->addWidget(webview,1);
webview->show();
//QString loadfirst = "";//QDir::homePath();
//loadfirst.append("html/index.html");
//webview->setUrl(QUrl(loadfirst));
//jslog = new QTextBrowser();
//this->ui->verticalLayout->addWidget(jslog,1);
//jslog->show();
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::WebGLEnabled, true);
QWebSettings::globalSettings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
//connect(ui->testButton, SIGNAL(clicked()), this->webview, SLOT(reload()));
connect(ui->testButton, SIGNAL(clicked()), this, SLOT(changeLocation()));
connect(ui->lineEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));
connect(webview, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
}
WebTabContents::~WebTabContents()
{
delete ui;
}
void WebTabContents::changeLocation()
{
QUrl url = QUrl(ui->lineEdit->text());
webview->load(url);
webview->setFocus();
}
void WebTabContents::adjustLocation()
{
ui->lineEdit->setText(webview->url().toString());
}
WebViewRS *WebTabContents::getWebView()
{
return webview;
}