-
Notifications
You must be signed in to change notification settings - Fork 9
/
credits.cpp
57 lines (47 loc) · 1.59 KB
/
credits.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
#include "credits.h"
#include <QDateTime>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QLabel>
#include <QTextBrowser>
#include "helpers/netman.h"
Credits::Credits(QWidget* parent)
: AShirtDialog(parent, AShirtDialog::commonWindowFlags)
, updateLabel(new QLabel(this))
{
setWindowTitle("About");
connect(NetMan::get(), &NetMan::releasesChecked, this, &Credits::onReleasesUpdate);
updateLabel->setVisible(false);
updateLabel->setOpenExternalLinks(true);
updateLabel->setTextFormat(Qt::RichText);
updateLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
auto creditsArea = new QTextBrowser(this);
creditsArea->setOpenExternalLinks(true);
creditsArea->setReadOnly(true);
creditsArea->setMarkdown(normalBodyMarkdown);
auto gridLayout = new QVBoxLayout(this);
gridLayout->addWidget(updateLabel);
gridLayout->addWidget(creditsArea);
gridLayout->addWidget(buttonBox);
setLayout(gridLayout);
setMinimumSize(425, 500);
}
void Credits::updateRelease() {
if (updateDigest.hasUpgrade()) {
updateLabel->setVisible(true);
updateLabel->setText(baseUpdateText.arg(ReleaseInfo::releasePageUrl));
}
else {
updateLabel->setVisible(false);
updateLabel->clear();
}
}
void Credits::onReleasesUpdate(bool success, QList<dto::GithubRelease> releases) {
if (!success)
return;
auto digest = dto::ReleaseDigest::fromReleases(ReleaseInfo::version, releases);
updateDigest = digest;
updateRelease();
}