mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-08 22:42:34 -04:00
Ignore focus when checking toolbar state
* Support copy shortcut when in QTextEdit to prevent inadvertently copying password when interacting with those elements.
This commit is contained in:
parent
fb5173cebd
commit
8ae718b747
3 changed files with 12 additions and 11 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
#include "autotype/AutoType.h"
|
#include "autotype/AutoType.h"
|
||||||
#include "core/Config.h"
|
#include "core/Config.h"
|
||||||
|
@ -638,6 +639,14 @@ void DatabaseWidget::copyUsername()
|
||||||
|
|
||||||
void DatabaseWidget::copyPassword()
|
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<QTextEdit*>(focusWidget());
|
||||||
|
if (textEdit) {
|
||||||
|
textEdit->copy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto currentEntry = currentSelectedEntry();
|
auto currentEntry = currentSelectedEntry();
|
||||||
if (currentEntry) {
|
if (currentEntry) {
|
||||||
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->password()));
|
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->password()));
|
||||||
|
@ -1566,11 +1575,6 @@ bool DatabaseWidget::isGroupSelected() const
|
||||||
return m_groupView->currentGroup();
|
return m_groupView->currentGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseWidget::currentEntryHasFocus()
|
|
||||||
{
|
|
||||||
return m_entryView->numberOfSelectedEntries() > 0 && m_entryView->hasFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseWidget::currentEntryHasTitle()
|
bool DatabaseWidget::currentEntryHasTitle()
|
||||||
{
|
{
|
||||||
auto currentEntry = currentSelectedEntry();
|
auto currentEntry = currentSelectedEntry();
|
||||||
|
|
|
@ -104,7 +104,6 @@ public:
|
||||||
bool isPasswordsHidden() const;
|
bool isPasswordsHidden() const;
|
||||||
void setPasswordsHidden(bool hide);
|
void setPasswordsHidden(bool hide);
|
||||||
void clearAllWidgets();
|
void clearAllWidgets();
|
||||||
bool currentEntryHasFocus();
|
|
||||||
bool currentEntryHasTitle();
|
bool currentEntryHasTitle();
|
||||||
bool currentEntryHasUsername();
|
bool currentEntryHasUsername();
|
||||||
bool currentEntryHasPassword();
|
bool currentEntryHasPassword();
|
||||||
|
|
|
@ -644,10 +644,8 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DatabaseWidget::Mode::ViewMode: {
|
case DatabaseWidget::Mode::ViewMode: {
|
||||||
bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus()
|
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1;
|
||||||
|| dbWidget->currentEntryHasFocus();
|
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0;
|
||||||
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus;
|
|
||||||
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus;
|
|
||||||
bool groupSelected = dbWidget->isGroupSelected();
|
bool groupSelected = dbWidget->isGroupSelected();
|
||||||
bool currentGroupHasChildren = dbWidget->currentGroup()->hasChildren();
|
bool currentGroupHasChildren = dbWidget->currentGroup()->hasChildren();
|
||||||
bool currentGroupHasEntries = !dbWidget->currentGroup()->entries().isEmpty();
|
bool currentGroupHasEntries = !dbWidget->currentGroup()->entries().isEmpty();
|
||||||
|
@ -1192,7 +1190,7 @@ void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
||||||
bool entrySelected = false;
|
bool entrySelected = false;
|
||||||
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
||||||
if (dbWidget) {
|
if (dbWidget) {
|
||||||
entrySelected = dbWidget->currentEntryHasFocus();
|
entrySelected = dbWidget->numberOfSelectedEntries() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entrySelected) {
|
if (entrySelected) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue