diff options
author | Florian Bruhin <me@the-compiler.org> | 2018-09-28 12:34:04 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2018-09-28 12:34:04 +0200 |
commit | 3eed63346e295163c12dd11e5568f95f5c3b6e0c (patch) | |
tree | 0b98781d4a312e679a467f6032d1c2c80ef23838 | |
parent | ead82d741ac691afd7f82a43c16eaa44c57cfd67 (diff) | |
parent | de148bb778105317b237d783e9f37311386760c8 (diff) | |
download | qutebrowser-3eed63346e295163c12dd11e5568f95f5c3b6e0c.tar.gz qutebrowser-3eed63346e295163c12dd11e5568f95f5c3b6e0c.zip |
Merge remote-tracking branch 'origin/pr/4261'
-rw-r--r-- | qutebrowser/config/configdata.yml | 17 | ||||
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 3 | ||||
-rw-r--r-- | tests/unit/mainwindow/test_tabwidget.py | 16 |
3 files changed, 35 insertions, 1 deletions
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index c4a61e203..0a2c1e2c7 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1602,6 +1602,23 @@ tabs.min_width: This setting does not apply to pinned tabs, unless `tabs.pinned.shrink` is False. +tabs.max_width: + default: -1 + type: + name: Int + minval: -1 + maxval: maxint + desc: >- + Maximum width (in pixels) of tabs (-1 for no maximum). + + This setting only applies when tabs are horizontal. + + This setting does not apply to pinned tabs, unless `tabs.pinned.shrink` is + False. + + This setting may not apply properly if max_width is smaller than the + minimum size of tab contents, or smaller than tabs.min_width. + tabs.width.indicator: renamed: tabs.indicator.width diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 751a294c3..d2b0f744e 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -616,6 +616,9 @@ class TabBar(QTabBar): # Qt shrink us down. If for some reason (tests, bugs) # self.width() gives 0, use a sane min of 10 px width = max(self.width(), 10) + max_width = config.cache['tabs.max_width'] + if max_width > 0: + width = min(max_width, width) size = QSize(width, height) qtutils.ensure_valid(size) return size diff --git a/tests/unit/mainwindow/test_tabwidget.py b/tests/unit/mainwindow/test_tabwidget.py index d16d31e01..3b780a3fc 100644 --- a/tests/unit/mainwindow/test_tabwidget.py +++ b/tests/unit/mainwindow/test_tabwidget.py @@ -38,6 +38,7 @@ class TestTabWidget: qtbot.addWidget(w) monkeypatch.setattr(tabwidget.objects, 'backend', usertypes.Backend.QtWebKit) + w.show() return w @pytest.fixture @@ -108,7 +109,7 @@ class TestTabWidget: for i in range(num_tabs): if i in pinned_num and shrink_pinned and not vertical: - assert (first_size.width() < + assert (first_size.width() > widget.tabBar().tabSizeHint(i).width()) assert (first_size_min.width() < widget.tabBar().minimumTabSizeHint(i).width()) @@ -128,6 +129,19 @@ class TestTabWidget: benchmark(widget.update_tab_titles) + def test_tab_min_width(self, widget, fake_web_tab, config_stub, qtbot): + widget.addTab(fake_web_tab(), 'foobar') + widget.addTab(fake_web_tab(), 'foobar1') + min_size = widget.tabBar().tabRect(0).width() + 10 + config_stub.val.tabs.min_width = min_size + assert widget.tabBar().tabRect(0).width() == min_size + + def test_tab_max_width(self, widget, fake_web_tab, config_stub, qtbot): + widget.addTab(fake_web_tab(), 'foobar') + max_size = widget.tabBar().tabRect(0).width() - 10 + config_stub.val.tabs.max_width = max_size + assert widget.tabBar().tabRect(0).width() == max_size + @pytest.mark.parametrize("num_tabs", [4, 10]) def test_add_remove_tab_benchmark(self, benchmark, browser, qtbot, fake_web_tab, num_tabs): |