when an applet fails to load only display an icon with a tooltip when

on anel, so it doesn't cause problems to the panel layout

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=869266
This commit is contained in:
Marco Martin 2008-10-08 16:44:01 +00:00
parent 7cb8380ff4
commit 57d1f48145

View File

@ -283,16 +283,29 @@ void Applet::setFailedToLaunch(bool failed, const QString& reason)
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this); QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
failureLayout->setContentsMargins(0, 0, 0, 0); failureLayout->setContentsMargins(0, 0, 0, 0);
Icon *failureIcon = new Icon(this);
failureIcon->setIcon(KIcon("dialog-error"));
failureLayout->addItem(failureIcon);
Label *failureWidget = new Plasma::Label(this); Label *failureWidget = new Plasma::Label(this);
failureWidget->setText(d->visibleFailureText(reason)); failureWidget->setText(d->visibleFailureText(reason));
QLabel *label = failureWidget->nativeWidget(); QLabel *label = failureWidget->nativeWidget();
label->setWordWrap(true); label->setWordWrap(true);
failureLayout->addItem(failureWidget); failureLayout->addItem(failureWidget);
Plasma::ToolTipManager::self()->registerWidget(failureIcon);
Plasma::ToolTipManager::ToolTipContent data;
data.mainText = i18n("Unable to load the widget");
data.subText = reason;
data.image = KIcon("dialog-error").pixmap(IconSize(KIconLoader::Desktop));
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
setLayout(failureLayout); setLayout(failureLayout);
resize(300,250); resize(300,250);
setMinimumSize(failureWidget->size()); setMinimumSize(failureLayout->minimumSize());
//resize(label->size());
d->background->resizePanel(geometry().size()); d->background->resizePanel(geometry().size());
} }
update(); update();
} }
@ -824,6 +837,15 @@ void Applet::flushPendingConstraintsEvents()
} else if(d->backgroundHints & TranslucentBackground) { } else if(d->backgroundHints & TranslucentBackground) {
setBackgroundHints(d->backgroundHints ^ TranslucentBackground); setBackgroundHints(d->backgroundHints ^ TranslucentBackground);
} }
if (d->failed) {
if (f == Vertical || f == Horizontal) {
setMinimumSize(0,0);
QGraphicsLayoutItem *item = layout()->itemAt(1);
layout()->removeAt(1);
delete item;
}
}
} }
//enforce square size in panels //enforce square size in panels