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);
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();
delete d;
}

View File

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

View File

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

View File

@@ -111,7 +111,7 @@ public:
auto const deployButton = new QPushButton(Tr::tr("Deploy Public Key"), this);
connect(deployButton, &QPushButton::clicked, this, [this] {
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());
});
auto const createButton = new QPushButton(Tr::tr("Create New Key Pair"), this);