-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtabbody.cpp
107 lines (83 loc) · 1.94 KB
/
tabbody.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <QtDebug>
#include "tabbody.h"
#include "ui_tabbody.h"
const qreal zoom_max = 1.6f;
const qreal zoom_min = 0.8f;
const qreal zoom_step = 0.1f;
TabBody::TabBody(QWidget *parent) :
QDialog(parent),
ui(new Ui::TabBody)
{
qDebug() << "TabBody::TabBody()";
ui->setupUi(this);
ui->webView->setContent("<p style='font-family:Consolas;font-size:12px;'>Loading...</p>");
mCurUrlString = "";
mCurTitle = "";
mZoomFactor = 1.1f;
ui->webView->setZoomFactor(mZoomFactor);
mRFCNumber = 3231;
}
TabBody::~TabBody()
{
delete ui;
qDebug() << "TabBody::~TabBody()";
}
int TabBody::getRFCNumber()
{
return mRFCNumber;
}
void TabBody::setRFCNumber(int number)
{
mRFCNumber = number;
ui->webView->load(QUrl(QString("http://tools.ietf.org/html/rfc%1").arg(number)));
}
const QString& TabBody::getCurrentTitle()
{
return mCurTitle;
}
void TabBody::findTextNext(const QString &text)
{
ui->webView->findText(text);
ui->webView->setFocus();
}
void TabBody::findTextPrev(const QString &text)
{
ui->webView->findText(text, QWebPage::FindBackward);
ui->webView->setFocus();
}
void TabBody::zoomIn()
{
mZoomFactor = qMin(mZoomFactor + zoom_step, zoom_max);
ui->webView->setZoomFactor(mZoomFactor);
}
void TabBody::zoomOut()
{
mZoomFactor = qMax(mZoomFactor - zoom_step, zoom_min);
ui->webView->setZoomFactor(mZoomFactor);
}
void TabBody::on_webView_urlChanged(const QUrl &arg1)
{
mCurUrlString = arg1.toDisplayString();
}
void TabBody::on_webView_titleChanged(const QString &title)
{
mCurTitle = title;
emit titleChanged();
}
void TabBody::on_webView_loadStarted()
{
mCurUrlString = "";
mCurTitle = "";
emit loadStarted();
}
void TabBody::on_webView_loadProgress(int progress)
{
if (!mCurUrlString.isEmpty())
{
emit loadProgress(mCurUrlString, progress);
}
}
void TabBody::on_webView_loadFinished()
{
emit loadFinished(mCurUrlString);
}