Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Tags / Saved Searches #8435

Merged
merged 5 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,24 @@ Files: share/icons/badges/2_Expired.svg
Copyright: 2022 KeePassXC Team <[email protected]>
License: MIT

Files: share/icons/application/scalable/actions/chevron-double-down.svg
Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/attributes-copy.svg
share/icons/application/scalable/actions/auto-type.svg
share/icons/application/scalable/actions/bugreport.svg
share/icons/application/scalable/actions/chevron-double-down.svg
share/icons/application/scalable/actions/chevron-double-right.svg
share/icons/application/scalable/actions/totp.svg
share/icons/application/scalable/actions/totp-copy.svg
share/icons/application/scalable/actions/totp-edit.svg
share/icons/application/scalable/actions/clipboard-text.svg
share/icons/application/scalable/actions/configure.svg
share/icons/application/scalable/actions/database-change-key.svg
share/icons/application/scalable/actions/database-lock.svg
share/icons/application/scalable/actions/database-lock-all.svg
share/icons/application/scalable/actions/database-merge.svg
share/icons/application/scalable/actions/database-search.svg
share/icons/application/scalable/actions/dialog-close.svg
share/icons/application/scalable/actions/dialog-ok.svg
share/icons/application/scalable/actions/document-close.svg
share/icons/application/scalable/actions/document-edit.svg
share/icons/application/scalable/actions/document-export.svg
Expand All @@ -159,43 +173,56 @@ Files: share/icons/application/scalable/actions/chevron-double-down.svg
share/icons/application/scalable/actions/document-save.svg
share/icons/application/scalable/actions/document-save-as.svg
share/icons/application/scalable/actions/document-save-copy.svg
share/icons/application/scalable/actions/donate.svg
share/icons/application/scalable/actions/edit-clear-locationbar-ltr.svg
share/icons/application/scalable/actions/edit-clear-locationbar-rtl.svg
share/icons/application/scalable/actions/entry-clone.svg
share/icons/application/scalable/actions/entry-delete.svg
share/icons/application/scalable/actions/entry-restore.svg
share/icons/application/scalable/actions/entry-edit.svg
share/icons/application/scalable/actions/entry-new.svg
share/icons/application/scalable/actions/favicon-download.svg
share/icons/application/scalable/actions/fingerprint.svg
share/icons/application/scalable/actions/group-clone.svg
share/icons/application/scalable/actions/getting-started.svg
share/icons/application/scalable/actions/group-delete.svg
share/icons/application/scalable/actions/group-edit.svg
share/icons/application/scalable/actions/group-clone.svg
share/icons/application/scalable/actions/group-empty-trash.svg
share/icons/application/scalable/actions/group-new.svg
share/icons/application/scalable/actions/hammer-wrench.svg
share/icons/application/scalable/actions/health.svg
share/icons/application/scalable/actions/help-about.svg
share/icons/application/scalable/actions/lock-question.svg
share/icons/application/scalable/actions/keyboard-shortcuts.svg
share/icons/application/scalable/actions/message-close.svg
share/icons/application/scalable/actions/move-down.svg
share/icons/application/scalable/actions/move-up.svg
share/icons/application/scalable/actions/object-locked.svg
share/icons/application/scalable/actions/object-unlocked.svg
share/icons/application/scalable/actions/paperclip.svg
share/icons/application/scalable/actions/password-copy.svg
share/icons/application/scalable/actions/password-generator.svg
share/icons/application/scalable/actions/password-show-off.svg
share/icons/application/scalable/actions/password-show-on.svg
share/icons/application/scalable/actions/qrcode.svg
share/icons/application/scalable/actions/refresh.svg
share/icons/application/scalable/actions/reports.svg
share/icons/application/scalable/actions/reports-exclude.svg
share/icons/application/scalable/actions/sort-alphabetical-ascending.svg
share/icons/application/scalable/actions/sort-alphabetical-descending.svg
share/icons/application/scalable/actions/statistics.svg
share/icons/application/scalable/actions/system-help.svg
share/icons/application/scalable/actions/system-search.svg
share/icons/application/scalable/actions/system-software-update.svg
share/icons/application/scalable/actions/tag.svg
share/icons/application/scalable/actions/tag-multiple.svg
share/icons/application/scalable/actions/tag-search.svg
share/icons/application/scalable/actions/trash.svg
share/icons/application/scalable/actions/url-copy.svg
share/icons/application/scalable/actions/user-guide.svg
share/icons/application/scalable/actions/username-copy.svg
share/icons/application/scalable/actions/view-history.svg
share/icons/application/scalable/actions/web.svg
share/icons/application/scalable/apps/internet-web-browser.svg
share/icons/application/scalable/apps/keepassxc.svg
share/icons/application/scalable/apps/keepassxc-dark.svg
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/qrcode.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/tag-multiple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/totp-copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/totp-edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
<file>application/256x256/apps/keepassxc.png</file>

