[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: KDE/kdelibs/plasma
From: "Thomas Braxton" <kde.braxton () gmail ! com>
Date: 2008-11-05 11:19:45
Message-ID: 928c3f1b0811050319we184cc5p2dd947aada6fc383 () mail ! gmail ! com
[Download RAW message or body]
On Tue, Nov 4, 2008 at 12:22 PM, Marco Martin <notmart@gmail.com> wrote:
> SVN commit 880089 by mart:
>
> add functions setBusy(bool) and isBusy()
> used to easily display a busy indicator as an overlay of the applet when
> is loading stuff
>
>
> M +32 -0 applet.cpp
> M +11 -0 applet.h
> M +2 -0 private/applet_p.h
>
>
> --- trunk/KDE/kdelibs/plasma/applet.cpp #880088:880089
> @@ -75,6 +75,7 @@
> #include "widgets/iconwidget.h"
> #include "widgets/label.h"
> #include "widgets/pushbutton.h"
> +#include "widgets/busywidget.h"
> #include "tooltipmanager.h"
> #include "wallpaper.h"
>
> @@ -539,6 +540,29 @@
> return d->extender;
> }
>
> +void Applet::setBusy(bool busy)
> +{
> + if (busy) {
> + if (!d->busyWidget) {
> + d->busyWidget = new Plasma::BusyWidget(this);
> + } else {
> + d->busyWidget->show();
> + }
> + int busySize = qMin(size().width(), size().height())/3;
> + QRect busyRect(0, 0, busySize, busySize);
> + busyRect.moveCenter(boundingRect().center().toPoint());
> + d->busyWidget->setGeometry(busyRect);
> + } else {
> + d->busyWidget->hide();
> + d->busyWidget->deleteLater();
> + }
> +}
> +
> +bool Applet::isBusy() const
> +{
> + return d->busyWidget && d->busyWidget->isVisible();
> +}
> +
> QString Applet::name() const
> {
> if (isContainment()) {
> @@ -834,6 +858,13 @@
> }
> }
>
> + if (c & Plasma::SizeConstraint && d->busyWidget && d->busyWidget->isVisible()) {
> + int busySize = qMin(size().width(), size().height())/3;
> + QRect busyRect(0, 0, busySize, busySize);
> + busyRect.moveCenter(boundingRect().center().toPoint());
> + d->busyWidget->setGeometry(busyRect);
> + }
> +
wouldn't it be easier to write the above as:
if (c & Plasma::SizeConstraint && isBusy()) {
setBusy(true);
}
that way you would keep the code that moves the busyWidget in one place.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic