From 0735c0e1ee8f4fc75c44b8e5ef2971c46392339d Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 20 Mar 2009 13:13:17 +0000 Subject: Fixed wierd bug introduced when upgrading to Qt4.5. --- client/collapser.cc | 23 ++++++++++++++++------- client/collapser.h | 7 +++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/client/collapser.cc b/client/collapser.cc index ff1ab69..7d95946 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -36,6 +36,11 @@ Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed) this->collapsed = NULL; this->expanded = NULL; + timer = new QTimer(this); + timer->setSingleShot(true); + timer->setInterval(ANIM_INTERVAL); + connect(timer, SIGNAL(timeout()), this, SLOT(anim())); + setLayout(new QHBoxLayout()); layout()->setContentsMargins(0,0,0,0); @@ -110,10 +115,10 @@ void Collapser::collapse() emit collapsing(); t_anim.start(); + printf("(%d) collapsing\n", (int)this); is_collapsed = true; - killTimer(timer_id); - timer_id = startTimer(ANIM_INTERVAL); + timer->start(); } void Collapser::expand() @@ -121,6 +126,7 @@ void Collapser::expand() emit expanding(); t_anim.start(); + printf("(%d) expanding\n", (int)this); // show expanded if(collapsed) { @@ -134,8 +140,7 @@ void Collapser::expand() } is_collapsed = false; - killTimer(timer_id); - timer_id = startTimer(ANIM_INTERVAL); + timer->start(); } void Collapser::toggleCollapse() @@ -158,9 +163,10 @@ void Collapser::anim() e_height = sz.height(); } - killTimer(timer_id); + // killTimer(timer_id); double x = (double)(t_anim.elapsed()) / (double)ANIM_TIME; + printf("(%d) x: %f\n", (int)this, x); double y = 1; if(x < 1) { @@ -174,7 +180,9 @@ void Collapser::anim() } setFixedHeight(height); - timer_id = startTimer(ANIM_INTERVAL); + // timer_id = startTimer(ANIM_INTERVAL); + timer->start(); + } else { if(is_collapsed) { @@ -196,8 +204,9 @@ void Collapser::anim() } } - +/* void Collapser::timerEvent(QTimerEvent *) { anim(); } +*/ diff --git a/client/collapser.h b/client/collapser.h index 2a3581b..d74a4cf 100644 --- a/client/collapser.h +++ b/client/collapser.h @@ -29,6 +29,7 @@ #include #include +#include class Collapser : public QWidget { Q_OBJECT @@ -50,13 +51,14 @@ public slots: void collapse(); void expand(); void toggleCollapse(); + void anim(); signals: void collapsing(); void expanding(); protected: - void timerEvent(QTimerEvent *); + // void timerEvent(QTimerEvent *); private: QWidget *collapsed; @@ -64,9 +66,10 @@ private: bool is_collapsed; - void anim(); QTime t_anim; int timer_id; + + QTimer *timer; }; #endif/*__PRACRO_COLLAPSER_H__*/ -- cgit v1.2.3