diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index fcb53d6a..b7e2fdbe 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -108,6 +108,8 @@ void EditEntryWidget::setupAdvanced()
m_attachmentsModel->setEntryAttachments(m_entryAttachments);
m_advancedUi->attachmentsView->setModel(m_attachmentsModel);
+ connect(m_advancedUi->attachmentsView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ SLOT(updateAttachmentButtonsEnabled(QModelIndex)));
connect(m_advancedUi->attachmentsView, SIGNAL(doubleClicked(QModelIndex)), SLOT(openAttachment(QModelIndex)));
connect(m_advancedUi->saveAttachmentButton, SIGNAL(clicked()), SLOT(saveCurrentAttachment()));
connect(m_advancedUi->openAttachmentButton, SIGNAL(clicked()), SLOT(openCurrentAttachment()));
@@ -235,6 +237,15 @@ void EditEntryWidget::useExpiryPreset(QAction* action)
m_mainUi->expireDatePicker->setDateTime(expiryDateTime);
}
+void EditEntryWidget::updateAttachmentButtonsEnabled(const QModelIndex& current)
+{
+ bool enable = current.isValid();
+
+ m_advancedUi->saveAttachmentButton->setEnabled(enable);
+ m_advancedUi->openAttachmentButton->setEnabled(enable);
+ m_advancedUi->removeAttachmentButton->setEnabled(enable && !m_history);
+}
+
QString EditEntryWidget::entryTitle() const
{
if (m_entry) {
@@ -284,7 +295,7 @@ void EditEntryWidget::setForms(const Entry* entry, bool restore)
m_mainUi->tooglePasswordGeneratorButton->setChecked(false);
m_mainUi->passwordGenerator->reset();
m_advancedUi->addAttachmentButton->setEnabled(!m_history);
- m_advancedUi->removeAttachmentButton->setEnabled(!m_history);
+ updateAttachmentButtonsEnabled(m_advancedUi->attachmentsView->currentIndex());
m_advancedUi->addAttributeButton->setEnabled(!m_history);
m_advancedUi->editAttributeButton->setEnabled(false);
m_advancedUi->removeAttributeButton->setEnabled(false);
diff --git a/src/gui/entry/EditEntryWidget.h b/src/gui/entry/EditEntryWidget.h
index 90302987..14434762 100644
--- a/src/gui/entry/EditEntryWidget.h
+++ b/src/gui/entry/EditEntryWidget.h
@@ -93,6 +93,7 @@ private Q_SLOTS:
void histEntryActivated(const QModelIndex& index);
void updateHistoryButtons(const QModelIndex& current, const QModelIndex& previous);
void useExpiryPreset(QAction* action);
+ void updateAttachmentButtonsEnabled(const QModelIndex& current);
private:
void setupMain();
diff --git a/src/gui/entry/EditEntryWidgetAdvanced.ui b/src/gui/entry/EditEntryWidgetAdvanced.ui
index 551ea4af..93e15260 100644
--- a/src/gui/entry/EditEntryWidgetAdvanced.ui
+++ b/src/gui/entry/EditEntryWidgetAdvanced.ui
@@ -101,6 +101,9 @@
-
+
+ false
+
Remove
@@ -108,6 +111,9 @@
-
+
+ false
+
Open
@@ -115,6 +121,9 @@
-
+
+ false
+
Save