RemoteLinux: Simplify PublicKeyDeploymentDialog

Change-Id: Iae53f4c3948176f0bc5df11d2cc24b33c113d774
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-20 18:43:47 +01:00
parent d6f4f68605
commit 2dbd2fb674
4 changed files with 11 additions and 14 deletions

View File

@@ -1029,7 +1029,7 @@ LinuxDevice::LinuxDevice()
setSshParameters(sshParams); setSshParameters(sshParams);
addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device) { addDeviceAction({Tr::tr("Deploy Public Key..."), [](const IDevice::Ptr &device) {
if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device, Core::ICore::dialogParent())) { if (auto d = Internal::PublicKeyDeploymentDialog::createDialog(device)) {
d->exec(); d->exec();
delete d; delete d;
} }

View File

@@ -5,6 +5,8 @@
#include "remotelinuxtr.h" #include "remotelinuxtr.h"
#include <coreplugin/icore.h>
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/sshparameters.h> #include <projectexplorer/devicesupport/sshparameters.h>
#include <projectexplorer/devicesupport/sshsettings.h> #include <projectexplorer/devicesupport/sshsettings.h>
@@ -27,8 +29,7 @@ public:
bool m_done; bool m_done;
}; };
PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog( PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(const DeviceConstRef &device)
const DeviceConstRef &device, QWidget *parent) // TODO: Use Core::ICore::dialogParent()
{ {
const FilePath dir = device.sshParameters().privateKeyFile.parentDir(); const FilePath dir = device.sshParameters().privateKeyFile.parentDir();
const FilePath publicKeyFileName = FileUtils::getOpenFilePath( const FilePath publicKeyFileName = FileUtils::getOpenFilePath(
@@ -36,14 +37,12 @@ PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
Tr::tr("Public Key Files (*.pub);;All Files (*)")); Tr::tr("Public Key Files (*.pub);;All Files (*)"));
if (publicKeyFileName.isEmpty()) if (publicKeyFileName.isEmpty())
return nullptr; return nullptr;
return new PublicKeyDeploymentDialog(device, publicKeyFileName, parent); return new PublicKeyDeploymentDialog(device, publicKeyFileName);
} }
PublicKeyDeploymentDialog::PublicKeyDeploymentDialog( PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const DeviceConstRef &device,
const DeviceConstRef &device, const FilePath &publicKeyFileName)
const FilePath &publicKeyFileName, : QProgressDialog(Core::ICore::dialogParent()), d(new PublicKeyDeploymentDialogPrivate)
QWidget *parent)
: QProgressDialog(parent), d(new PublicKeyDeploymentDialogPrivate)
{ {
setAutoReset(false); setAutoReset(false);
setAutoClose(false); setAutoClose(false);

View File

@@ -21,12 +21,10 @@ class PublicKeyDeploymentDialog : public QProgressDialog
Q_OBJECT Q_OBJECT
public: public:
// Asks for public key and returns null if the file dialog is canceled. // Asks for public key and returns null if the file dialog is canceled.
static PublicKeyDeploymentDialog *createDialog(const ProjectExplorer::DeviceConstRef &device, static PublicKeyDeploymentDialog *createDialog(const ProjectExplorer::DeviceConstRef &device);
QWidget *parent = nullptr);
PublicKeyDeploymentDialog(const ProjectExplorer::DeviceConstRef &device, PublicKeyDeploymentDialog(const ProjectExplorer::DeviceConstRef &device,
const Utils::FilePath &publicKeyFileName, const Utils::FilePath &publicKeyFileName);
QWidget *parent = nullptr);
~PublicKeyDeploymentDialog() override; ~PublicKeyDeploymentDialog() override;

View File

@@ -111,7 +111,7 @@ public:
auto const deployButton = new QPushButton(Tr::tr("Deploy Public Key"), this); auto const deployButton = new QPushButton(Tr::tr("Deploy Public Key"), this);
connect(deployButton, &QPushButton::clicked, this, [this] { connect(deployButton, &QPushButton::clicked, this, [this] {
Internal::PublicKeyDeploymentDialog dlg( Internal::PublicKeyDeploymentDialog dlg(
m_device, m_keyFileChooser.filePath().stringAppended(".pub"), this); m_device, m_keyFileChooser.filePath().stringAppended(".pub"));
m_iconLabel.setPixmap((dlg.exec() == QDialog::Accepted ? Icons::OK : Icons::BROKEN).pixmap()); m_iconLabel.setPixmap((dlg.exec() == QDialog::Accepted ? Icons::OK : Icons::BROKEN).pixmap());
}); });
auto const createButton = new QPushButton(Tr::tr("Create New Key Pair"), this); auto const createButton = new QPushButton(Tr::tr("Create New Key Pair"), this);