diff options
author | Tobias Markmann <tm@ayena.de> | 2015-11-30 17:27:05 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2015-11-30 17:27:05 (GMT) |
commit | 6c7c1411080dceed313f8d50e43454a160707121 (patch) | |
tree | 4795ed2438f7da8897838923449c229234d4fbb9 /Swift/QtUI/Trellis/QtDNDTabBar.cpp | |
parent | d5f073592e1d2ea5f57e12d5c2ddcae57c05f96f (diff) | |
download | swift-6c7c1411080dceed313f8d50e43454a160707121.zip swift-6c7c1411080dceed313f8d50e43454a160707121.tar.bz2 |
Workaround QTabBar early eliding bug on OS X
The issue is visible when having two chat windows with the
same label. One of them is elided even though enough horizontal
space is available.
Test-Information:
Tested multiple chats including some with the same tab
label.
Tested many open chat windows overflowing the horizontal space
of the tab bar to test scroll behavior on overflow.
Verified that the code stops the early eliding bug on
OS X 10.10.5 with Qt 5.4.2.
Verified that workaround is not needed on Debian 8.2 with
Qt 5.4.2.
Change-Id: I2dc0d417fb6f402dda2f7575a83ca3faf4eb63cf
Diffstat (limited to 'Swift/QtUI/Trellis/QtDNDTabBar.cpp')
-rw-r--r-- | Swift/QtUI/Trellis/QtDNDTabBar.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.cpp b/Swift/QtUI/Trellis/QtDNDTabBar.cpp index a6806c6..dbe397b 100644 --- a/Swift/QtUI/Trellis/QtDNDTabBar.cpp +++ b/Swift/QtUI/Trellis/QtDNDTabBar.cpp @@ -5,16 +5,16 @@ */ #include <Swift/QtUI/Trellis/QtDNDTabBar.h> #include <cassert> -#include <QMouseEvent> -#include <QDropEvent> #include <QDrag> +#include <QDropEvent> #include <QMimeData> +#include <QMouseEvent> #include <QPainter> #include <QTabWidget> namespace Swift { QtDNDTabBar::QtDNDTabBar(QWidget* parent) : QTabBar(parent) { @@ -47,12 +47,24 @@ QSize QtDNDTabBar::sizeHint() const { if (hint.isEmpty()) { hint = QSize(parentWidget()->width(), defaultTabHeight); } return hint; } +QSize QtDNDTabBar::tabSizeHint(int index) const { + QSize tabSize = QTabBar::tabSizeHint(index); +#if defined(Q_OS_MAC) + // With multiple tabs having the same label in a QTabBar, the size hint computed by + // Qt on OS X is too small and it is elided even though there is enough horizontal + // space available. We work around this issue by adding the width of a letter to the + // size hint. + tabSize += QSize(QFontMetrics(font()).width("I"), 0); +#endif + return tabSize; +} + void QtDNDTabBar::dragEnterEvent(QDragEnterEvent* dragEnterEvent) { QtDNDTabBar* sourceTabBar = dynamic_cast<QtDNDTabBar*>(dragEnterEvent->source()); if (sourceTabBar) { dragEnterEvent->acceptProposedAction(); } } |