diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 5bda87be1..6434ba923 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "autotype/AutoType.h" #include "core/Config.h" @@ -638,6 +639,14 @@ void DatabaseWidget::copyUsername() void DatabaseWidget::copyPassword() { + // QTextEdit does not properly trap Ctrl+C copy shortcut + // if a text edit has focus pass the copy operation to it + auto textEdit = qobject_cast(focusWidget()); + if (textEdit) { + textEdit->copy(); + return; + } + auto currentEntry = currentSelectedEntry(); if (currentEntry) { setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->password())); @@ -1566,11 +1575,6 @@ bool DatabaseWidget::isGroupSelected() const return m_groupView->currentGroup(); } -bool DatabaseWidget::currentEntryHasFocus() -{ - return m_entryView->numberOfSelectedEntries() > 0 && m_entryView->hasFocus(); -} - bool DatabaseWidget::currentEntryHasTitle() { auto currentEntry = currentSelectedEntry(); diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index a96a34a9f..2b9388f37 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -104,7 +104,6 @@ public: bool isPasswordsHidden() const; void setPasswordsHidden(bool hide); void clearAllWidgets(); - bool currentEntryHasFocus(); bool currentEntryHasTitle(); bool currentEntryHasUsername(); bool currentEntryHasPassword(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index a25213980..7623a13f8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -644,10 +644,8 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) switch (mode) { case DatabaseWidget::Mode::ViewMode: { - bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus() - || dbWidget->currentEntryHasFocus(); - bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus; - bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus; + bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1; + bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0; bool groupSelected = dbWidget->isGroupSelected(); bool currentGroupHasChildren = dbWidget->currentGroup()->hasChildren(); bool currentGroupHasEntries = !dbWidget->currentGroup()->entries().isEmpty(); @@ -1192,7 +1190,7 @@ void MainWindow::showEntryContextMenu(const QPoint& globalPos) bool entrySelected = false; auto dbWidget = m_ui->tabWidget->currentDatabaseWidget(); if (dbWidget) { - entrySelected = dbWidget->currentEntryHasFocus(); + entrySelected = dbWidget->numberOfSelectedEntries() > 0; } if (entrySelected) {