mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-24 15:25:31 -04:00
Fix minor issues with tags context menu
* Fixes #11808 * Don't show tear off menu or option to tear off if there are no tags * Fix "No Tags" not being shown on first hover * Fix issues when using a tag named "No Tags" * Fix #12153 - tags becoming unsorted in the context menu when switching between database tabs
This commit is contained in:
parent
f2a4cc7e66
commit
5dfcc72f98
2 changed files with 27 additions and 16 deletions
|
@ -826,7 +826,12 @@ void Database::updateTagList()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tagList = tagSet.values();
|
m_tagList = tagSet.values();
|
||||||
m_tagList.sort();
|
|
||||||
|
QCollator collator;
|
||||||
|
collator.setNumericMode(true);
|
||||||
|
collator.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
std::sort(m_tagList.begin(), m_tagList.end(), collator);
|
||||||
|
|
||||||
emit tagListUpdated();
|
emit tagListUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -821,6 +821,8 @@ void MainWindow::updateSetTagsMenu()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
m_ui->menuTags->setTearOffEnabled(true);
|
||||||
|
|
||||||
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
||||||
if (dbWidget) {
|
if (dbWidget) {
|
||||||
// Enumerate tags applied to the selected entries
|
// Enumerate tags applied to the selected entries
|
||||||
|
@ -831,31 +833,30 @@ void MainWindow::updateSetTagsMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add known database tags as actions and set checked if
|
// Remove missing tags
|
||||||
// a selected entry has that tag
|
|
||||||
const auto tagList = dbWidget->database()->tagList();
|
const auto tagList = dbWidget->database()->tagList();
|
||||||
for (const auto& tag : tagList) {
|
for (const auto action : m_ui->menuTags->actions()) {
|
||||||
auto action = actionForTag(m_ui->menuTags, tag);
|
if (!tagList.contains(action->text()) || !action->isEnabled()) {
|
||||||
if (action) {
|
delete action;
|
||||||
action->setChecked(selectedTags.contains(tag));
|
|
||||||
} else {
|
|
||||||
action = m_ui->menuTags->addAction(icons()->icon("tag"), tag);
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(selectedTags.contains(tag));
|
|
||||||
m_setTagsMenuActions->addAction(action);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove missing tags
|
// Add known database tags as actions and set checked if
|
||||||
for (const auto action : m_ui->menuTags->actions()) {
|
// a selected entry has that tag
|
||||||
if (!tagList.contains(action->text())) {
|
for (const auto& tag : tagList) {
|
||||||
action->deleteLater();
|
auto action = actionForTag(m_ui->menuTags, tag);
|
||||||
|
if (!action) {
|
||||||
|
action = m_ui->menuTags->addAction(icons()->icon("tag"), tag);
|
||||||
|
action->setCheckable(true);
|
||||||
|
m_setTagsMenuActions->addAction(action);
|
||||||
}
|
}
|
||||||
|
action->setChecked(selectedTags.contains(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no tags exist in the database then show a tip to the user
|
// If no tags exist in the database then show a tip to the user
|
||||||
if (m_ui->menuTags->isEmpty()) {
|
if (m_ui->menuTags->isEmpty()) {
|
||||||
|
m_ui->menuTags->setTearOffEnabled(false);
|
||||||
auto action = m_ui->menuTags->addAction(tr("No Tags"));
|
auto action = m_ui->menuTags->addAction(tr("No Tags"));
|
||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -1314,6 +1315,11 @@ void MainWindow::databaseTabChanged(int tabIndex)
|
||||||
|
|
||||||
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());
|
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());
|
||||||
updateEntryCountLabel();
|
updateEntryCountLabel();
|
||||||
|
|
||||||
|
// Clear the tags menu to prevent re-use between databases
|
||||||
|
for (const auto action : m_ui->menuTags->actions()) {
|
||||||
|
delete action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::event(QEvent* event)
|
bool MainWindow::event(QEvent* event)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue