From a75143628be79d682516fa3e776e767532c58567 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 26 Aug 2026 11:29:47 +0200 Subject: [PATCH] fix: email selection in table view + responsive filter bar - Connect currentRowChanged to onRowSelected so single-click in table shows email in reader - Add responsive filter bar: hide groupBy/displayMode/pivot combos progressively as width decreases - Set Fixed size policy on combos to prevent unwanted stretching - Reduced filter layout spacing from 12 to 8px --- src/ui/maillistview.cpp | 29 ++++++++++++++++++++++++++++- src/ui/maillistview.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ui/maillistview.cpp b/src/ui/maillistview.cpp index 93d1bf9..7f19273 100644 --- a/src/ui/maillistview.cpp +++ b/src/ui/maillistview.cpp @@ -72,24 +72,29 @@ void MailListView::setupUI() QWidget *filterBar = new QWidget(); filterBar->setFixedHeight(36); filterBar->setStyleSheet("background-color: #f5f5f7; border-bottom: 1px solid #d1d1d6;"); + filterBar->setObjectName("filterBar"); QHBoxLayout *filterLayout = new QHBoxLayout(filterBar); filterLayout->setContentsMargins(12, 2, 12, 2); - filterLayout->setSpacing(12); + filterLayout->setSpacing(8); m_unreadOnlyCheck = new QCheckBox("No leídos"); m_unreadOnlyCheck->setStyleSheet("QCheckBox { font-size: 12px; color: #333; }"); + m_unreadOnlyCheck->setObjectName("filterCheck"); filterLayout->addWidget(m_unreadOnlyCheck); m_flaggedOnlyCheck = new QCheckBox("Marcados"); m_flaggedOnlyCheck->setStyleSheet("QCheckBox { font-size: 12px; color: #333; }"); + m_flaggedOnlyCheck->setObjectName("filterCheck"); filterLayout->addWidget(m_flaggedOnlyCheck); m_hasAttachmentsCheck = new QCheckBox("Con adjuntos"); m_hasAttachmentsCheck->setStyleSheet("QCheckBox { font-size: 12px; color: #333; }"); + m_hasAttachmentsCheck->setObjectName("filterCheck"); filterLayout->addWidget(m_hasAttachmentsCheck); m_pinnedOnlyCheck = new QCheckBox("Solo fijados"); m_pinnedOnlyCheck->setStyleSheet("QCheckBox { font-size: 12px; color: #333; }"); + m_pinnedOnlyCheck->setObjectName("filterCheck"); filterLayout->addWidget(m_pinnedOnlyCheck); filterLayout->addStretch(); @@ -99,6 +104,7 @@ void MailListView::setupUI() m_pivotCombo->addItem("Principal"); // Focused m_pivotCombo->addItem("Otros"); // Other m_pivotCombo->setFixedWidth(140); + m_pivotCombo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_pivotCombo->setStyleSheet( "QComboBox { border: 1px solid #d1d1d6; border-radius: 4px; padding: 4px 8px; " "background: white; min-height: 20px; }" @@ -116,6 +122,7 @@ void MailListView::setupUI() m_displayModeCombo->addItem("Medio"); m_displayModeCombo->addItem("Espacioso"); m_displayModeCombo->setFixedWidth(120); + m_displayModeCombo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_displayModeCombo->setStyleSheet( "QComboBox { border: 1px solid #d1d1d6; border-radius: 4px; padding: 4px 8px; " "background: white; min-height: 20px; }" @@ -133,6 +140,7 @@ void MailListView::setupUI() m_groupByCombo->addItem("Agrupar por conversación"); m_groupByCombo->addItem("Agrupar por remitente"); m_groupByCombo->setFixedWidth(180); + m_groupByCombo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_groupByCombo->setStyleSheet( "QComboBox { border: 1px solid #d1d1d6; border-radius: 4px; padding: 4px 8px; " "background: white; min-height: 20px; }" @@ -249,6 +257,9 @@ void MailListView::setupUI() connect(m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MailListView::onSelectionChanged); + // Single-click selection in tree view -> emit emailSelected for reader pane + connect(m_treeView->selectionModel(), &QItemSelectionModel::currentRowChanged, + this, &MailListView::onRowSelected); connect(m_treeView, &QTreeView::doubleClicked, this, [this](const QModelIndex &index) { if (!index.isValid()) return; QModelIndex proxyIdx = m_proxyModel->mapToSource(index); @@ -385,6 +396,22 @@ void MailListView::updateViewMode() m_treeView->header()->show(); } } + + // Also update filter bar responsiveness + updateFilterBarVisibility(viewportWidth); +} + +void MailListView::updateFilterBarVisibility(int viewportWidth) +{ + // Hide controls progressively as width decreases + // Thresholds: show all > 900px, hide groupBy > 750px, hide displayMode > 600px, hide pivot > 500px + bool showGroupBy = viewportWidth > 750; + bool showDisplayMode = viewportWidth > 600; + bool showPivot = viewportWidth > 500; + + m_groupByCombo->setVisible(showGroupBy); + m_displayModeCombo->setVisible(showDisplayMode); + m_pivotCombo->setVisible(showPivot && m_pivotCombo->isVisible()); // respect folder-type visibility } QVector MailListView::getSelectedMailIds() const diff --git a/src/ui/maillistview.h b/src/ui/maillistview.h index 82f3a23..11fd90c 100644 --- a/src/ui/maillistview.h +++ b/src/ui/maillistview.h @@ -94,6 +94,7 @@ private: void setupUI(); void refreshViews(); void updateViewMode(); + void updateFilterBarVisibility(int viewportWidth); // New: responsive filter bar void updateActionBar(); QVector getSelectedMailIds() const; void initDrag();