make setNeedsConfiguring behave nicely
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=792371
This commit is contained in:
parent
41ad617765
commit
1833641e3b
81
applet.cpp
81
applet.cpp
@ -70,6 +70,29 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class OverlayWidget : public Widget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OverlayWidget(Widget *parent)
|
||||||
|
: Widget(parent, parent)
|
||||||
|
{
|
||||||
|
resize(parent->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option)
|
||||||
|
Q_UNUSED(widget)
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
QColor wash = Plasma::Theme::self()->backgroundColor();
|
||||||
|
wash.setAlphaF(.6);
|
||||||
|
painter->fillPath(parent()->shape(), wash);
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Applet::Private
|
class Applet::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -77,6 +100,7 @@ public:
|
|||||||
: appletId(uniqueID),
|
: appletId(uniqueID),
|
||||||
appletDescription(service),
|
appletDescription(service),
|
||||||
package(0),
|
package(0),
|
||||||
|
needsConfigOverlay(0),
|
||||||
background(0),
|
background(0),
|
||||||
failureText(0),
|
failureText(0),
|
||||||
script(0),
|
script(0),
|
||||||
@ -90,7 +114,6 @@ public:
|
|||||||
immutable(false),
|
immutable(false),
|
||||||
hasConfigurationInterface(false),
|
hasConfigurationInterface(false),
|
||||||
failed(false),
|
failed(false),
|
||||||
needsConfig(false),
|
|
||||||
isContainment(false),
|
isContainment(false),
|
||||||
square(false)
|
square(false)
|
||||||
{
|
{
|
||||||
@ -294,6 +317,7 @@ public:
|
|||||||
uint appletId;
|
uint appletId;
|
||||||
KPluginInfo appletDescription;
|
KPluginInfo appletDescription;
|
||||||
Package* package;
|
Package* package;
|
||||||
|
OverlayWidget *needsConfigOverlay;
|
||||||
QList<QObject*> watchedForFocus;
|
QList<QObject*> watchedForFocus;
|
||||||
QList<QGraphicsItem*> watchedForMouseMove;
|
QList<QGraphicsItem*> watchedForMouseMove;
|
||||||
QStringList loadedEngines;
|
QStringList loadedEngines;
|
||||||
@ -310,7 +334,6 @@ public:
|
|||||||
bool immutable : 1;
|
bool immutable : 1;
|
||||||
bool hasConfigurationInterface : 1;
|
bool hasConfigurationInterface : 1;
|
||||||
bool failed : 1;
|
bool failed : 1;
|
||||||
bool needsConfig : 1;
|
|
||||||
bool isContainment : 1;
|
bool isContainment : 1;
|
||||||
bool square : 1;
|
bool square : 1;
|
||||||
};
|
};
|
||||||
@ -693,35 +716,35 @@ void Applet::setFailedToLaunch(bool failed, const QString& reason)
|
|||||||
|
|
||||||
bool Applet::needsConfiguring() const
|
bool Applet::needsConfiguring() const
|
||||||
{
|
{
|
||||||
return d->needsConfig;
|
return d->needsConfigOverlay != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::setNeedsConfiguring(bool needsConfig)
|
void Applet::setNeedsConfiguring(bool needsConfig)
|
||||||
{
|
{
|
||||||
if (d->needsConfig == needsConfig) {
|
if ((d->needsConfigOverlay != 0) == needsConfig) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->needsConfig = needsConfig;
|
if (d->needsConfigOverlay) {
|
||||||
prepareGeometryChange();
|
delete d->needsConfigOverlay;
|
||||||
qDeleteAll(QGraphicsItem::children());
|
d->needsConfigOverlay = 0;
|
||||||
setLayout(0);
|
return;
|
||||||
|
|
||||||
if (needsConfig) {
|
|
||||||
setDrawStandardBackground(true);
|
|
||||||
Layout* layout = new BoxLayout(BoxLayout::TopToBottom,this);
|
|
||||||
PushButton* button = new PushButton(this);
|
|
||||||
button->setText(i18n("Configure..."));
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(performSetupConfig()));
|
|
||||||
layout->addItem(button);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Applet::performSetupConfig()
|
d->needsConfigOverlay = new OverlayWidget(this);
|
||||||
{
|
d->needsConfigOverlay->resize(contentSize());
|
||||||
qDeleteAll(QGraphicsItem::children());
|
|
||||||
setLayout(0);
|
setDrawStandardBackground(true);
|
||||||
showConfigurationInterface();
|
qDeleteAll(d->needsConfigOverlay->QGraphicsItem::children());
|
||||||
|
PushButton* button = new PushButton(d->needsConfigOverlay);
|
||||||
|
button->setText(i18n("Configure..."));
|
||||||
|
connect(button, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()));
|
||||||
|
QSizeF s = button->sizeHint();
|
||||||
|
button->resize(s);
|
||||||
|
button->setPos(d->needsConfigOverlay->boundingRect().width() / 2 - s.width() / 2,
|
||||||
|
d->needsConfigOverlay->boundingRect().height() / 2 - s.height() / 2);
|
||||||
|
button->show();
|
||||||
|
d->needsConfigOverlay->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::checkImmutability()
|
void Applet::checkImmutability()
|
||||||
@ -745,6 +768,18 @@ void Applet::flushUpdatedConstraints()
|
|||||||
Plasma::Constraints c = d->pendingConstraints;
|
Plasma::Constraints c = d->pendingConstraints;
|
||||||
d->pendingConstraints = NoConstraint;
|
d->pendingConstraints = NoConstraint;
|
||||||
|
|
||||||
|
if (c & Plasma::SizeConstraint && d->needsConfigOverlay) {
|
||||||
|
d->needsConfigOverlay->setGeometry(QRectF(QPointF(0, 0), contentSize()));
|
||||||
|
// FIXME:: rather horrible hack to work around the fact we don't have spacers
|
||||||
|
// for layouts, and with WoC coming i'd rather not expend effort there
|
||||||
|
QGraphicsItem * button = d->needsConfigOverlay->QGraphicsItem::children().first();
|
||||||
|
if (button) {
|
||||||
|
QSizeF s = button->boundingRect().size();
|
||||||
|
button->setPos(d->needsConfigOverlay->boundingRect().width() / 2 - s.width() / 2,
|
||||||
|
d->needsConfigOverlay->boundingRect().height() / 2 - s.height() / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (c & Plasma::FormFactorConstraint) {
|
if (c & Plasma::FormFactorConstraint) {
|
||||||
FormFactor f = formFactor();
|
FormFactor f = formFactor();
|
||||||
setShadowShown(f == Planar);
|
setShadowShown(f == Planar);
|
||||||
@ -908,7 +943,7 @@ void Applet::paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
d->background->paint(painter, option->rect);
|
d->background->paint(painter, option->rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->failed && !d->needsConfig) {
|
if (!d->failed) {
|
||||||
if (widget && isContainment()) {
|
if (widget && isContainment()) {
|
||||||
// note that the widget we get is actually the viewport of the view, not the view itself
|
// note that the widget we get is actually the viewport of the view, not the view itself
|
||||||
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
||||||
|
5
applet.h
5
applet.h
@ -779,11 +779,6 @@ class PLASMA_EXPORT Applet : public Widget
|
|||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
/**
|
|
||||||
* @internal used to show the configuration of an applet on first show
|
|
||||||
*/
|
|
||||||
void performSetupConfig();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal used to check the immutability of the item in the config file
|
* @internal used to check the immutability of the item in the config file
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user