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/iconwidget.h"
|
||||||
#include "widgets/label.h"
|
#include "widgets/label.h"
|
||||||
#include "widgets/pushbutton.h"
|
#include "widgets/pushbutton.h"
|
||||||
|
#include "widgets/busywidget.h"
|
||||||
#include "tooltipmanager.h"
|
#include "tooltipmanager.h"
|
||||||
#include "wallpaper.h"
|
#include "wallpaper.h"
|
||||||
|
|
||||||
@ -539,6 +540,29 @@ Extender *Applet::extender() const
|
|||||||
return d->extender;
|
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
|
QString Applet::name() const
|
||||||
{
|
{
|
||||||
if (isContainment()) {
|
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) {
|
if (c & Plasma::FormFactorConstraint) {
|
||||||
FormFactor f = formFactor();
|
FormFactor f = formFactor();
|
||||||
if (!isContainment() && f != Vertical && f != Horizontal) {
|
if (!isContainment() && f != Vertical && f != Horizontal) {
|
||||||
@ -1666,6 +1697,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
|
|||||||
backgroundHints(Applet::StandardBackground),
|
backgroundHints(Applet::StandardBackground),
|
||||||
appletDescription(service),
|
appletDescription(service),
|
||||||
needsConfigOverlay(0),
|
needsConfigOverlay(0),
|
||||||
|
busyWidget(0),
|
||||||
background(0),
|
background(0),
|
||||||
script(0),
|
script(0),
|
||||||
package(0),
|
package(0),
|
||||||
|
11
applet.h
11
applet.h
@ -542,6 +542,17 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
const QString &serviceId = QString(),
|
const QString &serviceId = QString(),
|
||||||
uint appletId = 0);
|
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:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* This signal indicates that an application launch, window
|
* This signal indicates that an application launch, window
|
||||||
|
@ -30,6 +30,7 @@ namespace Plasma
|
|||||||
class FrameSvg;
|
class FrameSvg;
|
||||||
class AppletScript;
|
class AppletScript;
|
||||||
class Wallpaper;
|
class Wallpaper;
|
||||||
|
class BusyWidget;
|
||||||
|
|
||||||
class AppletOverlayWidget : public QGraphicsWidget
|
class AppletOverlayWidget : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
@ -85,6 +86,7 @@ public:
|
|||||||
Applet::BackgroundHints backgroundHints;
|
Applet::BackgroundHints backgroundHints;
|
||||||
KPluginInfo appletDescription;
|
KPluginInfo appletDescription;
|
||||||
AppletOverlayWidget *needsConfigOverlay;
|
AppletOverlayWidget *needsConfigOverlay;
|
||||||
|
Plasma::BusyWidget *busyWidget;
|
||||||
QList<QGraphicsItem*> registeredAsDragHandle;
|
QList<QGraphicsItem*> registeredAsDragHandle;
|
||||||
QStringList loadedEngines;
|
QStringList loadedEngines;
|
||||||
Plasma::FrameSvg *background;
|
Plasma::FrameSvg *background;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user