1
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:
nowrep 2013-12-24 00:01:18 +01:00
parent b4f3b5962e
commit e8bbe53edb
2 changed files with 24 additions and 15 deletions

View File

@ -197,18 +197,19 @@ 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 (m_mainTabBarWidget->hasTabBarAt(m_mainTabBarWidget->mapFromGlobal(globalPos))) {
index = m_mainTabBar->tabAt(m_mainTabBar->mapFromGlobal(globalPos));
if (index != -1) {
index += pinnedTabsCount();
}
if (index != -1) {
return index;
}
else if (m_pinnedTabBarWidget->hasTabBarAt(m_pinnedTabBarWidget->mapFromGlobal(globalPos))) {
index = m_pinnedTabBar->tabAt(m_pinnedTabBar->mapFromGlobal(globalPos));
QPoint p = pos;
p.setX(p.x() - m_pinnedTabBarWidget->width());
index = m_mainTabBarWidget->tabAt(p);
if (index != -1) {
index += pinnedTabsCount();
}
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)

View File

@ -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);