[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KFadeWidgetEffect bugfix
From: Matthias Kretz <kretz () kde ! org>
Date: 2008-02-21 16:16:12
Message-ID: 200802211716.16755.kretz () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
On Thursday 21 February 2008, Rafael Fernández López wrote:
> > Did you notice the Q_ASSERT a few lines down? If destWidget were 0 it
> > would abort() (in a debug build). There must be a different problem
> > you're looking for.
>
> If you run systemsettings, is not about not having a parentWidget(), is
> about it _has_ a parentWidget, but when the kcm's are being loaded you see
> all titles on the left top corner of the window, what is pretty ugly.
that's the setGeometry call getting "wrong" numbers
> As the widget developer user, I'd like to know who the parent is, maybe
>
> MyWidget(QWidget *parent)
> : QWidget(parent->parent());
>
> I really think is better to do it as the patch does:
>
> MyWidget(QWidget *parent)
> : QWidget(parent)
I don't understand what you're trying to say. Did you ever read the apidox?
The problem is that if you make KFadeWidgetEffect a child of the widget
you're about to take a snapshot of, then the child will be asked to paint
itself, too. Which is not what is wanted here. I.e. the fade widget may not
be a child of the widget that is to be animated.
See attached patch for what I think you wanted to fix.
Regards,
Matthias
--
________________________________________________________
Matthias Kretz (Germany) <><
http://Vir.homelinux.org/
MatthiasKretz@gmx.net, kretz@kde.org,
Matthias.Kretz@urz.uni-heidelberg.de
["kfadewidgeteffect.patch" (text/x-diff)]
Index: kfadewidgeteffect.cpp
===================================================================
--- kfadewidgeteffect.cpp (revision 777279)
+++ kfadewidgeteffect.cpp (working copy)
@@ -23,18 +23,26 @@
#include <QtCore/QEvent>
#include <QtGui/QPainter>
+#include <kglobalsettings.h>
+
KFadeWidgetEffectPrivate::KFadeWidgetEffectPrivate(QWidget *_destWidget)
- : destWidget(_destWidget)
+ : destWidget(_destWidget), disabled(false)
{
}
KFadeWidgetEffect::KFadeWidgetEffect(QWidget *destWidget)
- : QWidget(destWidget && destWidget->parentWidget() ? destWidget->parentWidget() : destWidget)
- , d_ptr(new KFadeWidgetEffectPrivate(destWidget))
+ : QWidget(destWidget ? destWidget->parentWidget() : 0),
+ d_ptr(new KFadeWidgetEffectPrivate(destWidget))
{
Q_D(KFadeWidgetEffect);
d->q_ptr = this;
Q_ASSERT(destWidget && destWidget->parentWidget());
+ if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible() ||
+ (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
+ d->disabled = true;
+ hide();
+ return;
+ }
setGeometry(QRect(destWidget->mapTo(parentWidget(), QPoint(0, 0)), destWidget->size()));
d->oldPixmap = QPixmap::grabWidget(destWidget);
d->timeLine.setFrameRange(0, 255);
@@ -60,6 +68,10 @@
void KFadeWidgetEffect::start(int duration)
{
Q_D(KFadeWidgetEffect);
+ if (d->disabled) {
+ deleteLater();
+ return;
+ }
d->timeLine.setDuration(duration);
d->timeLine.start();
}
Index: kfadewidgeteffect_p.h
===================================================================
--- kfadewidgeteffect_p.h (revision 777279)
+++ kfadewidgeteffect_p.h (working copy)
@@ -39,6 +39,7 @@
QTimeLine timeLine;
QPixmap oldPixmap;
QWidget *destWidget;
+ bool disabled;
};
#endif // KFADEWIDGETEFFECT_P_H
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic