aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/ssh/sshkeycreationdialog.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <[email protected]>2013-03-27 16:42:08 +0100
committerChristian Kandeler <[email protected]>2013-04-08 10:28:08 +0200
commita167286b3f4e5f24851f6603d718f49b61f0be03 (patch)
tree2279e996f006dcdeef034e2d03671c064a0fc2c5 /src/libs/ssh/sshkeycreationdialog.cpp
parent6c12a060290ec094faea22fadfaf6aa7fb2d5db2 (diff)
Ssh: Get confirmation from user for overwriting an existing key.
Change-Id: I3d74423ef647fd59d303517b0a0e987b24973095 Reviewed-by: Robert Loehning <[email protected]>
Diffstat (limited to 'src/libs/ssh/sshkeycreationdialog.cpp')
-rw-r--r--src/libs/ssh/sshkeycreationdialog.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libs/ssh/sshkeycreationdialog.cpp b/src/libs/ssh/sshkeycreationdialog.cpp
index 7ffa2c9b4b5..139b3bab72c 100644
--- a/src/libs/ssh/sshkeycreationdialog.cpp
+++ b/src/libs/ssh/sshkeycreationdialog.cpp
@@ -69,6 +69,9 @@ void SshKeyCreationDialog::keyTypeChanged()
void SshKeyCreationDialog::generateKeys()
{
+ if (userForbidsOverwriting())
+ return;
+
const SshKeyGenerator::KeyType keyType = m_ui->rsa->isChecked()
? SshKeyGenerator::Rsa
: SshKeyGenerator::Dsa;
@@ -130,6 +133,16 @@ void SshKeyCreationDialog::saveKeys()
accept();
}
+bool SshKeyCreationDialog::userForbidsOverwriting()
+{
+ if (!QFileInfo(privateKeyFilePath()).exists() && !QFileInfo(publicKeyFilePath()).exists())
+ return false;
+ const QMessageBox::StandardButton reply = QMessageBox::question(this, tr("File Exists"),
+ tr("There already is a file of that name. Do you want to overwrite it?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ return reply != QMessageBox::Yes;
+}
+
QString SshKeyCreationDialog::privateKeyFilePath() const
{
return m_ui->privateKeyFileValueLabel->text();