properties configurationRequired and reason
unbreak api of Applet::SetConfigurationRequired + add bindings to appletInterface as properties. new properties configurationRequired and configurationRequiredReason Change-Id: I18ff01df94c1a0c5fac79ff801bfa76714c9f986 REVIEW:127218
This commit is contained in:
parent
88ec6de113
commit
f55e20cc5f
@ -421,14 +421,21 @@ bool Applet::configurationRequired() const
|
||||
return d->needsConfig;
|
||||
}
|
||||
|
||||
QString Applet::configurationRequiredReason() const
|
||||
{
|
||||
return d->configurationRequiredReason;
|
||||
}
|
||||
|
||||
void Applet::setConfigurationRequired(bool needsConfig, const QString &reason)
|
||||
{
|
||||
if (d->needsConfig == needsConfig) {
|
||||
if (d->needsConfig == needsConfig && reason == d->configurationRequiredReason) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->needsConfig = needsConfig;
|
||||
d->showConfigurationRequiredMessage(needsConfig, reason);
|
||||
d->configurationRequiredReason = reason;
|
||||
|
||||
emit configurationRequiredChanged(needsConfig, reason);
|
||||
}
|
||||
|
||||
bool Applet::isUserConfiguring() const
|
||||
|
@ -213,6 +213,16 @@ public:
|
||||
*/
|
||||
bool configurationRequired() const;
|
||||
|
||||
/**
|
||||
* @return A translated message for the user explaining that the
|
||||
* applet needs configuring; this should note what needs
|
||||
* to be configured
|
||||
*
|
||||
* @see setConfigurationRequired
|
||||
* @since 5.20
|
||||
*/
|
||||
QString configurationRequiredReason() const;
|
||||
|
||||
/**
|
||||
* @return true when the configuration interface is being shown
|
||||
* @since 4.5
|
||||
@ -455,6 +465,13 @@ Q_SIGNALS:
|
||||
*/
|
||||
void locationChanged(Plasma::Types::Location location);
|
||||
|
||||
/**
|
||||
* Emitted when setConfigurationRequired was called
|
||||
* @see setConfigurationRequired
|
||||
* @since 5.20
|
||||
*/
|
||||
void configurationRequiredChanged(bool needsConfig, const QString &reason);
|
||||
|
||||
public Q_SLOTS:
|
||||
//BOOKKEEPING
|
||||
/**
|
||||
|
@ -228,13 +228,6 @@ void AppletPrivate::cleanUpAndDelete()
|
||||
q->deleteLater();
|
||||
}
|
||||
|
||||
void AppletPrivate::showConfigurationRequiredMessage(bool show, const QString &reason)
|
||||
{
|
||||
// reimplemented in the UI specific library
|
||||
Q_UNUSED(show)
|
||||
Q_UNUSED(reason)
|
||||
}
|
||||
|
||||
void AppletPrivate::askDestroy()
|
||||
{
|
||||
if (q->immutability() != Types::Mutable || !started) {
|
||||
|
@ -51,8 +51,6 @@ public:
|
||||
|
||||
void init(const QString &packagePath = QString(), const QVariantList &args = QVariantList());
|
||||
|
||||
// the interface
|
||||
virtual void showConfigurationRequiredMessage(bool show, const QString &reason);
|
||||
void askDestroy();
|
||||
virtual void cleanUpAndDelete();
|
||||
|
||||
@ -111,6 +109,8 @@ public:
|
||||
QPointer <KNotification> deleteNotification;
|
||||
QTimer *deleteNotificationTimer;
|
||||
|
||||
QString configurationRequiredReason;
|
||||
|
||||
// a great green field of booleans :)
|
||||
bool hasConfigurationInterface : 1;
|
||||
bool failed : 1;
|
||||
|
@ -133,6 +133,11 @@ AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQ
|
||||
this, &AppletInterface::immutableChanged);
|
||||
connect(applet(), &Plasma::Applet::userConfiguringChanged,
|
||||
this, &AppletInterface::userConfiguringChanged);
|
||||
connect(applet(), &Plasma::Applet::configurationRequiredChanged,
|
||||
this, [this](bool needsConfig, const QString &reason) {
|
||||
emit configurationRequiredChanged();
|
||||
emit configurationRequiredReasonChanged();
|
||||
});
|
||||
|
||||
connect(applet(), &Plasma::Applet::statusChanged,
|
||||
this, &AppletInterface::statusChanged);
|
||||
@ -632,6 +637,26 @@ QObject *AppletInterface::nativeInterface()
|
||||
}
|
||||
}
|
||||
|
||||
bool AppletInterface::configurationRequired() const
|
||||
{
|
||||
return applet()->configurationRequired();
|
||||
}
|
||||
|
||||
void AppletInterface::setConfigurationRequiredProperty(bool needsConfiguring)
|
||||
{
|
||||
appletScript()->setConfigurationRequired(needsConfiguring, applet()->configurationRequiredReason());
|
||||
}
|
||||
|
||||
QString AppletInterface::configurationRequiredReason() const
|
||||
{
|
||||
return applet()->configurationRequiredReason();
|
||||
}
|
||||
|
||||
void AppletInterface::setConfigurationRequiredReason(const QString &reason)
|
||||
{
|
||||
appletScript()->setConfigurationRequired(applet()->configurationRequired(), reason);
|
||||
}
|
||||
|
||||
QString AppletInterface::downloadPath(const QString &file)
|
||||
{
|
||||
const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Plasma/" + applet()->pluginInfo().pluginName() + '/';
|
||||
|
@ -206,6 +206,16 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
|
||||
*/
|
||||
Q_PROPERTY(QObject *nativeInterface READ nativeInterface CONSTANT)
|
||||
|
||||
/**
|
||||
* If true the applet requires manual configuration from the user
|
||||
*/
|
||||
Q_PROPERTY(bool configurationRequired READ configurationRequired WRITE setConfigurationRequiredProperty NOTIFY configurationRequiredChanged)
|
||||
|
||||
/**
|
||||
* Reason why the manual user configuration is required
|
||||
*/
|
||||
Q_PROPERTY(QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged)
|
||||
|
||||
public:
|
||||
AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = 0);
|
||||
AppletInterface(Plasma::Applet *applet, const QVariantList &args = QVariantList(), QQuickItem *parent = 0);
|
||||
@ -339,6 +349,14 @@ public:
|
||||
|
||||
QObject *nativeInterface();
|
||||
|
||||
//NOTE: setConfigurationRequiredProperty because ambiguous with the
|
||||
// setConfigurationRequired invokable
|
||||
bool configurationRequired() const;
|
||||
void setConfigurationRequiredProperty(bool required);
|
||||
|
||||
QString configurationRequiredReason() const;
|
||||
void setConfigurationRequiredReason(const QString &reason);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* somebody else, usually the containment sent some data to the applet
|
||||
@ -382,6 +400,8 @@ Q_SIGNALS:
|
||||
|
||||
void userConfiguringChanged();
|
||||
void globalShortcutChanged();
|
||||
void configurationRequiredChanged();
|
||||
void configurationRequiredReasonChanged();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void init() Q_DECL_OVERRIDE;
|
||||
|
Loading…
Reference in New Issue
Block a user