From e287fbd812ae9fbac36726ac4565739b078bf48e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 29 Nov 2011 15:49:37 +0100 Subject: [PATCH] RemoteLinux: Fix visual glitch when canceling key deployment. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTCREATORBUG-6568 Change-Id: I62da4b5e6ebed90fa51ed02107cfc083218802a4 Reviewed-by: Robert Löhning --- .../madde/maddedeviceconfigurationfactory.cpp | 2 +- ...genericlinuxdeviceconfigurationfactory.cpp | 2 +- ...inuxdeviceconfigurationssettingswidget.cpp | 4 +- .../remotelinux/publickeydeploymentdialog.cpp | 42 ++++++++++--------- .../remotelinux/publickeydeploymentdialog.h | 6 ++- 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/plugins/madde/maddedeviceconfigurationfactory.cpp b/src/plugins/madde/maddedeviceconfigurationfactory.cpp index c81d51cbc36..7dfff2837ac 100644 --- a/src/plugins/madde/maddedeviceconfigurationfactory.cpp +++ b/src/plugins/madde/maddedeviceconfigurationfactory.cpp @@ -112,7 +112,7 @@ QDialog *MaddeDeviceConfigurationFactory::createDeviceAction(const QString &acti if (actionId == QLatin1String(MaddeRemoteProcessesActionId)) return new RemoteLinuxProcessesDialog(new GenericRemoteLinuxProcessList(deviceConfig), parent); if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) - return new PublicKeyDeploymentDialog(deviceConfig, parent); + return PublicKeyDeploymentDialog::createDialog(deviceConfig, parent); return 0; // Can't happen. } diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp index 9cc3aaf4233..65f36533085 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp @@ -100,7 +100,7 @@ QDialog *GenericLinuxDeviceConfigurationFactory::createDeviceAction(const QStrin parent); } if (actionId == QLatin1String(Constants::GenericDeployKeyToDeviceActionId)) - return new PublicKeyDeploymentDialog(deviceConfig, parent); + return PublicKeyDeploymentDialog::createDialog(deviceConfig, parent); return 0; // Can't happen. } diff --git a/src/plugins/remotelinux/linuxdeviceconfigurationssettingswidget.cpp b/src/plugins/remotelinux/linuxdeviceconfigurationssettingswidget.cpp index fef007b06ca..8fb67095390 100644 --- a/src/plugins/remotelinux/linuxdeviceconfigurationssettingswidget.cpp +++ b/src/plugins/remotelinux/linuxdeviceconfigurationssettingswidget.cpp @@ -426,8 +426,8 @@ void LinuxDeviceConfigurationsSettingsWidget::handleAdditionalActionRequest(cons const ILinuxDeviceConfigurationFactory * const factory = factoryForCurrentConfig(); Q_ASSERT(factory); QDialog * const action = factory->createDeviceAction(actionId, currentConfig(), this); - Q_ASSERT(action); - action->exec(); + if (action) + action->exec(); delete action; } diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.cpp b/src/plugins/remotelinux/publickeydeploymentdialog.cpp index 16c26319b0c..fef99bf8553 100644 --- a/src/plugins/remotelinux/publickeydeploymentdialog.cpp +++ b/src/plugins/remotelinux/publickeydeploymentdialog.cpp @@ -33,25 +33,40 @@ #include "linuxdeviceconfiguration.h" #include "sshkeydeployer.h" +#include #include #include #include +#include namespace RemoteLinux { namespace Internal { class PublicKeyDeploymentDialogPrivate { public: - SshKeyDeployer *keyDeployer; + SshKeyDeployer keyDeployer; bool done; }; } // namespace Internal; using namespace Internal; +PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(const LinuxDeviceConfiguration::ConstPtr &deviceConfig, + QWidget *parent) +{ + const QString &dir = QFileInfo(deviceConfig->sshParameters().privateKeyFile).path(); + const QString publicKeyFileName = QFileDialog::getOpenFileName(parent + ? parent : Core::ICore::instance()->mainWindow(), + tr("Choose Public Key File"), dir, + tr("Public Key Files (*.pub);;All Files (*)")); + if (publicKeyFileName.isEmpty()) + return 0; + return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName, parent); +} + PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const LinuxDeviceConfiguration::ConstPtr &deviceConfig, - QWidget *parent) + const QString &publicKeyFileName, QWidget *parent) : QProgressDialog(parent), d(new PublicKeyDeploymentDialogPrivate) { setAutoReset(false); @@ -59,26 +74,13 @@ PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const LinuxDeviceConfigurat setMinimumDuration(0); setMaximum(1); - d->keyDeployer = new SshKeyDeployer(this); d->done = false; - - setLabelText(tr("Waiting for file name...")); - const Utils::SshConnectionParameters sshParams = deviceConfig->sshParameters(); - const QString &dir = QFileInfo(sshParams.privateKeyFile).path(); - QString publicKeyFileName = QFileDialog::getOpenFileName(this, - tr("Choose Public Key File"), dir, - tr("Public Key Files (*.pub);;All Files (*)")); - if (publicKeyFileName.isEmpty()) { - QTimer::singleShot(0, this, SLOT(reject())); - return; - } - setLabelText(tr("Deploying...")); setValue(0); connect(this, SIGNAL(canceled()), SLOT(handleCanceled())); - connect(d->keyDeployer, SIGNAL(error(QString)), SLOT(handleDeploymentError(QString))); - connect(d->keyDeployer, SIGNAL(finishedSuccessfully()), SLOT(handleDeploymentSuccess())); - d->keyDeployer->deployPublicKey(sshParams, publicKeyFileName); + connect(&d->keyDeployer, SIGNAL(error(QString)), SLOT(handleDeploymentError(QString))); + connect(&d->keyDeployer, SIGNAL(finishedSuccessfully()), SLOT(handleDeploymentSuccess())); + d->keyDeployer.deployPublicKey(deviceConfig->sshParameters(), publicKeyFileName); } PublicKeyDeploymentDialog::~PublicKeyDeploymentDialog() @@ -115,8 +117,8 @@ void PublicKeyDeploymentDialog::handleDeploymentFinished(const QString &errorMsg void PublicKeyDeploymentDialog::handleCanceled() { - disconnect(d->keyDeployer, 0, this, 0); - d->keyDeployer->stopDeployment(); + disconnect(&d->keyDeployer, 0, this, 0); + d->keyDeployer.stopDeployment(); if (d->done) accept(); else diff --git a/src/plugins/remotelinux/publickeydeploymentdialog.h b/src/plugins/remotelinux/publickeydeploymentdialog.h index 04071efd7fb..01678820c30 100644 --- a/src/plugins/remotelinux/publickeydeploymentdialog.h +++ b/src/plugins/remotelinux/publickeydeploymentdialog.h @@ -51,8 +51,10 @@ class REMOTELINUX_EXPORT PublicKeyDeploymentDialog : public QProgressDialog { Q_OBJECT public: - explicit PublicKeyDeploymentDialog(const QSharedPointer &deviceConfig, + // Asks for public key and returns null if the file dialog is canceled. + static PublicKeyDeploymentDialog *createDialog(const QSharedPointer &deviceConfig, QWidget *parent = 0); + ~PublicKeyDeploymentDialog(); private slots: @@ -61,6 +63,8 @@ private slots: void handleCanceled(); private: + explicit PublicKeyDeploymentDialog(const QSharedPointer &deviceConfig, + const QString &publicKeyFileName, QWidget *parent = 0); void handleDeploymentFinished(const QString &errorMsg); Internal::PublicKeyDeploymentDialogPrivate * const d;