Open and save attachment in readonly mode

* Fix #2039
This commit is contained in:
fpohtmeh 2020-07-07 21:18:55 +03:00 committed by Jonathan White
parent 22e0d8b442
commit 004f5d407f
2 changed files with 9 additions and 3 deletions

View File

@ -40,9 +40,7 @@ EntryAttachmentsWidget::EntryAttachmentsWidget(QWidget* parent)
m_ui->attachmentsView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_ui->attachmentsView->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_ui->actionsWidget->setVisible(m_buttonsVisible);
connect(this, SIGNAL(buttonsVisibleChanged(bool)), m_ui->actionsWidget, SLOT(setVisible(bool)));
connect(this, SIGNAL(buttonsVisibleChanged(bool)), this, SLOT(updateButtonsVisible()));
connect(this, SIGNAL(readOnlyChanged(bool)), SLOT(updateButtonsEnabled()));
connect(m_attachmentsModel, SIGNAL(modelReset()), SLOT(updateButtonsEnabled()));
@ -58,6 +56,7 @@ EntryAttachmentsWidget::EntryAttachmentsWidget(QWidget* parent)
connect(m_ui->addAttachmentButton, SIGNAL(clicked()), SLOT(insertAttachments()));
connect(m_ui->removeAttachmentButton, SIGNAL(clicked()), SLOT(removeSelectedAttachments()));
updateButtonsVisible();
updateButtonsEnabled();
}
@ -295,6 +294,12 @@ void EntryAttachmentsWidget::updateButtonsEnabled()
m_ui->openAttachmentButton->setEnabled(hasSelection);
}
void EntryAttachmentsWidget::updateButtonsVisible()
{
m_ui->addAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly);
m_ui->removeAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly);
}
bool EntryAttachmentsWidget::insertAttachments(const QStringList& filenames, QString& errorMessage)
{
Q_ASSERT(!isReadOnly());

View File

@ -48,6 +48,7 @@ private slots:
void saveSelectedAttachments();
void openAttachment(const QModelIndex& index);
void openSelectedAttachments();
void updateButtonsVisible();
void updateButtonsEnabled();
private: