From 79af001bc6892c713adb4eb1860d415652aadad2 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Mon, 29 Jul 2024 12:06:21 +0200 Subject: [PATCH] Use QDialogButtonBox --- config-dialog.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/config-dialog.cpp b/config-dialog.cpp index 8cc1139..802f978 100644 --- a/config-dialog.cpp +++ b/config-dialog.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "obs-module.h" #include "version.h" @@ -265,17 +266,15 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent) newVersion->setOpenExternalLinks(true); newVersion->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - QPushButton *okButton = new QPushButton(QString::fromUtf8(obs_frontend_get_locale_string("OK"))); - connect(okButton, &QPushButton::clicked, [this] { accept(); }); + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - QPushButton *cancelButton = new QPushButton(QString::fromUtf8(obs_frontend_get_locale_string("Cancel"))); - connect(cancelButton, &QPushButton::clicked, [this] { reject(); }); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addWidget(version, 1, Qt::AlignLeft); bottomLayout->addWidget(newVersion, 1, Qt::AlignLeft); - bottomLayout->addWidget(cancelButton, 0, Qt::AlignRight); - bottomLayout->addWidget(okButton, 0, Qt::AlignRight); + bottomLayout->addWidget(buttonBox, 0, Qt::AlignRight); QHBoxLayout *contentLayout = new QHBoxLayout; contentLayout->addWidget(listWidget);