Show Row-Backgroundcolor in a column

Fixes #6553

Allow users to choose to show the entry background color as a column instead of changing the background of the entire row.
This commit is contained in:
Felix Nüsse authored and Jonathan White committed 2025-01-19 09:32:12 -05:00
1 parent 4df16fa501
commit e82e9dad3b
6 files changed
+55 -20

No files matched your search

+13
View File
@@ -336,6 +336,7 @@ bool EntryView::setViewState(const QByteArray& state)
bool status = header()->restoreState(state);
resetFixedColumns();
m_columnsNeedRelayout = state.isEmpty();
onHeaderChanged();
return status;
}
@@ -376,6 +377,9 @@ void EntryView::toggleColumnVisibility(QAction* action)
// least one visible column remains, as the table header will disappear
// entirely when all columns are hidden
int columnIndex = action->data().toInt();
if (columnIndex == EntryModel::Color) {
m_model->setBackgroundColorVisible(!action->isChecked());
}
if (action->isChecked()) {
header()->showSection(columnIndex);
if (header()->sectionSize(columnIndex) == 0) {
@@ -447,6 +451,8 @@ void EntryView::resetFixedColumns()
header()->resizeSection(col, width);
}
}
header()->setMinimumSectionSize(1);
header()->resizeSection(EntryModel::Color, ICON_ONLY_SECTION_SIZE);
}
/**
@@ -475,6 +481,8 @@ void EntryView::resetViewToDefaults()
header()->hideSection(EntryModel::Attachments);
header()->hideSection(EntryModel::Size);
header()->hideSection(EntryModel::PasswordStrength);
header()->hideSection(EntryModel::Color);
onHeaderChanged();
// Reset column order to logical indices
for (int i = 0; i < header()->count(); ++i) {
@@ -502,6 +510,11 @@ void EntryView::resetViewToDefaults()
}
}
void EntryView::onHeaderChanged()
{
m_model->setBackgroundColorVisible(isColumnHidden(EntryModel::Color));
}
void EntryView::showEvent(QShowEvent* event)
{
QTreeView::showEvent(event);