forked from ij96/163-lyrics-getter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonviewer.cpp
43 lines (33 loc) · 1.29 KB
/
jsonviewer.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 "jsonviewer.h"
JsonViewer::JsonViewer(QWidget *parent) : QWidget(parent) {
window = new QLabel;
window_layout = new QGridLayout;
info_json_text = new QTextEdit;
lyrics_json_text = new QTextEdit;
info_json_hl = new JsonHighlighter(info_json_text->document());
lyrics_json_hl = new JsonHighlighter(lyrics_json_text->document());
info_json_text->setFontFamily("Courier");
lyrics_json_text->setFontFamily("Courier");
window_layout->addWidget(info_json_text, 0, 0);
window_layout->addWidget(lyrics_json_text, 0, 1);
window->setWindowModality(Qt::NonModal);
window->setWindowFlags(Qt::Window);
window->setLayout(window_layout);
window->resize(800, 640);
}
void JsonViewer::update(QJsonObject info, QJsonObject lyrics) {
QJsonDocument doc;
QString formatted_json_string;
doc.setObject(info);
formatted_json_string = doc.toJson(QJsonDocument::Indented);
info_json_text->setText(formatted_json_string);
doc.setObject(lyrics);
formatted_json_string = doc.toJson(QJsonDocument::Indented);
lyrics_json_text->setText(formatted_json_string);
}
void JsonViewer::show() const {
window->show();
}
void JsonViewer::set_window_title(QString title) {
window->setWindowTitle(title);
}