From dc5075774cd0e746f6d2e324c96af36806e847d4 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 3 Mar 2011 10:56:50 +0000 Subject: Unify grabber functions. --- client/collapser.cc | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/client/collapser.cc b/client/collapser.cc index 81c9b23..13357f4 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -31,7 +31,7 @@ #include "debug.h" -#define ANIM_TIME 400 // ms +#define ANIM_TIME 300 // ms #define ANIM_INTERVAL 5 // ms Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed, @@ -157,11 +157,9 @@ void Collapser::expand() // show expanded if(collapsed) { collapsed->setVisible(false); - //qApp->processEvents(); // Make sure it is actually invisble before removing it form the layout. layout()->removeWidget(collapsed); - - placeholder.grab_from(collapsed); - } + placeholder.grab_from(collapsed); + } layout()->addWidget(&placeholder); placeholder.setVisible(true); @@ -258,16 +256,21 @@ void Collapser::Placeholder::paintEvent(QPaintEvent *) p.drawPixmap(rect(), pixmap_to, pixmap_to.rect()); } +static QPixmap grab(QWidget *w, int width) +{ + QPixmap pix; + QSize sz = w->minimumSizeHint(); + sz.setWidth(width); + w->resize(sz); + pix = QPixmap::grabWidget(w, 0, 0); + return pix; +} void Collapser::Placeholder::grab_from(QWidget *w) { weight = 0; // Reset if(!w) return; - // w->setFixedWidth(contentsRect().width()); - QSize sz = w->minimumSizeHint(); - // w->setFixedHeight(sz.height()); - w->resize(width(), sz.height()); - pixmap_from = QPixmap::grabWidget(w, 0, 0); + pixmap_from = grab(w, width()); } void Collapser::Placeholder::grab_to(QWidget *w) @@ -275,11 +278,7 @@ void Collapser::Placeholder::grab_to(QWidget *w) weight = 0; // Reset if(!w) return; - // w->setFixedWidth(contentsRect().width()); - QSize sz = w->minimumSizeHint(); - // w->setFixedHeight(sz.height()); - w->resize(width(), sz.height()); - pixmap_to = QPixmap::grabWidget(w, 0, 0); + pixmap_to = grab(w, width()); } void Collapser::Placeholder::setWeight(double w) -- cgit v1.2.3