Ladybird/Qt: Specify a minimum and maxium tab width

By default, Qt will grow the width of a tab button to fit the title text
of the tab. For long titles or file:// URLs, this looks rather bad. This
sets a min/max tab width to prevent such infinite growth.

To do this, we have to subclass both QTabWidget and QTabBar, because the
functions to be called/overridden are protected.
This commit is contained in:
Timothy Flynn
2024-04-02 21:38:01 -04:00
committed by Andreas Kling
parent 0234add5fa
commit 2713d4651d
3 changed files with 45 additions and 8 deletions

View File

@@ -46,18 +46,12 @@ static QIcon const& app_icon()
}
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path)
: m_cookie_jar(cookie_jar)
: m_tabs_container(new TabWidget(this))
, m_cookie_jar(cookie_jar)
, m_web_content_options(web_content_options)
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
{
setWindowIcon(app_icon());
m_tabs_container = new QTabWidget(this);
m_tabs_container->installEventFilter(this);
m_tabs_container->setElideMode(Qt::TextElideMode::ElideRight);
m_tabs_container->setMovable(true);
m_tabs_container->setTabsClosable(true);
m_tabs_container->setDocumentMode(true);
m_tabs_container->setTabBarAutoHide(true);
// Listen for DPI changes
m_device_pixel_ratio = devicePixelRatio();