From 57d1f481455f865af65bc9a12707df9c7af79a59 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 8 Oct 2008 16:44:01 +0000 Subject: [PATCH] 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 --- applet.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/applet.cpp b/applet.cpp index fd76b95a9..db543442f 100644 --- a/applet.cpp +++ b/applet.cpp @@ -283,16 +283,29 @@ void Applet::setFailedToLaunch(bool failed, const QString& reason) QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this); 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); failureWidget->setText(d->visibleFailureText(reason)); QLabel *label = failureWidget->nativeWidget(); label->setWordWrap(true); 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); resize(300,250); - setMinimumSize(failureWidget->size()); - //resize(label->size()); + setMinimumSize(failureLayout->minimumSize()); d->background->resizePanel(geometry().size()); + } update(); } @@ -824,6 +837,15 @@ void Applet::flushPendingConstraintsEvents() } else if(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