paint the busy widget always square
use overlay widget to show the busy widget, duplication-- svn path=/trunk/KDE/kdelibs/; revision=935520
This commit is contained in:
parent
0d12d6b3b8
commit
754b8d34c3
70
applet.cpp
70
applet.cpp
@ -542,6 +542,9 @@ void AppletPrivate::createMessageOverlay()
|
||||
void AppletPrivate::destroyMessageOverlay()
|
||||
{
|
||||
//TODO: fade out? =)
|
||||
if (!messageOverlay) {
|
||||
return;
|
||||
}
|
||||
messageOverlay->destroy();
|
||||
|
||||
messageOverlay = 0;
|
||||
@ -680,53 +683,17 @@ Extender *Applet::extender() const
|
||||
void Applet::setBusy(bool busy)
|
||||
{
|
||||
if (busy) {
|
||||
PopupApplet *popup = qobject_cast<Plasma::PopupApplet*>(this);
|
||||
d->createMessageOverlay();
|
||||
d->messageOverlay->opacity = 0.4;
|
||||
|
||||
if (!d->busyWidget) {
|
||||
if (popup && popup->widget()) {
|
||||
d->messageOverlayProxy = new QGraphicsProxyWidget(this);
|
||||
d->messageOverlayProxy->setWidget(popup->widget());
|
||||
d->busyWidget = new Plasma::BusyWidget(d->messageOverlayProxy);
|
||||
} else if (popup && popup->graphicsWidget()) {
|
||||
d->busyWidget = new Plasma::BusyWidget(popup->graphicsWidget());
|
||||
} else {
|
||||
d->busyWidget = new Plasma::BusyWidget(this);
|
||||
}
|
||||
} else {
|
||||
d->busyWidget->show();
|
||||
}
|
||||
QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(d->messageOverlay);
|
||||
d->busyWidget = new Plasma::BusyWidget(d->messageOverlay);
|
||||
|
||||
if (popup && popup->widget()) {
|
||||
// popupapplet with widget()
|
||||
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) {
|
||||
d->busyWidget->hide();
|
||||
d->busyWidget->deleteLater();
|
||||
d->busyWidget = 0;
|
||||
|
||||
if (d->messageOverlayProxy) {
|
||||
delete d->messageOverlayProxy;
|
||||
d->messageOverlayProxy = 0;
|
||||
}
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addItem(d->busyWidget);
|
||||
mainLayout->addStretch();
|
||||
} else {
|
||||
d->destroyMessageOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -933,22 +900,23 @@ void Applet::setConfigurationRequired(bool needsConfig, const QString &reason)
|
||||
}
|
||||
|
||||
d->createMessageOverlay();
|
||||
d->messageOverlay->opacity = 0.4;
|
||||
|
||||
QGraphicsGridLayout *configLayout = new QGraphicsGridLayout(d->messageOverlay);
|
||||
configLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
// configLayout->addStretch();
|
||||
configLayout->setColumnStretchFactor(0, 10);
|
||||
/*configLayout->setColumnStretchFactor(0, 10);
|
||||
configLayout->setColumnStretchFactor(2, 10);
|
||||
configLayout->setRowStretchFactor(0, 10);
|
||||
configLayout->setRowStretchFactor(3, 10);
|
||||
configLayout->setRowStretchFactor(3, 10);*/
|
||||
|
||||
int row = 1;
|
||||
if (!reason.isEmpty()) {
|
||||
Label *explanation = new Label(d->messageOverlay);
|
||||
explanation->setText(reason);
|
||||
configLayout->addItem(explanation, row, 1);
|
||||
configLayout->setColumnStretchFactor(1, 10);
|
||||
//configLayout->setColumnStretchFactor(1, 10);
|
||||
++row;
|
||||
//configLayout->setAlignment(explanation, Qt::AlignBottom | Qt::AlignCenter);
|
||||
}
|
||||
@ -972,6 +940,7 @@ void Applet::showMessage(const QIcon &icon, const QString &message, const Messag
|
||||
}
|
||||
|
||||
d->createMessageOverlay();
|
||||
d->messageOverlay->opacity = 0.8;
|
||||
QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(d->messageOverlay);
|
||||
mainLayout->setOrientation(Qt::Vertical);
|
||||
mainLayout->addStretch();
|
||||
@ -2351,7 +2320,8 @@ int AppletPrivate::s_minZValue = 0;
|
||||
PackageStructure::Ptr AppletPrivate::packageStructure(0);
|
||||
|
||||
AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent)
|
||||
: QGraphicsWidget(parent)
|
||||
: QGraphicsWidget(parent),
|
||||
opacity(0.4)
|
||||
{
|
||||
resize(parent->size());
|
||||
Animator::self()->animateItem(this, Animator::AppearAnimation);
|
||||
@ -2378,7 +2348,7 @@ void AppletOverlayWidget::paint(QPainter *painter,
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||
wash.setAlphaF(.7);
|
||||
wash.setAlphaF(opacity);
|
||||
|
||||
Applet *applet = qobject_cast<Applet *>(parentWidget());
|
||||
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
AppletOverlayWidget(QGraphicsWidget *parent);
|
||||
void destroy();
|
||||
|
||||
qreal opacity;
|
||||
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
|
||||
|
@ -104,10 +104,13 @@ void BusyWidget::paint(QPainter *painter,
|
||||
|
||||
int intRotation = int(d->rotation);
|
||||
|
||||
if (!d->frames[intRotation]) {
|
||||
QPointF translatedPos(size().width()/2.0, size().height()/2.0);
|
||||
QRect spinnerRect(QPoint(0, 0), QSize(qMin(size().width(), size().height()), qMin(size().width(), size().height())));
|
||||
spinnerRect.moveCenter(QPoint(size().width()/2, size().height()/2));
|
||||
|
||||
d->frames[intRotation] = QPixmap(size().toSize());
|
||||
if (!d->frames[intRotation]) {
|
||||
QPointF translatedPos(spinnerRect.width()/2, spinnerRect.height()/2);
|
||||
|
||||
d->frames[intRotation] = QPixmap(spinnerRect.size());
|
||||
d->frames[intRotation].fill(Qt::transparent);
|
||||
|
||||
QPainter buffPainter(&d->frames[intRotation]);
|
||||
@ -119,15 +122,15 @@ void BusyWidget::paint(QPainter *painter,
|
||||
buffPainter.save();
|
||||
buffPainter.translate(2,2);
|
||||
buffPainter.rotate(intRotation);
|
||||
d->svg->paint(&buffPainter, QRect(-translatedPos.toPoint(), size().toSize()), "busywidget-shadow");
|
||||
d->svg->paint(&buffPainter, QRect(-translatedPos.toPoint(), spinnerRect.size()), "busywidget-shadow");
|
||||
buffPainter.restore();
|
||||
}
|
||||
|
||||
buffPainter.rotate(intRotation);
|
||||
d->svg->paint(&buffPainter, QRect(-translatedPos.toPoint(), size().toSize()), "busywidget");
|
||||
d->svg->paint(&buffPainter, QRect(-translatedPos.toPoint(), spinnerRect.size()), "busywidget");
|
||||
}
|
||||
|
||||
painter->drawPixmap(QPoint(0,0), d->frames[intRotation]);
|
||||
painter->drawPixmap(spinnerRect.topLeft(), d->frames[intRotation]);
|
||||
}
|
||||
|
||||
void BusyWidget::showEvent(QShowEvent *event)
|
||||
|
Loading…
Reference in New Issue
Block a user