summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-11-30 17:27:05 (GMT)
committerTobias Markmann <tm@ayena.de>2015-11-30 17:27:05 (GMT)
commit6c7c1411080dceed313f8d50e43454a160707121 (patch)
tree4795ed2438f7da8897838923449c229234d4fbb9 /Swift/QtUI/Trellis
parentd5f073592e1d2ea5f57e12d5c2ddcae57c05f96f (diff)
downloadswift-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')
-rw-r--r--Swift/QtUI/Trellis/QtDNDTabBar.cpp16
-rw-r--r--Swift/QtUI/Trellis/QtDNDTabBar.h9
2 files changed, 19 insertions, 6 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
@@ -8,10 +8,10 @@
#include <cassert>
-#include <QMouseEvent>
-#include <QDropEvent>
#include <QDrag>
+#include <QDropEvent>
#include <QMimeData>
+#include <QMouseEvent>
#include <QPainter>
#include <QTabWidget>
@@ -50,6 +50,18 @@ QSize QtDNDTabBar::sizeHint() const {
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) {
diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.h b/Swift/QtUI/Trellis/QtDNDTabBar.h
index 194cce8..71ca94b 100644
--- a/Swift/QtUI/Trellis/QtDNDTabBar.h
+++ b/Swift/QtUI/Trellis/QtDNDTabBar.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -26,9 +26,10 @@ class QtDNDTabBar : public QTabBar {
void onDropSucceeded();
protected:
- void dragEnterEvent(QDragEnterEvent* dragEnterEvent);
- void dropEvent(QDropEvent* dropEvent);
- bool event(QEvent* event);
+ virtual void dragEnterEvent(QDragEnterEvent* dragEnterEvent);
+ virtual void dropEvent(QDropEvent* dropEvent);
+ virtual bool event(QEvent* event);
+ virtual QSize tabSizeHint(int index) const;
private:
int defaultTabHeight;