From 2fc9fca715ae197ded0863bf8a8f5d6560a2846a Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 24 Jun 2008 03:17:38 +0000 Subject: [PATCH] make setConfigurationRequired match setFailedToLaunch by adding a reason string. this allows more than just a mysterious "Configure" button. thanks to Chani for spotting the API irregularity. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=823770 --- applet.cpp | 42 +++++++++++++++++++++++++++++++----------- applet.h | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/applet.cpp b/applet.cpp index 241373e27..63a98698a 100644 --- a/applet.cpp +++ b/applet.cpp @@ -25,22 +25,23 @@ #include #include +#include #include +#include #include #include +#include +#include +#include +#include #include +#include #include #include #include #include #include #include -#include -#include -#include -#include -#include -#include #include #include @@ -649,7 +650,7 @@ bool Applet::configurationRequired() const return d->needsConfigOverlay != 0; } -void Applet::setConfigurationRequired(bool needsConfig) +void Applet::setConfigurationRequired(bool needsConfig, const QString &reason) { if ((d->needsConfigOverlay != 0) == needsConfig) { return; @@ -663,6 +664,7 @@ void Applet::setConfigurationRequired(bool needsConfig) d->needsConfigOverlay = new AppletOverlayWidget(this); d->needsConfigOverlay->resize(contentsRect().size()); + d->needsConfigOverlay->setPos(contentsRect().topLeft()); int zValue = 100; foreach (QGraphicsItem *child, QGraphicsItem::children()) { @@ -673,14 +675,32 @@ void Applet::setConfigurationRequired(bool needsConfig) d->needsConfigOverlay->setZValue(zValue); qDeleteAll(d->needsConfigOverlay->QGraphicsItem::children()); - QGraphicsLinearLayout *configLayout = new QGraphicsLinearLayout(d->needsConfigOverlay); + QGraphicsGridLayout *configLayout = new QGraphicsGridLayout(d->needsConfigOverlay); configLayout->setContentsMargins(0, 0, 0, 0); + + // configLayout->addStretch(); + configLayout->setColumnStretchFactor(0, 10); + configLayout->setColumnStretchFactor(2, 10); + configLayout->setRowStretchFactor(0, 10); + configLayout->setRowStretchFactor(3, 10); + + int row = 1; + if (!reason.isEmpty()) { + Label *explanation = new Label(d->needsConfigOverlay); + explanation->setText(reason); + configLayout->addItem(explanation, row, 1); + configLayout->setColumnStretchFactor(1, 10); + ++row; + //configLayout->setAlignment(explanation, Qt::AlignBottom | Qt::AlignCenter); + } + PushButton *configWidget = new PushButton(d->needsConfigOverlay); configWidget->setText(i18n("Configure...")); connect(configWidget, SIGNAL(clicked()), this, SLOT(showConfigurationInterface())); - configLayout->addStretch(); - configLayout->addItem(configWidget); - d->needsConfigOverlay->setLayout(configLayout); + configLayout->addItem(configWidget, row, 1); + //configLayout->setAlignment(configWidget, Qt::AlignTop | Qt::AlignCenter); + //configLayout->addStretch(); + d->needsConfigOverlay->show(); } diff --git a/applet.h b/applet.h index 83894f5ef..47e479580 100644 --- a/applet.h +++ b/applet.h @@ -630,7 +630,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget * @param needsConfiguring true if the applet needs to be configured, * or false if it doesn't */ - void setConfigurationRequired(bool needsConfiguring); + void setConfigurationRequired(bool needsConfiguring, const QString& reason = QString()); /** * Reimplement this method so provide a configuration interface,