move animation setup to finalizeStyles

- This commit fixed layout shifting in glider
This commit is contained in:
uncor3
2025-11-19 20:37:23 -08:00
parent 024630cee6
commit 4c95ee6744
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -85,10 +85,6 @@ void ZTabWidget::setupGlider()
" border-radius: 1px;"
"}");
m_glider->hide(); // Hide initially until tabs are added
m_gliderAnimation = new QPropertyAnimation(m_glider, "pos");
m_gliderAnimation->setDuration(250);
m_gliderAnimation->setEasingCurve(QEasingCurve::OutCubic);
}
ZTab *ZTabWidget::addTab(QWidget *widget, const QString &label)
@@ -132,6 +128,9 @@ void ZTabWidget::finalizeStyles()
int targetX = tab->pos().x();
int targetY = tab->pos().y() + tab->size().height() - 2;
m_glider->move(targetX, targetY);
m_gliderAnimation = new QPropertyAnimation(m_glider, "pos");
m_gliderAnimation->setDuration(250);
m_gliderAnimation->setEasingCurve(QEasingCurve::OutCubic);
m_glider->show();
}
});
@@ -183,6 +182,9 @@ void ZTabWidget::animateGlider(int index)
// targetTabPos.y() + targetTabSize.height() + 6; // Position at bottom
targetTabPos.y() + targetTabSize.height() - 2; // Position at bottom
if (m_gliderAnimation == nullptr)
return;
m_gliderAnimation->stop();
m_gliderAnimation->setStartValue(m_glider->pos());
m_gliderAnimation->setEndValue(QPoint(targetX, targetY));
+1 -1
View File
@@ -67,7 +67,7 @@ private:
QStackedWidget *m_stackedWidget;
QButtonGroup *m_buttonGroup;
QWidget *m_glider;
QPropertyAnimation *m_gliderAnimation;
QPropertyAnimation *m_gliderAnimation = nullptr;
QList<ZTab *> m_tabs;
QList<QWidget *> m_widgets;
int m_currentIndex;