diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 1f755f1bd04..75899417c2b 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -31,7 +31,7 @@ add_qtc_plugin(RemoteLinux remotelinuxrunconfiguration.cpp remotelinuxrunconfiguration.h remotelinuxsignaloperation.cpp remotelinuxsignaloperation.h rsyncdeploystep.cpp rsyncdeploystep.h - sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui + sshkeycreationdialog.cpp sshkeycreationdialog.h sshprocessinterface.h tarpackagecreationstep.cpp tarpackagecreationstep.h tarpackagedeploystep.cpp tarpackagedeploystep.h diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 59d71062932..4ad512e75d4 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -69,7 +69,6 @@ Project { "rsyncdeploystep.h", "sshkeycreationdialog.cpp", "sshkeycreationdialog.h", - "sshkeycreationdialog.ui", "sshprocessinterface.h", "tarpackagecreationstep.cpp", "tarpackagecreationstep.h", diff --git a/src/plugins/remotelinux/sshkeycreationdialog.cpp b/src/plugins/remotelinux/sshkeycreationdialog.cpp index 7cf97c23d8a..fc6649d6696 100644 --- a/src/plugins/remotelinux/sshkeycreationdialog.cpp +++ b/src/plugins/remotelinux/sshkeycreationdialog.cpp @@ -24,16 +24,22 @@ ****************************************************************************/ #include "sshkeycreationdialog.h" -#include "ui_sshkeycreationdialog.h" #include #include +#include #include #include #include +#include +#include +#include +#include #include +#include +#include #include using namespace ProjectExplorer; @@ -42,40 +48,73 @@ using namespace Utils; namespace RemoteLinux { SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent) - : QDialog(parent), m_ui(new Ui::SshKeyCreationDialog) + : QDialog(parent) { - m_ui->setupUi(this); - m_ui->privateKeyFileButton->setText(Utils::PathChooser::browseButtonLabel()); + setWindowTitle(tr("SSH Key Configuration")); + resize(385, 231); + + m_rsa = new QRadioButton(tr("&RSA")); + m_rsa->setChecked(true); + + m_ecdsa = new QRadioButton(tr("ECDSA")); + + m_comboBox = new QComboBox; + + m_privateKeyFileValueLabel = new QLabel; + + m_publicKeyFileLabel = new QLabel; + + auto privateKeyFileButton = new QPushButton(PathChooser::browseButtonLabel()); + m_generateButton = new QPushButton(tr("&Generate And Save Key Pair")); + auto closeButton = new QPushButton(tr("&Cancel")); + + using namespace Layouting; + const Break nl; + const Stretch st; + + Column { + Group { + Title(tr("Options")), + Form { + tr("Key algorithm:"), m_rsa, m_ecdsa, st, nl, + tr("Key &size:"), m_comboBox, st, nl, + tr("Private key file:"), m_privateKeyFileValueLabel, privateKeyFileButton, st, nl, + tr("Public key file:"), m_publicKeyFileLabel + } + }, + Stretch(), + Row { m_generateButton, closeButton, st } + }.attachTo(this); + const QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QLatin1String("/.ssh/qtc_id"); setPrivateKeyFile(FilePath::fromString(defaultPath)); - connect(m_ui->rsa, &QRadioButton::toggled, + connect(closeButton, &QPushButton::clicked, + this, &QDialog::close); + connect(m_rsa, &QRadioButton::toggled, this, &SshKeyCreationDialog::keyTypeChanged); - connect(m_ui->privateKeyFileButton, &QPushButton::clicked, + connect(privateKeyFileButton, &QPushButton::clicked, this, &SshKeyCreationDialog::handleBrowseButtonClicked); - connect(m_ui->generateButton, &QPushButton::clicked, + connect(m_generateButton, &QPushButton::clicked, this, &SshKeyCreationDialog::generateKeys); keyTypeChanged(); } -SshKeyCreationDialog::~SshKeyCreationDialog() -{ - delete m_ui; -} +SshKeyCreationDialog::~SshKeyCreationDialog() = default; void SshKeyCreationDialog::keyTypeChanged() { - m_ui->comboBox->clear(); + m_comboBox->clear(); QStringList keySizes; - if (m_ui->rsa->isChecked()) + if (m_rsa->isChecked()) keySizes << QLatin1String("1024") << QLatin1String("2048") << QLatin1String("4096"); - else if (m_ui->ecdsa->isChecked()) + else if (m_ecdsa->isChecked()) keySizes << QLatin1String("256") << QLatin1String("384") << QLatin1String("521"); - m_ui->comboBox->addItems(keySizes); + m_comboBox->addItems(keySizes); if (!keySizes.isEmpty()) - m_ui->comboBox->setCurrentIndex(0); - m_ui->comboBox->setEnabled(!keySizes.isEmpty()); + m_comboBox->setCurrentIndex(0); + m_comboBox->setEnabled(!keySizes.isEmpty()); } void SshKeyCreationDialog::generateKeys() @@ -89,10 +128,10 @@ void SshKeyCreationDialog::generateKeys() .arg(privateKeyFilePath().toUserOutput())); return; } - const QString keyTypeString = QLatin1String(m_ui->rsa->isChecked() ? "rsa": "ecdsa"); + const QString keyTypeString = QLatin1String(m_rsa->isChecked() ? "rsa": "ecdsa"); QApplication::setOverrideCursor(Qt::BusyCursor); QtcProcess keygen; - const QStringList args{"-t", keyTypeString, "-b", m_ui->comboBox->currentText(), + const QStringList args{"-t", keyTypeString, "-b", m_comboBox->currentText(), "-N", QString(), "-f", privateKeyFilePath().path()}; QString errorMsg; keygen.setCommand({SshSettings::keygenFilePath(), args}); @@ -118,9 +157,9 @@ void SshKeyCreationDialog::handleBrowseButtonClicked() void SshKeyCreationDialog::setPrivateKeyFile(const FilePath &filePath) { - m_ui->privateKeyFileValueLabel->setText(filePath.toUserOutput()); - m_ui->generateButton->setEnabled(!privateKeyFilePath().isEmpty()); - m_ui->publicKeyFileLabel->setText(filePath.toUserOutput() + ".pub"); + m_privateKeyFileValueLabel->setText(filePath.toUserOutput()); + m_generateButton->setEnabled(!privateKeyFilePath().isEmpty()); + m_publicKeyFileLabel->setText(filePath.toUserOutput() + ".pub"); } void SshKeyCreationDialog::showError(const QString &details) @@ -130,12 +169,12 @@ void SshKeyCreationDialog::showError(const QString &details) FilePath SshKeyCreationDialog::privateKeyFilePath() const { - return FilePath::fromUserInput(m_ui->privateKeyFileValueLabel->text()); + return FilePath::fromUserInput(m_privateKeyFileValueLabel->text()); } FilePath SshKeyCreationDialog::publicKeyFilePath() const { - return FilePath::fromUserInput(m_ui->publicKeyFileLabel->text()); + return FilePath::fromUserInput(m_publicKeyFileLabel->text()); } } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/sshkeycreationdialog.h b/src/plugins/remotelinux/sshkeycreationdialog.h index 859ac326a67..e703a4c6907 100644 --- a/src/plugins/remotelinux/sshkeycreationdialog.h +++ b/src/plugins/remotelinux/sshkeycreationdialog.h @@ -27,12 +27,17 @@ #include +QT_BEGIN_NAMESPACE +class QComboBox; +class QLabel; +class QPushButton; +class QRadioButton; +QT_END_NAMESPACE + namespace Utils { class FilePath; } namespace RemoteLinux { -namespace Ui { class SshKeyCreationDialog; } - class SshKeyCreationDialog : public QDialog { Q_OBJECT @@ -51,7 +56,12 @@ private: void showError(const QString &details); private: - Ui::SshKeyCreationDialog *m_ui; + QComboBox *m_comboBox; + QLabel *m_privateKeyFileValueLabel; + QLabel *m_publicKeyFileLabel; + QPushButton *m_generateButton; + QRadioButton *m_rsa; + QRadioButton *m_ecdsa; }; } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/sshkeycreationdialog.ui b/src/plugins/remotelinux/sshkeycreationdialog.ui deleted file mode 100644 index 21f435be227..00000000000 --- a/src/plugins/remotelinux/sshkeycreationdialog.ui +++ /dev/null @@ -1,250 +0,0 @@ - - - RemoteLinux::SshKeyCreationDialog - - - true - - - - 0 - 0 - 385 - 231 - - - - - 0 - 0 - - - - SSH Key Configuration - - - - - - Options - - - - - - Key algorithm: - - - - - - - - - - 0 - 0 - - - - &RSA - - - true - - - - - - - ECDSA - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 0 - - - - Key &size: - - - comboBox - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Private key file: - - - - - - - - - - - - - - - - Browse... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Public key file: - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 6 - - - - - - 0 - 0 - - - - &Generate And Save Key Pair - - - - - - - - 0 - 0 - - - - &Cancel - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - - - - closeButton - clicked() - RemoteLinux::SshKeyCreationDialog - close() - - - 195 - 184 - - - 381 - 107 - - - - -