mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 08:15:32 -04:00
Fix Paperclip and Totp columns not saving state
* Work around Qt bug that causes isSectionHidden to return false after restoring state due to the section actually only being set to 0 width. * Fixes #5317
This commit is contained in:
parent
639e44e182
commit
f17fce9461
2 changed files with 16 additions and 6 deletions
|
@ -379,8 +379,7 @@ void EntryView::showHeaderMenu(const QPoint& position)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int columnIndex = action->data().toInt();
|
int columnIndex = action->data().toInt();
|
||||||
bool hidden = header()->isSectionHidden(columnIndex) || (header()->sectionSize(columnIndex) == 0);
|
action->setChecked(!isColumnHidden(columnIndex));
|
||||||
action->setChecked(!hidden);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_headerMenu->popup(mapToGlobal(position));
|
m_headerMenu->popup(mapToGlobal(position));
|
||||||
|
@ -408,6 +407,7 @@ void EntryView::toggleColumnVisibility(QAction* action)
|
||||||
if (header()->sectionSize(columnIndex) == 0) {
|
if (header()->sectionSize(columnIndex) == 0) {
|
||||||
header()->resizeSection(columnIndex, header()->defaultSectionSize());
|
header()->resizeSection(columnIndex, header()->defaultSectionSize());
|
||||||
}
|
}
|
||||||
|
resetFixedColumns();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((header()->count() - header()->hiddenSectionCount()) > 1) {
|
if ((header()->count() - header()->hiddenSectionCount()) > 1) {
|
||||||
|
@ -460,12 +460,16 @@ void EntryView::fitColumnsToContents()
|
||||||
*/
|
*/
|
||||||
void EntryView::resetFixedColumns()
|
void EntryView::resetFixedColumns()
|
||||||
{
|
{
|
||||||
|
if (!isColumnHidden(EntryModel::Paperclip)) {
|
||||||
header()->setSectionResizeMode(EntryModel::Paperclip, QHeaderView::Fixed);
|
header()->setSectionResizeMode(EntryModel::Paperclip, QHeaderView::Fixed);
|
||||||
header()->resizeSection(EntryModel::Paperclip, header()->minimumSectionSize());
|
header()->resizeSection(EntryModel::Paperclip, header()->minimumSectionSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isColumnHidden(EntryModel::Totp)) {
|
||||||
header()->setSectionResizeMode(EntryModel::Totp, QHeaderView::Fixed);
|
header()->setSectionResizeMode(EntryModel::Totp, QHeaderView::Fixed);
|
||||||
header()->resizeSection(EntryModel::Totp, header()->minimumSectionSize());
|
header()->resizeSection(EntryModel::Totp, header()->minimumSectionSize());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset item view to defaults.
|
* Reset item view to defaults.
|
||||||
|
@ -533,3 +537,8 @@ void EntryView::showEvent(QShowEvent* event)
|
||||||
m_columnsNeedRelayout = false;
|
m_columnsNeedRelayout = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntryView::isColumnHidden(int logicalIndex)
|
||||||
|
{
|
||||||
|
return header()->isSectionHidden(logicalIndex) || header()->sectionSize(logicalIndex) == 0;
|
||||||
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetFixedColumns();
|
void resetFixedColumns();
|
||||||
|
bool isColumnHidden(int logicalIndex);
|
||||||
|
|
||||||
EntryModel* const m_model;
|
EntryModel* const m_model;
|
||||||
SortFilterHideProxyModel* const m_sortModel;
|
SortFilterHideProxyModel* const m_sortModel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue