diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 8d79c1a92..c5b7b5148 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -911,3 +911,53 @@ bool DatabaseWidget::isGroupSelected() const { return m_groupView->currentGroup() != Q_NULLPTR; } + +bool DatabaseWidget::currentEntryHasTitle() +{ + Entry* currentEntry = m_entryView->currentEntry(); + if (!currentEntry) { + Q_ASSERT(false); + return false; + } + return !currentEntry->title().isEmpty(); +} + +bool DatabaseWidget::currentEntryHasUsername() +{ + Entry* currentEntry = m_entryView->currentEntry(); + if (!currentEntry) { + Q_ASSERT(false); + return false; + } + return !currentEntry->username().isEmpty(); +} + +bool DatabaseWidget::currentEntryHasPassword() +{ + Entry* currentEntry = m_entryView->currentEntry(); + if (!currentEntry) { + Q_ASSERT(false); + return false; + } + return !currentEntry->password().isEmpty(); +} + +bool DatabaseWidget::currentEntryHasUrl() +{ + Entry* currentEntry = m_entryView->currentEntry(); + if (!currentEntry) { + Q_ASSERT(false); + return false; + } + return !currentEntry->url().isEmpty(); +} + +bool DatabaseWidget::currentEntryHasNotes() +{ + Entry* currentEntry = m_entryView->currentEntry(); + if (!currentEntry) { + Q_ASSERT(false); + return false; + } + return !currentEntry->notes().isEmpty(); +} diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index a38af731e..1ba3dd1f5 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -80,6 +80,11 @@ public: QList entryHeaderViewSizes() const; void setEntryViewHeaderSizes(const QList& sizes); void clearAllWidgets(); + bool currentEntryHasTitle(); + bool currentEntryHasUsername(); + bool currentEntryHasPassword(); + bool currentEntryHasUrl(); + bool currentEntryHasNotes(); Q_SIGNALS: void closeRequest(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 93084f643..ce814ae98 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -286,14 +286,14 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) m_ui->actionEntryClone->setEnabled(singleEntrySelected && !inSearch); m_ui->actionEntryEdit->setEnabled(singleEntrySelected); m_ui->actionEntryDelete->setEnabled(entriesSelected); - m_ui->actionEntryCopyTitle->setEnabled(singleEntrySelected); - m_ui->actionEntryCopyUsername->setEnabled(singleEntrySelected); - m_ui->actionEntryCopyPassword->setEnabled(singleEntrySelected); - m_ui->actionEntryCopyURL->setEnabled(singleEntrySelected); - m_ui->actionEntryCopyNotes->setEnabled(singleEntrySelected); + m_ui->actionEntryCopyTitle->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTitle()); + m_ui->actionEntryCopyUsername->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUsername()); + m_ui->actionEntryCopyPassword->setEnabled(singleEntrySelected && dbWidget->currentEntryHasPassword()); + m_ui->actionEntryCopyURL->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); + m_ui->actionEntryCopyNotes->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); m_ui->menuEntryCopyAttribute->setEnabled(singleEntrySelected); m_ui->actionEntryAutoType->setEnabled(singleEntrySelected); - m_ui->actionEntryOpenUrl->setEnabled(singleEntrySelected); + m_ui->actionEntryOpenUrl->setEnabled(singleEntrySelected && dbWidget->currentEntryHasUrl()); m_ui->actionGroupNew->setEnabled(groupSelected); m_ui->actionGroupEdit->setEnabled(groupSelected); m_ui->actionGroupDelete->setEnabled(groupSelected && dbWidget->canDeleteCurrentGroup());