forked from qt-creator/qt-creator
Fix a hover bug with the sidebar
This commit is contained in:
@@ -69,6 +69,12 @@ void FancyTab::fadeOut()
|
|||||||
animator.start();
|
animator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FancyTab::setFader(float value)
|
||||||
|
{
|
||||||
|
m_fader = value;
|
||||||
|
tabbar->update();
|
||||||
|
}
|
||||||
|
|
||||||
FancyTabBar::FancyTabBar(QWidget *parent)
|
FancyTabBar::FancyTabBar(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
@@ -121,25 +127,25 @@ void FancyTabBar::paintEvent(QPaintEvent *event)
|
|||||||
// Handle hover events for mouse fade ins
|
// Handle hover events for mouse fade ins
|
||||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
if (!m_hoverRect.contains(e->pos())) {
|
int newHover = -1;
|
||||||
int newHover = -1;
|
for (int i = 0; i < count(); ++i) {
|
||||||
for (int i = 0; i < count(); ++i) {
|
QRect area = tabRect(i);
|
||||||
QRect area = tabRect(i);
|
if (area.contains(e->pos())) {
|
||||||
if (area.contains(e->pos())) {
|
newHover = i;
|
||||||
newHover = i;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (newHover == m_hoverIndex)
|
||||||
|
return;
|
||||||
|
|
||||||
if (validIndex(m_hoverIndex))
|
if (validIndex(m_hoverIndex))
|
||||||
m_tabs[m_hoverIndex]->fadeOut();
|
m_tabs[m_hoverIndex]->fadeOut();
|
||||||
|
|
||||||
m_hoverIndex = newHover;
|
m_hoverIndex = newHover;
|
||||||
|
|
||||||
if (validIndex(m_hoverIndex)) {
|
if (validIndex(m_hoverIndex)) {
|
||||||
m_tabs[m_hoverIndex]->fadeIn();
|
m_tabs[m_hoverIndex]->fadeIn();
|
||||||
m_hoverRect = tabRect(m_hoverIndex);
|
m_hoverRect = tabRect(m_hoverIndex);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,11 +163,6 @@ bool FancyTabBar::event(QEvent *event)
|
|||||||
return QWidget::event(event);
|
return QWidget::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::updateHover()
|
|
||||||
{
|
|
||||||
update(m_hoverRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resets hover animation on mouse enter
|
// Resets hover animation on mouse enter
|
||||||
void FancyTabBar::enterEvent(QEvent *e)
|
void FancyTabBar::enterEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
@@ -175,7 +176,6 @@ void FancyTabBar::leaveEvent(QEvent *e)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
m_hoverIndex = -1;
|
m_hoverIndex = -1;
|
||||||
update(m_hoverRect);
|
|
||||||
m_hoverRect = QRect();
|
m_hoverRect = QRect();
|
||||||
for (int i = 0 ; i < m_tabs.count() ; ++i) {
|
for (int i = 0 ; i < m_tabs.count() ; ++i) {
|
||||||
m_tabs[i]->fadeOut();
|
m_tabs[i]->fadeOut();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
animator.setTargetObject(this);
|
animator.setTargetObject(this);
|
||||||
}
|
}
|
||||||
float fader() { return m_fader; }
|
float fader() { return m_fader; }
|
||||||
void setFader(float value) { m_fader = value; tabbar->update(); }
|
void setFader(float value);
|
||||||
|
|
||||||
void fadeIn();
|
void fadeIn();
|
||||||
void fadeOut();
|
void fadeOut();
|
||||||
@@ -121,7 +121,6 @@ signals:
|
|||||||
void currentChanged(int);
|
void currentChanged(int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateHover();
|
|
||||||
void emitCurrentIndex();
|
void emitCurrentIndex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user