diff --git a/src/gui/entry/EntryAttachmentsWidget.cpp b/src/gui/entry/EntryAttachmentsWidget.cpp index e837f61e71..cb00cb2357 100644 --- a/src/gui/entry/EntryAttachmentsWidget.cpp +++ b/src/gui/entry/EntryAttachmentsWidget.cpp @@ -73,7 +73,6 @@ EntryAttachmentsWidget::EntryAttachmentsWidget(QWidget* parent) connect(m_ui->newAttachmentButton, SIGNAL(clicked()), SLOT(newAttachments())); connect(m_ui->previewAttachmentButton, SIGNAL(clicked()), SLOT(previewSelectedAttachment())); connect(m_ui->removeAttachmentButton, SIGNAL(clicked()), SLOT(removeSelectedAttachments())); - connect(m_ui->renameAttachmentButton, SIGNAL(clicked()), SLOT(renameSelectedAttachments())); updateButtonsVisible(); updateButtonsEnabled(); @@ -248,12 +247,6 @@ void EntryAttachmentsWidget::removeSelectedAttachments() } } -void EntryAttachmentsWidget::renameSelectedAttachments() -{ - Q_ASSERT(m_entryAttachments); - m_ui->attachmentsView->edit(m_ui->attachmentsView->selectionModel()->selectedIndexes().first()); -} - void EntryAttachmentsWidget::saveSelectedAttachments() { Q_ASSERT(m_entryAttachments); @@ -358,11 +351,21 @@ void EntryAttachmentsWidget::updateButtonsEnabled() m_ui->addAttachmentButton->setEnabled(!m_readOnly); m_ui->newAttachmentButton->setEnabled(!m_readOnly); m_ui->removeAttachmentButton->setEnabled(hasSelection && !m_readOnly); - m_ui->renameAttachmentButton->setEnabled(hasSelection && !m_readOnly); m_ui->saveAttachmentButton->setEnabled(hasSelection); m_ui->previewAttachmentButton->setEnabled(hasSelection); m_ui->openAttachmentButton->setEnabled(hasSelection); + + updateSpacers(); +} + +void EntryAttachmentsWidget::updateSpacers() +{ + if (m_buttonsVisible && !m_readOnly) { + m_ui->previewVSpacer->changeSize(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + } else { + m_ui->previewVSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); + } } void EntryAttachmentsWidget::updateButtonsVisible() @@ -370,7 +373,8 @@ void EntryAttachmentsWidget::updateButtonsVisible() m_ui->addAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly); m_ui->newAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly); m_ui->removeAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly); - m_ui->renameAttachmentButton->setVisible(m_buttonsVisible && !m_readOnly); + + updateSpacers(); } bool EntryAttachmentsWidget::insertAttachments(const QStringList& filenames, QString& errorMessage) diff --git a/src/gui/entry/EntryAttachmentsWidget.h b/src/gui/entry/EntryAttachmentsWidget.h index 6dc1ee94db..8c15fd68a5 100644 --- a/src/gui/entry/EntryAttachmentsWidget.h +++ b/src/gui/entry/EntryAttachmentsWidget.h @@ -60,7 +60,6 @@ private slots: void newAttachments(); void previewSelectedAttachment(); void removeSelectedAttachments(); - void renameSelectedAttachments(); void saveSelectedAttachments(); void openAttachment(const QModelIndex& index); void openSelectedAttachments(); @@ -69,6 +68,8 @@ private slots: void attachmentModifiedExternally(const QString& key, const QString& filePath); private: + void updateSpacers(); + bool insertAttachments(const QStringList& fileNames, QString& errorMessage); QStringList confirmAttachmentSelection(const QStringList& filenames); diff --git a/src/gui/entry/EntryAttachmentsWidget.ui b/src/gui/entry/EntryAttachmentsWidget.ui index 99a16ca4e9..495a4ca38e 100644 --- a/src/gui/entry/EntryAttachmentsWidget.ui +++ b/src/gui/entry/EntryAttachmentsWidget.ui @@ -7,7 +7,7 @@ 0 0 337 - 294 + 258 @@ -38,7 +38,7 @@ - + 0 @@ -75,30 +75,17 @@ - - - false - - - Remove selected attachment - - - Remove - - - - - - - false - - - Rename selected attachment + + + Qt::Vertical - - Rename + + + 20 + 40 + - + @@ -149,6 +136,35 @@ + + + + false + + + Remove selected attachment + + + Remove + + + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 0 + + + +