diff --git a/src/plugins/VerticalTabs/tablistdelegate.cpp b/src/plugins/VerticalTabs/tablistdelegate.cpp index 7fd84d6c8..ac0bf046f 100644 --- a/src/plugins/VerticalTabs/tablistdelegate.cpp +++ b/src/plugins/VerticalTabs/tablistdelegate.cpp @@ -31,9 +31,7 @@ TabListDelegate::TabListDelegate(TabListView *view) m_padding = qMax(5, m_view->style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1); m_loadingAnimator = new LoadingAnimator(this); - connect(m_loadingAnimator, &LoadingAnimator::updateIndex, this, [this](const QModelIndex &index) { - m_view->update(index); - }); + connect(m_loadingAnimator, &LoadingAnimator::updateIndex, m_view, &TabListView::updateIndex); } QRect TabListDelegate::audioButtonRect(const QModelIndex &index) const diff --git a/src/plugins/VerticalTabs/tablistview.cpp b/src/plugins/VerticalTabs/tablistview.cpp index 67e3bb880..24952af9c 100644 --- a/src/plugins/VerticalTabs/tablistview.cpp +++ b/src/plugins/VerticalTabs/tablistview.cpp @@ -45,6 +45,18 @@ TabListView::TabListView(QWidget *parent) setFixedHeight(m_delegate->sizeHint(viewOptions(), QModelIndex()).height()); } +void TabListView::updateIndex(const QModelIndex &index) +{ + QRect rect = visualRect(index); + if (!rect.isValid()) { + return; + } + // Need to update a little above/under to account for negative margins + rect.moveTop(rect.y() - rect.height() / 2); + rect.setHeight(rect.height() * 2); + viewport()->update(rect); +} + void TabListView::adjustStyleOption(QStyleOptionViewItem *option) { const QModelIndex index = option->index; diff --git a/src/plugins/VerticalTabs/tablistview.h b/src/plugins/VerticalTabs/tablistview.h index e6620e73b..78b5e6f31 100644 --- a/src/plugins/VerticalTabs/tablistview.h +++ b/src/plugins/VerticalTabs/tablistview.h @@ -28,6 +28,7 @@ class TabListView : public QListView public: explicit TabListView(QWidget *parent = nullptr); + void updateIndex(const QModelIndex &index); void adjustStyleOption(QStyleOptionViewItem *option); private: diff --git a/src/plugins/VerticalTabs/tabtreedelegate.cpp b/src/plugins/VerticalTabs/tabtreedelegate.cpp index 5c2f1d3d8..641c0d1c5 100644 --- a/src/plugins/VerticalTabs/tabtreedelegate.cpp +++ b/src/plugins/VerticalTabs/tabtreedelegate.cpp @@ -94,9 +94,7 @@ TabTreeDelegate::TabTreeDelegate(TabTreeView *view) m_indentation = 15; m_loadingAnimator = new LoadingAnimator(this); - connect(m_loadingAnimator, &LoadingAnimator::updateIndex, this, [this](const QModelIndex &index) { - m_view->update(index); - }); + connect(m_loadingAnimator, &LoadingAnimator::updateIndex, m_view, &TabTreeView::updateIndex); // Needed to make it stylable the same way as real tabbar close button QTabBar *tabBar = new QTabBar(m_view); diff --git a/src/plugins/VerticalTabs/tabtreeview.cpp b/src/plugins/VerticalTabs/tabtreeview.cpp index ecbd272ae..4f05a962d 100644 --- a/src/plugins/VerticalTabs/tabtreeview.cpp +++ b/src/plugins/VerticalTabs/tabtreeview.cpp @@ -81,6 +81,18 @@ void TabTreeView::setTabsInOrder(bool enable) m_tabsInOrder = enable; } +void TabTreeView::updateIndex(const QModelIndex &index) +{ + QRect rect = visualRect(index); + if (!rect.isValid()) { + return; + } + // Need to update a little above/under to account for negative margins + rect.moveTop(rect.y() - rect.height() / 2); + rect.setHeight(rect.height() * 2); + viewport()->update(rect); +} + void TabTreeView::adjustStyleOption(QStyleOptionViewItem *option) { const QModelIndex index = option->index; @@ -155,7 +167,7 @@ bool TabTreeView::viewportEvent(QEvent *event) case QEvent::MouseButtonPress: { QMouseEvent *me = static_cast(event); const QModelIndex index = indexAt(me->pos()); - update(index); + updateIndex(index); WebTab *tab = index.data(TabModel::WebTabRole).value(); if (me->buttons() == Qt::MiddleButton && tab) { tab->closeTab(); @@ -200,7 +212,7 @@ bool TabTreeView::viewportEvent(QEvent *event) break; } const QModelIndex index = indexAt(me->pos()); - update(index); + updateIndex(index); if (m_pressedIndex != index) { break; } @@ -230,9 +242,9 @@ bool TabTreeView::viewportEvent(QEvent *event) case QEvent::HoverLeave: case QEvent::HoverMove: { QHoverEvent *he = static_cast(event); - update(m_hoveredIndex); + updateIndex(m_hoveredIndex); m_hoveredIndex = indexAt(he->pos()); - update(m_hoveredIndex); + updateIndex(m_hoveredIndex); break; } diff --git a/src/plugins/VerticalTabs/tabtreeview.h b/src/plugins/VerticalTabs/tabtreeview.h index fabb39add..68d31f9c6 100644 --- a/src/plugins/VerticalTabs/tabtreeview.h +++ b/src/plugins/VerticalTabs/tabtreeview.h @@ -40,6 +40,7 @@ public: bool areTabsInOrder() const; void setTabsInOrder(bool enable); + void updateIndex(const QModelIndex &index); void adjustStyleOption(QStyleOptionViewItem *option); private: