Changes inside Plasma::Applet to test if we have a popup

and if this is true, if we should use widget() or graphicsWidget()
to show the BusyWidget.


svn path=/trunk/KDE/kdelibs/; revision=933444
This commit is contained in:
Artur Duque de Souza 2009-02-28 22:52:17 +00:00
parent 0d9a13405e
commit d0205d92b3
2 changed files with 43 additions and 7 deletions

View File

@ -523,8 +523,6 @@ void AppletPrivate::createMessageOverlay()
void AppletPrivate::destroyMessageOverlay() void AppletPrivate::destroyMessageOverlay()
{ {
//TODO: fade out? =) //TODO: fade out? =)
QGraphicsWidget *w = messageOverlay;
messageOverlay->destroy(); messageOverlay->destroy();
messageOverlay = 0; messageOverlay = 0;
@ -663,19 +661,53 @@ Extender *Applet::extender() const
void Applet::setBusy(bool busy) void Applet::setBusy(bool busy)
{ {
if (busy) { if (busy) {
PopupApplet *popup = qobject_cast<Plasma::PopupApplet*>(this);
if (!d->busyWidget) { if (!d->busyWidget) {
d->busyWidget = new Plasma::BusyWidget(this); if (popup && popup->widget()) {
d->popupBusyWidgetProxy = new QGraphicsProxyWidget(this);
d->popupBusyWidgetProxy->setWidget(popup->widget());
d->busyWidget = new Plasma::BusyWidget(d->popupBusyWidgetProxy);
} else if (popup && popup->graphicsWidget()) {
d->busyWidget = new Plasma::BusyWidget(popup->graphicsWidget());
} else {
d->busyWidget = new Plasma::BusyWidget(this);
}
} else { } else {
d->busyWidget->show(); d->busyWidget->show();
} }
int busySize = qMin(size().width(), size().height())/3;
QRect busyRect(0, 0, busySize, busySize); if (popup && popup->widget()) {
busyRect.moveCenter(boundingRect().center().toPoint()); // popupapplet with widget()
d->busyWidget->setGeometry(busyRect); int busySize = qMin(popup->widget()->size().width(),
popup->widget()->size().height())/3;
QRect busyRect(0, 0, busySize, busySize);
busyRect.moveCenter(popup->widget()->contentsRect().center());
d->busyWidget->setGeometry(busyRect);
} else if (popup && popup->graphicsWidget()) {
// popupapplet with graphicsWidget()
int busySize = qMin(popup->graphicsWidget()->size().width(),
popup->graphicsWidget()->size().height())/3;
QRect busyRect(0, 0, busySize, busySize);
busyRect.moveCenter(popup->graphicsWidget()->boundingRect().center().toPoint());
d->busyWidget->setGeometry(busyRect);
} else {
// normal applet
int busySize = qMin(size().width(), size().height())/3;
QRect busyRect(0, 0, busySize, busySize);
busyRect.moveCenter(boundingRect().center().toPoint());
d->busyWidget->setGeometry(busyRect);
}
} else if (d->busyWidget) { } else if (d->busyWidget) {
d->busyWidget->hide(); d->busyWidget->hide();
d->busyWidget->deleteLater(); d->busyWidget->deleteLater();
d->busyWidget = 0; d->busyWidget = 0;
if (d->popupBusyWidgetProxy) {
delete d->popupBusyWidgetProxy;
d->popupBusyWidgetProxy = 0;
}
} }
} }
@ -1995,6 +2027,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
actions(applet), actions(applet),
activationAction(0), activationAction(0),
shortcutEditor(0), shortcutEditor(0),
popupBusyWidgetProxy(0),
constraintsTimerId(0), constraintsTimerId(0),
modificationsTimerId(-1), modificationsTimerId(-1),
hasConfigurationInterface(false), hasConfigurationInterface(false),

View File

@ -22,6 +22,8 @@
#ifndef PLASMA_APPLET_P_H #ifndef PLASMA_APPLET_P_H
#define PLASMA_APPLET_P_H #define PLASMA_APPLET_P_H
#include <QGraphicsProxyWidget>
#include <kactioncollection.h> #include <kactioncollection.h>
class KKeySequenceWidget; class KKeySequenceWidget;
@ -116,6 +118,7 @@ public:
KActionCollection actions; KActionCollection actions;
KAction *activationAction; KAction *activationAction;
KKeySequenceWidget *shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there KKeySequenceWidget *shortcutEditor; //TODO: subclass KConfigDialog and encapsulate this in there
QGraphicsProxyWidget *popupBusyWidgetProxy;
int constraintsTimerId; int constraintsTimerId;
int modificationsTimerId; int modificationsTimerId;
bool hasConfigurationInterface : 1; bool hasConfigurationInterface : 1;