|
33 | 33 | #include "gui/Icons.h" |
34 | 34 | #include "gui/SortFilterHideProxyModel.h" |
35 | 35 |
|
| 36 | +#include "core/Config.h" |
| 37 | + |
36 | 38 | #define ICON_ONLY_SECTION_SIZE 26 |
37 | 39 |
|
38 | 40 | class PasswordStrengthItemDelegate : public QStyledItemDelegate |
@@ -94,6 +96,9 @@ EntryView::EntryView(QWidget* parent) |
94 | 96 | emit entrySelectionChanged(currentEntry()); |
95 | 97 | }); |
96 | 98 |
|
| 99 | + // Listen for config changes to update Group column visibility |
| 100 | + connect(config(), &Config::changed, this, &EntryView::onConfigChanged); |
| 101 | + |
97 | 102 | new QShortcut(Qt::CTRL + Qt::Key_F10, this, SLOT(contextMenuShortcutPressed()), nullptr, Qt::WidgetShortcut); |
98 | 103 |
|
99 | 104 | resetViewToDefaults(); |
@@ -209,7 +214,16 @@ void EntryView::focusInEvent(QFocusEvent* event) |
209 | 214 | void EntryView::displayGroup(Group* group) |
210 | 215 | { |
211 | 216 | m_model->setGroup(group); |
212 | | - header()->hideSection(EntryModel::ParentGroup); |
| 217 | + |
| 218 | + // Show Group column when subgroup entries are enabled, since entries from different groups will be shown |
| 219 | + // But respect user's preference if they've manually hidden it |
| 220 | + if (config()->get(Config::GUI_ShowSubgroupEntries).toBool() && !m_userHidGroupColumnInSubgroupMode) { |
| 221 | + header()->showSection(EntryModel::ParentGroup); |
| 222 | + } else if (!config()->get(Config::GUI_ShowSubgroupEntries).toBool()) { |
| 223 | + header()->hideSection(EntryModel::ParentGroup); |
| 224 | + } |
| 225 | + // If user has hidden the column in subgroup mode, don't force it to show |
| 226 | + |
213 | 227 | setFirstEntryActive(); |
214 | 228 | m_inSearchMode = false; |
215 | 229 | } |
@@ -355,7 +369,8 @@ void EntryView::showHeaderMenu(const QPoint& position) |
355 | 369 | int columnIndex = action->data().toInt(); |
356 | 370 | action->setChecked(!isColumnHidden(columnIndex)); |
357 | 371 | } |
358 | | - actions[EntryModel::ParentGroup]->setVisible(inSearchMode()); |
| 372 | + actions[EntryModel::ParentGroup]->setVisible(inSearchMode() |
| 373 | + || config()->get(Config::GUI_ShowSubgroupEntries).toBool()); |
359 | 374 |
|
360 | 375 | m_headerMenu->popup(mapToGlobal(position)); |
361 | 376 | } |
@@ -385,11 +400,21 @@ void EntryView::toggleColumnVisibility(QAction* action) |
385 | 400 | if (header()->sectionSize(columnIndex) == 0) { |
386 | 401 | header()->resizeSection(columnIndex, header()->defaultSectionSize()); |
387 | 402 | } |
| 403 | + // Reset flag when user manually shows Group column |
| 404 | + if (columnIndex == EntryModel::ParentGroup && !m_inSearchMode |
| 405 | + && config()->get(Config::GUI_ShowSubgroupEntries).toBool()) { |
| 406 | + m_userHidGroupColumnInSubgroupMode = false; |
| 407 | + } |
388 | 408 | resetFixedColumns(); |
389 | 409 | return; |
390 | 410 | } |
391 | 411 | if ((header()->count() - header()->hiddenSectionCount()) > 1) { |
392 | 412 | header()->hideSection(columnIndex); |
| 413 | + // Track when user manually hides Group column while subgroup entries is enabled |
| 414 | + if (columnIndex == EntryModel::ParentGroup && !m_inSearchMode |
| 415 | + && config()->get(Config::GUI_ShowSubgroupEntries).toBool()) { |
| 416 | + m_userHidGroupColumnInSubgroupMode = true; |
| 417 | + } |
393 | 418 | return; |
394 | 419 | } |
395 | 420 | action->setChecked(true); |
@@ -461,7 +486,8 @@ void EntryView::resetFixedColumns() |
461 | 486 | void EntryView::resetViewToDefaults() |
462 | 487 | { |
463 | 488 | // Reduce number of columns that are shown by default |
464 | | - if (m_inSearchMode) { |
| 489 | + if (m_inSearchMode |
| 490 | + || (config()->get(Config::GUI_ShowSubgroupEntries).toBool() && !m_userHidGroupColumnInSubgroupMode)) { |
465 | 491 | header()->showSection(EntryModel::ParentGroup); |
466 | 492 | } else { |
467 | 493 | header()->hideSection(EntryModel::ParentGroup); |
@@ -595,3 +621,19 @@ bool EntryView::isColumnHidden(int logicalIndex) |
595 | 621 | { |
596 | 622 | return header()->isSectionHidden(logicalIndex) || header()->sectionSize(logicalIndex) == 0; |
597 | 623 | } |
| 624 | + |
| 625 | +void EntryView::onConfigChanged(Config::ConfigKey key) |
| 626 | +{ |
| 627 | + if (key == Config::GUI_ShowSubgroupEntries && !m_inSearchMode) { |
| 628 | + // Reset user preference when setting is toggled - this allows the |
| 629 | + // Group column to auto-appear when re-enabling the feature |
| 630 | + m_userHidGroupColumnInSubgroupMode = false; |
| 631 | + |
| 632 | + // Update Group column visibility when subgroup entries setting changes |
| 633 | + if (config()->get(Config::GUI_ShowSubgroupEntries).toBool()) { |
| 634 | + header()->showSection(EntryModel::ParentGroup); |
| 635 | + } else { |
| 636 | + header()->hideSection(EntryModel::ParentGroup); |
| 637 | + } |
| 638 | + } |
| 639 | +} |
0 commit comments