From 5927821896a52ecf84b6f26725727f379fbc744c Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Mon, 7 Feb 2022 09:16:17 +0200 Subject: [PATCH] Auto-Type: Only match non-empty associations Previously empty associations matched any window but since you can use a wildcard (*) if you specifically want that this change makes it possible to define multiple sequences for the global search if you need to. Additionally show empty associations in the list as "(empty)" to better differentiate between rows if no title is set. --- share/translations/keepassxc_en.ts | 4 ++++ src/core/Entry.cpp | 2 +- src/gui/entry/AutoTypeAssociationsModel.cpp | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index 99b1eef2..f9f746ff 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -656,6 +656,10 @@ Default sequence Default sequence + + (empty) + + AutoTypeMatchModel diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 6feb2624..c7920715 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -328,7 +328,7 @@ QList Entry::autoTypeSequences(const QString& windowTitle) const const auto assocList = autoTypeAssociations()->getAll(); for (const auto& assoc : assocList) { auto window = resolveMultiplePlaceholders(assoc.window); - if (windowMatches(window)) { + if (!assoc.window.isEmpty() && windowMatches(window)) { if (!assoc.sequence.isEmpty()) { sequenceList << assoc.sequence; } else { diff --git a/src/gui/entry/AutoTypeAssociationsModel.cpp b/src/gui/entry/AutoTypeAssociationsModel.cpp index fadd4fa1..6e7b08bc 100644 --- a/src/gui/entry/AutoTypeAssociationsModel.cpp +++ b/src/gui/entry/AutoTypeAssociationsModel.cpp @@ -92,6 +92,9 @@ QVariant AutoTypeAssociationsModel::data(const QModelIndex& index, int role) con if (role == Qt::DisplayRole) { if (index.column() == 0) { QString window = m_autoTypeAssociations->get(index.row()).window; + if (window.isEmpty()) { + return tr("(empty)"); + } if (m_entry) { window = m_entry->maskPasswordPlaceholders(window); window = m_entry->resolveMultiplePlaceholders(window);