From 46099fdd719ed4296a98b820dfb11446a404bb0a Mon Sep 17 00:00:00 2001 From: Thomas Luzat Date: Thu, 8 Mar 2018 03:35:06 +0100 Subject: [PATCH] SSH Agent: Update available attachments immediately The list of available attachments for SSH agent is now updated immediately when adding or removing file attachments. Closes #1668. --- src/gui/entry/EditEntryWidget.cpp | 43 ++++++++++++++++++------------- src/gui/entry/EditEntryWidget.h | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 079f81056..7acd3af34 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -281,6 +281,8 @@ void EditEntryWidget::setupSSHAgent() connect(m_sshAgentUi->decryptButton, SIGNAL(clicked()), SLOT(decryptPrivateKey())); connect(m_sshAgentUi->copyToClipboardButton, SIGNAL(clicked()), SLOT(copyPublicKey())); + connect(m_advancedUi->attachmentsWidget->entryAttachments(), SIGNAL(modified()), SLOT(updateAttachments())); + addPage(tr("SSH Agent"), FilePath::instance()->icon("apps", "utilities-terminal"), m_sshAgentWidget); } @@ -299,6 +301,27 @@ void EditEntryWidget::updateSSHAgent() m_sshAgentUi->removeFromAgentButton->setEnabled(false); m_sshAgentUi->copyToClipboardButton->setEnabled(false); + m_sshAgentSettings = settings; + updateSSHAgentAttachments(); + + if (settings.selectedType() == "attachment") { + m_sshAgentUi->attachmentRadioButton->setChecked(true); + } else { + m_sshAgentUi->externalFileRadioButton->setChecked(true); + } + + updateSSHAgentKeyInfo(); +} + +void EditEntryWidget::updateSSHAgentAttachment() +{ + m_sshAgentUi->attachmentRadioButton->setChecked(true); + updateSSHAgentKeyInfo(); +} + +void EditEntryWidget::updateSSHAgentAttachments() +{ + m_sshAgentUi->attachmentComboBox->clear(); m_sshAgentUi->attachmentComboBox->addItem(""); auto attachments = m_advancedUi->attachmentsWidget->entryAttachments(); @@ -310,24 +333,8 @@ void EditEntryWidget::updateSSHAgent() m_sshAgentUi->attachmentComboBox->addItem(fileName); } - m_sshAgentUi->attachmentComboBox->setCurrentText(settings.attachmentName()); - m_sshAgentUi->externalFileEdit->setText(settings.fileName()); - - if (settings.selectedType() == "attachment") { - m_sshAgentUi->attachmentRadioButton->setChecked(true); - } else { - m_sshAgentUi->externalFileRadioButton->setChecked(true); - } - - m_sshAgentSettings = settings; - - updateSSHAgentKeyInfo(); -} - -void EditEntryWidget::updateSSHAgentAttachment() -{ - m_sshAgentUi->attachmentRadioButton->setChecked(true); - updateSSHAgentKeyInfo(); + m_sshAgentUi->attachmentComboBox->setCurrentText(m_sshAgentSettings.attachmentName()); + m_sshAgentUi->externalFileEdit->setText(m_sshAgentSettings.fileName()); } void EditEntryWidget::updateSSHAgentKeyInfo() diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h index a7c8e3271..9b2a919c6 100644 --- a/src/gui/entry/EditEntryWidget.h +++ b/src/gui/entry/EditEntryWidget.h @@ -103,6 +103,7 @@ private slots: #ifdef WITH_XC_SSHAGENT void updateSSHAgent(); void updateSSHAgentAttachment(); + void updateSSHAgentAttachments(); void updateSSHAgentKeyInfo(); void browsePrivateKey(); void addKeyToAgent();