Skip to content

Truly independent web browser

UI/Qt: Let the tab strip shrink with the window

Andreas Kling2d34e8ca38ae
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index eb4ee2e14f9..530f1bccb06 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -1949,6 +1949,11 @@ TabWidget::TabWidget(QWidget* parent)
m_tab_bar_row->setAcceptDrops(true);
m_tab_bar_row_layout = new QHBoxLayout(m_tab_bar_row);
m_tab_bar_row->installEventFilter(this);
+ // NB: The tab bar is given a fixed width that fills the row whenever there are enough tabs, so the row's minimum
+ // width would be the window's current width. Keep it out of the window's minimum size, or the window could only
+ // be narrowed by the row's few spare pixels at each step of a resize. The tab bar is fitted to the new width,
+ // and update_tab_layout() gives the row the minimum width its controls need.
+ m_tab_bar_row->setSizePolicy(QSizePolicy::Ignored, m_tab_bar_row->sizePolicy().verticalPolicy());
m_vertical_tabs_content = new QWidget(this);
m_vertical_tabs_content_layout = new QHBoxLayout(m_vertical_tabs_content);
@@ -2826,6 +2831,10 @@ void TabWidget::update_tab_layout()
auto available_for_tabs = width() - controls_width - 36;
+ // NB: The tab strip has no minimum width from its contents (see the constructor), so it keeps the window wide enough
+ // for its controls with a minimum of its own.
+ m_tab_bar_row->setMinimumWidth(controls_width + 36);
+
m_tab_bar->set_available_width(available_for_tabs);
auto tab_bar_width = min(available_for_tabs, m_tab_bar->count() * HORIZONTAL_TAB_MAX_WIDTH);