mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[ComboTabBar] Correctly fix tabAt function
This commit is contained in:
parent
b4f3b5962e
commit
e8bbe53edb
@ -197,19 +197,20 @@ QRect ComboTabBar::tabRect(int index) const
|
||||
|
||||
int ComboTabBar::tabAt(const QPoint &pos) const
|
||||
{
|
||||
int index = -1;
|
||||
int index = m_pinnedTabBarWidget->tabAt(pos);
|
||||
|
||||
const QPoint globalPos = mapToGlobal(pos);
|
||||
if (index != -1) {
|
||||
return index;
|
||||
}
|
||||
|
||||
QPoint p = pos;
|
||||
p.setX(p.x() - m_pinnedTabBarWidget->width());
|
||||
|
||||
index = m_mainTabBarWidget->tabAt(p);
|
||||
|
||||
if (m_mainTabBarWidget->hasTabBarAt(m_mainTabBarWidget->mapFromGlobal(globalPos))) {
|
||||
index = m_mainTabBar->tabAt(m_mainTabBar->mapFromGlobal(globalPos));
|
||||
if (index != -1) {
|
||||
index += pinnedTabsCount();
|
||||
}
|
||||
}
|
||||
else if (m_pinnedTabBarWidget->hasTabBarAt(m_pinnedTabBarWidget->mapFromGlobal(globalPos))) {
|
||||
index = m_pinnedTabBar->tabAt(m_pinnedTabBar->mapFromGlobal(globalPos));
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -1366,13 +1367,21 @@ void TabBarScrollWidget::setUsesScrollButtons(bool useButtons)
|
||||
}
|
||||
}
|
||||
|
||||
bool TabBarScrollWidget::hasTabBarAt(const QPoint &pos) const
|
||||
int TabBarScrollWidget::tabAt(const QPoint &pos) const
|
||||
{
|
||||
if (m_leftScrollButton->rect().contains(pos) || m_rightScrollButton->rect().contains(pos)) {
|
||||
return false;
|
||||
if (!m_leftScrollButton->isVisible()) {
|
||||
return m_tabBar->tabAt(pos);
|
||||
}
|
||||
|
||||
return m_scrollArea->rect().contains(pos);
|
||||
|
||||
QPoint p = pos;
|
||||
p.setX(p.x() - m_leftScrollButton->width() - m_scrollArea->viewport()->width());
|
||||
|
||||
if (m_leftScrollButton->rect().contains(pos) || m_rightScrollButton->rect().contains(p)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return m_tabBar->tabAt(m_tabBar->mapFromGlobal(mapToGlobal(pos)));
|
||||
}
|
||||
|
||||
void TabBarScrollWidget::setContainersName(const QString &name)
|
||||
|
@ -265,7 +265,7 @@ public:
|
||||
bool usesScrollButtons() const;
|
||||
void setUsesScrollButtons(bool useButtons);
|
||||
|
||||
bool hasTabBarAt(const QPoint &pos) const;
|
||||
int tabAt(const QPoint &pos) const;
|
||||
|
||||
void setContainersName(const QString &name);
|
||||
void enableBluredBackground(bool enable);
|
||||
|
Loading…
Reference in New Issue
Block a user