1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[ComboTabBar] Fixed isOverflowed() for empty tabbar.

It returned true for empty tabbar. Switching tabs with
mouse wheel now works correctly in all scenarios.
This commit is contained in:
nowrep 2014-01-22 16:57:04 +01:00
parent 5c235f6775
commit 555453a7e2
2 changed files with 12 additions and 13 deletions

View File

@ -543,23 +543,23 @@ void ComboTabBar::wheelEvent(QWheelEvent* event)
} }
if (m_mainTabBarWidget->underMouse()) { if (m_mainTabBarWidget->underMouse()) {
if (m_mainTabBarWidget->scrollBar()->isOverFlowed()) { if (m_mainTabBarWidget->isOverflowed()) {
m_mainTabBarWidget->scrollByWheel(event); m_mainTabBarWidget->scrollByWheel(event);
} }
else if (m_pinnedTabBarWidget->scrollBar()->isOverFlowed()) { else if (m_pinnedTabBarWidget->isOverflowed()) {
m_pinnedTabBarWidget->scrollByWheel(event); m_pinnedTabBarWidget->scrollByWheel(event);
} }
} }
else if (m_pinnedTabBarWidget->underMouse()) { else if (m_pinnedTabBarWidget->underMouse()) {
if (m_pinnedTabBarWidget->scrollBar()->isOverFlowed()) { if (m_pinnedTabBarWidget->isOverflowed()) {
m_pinnedTabBarWidget->scrollByWheel(event); m_pinnedTabBarWidget->scrollByWheel(event);
} }
else if (m_mainTabBarWidget->scrollBar()->isOverFlowed()) { else if (m_mainTabBarWidget->isOverflowed()) {
m_mainTabBarWidget->scrollByWheel(event); m_mainTabBarWidget->scrollByWheel(event);
} }
} }
if (!m_mainTabBarWidget->scrollBar()->isOverFlowed() && !m_pinnedTabBarWidget->scrollBar()->isOverFlowed()) { if (!m_mainTabBarWidget->isOverflowed() && !m_pinnedTabBarWidget->isOverflowed()) {
setCurrentNextEnabledIndex(event->delta() > 0 ? -1 : 1); setCurrentNextEnabledIndex(event->delta() > 0 ? -1 : 1);
} }
} }
@ -568,7 +568,7 @@ void ComboTabBar::resizeEvent(QResizeEvent* event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
if (m_mainBarOverFlowed != m_mainTabBarWidget->scrollBar()->isOverFlowed()) { if (m_mainBarOverFlowed != m_mainTabBarWidget->isOverflowed()) {
setMinimumWidths(); setMinimumWidths();
} }
} }
@ -1086,11 +1086,6 @@ void TabScrollBar::animateToValue(int to, QEasingCurve::Type type)
m_animation->start(); m_animation->start();
} }
bool TabScrollBar::isOverFlowed()
{
return maximum() != minimum();
}
void TabScrollBar::wheelEvent(QWheelEvent* event) void TabScrollBar::wheelEvent(QWheelEvent* event)
{ {
int delta = isRightToLeft() ? -event->delta() : event->delta(); int delta = isRightToLeft() ? -event->delta() : event->delta();
@ -1375,6 +1370,11 @@ void TabBarScrollWidget::setUsesScrollButtons(bool useButtons)
} }
} }
bool TabBarScrollWidget::isOverflowed() const
{
return m_tabBar->count() > 0 && m_scrollBar->minimum() != m_scrollBar->maximum();
}
int TabBarScrollWidget::tabAt(const QPoint &pos) const int TabBarScrollWidget::tabAt(const QPoint &pos) const
{ {
if (!m_leftScrollButton->isVisible()) { if (!m_leftScrollButton->isVisible()) {

View File

@ -237,8 +237,6 @@ public:
~TabScrollBar(); ~TabScrollBar();
void animateToValue(int to, QEasingCurve::Type type = QEasingCurve::InOutExpo); void animateToValue(int to, QEasingCurve::Type type = QEasingCurve::InOutExpo);
bool isOverFlowed();
void wheelEvent(QWheelEvent* event); void wheelEvent(QWheelEvent* event);
private: private:
@ -264,6 +262,7 @@ public:
bool usesScrollButtons() const; bool usesScrollButtons() const;
void setUsesScrollButtons(bool useButtons); void setUsesScrollButtons(bool useButtons);
bool isOverflowed() const;
int tabAt(const QPoint &pos) const; int tabAt(const QPoint &pos) const;
void setContainersName(const QString &name); void setContainersName(const QString &name);