<file>application/scalable/actions/application-exit.svg</file>
<file>application/scalable/actions/attributes-copy.svg</file>
<file>application/scalable/actions/auto-type.svg</file>
<file>application/scalable/actions/bugreport.svg</file>
<file>application/scalable/actions/chevron-double-down.svg</file>
<file>application/scalable/actions/chevron-double-right.svg</file>
<file>application/scalable/actions/chronometer.svg</file>
<file>application/scalable/actions/totp.svg</file>
<file>application/scalable/actions/totp-copy.svg</file>
<file>application/scalable/actions/totp-edit.svg</file>
<file>application/scalable/actions/clipboard-text.svg</file>
<file>application/scalable/actions/configure.svg</file>
<file>application/scalable/actions/database-change-key.svg</file>
<file>application/scalable/actions/database-lock.svg</file>
<file>application/scalable/actions/database-lock-all.svg</file>
<file>application/scalable/actions/database-merge.svg</file>
<file>application/scalable/actions/database-search.svg</file>
<file>application/scalable/actions/dialog-close.svg</file>
<file>application/scalable/actions/dialog-ok.svg</file>
<file>application/scalable/actions/document-close.svg</file>
Expand Down Expand Up @@ -62,6 +66,7 @@
<file>application/scalable/actions/password-generator.svg</file>
<file>application/scalable/actions/password-show-off.svg</file>
<file>application/scalable/actions/password-show-on.svg</file>
<file>application/scalable/actions/qrcode.svg</file>
<file>application/scalable/actions/refresh.svg</file>
<file>application/scalable/actions/reports.svg</file>
<file>application/scalable/actions/reports-exclude.svg</file>
Expand All @@ -72,6 +77,7 @@
<file>application/scalable/actions/system-search.svg</file>
<file>application/scalable/actions/system-software-update.svg</file>
<file>application/scalable/actions/tag.svg</file>
<file>application/scalable/actions/tag-multiple.svg</file>
<file>application/scalable/actions/tag-search.svg</file>
<file>application/scalable/actions/trash.svg</file>
<file>application/scalable/actions/url-copy.svg</file>
Expand Down
68 changes: 61 additions & 7 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2249,10 +2249,6 @@ This is definitely a bug, please report it to the developers.</source>
</context>
<context>
<name>DatabaseWidget</name>
<message>
<source>Database Tags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Searching…</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -2417,6 +2413,22 @@ Disable safe saves and try again?</source>
<numerusform></numerusform>
</translation>
</message>
<message>
<source>Searches and Tags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter a unique name or overwrite an existing search from the list:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Search</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditEntryWidget</name>
Expand Down Expand Up @@ -5403,6 +5415,21 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>You must restart the application to apply this setting. Would you like to restart now?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tags</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No Tags</source>
<translation type="unfinished"></translation>
</message>
<message numerus="yes">
<source>%1 Entry(s)</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
</translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down Expand Up @@ -8372,6 +8399,10 @@ Kernel: %3 %4</source>
<source>Limit search to selected group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save Search</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsClientModel</name>
Expand Down Expand Up @@ -8585,15 +8616,38 @@ Kernel: %3 %4</source>
<context>
<name>TagModel</name>
<message>
<source>All</source>
<source>Expired</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expired</source>
<source>Weak Passwords</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Weak Passwords</source>
<source>All Entries</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Clear Search</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TagView</name>
<message>
<source>Remove Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Tag</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm Remove Tag</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove tag &quot;%1&quot; from all entries in this database?</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ set(keepassx_SOURCES
gui/group/GroupModel.cpp
gui/group/GroupView.cpp
gui/tag/TagModel.cpp
gui/tag/TagView.cpp
gui/tag/TagsEdit.cpp
gui/databasekey/KeyComponentWidget.cpp
gui/databasekey/PasswordEditWidget.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/autotype/AutoTypeSelectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void AutoTypeSelectDialog::buildActionMenu()
auto typeTotpAction = new QAction(icons()->icon("auto-type"), tr("Type {TOTP}"), this);
auto copyUsernameAction = new QAction(icons()->icon("username-copy"), tr("Copy Username"), this);
auto copyPasswordAction = new QAction(icons()->icon("password-copy"), tr("Copy Password"), this);
auto copyTotpAction = new QAction(icons()->icon("chronometer"), tr("Copy TOTP"), this);
auto copyTotpAction = new QAction(icons()->icon("totp"), tr("Copy TOTP"), this);
m_actionMenu->addAction(typeUsernameAction);
m_actionMenu->addAction(typePasswordAction);
m_actionMenu->addAction(typeTotpAction);
Expand Down
15 changes: 13 additions & 2 deletions src/core/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ void Database::updateTagList()
// Search groups recursively looking for tags
// Use a set to prevent adding duplicates
QSet<QString> tagSet;
for (const auto group : m_rootGroup->groupsRecursive(true)) {
for (const auto entry : group->entries()) {
for (auto entry : m_rootGroup->entriesRecursive()) {
if (!entry->isRecycled()) {
for (auto tag : entry->tagList()) {
tagSet.insert(tag);
}
Expand All @@ -714,6 +714,17 @@ void Database::updateTagList()
emit tagListUpdated();
}

void Database::removeTag(const QString& tag)
{
if (!m_rootGroup) {
return;
}

for (auto entry : m_rootGroup->entriesRecursive()) {
entry->removeTag(tag);
}
}

const QUuid& Database::cipher() const
{
return m_data.cipher;
Expand Down
1 change: 1 addition & 0 deletions src/core/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class Database : public ModifiableObject

const QStringList& commonUsernames() const;
const QStringList& tagList() const;
void removeTag(const QString& tag);

QSharedPointer<const CompositeKey> key() const;
bool setKey(const QSharedPointer<const CompositeKey>& key,
Expand Down
44 changes: 38 additions & 6 deletions src/core/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,12 @@ QString Entry::overrideUrl() const

QString Entry::tags() const
{
return m_data.tags;
return m_data.tags.join(",");
}

QStringList Entry::tagList() const
{
static QRegExp rx("(\\,|\\t|\\;)");
auto taglist = tags().split(rx, QString::SkipEmptyParts);
std::sort(taglist.begin(), taglist.end());
return taglist;
return m_data.tags;
}

const TimeInfo& Entry::timeInfo() const
Expand Down Expand Up @@ -654,7 +651,42 @@ void Entry::setOverrideUrl(const QString& url)

void Entry::setTags(const QString& tags)
{
set(m_data.tags, tags);
static QRegExp rx("(\\,|\\t|\\;)");
auto taglist = tags.split(rx, QString::SkipEmptyParts);
// Trim whitespace before/after tag text
for (auto itr = taglist.begin(); itr != taglist.end(); ++itr) {
*itr = itr->trimmed();
}
// Remove duplicates
auto tagSet = QSet<QString>::fromList(taglist);
taglist = tagSet.toList();
// Sort alphabetically
taglist.sort();
set(m_data.tags, taglist);
}

void Entry::addTag(const QString& tag)
{
auto cleanTag = tag.trimmed();
cleanTag.remove(QRegExp("(\\,|\\t|\\;)"));

auto taglist = m_data.tags;
if (!taglist.contains(cleanTag)) {
taglist.append(cleanTag);
taglist.sort();
set(m_data.tags, taglist);
}
}

void Entry::removeTag(const QString& tag)
{
auto cleanTag = tag.trimmed();
cleanTag.remove(QRegExp("(\\,|\\t|\\;)"));

auto taglist = m_data.tags;
if (taglist.removeAll(tag) > 0) {
set(m_data.tags, taglist);
}
}

void Entry::setTimeInfo(const TimeInfo& timeInfo)
Expand Down
5 changes: 4 additions & 1 deletion src/core/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct EntryData
QString foregroundColor;
QString backgroundColor;
QString overrideUrl;
QString tags;
QStringList tags;
bool autoTypeEnabled;
int autoTypeObfuscation;
QString defaultAutoTypeSequence;
Expand Down Expand Up @@ -158,6 +158,9 @@ class Entry : public ModifiableObject
void setPreviousParentGroup(const Group* group);
void setPreviousParentGroupUuid(const QUuid& uuid);

void addTag(const QString& tag);
void removeTag(const QString& tag);

QList<Entry*> historyItems();
const QList<Entry*>& historyItems() const;
void addHistoryItem(Entry* entry);
Expand Down
Loading