add functions setBusy(bool) and isBusy()
used to easily display a busy indicator as an overlay of the applet when is loading stuff svn path=/trunk/KDE/kdelibs/; revision=880089
This commit is contained in:
parent
daf80c7f17
commit
d9a77cf958
32
applet.cpp
32
applet.cpp
@ -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 @@ Extender *Applet::extender() const
|
||||
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 @@ void Applet::flushPendingConstraintsEvents()
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (c & Plasma::FormFactorConstraint) {
|
||||
FormFactor f = formFactor();
|
||||
if (!isContainment() && f != Vertical && f != Horizontal) {
|
||||
@ -1666,6 +1697,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
|
||||
backgroundHints(Applet::StandardBackground),
|
||||
appletDescription(service),
|
||||
needsConfigOverlay(0),
|
||||
busyWidget(0),
|
||||
background(0),
|
||||
script(0),
|
||||
package(0),
|
||||
|
11
applet.h
11
applet.h
@ -542,6 +542,17 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||
const QString &serviceId = QString(),
|
||||
uint appletId = 0);
|
||||
|
||||
/**
|
||||
* Shows a busy indicator that overlays the applet
|
||||
* @param busy show or hide the busy indicator
|
||||
*/
|
||||
void setBusy(bool busy);
|
||||
|
||||
/**
|
||||
* @return true if the applet is busy and is showing an indicator widget for that
|
||||
*/
|
||||
bool isBusy() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal indicates that an application launch, window
|
||||
|
@ -30,6 +30,7 @@ namespace Plasma
|
||||
class FrameSvg;
|
||||
class AppletScript;
|
||||
class Wallpaper;
|
||||
class BusyWidget;
|
||||
|
||||
class AppletOverlayWidget : public QGraphicsWidget
|
||||
{
|
||||
@ -85,6 +86,7 @@ public:
|
||||
Applet::BackgroundHints backgroundHints;
|
||||
KPluginInfo appletDescription;
|
||||
AppletOverlayWidget *needsConfigOverlay;
|
||||
Plasma::BusyWidget *busyWidget;
|
||||
QList<QGraphicsItem*> registeredAsDragHandle;
|
||||
QStringList loadedEngines;
|
||||
Plasma::FrameSvg *background;
|
||||
|
Loading…
x
Reference in New Issue
Block a user