void TabBar::mouseReleaseEvent(QMouseEvent *event) { MainView *mv = qobject_cast<MainView *>(parent()); QTimer::singleShot(200, mv->addTabButton(), SLOT(show())); KTabBar::mouseReleaseEvent(event); }
QSize TabBar::tabSizeHint(int index) const { MainView *view = qobject_cast<MainView *>(parent()); int buttonSize = view->addTabButton()->size().width(); int tabBarWidth = view->size().width() - buttonSize; int baseWidth = view->sizeHint().width() / BASE_WIDTH_DIVISOR; int minWidth = view->sizeHint().width() / MIN_WIDTH_DIVISOR; int w; if (baseWidth*count() < tabBarWidth) { w = baseWidth; } else { if (count() > 0 && tabBarWidth / count() > minWidth) { w = tabBarWidth / count(); } else { w = minWidth; } } int h = KTabBar::tabSizeHint(index).height(); QSize ts = QSize(w, h); return ts; }
void TabBar::mouseMoveEvent(QMouseEvent *event) { if (count() == 1) { return; } if (event->buttons() & Qt::LeftButton) { // hide addNewTabButton when moving tabs MainView *view = qobject_cast<MainView *>(parent()); QTimer::singleShot(200, view->addTabButton(), SLOT(hide())); } KTabBar::mouseMoveEvent(event); if (ReKonfig::hoveringTabOption() == 0) { //Find the tab under the mouse const int tabIndex = tabAt(event->pos()); // if found and not the current tab then show tab preview if (tabIndex != -1 && tabIndex != currentIndex() && m_currentTabPreviewIndex != tabIndex && event->buttons() == Qt::NoButton ) { m_currentTabPreviewIndex = tabIndex; QTimer::singleShot(200, this, SLOT( showTabPreview() ) ); } // if current tab or not found then hide previous tab preview if (tabIndex == currentIndex() || tabIndex == -1) { if (!m_previewPopup.isNull()) { m_previewPopup.data()->hide(); } m_currentTabPreviewIndex = -1; } } }