Use Qt's dialog where applicable (#1843)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -165,13 +165,11 @@ ColorButton *GeneralPageView::addColorButton(
|
||||
layout->addWidget(colorButton);
|
||||
this->addLayout(layout);
|
||||
QObject::connect(
|
||||
colorButton, &ColorButton::clicked, [&setting, colorButton]() {
|
||||
auto dialog = new ColorPickerDialog(QColor(setting));
|
||||
colorButton, &ColorButton::clicked, [this, &setting, colorButton]() {
|
||||
auto dialog = new ColorPickerDialog(QColor(setting), this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
dialog->closed.connect([&setting, colorButton, &dialog] {
|
||||
QColor selected = dialog->selectedColor();
|
||||
|
||||
dialog->closed.connect([&setting, colorButton](QColor selected) {
|
||||
if (selected.isValid())
|
||||
{
|
||||
setting = selected.name(QColor::HexArgb);
|
||||
|
||||
@@ -244,9 +244,7 @@ void HighlightingPage::tableCellClicked(const QModelIndex &clicked,
|
||||
auto dialog = new ColorPickerDialog(initial, this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->show();
|
||||
dialog->closed.connect([=] {
|
||||
QColor selected = dialog->selectedColor();
|
||||
|
||||
dialog->closed.connect([=](QColor selected) {
|
||||
if (selected.isValid())
|
||||
{
|
||||
view->getModel()->setData(clicked, selected,
|
||||
|
||||
Reference in New Issue
Block a user