summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;