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
This commit is contained in:
parent
8a974f0f46
commit
2fc9fca715
42
applet.cpp
42
applet.cpp
@ -25,22 +25,23 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QGraphicsGridLayout>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
#include <QLabel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QGraphicsLinearLayout>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QLabel>
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QGraphicsView>
|
|
||||||
#include <QAction>
|
|
||||||
|
|
||||||
#include <KAction>
|
#include <KAction>
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
@ -649,7 +650,7 @@ bool Applet::configurationRequired() const
|
|||||||
return d->needsConfigOverlay != 0;
|
return d->needsConfigOverlay != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::setConfigurationRequired(bool needsConfig)
|
void Applet::setConfigurationRequired(bool needsConfig, const QString &reason)
|
||||||
{
|
{
|
||||||
if ((d->needsConfigOverlay != 0) == needsConfig) {
|
if ((d->needsConfigOverlay != 0) == needsConfig) {
|
||||||
return;
|
return;
|
||||||
@ -663,6 +664,7 @@ void Applet::setConfigurationRequired(bool needsConfig)
|
|||||||
|
|
||||||
d->needsConfigOverlay = new AppletOverlayWidget(this);
|
d->needsConfigOverlay = new AppletOverlayWidget(this);
|
||||||
d->needsConfigOverlay->resize(contentsRect().size());
|
d->needsConfigOverlay->resize(contentsRect().size());
|
||||||
|
d->needsConfigOverlay->setPos(contentsRect().topLeft());
|
||||||
|
|
||||||
int zValue = 100;
|
int zValue = 100;
|
||||||
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
|
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
|
||||||
@ -673,14 +675,32 @@ void Applet::setConfigurationRequired(bool needsConfig)
|
|||||||
d->needsConfigOverlay->setZValue(zValue);
|
d->needsConfigOverlay->setZValue(zValue);
|
||||||
|
|
||||||
qDeleteAll(d->needsConfigOverlay->QGraphicsItem::children());
|
qDeleteAll(d->needsConfigOverlay->QGraphicsItem::children());
|
||||||
QGraphicsLinearLayout *configLayout = new QGraphicsLinearLayout(d->needsConfigOverlay);
|
QGraphicsGridLayout *configLayout = new QGraphicsGridLayout(d->needsConfigOverlay);
|
||||||
configLayout->setContentsMargins(0, 0, 0, 0);
|
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);
|
PushButton *configWidget = new PushButton(d->needsConfigOverlay);
|
||||||
configWidget->setText(i18n("Configure..."));
|
configWidget->setText(i18n("Configure..."));
|
||||||
connect(configWidget, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()));
|
connect(configWidget, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()));
|
||||||
configLayout->addStretch();
|
configLayout->addItem(configWidget, row, 1);
|
||||||
configLayout->addItem(configWidget);
|
//configLayout->setAlignment(configWidget, Qt::AlignTop | Qt::AlignCenter);
|
||||||
d->needsConfigOverlay->setLayout(configLayout);
|
//configLayout->addStretch();
|
||||||
|
|
||||||
d->needsConfigOverlay->show();
|
d->needsConfigOverlay->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
applet.h
2
applet.h
@ -630,7 +630,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
* @param needsConfiguring true if the applet needs to be configured,
|
* @param needsConfiguring true if the applet needs to be configured,
|
||||||
* or false if it doesn't
|
* 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,
|
* Reimplement this method so provide a configuration interface,
|
||||||
|
Loading…
Reference in New Issue
Block a user