-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtmlViewer.cpp
43 lines (37 loc) · 1001 Bytes
/
htmlViewer.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
#include "htmlViewer.h"
#include "viewer.h"
#include <QTextEdit>
#include <QWebView>
#include <QDebug>
#include <QCheckBox>
HtmlViewer::HtmlViewer(const QString& html, QWidget *parent) :
Viewer(parent)
{
layout = new QVBoxLayout;
wv = new QWebView();
tv = new QPlainTextEdit();
QCheckBox *checkbox = new QCheckBox("Source Code?");
tv->setHidden(true);
tv->setPlainText(html);
wv->setHtml(html);
layout->addWidget(checkbox);
layout->addWidget(tv);
layout->addWidget(wv);
QObject::connect(checkbox, SIGNAL(clicked(bool)), this, SLOT(SWITCH_BETWEEN_TV_AND_WV(bool)));
this->setLayout(layout);
}
void HtmlViewer::setContent(const QString &html)
{
qDebug() << html;
wv->setHtml(html);
}
void HtmlViewer::SWITCH_BETWEEN_TV_AND_WV(bool checked){
if(checked){
wv->setHidden(true);
tv->setHidden(false);
} else {
tv->setHidden(true);
wv->setHtml(tv->toPlainText());
wv->setHidden(false);
}
}