Use Qt's dialog where applicable (#1843)

This commit is contained in:
pajlada
2020-10-31 16:42:48 +01:00
committed by GitHub
parent 523874dc21
commit 1ee1e8837f
27 changed files with 118 additions and 62 deletions
+19 -10
View File
@@ -4,6 +4,7 @@
#include "common/Version.hpp"
#include "util/LayoutCreator.hpp"
#include "util/RemoveScrollAreaBackground.hpp"
#include "widgets/BasePopup.hpp"
#include "widgets/helper/SignalLabel.hpp"
#include <QFormLayout>
@@ -230,17 +231,25 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name,
auto *a = new QLabel("<a href=\"" + website + "\">" + name + "</a>");
a->setOpenExternalLinks(true);
auto *b = new QLabel("<a href=\"" + licenseLink + "\">show license</a>");
QObject::connect(b, &QLabel::linkActivated, [licenseLink, name] {
auto *edit = new QTextEdit;
QObject::connect(
b, &QLabel::linkActivated, [parent = this, name, licenseLink] {
auto window =
new BasePopup(BaseWindow::Flags::EnableCustomFrame, parent);
window->setWindowTitle("Chatterino - License for " + name);
window->setAttribute(Qt::WA_DeleteOnClose);
auto layout = new QVBoxLayout();
auto *edit = new QTextEdit;
edit->setWindowTitle(
QString("Chatterino - showing %1's license").arg(name));
QFile file(licenseLink);
file.open(QIODevice::ReadOnly);
edit->setText(file.readAll());
edit->setReadOnly(true);
edit->show();
});
QFile file(licenseLink);
file.open(QIODevice::ReadOnly);
edit->setText(file.readAll());
edit->setReadOnly(true);
layout->addWidget(edit);
window->getLayoutContainer()->setLayout(layout);
window->show();
});
form->addRow(a, b);
}