mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-21 19:35:49 +08:00
move animation setup to finalizeStyles
- This commit fixed layout shifting in glider
This commit is contained in:
+6
-4
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user