mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[ComboTabBar] Fixed tabAt() on scroll buttons
This commit is contained in:
parent
7568ee3e2d
commit
6797433e39
@ -215,26 +215,24 @@ QRect ComboTabBar::tabRect(int index) const
|
|||||||
|
|
||||||
int ComboTabBar::tabAt(const QPoint &pos) const
|
int ComboTabBar::tabAt(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
int index = m_pinnedTabBarWidget->tabAt(m_pinnedTabBarWidget->mapFromParent(pos));
|
if (!qobject_cast<TabBarHelper*>(QApplication::widgetAt(mapToGlobal(pos))))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (index != -1) {
|
int index = m_pinnedTabBarWidget->tabAt(m_pinnedTabBarWidget->mapFromParent(pos));
|
||||||
|
if (index != -1)
|
||||||
return index;
|
return index;
|
||||||
}
|
|
||||||
|
|
||||||
index = m_mainTabBarWidget->tabAt(m_mainTabBarWidget->mapFromParent(pos));
|
index = m_mainTabBarWidget->tabAt(m_mainTabBarWidget->mapFromParent(pos));
|
||||||
|
if (index != -1)
|
||||||
if (index != -1) {
|
|
||||||
index += pinnedTabsCount();
|
index += pinnedTabsCount();
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComboTabBar::emptyArea(const QPoint &pos) const
|
bool ComboTabBar::emptyArea(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
if (tabAt(pos) != -1) {
|
if (tabAt(pos) != -1)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return qobject_cast<TabBarHelper*>(QApplication::widgetAt(mapToGlobal(pos)));
|
return qobject_cast<TabBarHelper*>(QApplication::widgetAt(mapToGlobal(pos)));
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,12 @@ public:
|
|||||||
void setTabTextColor(int index, const QColor &color);
|
void setTabTextColor(int index, const QColor &color);
|
||||||
|
|
||||||
QRect tabRect(int index) const;
|
QRect tabRect(int index) const;
|
||||||
|
|
||||||
|
// Returns tab index at pos, or -1
|
||||||
int tabAt(const QPoint &pos) const;
|
int tabAt(const QPoint &pos) const;
|
||||||
|
|
||||||
|
// Returns true if there is an empty area at pos
|
||||||
|
// (returns false if there are buttons or other widgets on the pos)
|
||||||
bool emptyArea(const QPoint &pos) const;
|
bool emptyArea(const QPoint &pos) const;
|
||||||
|
|
||||||
int mainTabBarCurrentIndex() const;
|
int mainTabBarCurrentIndex() const;
|
||||||
|
@ -644,14 +644,17 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = tabAt(event->pos());
|
if (event->button() == Qt::MiddleButton) {
|
||||||
if (id != -1 && event->button() == Qt::MiddleButton) {
|
if (emptyArea(event->pos())) {
|
||||||
m_tabWidget->closeTab(id);
|
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (id == -1 && event->button() == Qt::MiddleButton) {
|
|
||||||
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
|
int id = tabAt(event->pos());
|
||||||
return;
|
if (id != -1) {
|
||||||
|
m_tabWidget->closeTab(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboTabBar::mouseReleaseEvent(event);
|
ComboTabBar::mouseReleaseEvent(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user