| 90 | // class ContainerTabBar |
| 91 | |
| 92 | class ContainerTabBar : public QTabBar |
| 93 | { |
| 94 | Q_OBJECT |
| 95 | |
| 96 | public: |
| 97 | explicit ContainerTabBar(Container* container) |
| 98 | : QTabBar(container), m_container(container) |
| 99 | { |
| 100 | if (QApplication::style()->objectName() == QLatin1String("macintosh")) { |
| 101 | static QPointer<QStyle> qTabBarStyle = QStyleFactory::create(QStringLiteral("fusion")); |
| 102 | if (qTabBarStyle) { |
| 103 | setStyle(qTabBarStyle); |
| 104 | } |
| 105 | } |
| 106 | // configure the QTabBar style so it behaves as appropriately as possible, |
| 107 | // even if we end up using the native Macintosh style because the user's |
| 108 | // Qt doesn't have the Fusion style installed. |
| 109 | setDocumentMode(true); |
| 110 | setUsesScrollButtons(true); |
| 111 | setElideMode(Qt::ElideNone); |
| 112 | } |
| 113 | |
| 114 | bool event(QEvent* ev) override { |
| 115 | if(ev->type() == QEvent::ToolTip) |
| 116 | { |
| 117 | ev->accept(); |
| 118 | |
| 119 | auto* helpEvent = static_cast<QHelpEvent*>(ev); |
| 120 | int tab = tabAt(helpEvent->pos()); |
| 121 | |
| 122 | if(tab != -1) |
| 123 | { |
| 124 | m_container->showTooltipForTab(tab); |
| 125 | } |
| 126 | |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | return QTabBar::event(ev); |
| 131 | } |
| 132 | void mousePressEvent(QMouseEvent* event) override { |
| 133 | if (event->button() == Qt::MiddleButton) { |
| 134 | // just close on midbutton, drag can still be done with left mouse button |