SshKeyCreationDialog: Use QDialogButtonBox

This makes the buttons conform to the platform guidelines.

Change-Id: Ide0d7460867e632550c08bc78301d12b66c1f474
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2022-08-26 09:33:42 +02:00
parent 025bdfe702
commit aa361b886e

View File

@@ -37,6 +37,7 @@
#include <QApplication> #include <QApplication>
#include <QComboBox> #include <QComboBox>
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QMessageBox> #include <QMessageBox>
@@ -67,9 +68,12 @@ SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent)
m_publicKeyFileLabel = new QLabel; m_publicKeyFileLabel = new QLabel;
auto privateKeyFileButton = new QPushButton(PathChooser::browseButtonLabel()); auto privateKeyFileButton = new QPushButton(PathChooser::browseButtonLabel());
m_generateButton = new QPushButton(Tr::tr("&Generate And Save Key Pair")); auto buttonBox = new QDialogButtonBox;
auto closeButton = new QPushButton(Tr::tr("&Cancel")); m_generateButton = buttonBox->addButton(Tr::tr("&Generate And Save Key Pair"),
QDialogButtonBox::AcceptRole);
buttonBox->addButton(QDialogButtonBox::Cancel);
// clang-format off
using namespace Layouting; using namespace Layouting;
Column { Column {
Group { Group {
@@ -82,21 +86,19 @@ SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent)
} }
}, },
st, st,
Row { m_generateButton, closeButton, st } buttonBox
}.attachTo(this); }.attachTo(this);
// clang-format on
const QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) const QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation)
+ QLatin1String("/.ssh/qtc_id"); + QLatin1String("/.ssh/qtc_id");
setPrivateKeyFile(FilePath::fromString(defaultPath)); setPrivateKeyFile(FilePath::fromString(defaultPath));
connect(closeButton, &QPushButton::clicked, connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::close);
this, &QDialog::close); connect(buttonBox, &QDialogButtonBox::accepted, this, &SshKeyCreationDialog::generateKeys);
connect(m_rsa, &QRadioButton::toggled, connect(m_rsa, &QRadioButton::toggled, this, &SshKeyCreationDialog::keyTypeChanged);
this, &SshKeyCreationDialog::keyTypeChanged);
connect(privateKeyFileButton, &QPushButton::clicked, connect(privateKeyFileButton, &QPushButton::clicked,
this, &SshKeyCreationDialog::handleBrowseButtonClicked); this, &SshKeyCreationDialog::handleBrowseButtonClicked);
connect(m_generateButton, &QPushButton::clicked,
this, &SshKeyCreationDialog::generateKeys);
keyTypeChanged(); keyTypeChanged();
} }