ensure the scriptengine is here
ensure the scriptengine gets created also for c++ applets that have a valid scriptengine, move the script init out of applet::init that can be reimplemented. remove the second appletscript constructor that is not necessary anymore REVIEWED-BY: Kai Uwe Broulik
This commit is contained in:
parent
967e81611f
commit
6f5816fc57
@ -123,11 +123,7 @@ Applet::~Applet()
|
||||
|
||||
void Applet::init()
|
||||
{
|
||||
if (d->script) {
|
||||
if (!d->script->init() && !d->failed) {
|
||||
setLaunchErrorMessage(i18n("Script initialization failed"));
|
||||
}
|
||||
}
|
||||
//Don't implement anything here, it will be overridden by subclasses
|
||||
}
|
||||
|
||||
uint Applet::id() const
|
||||
|
@ -97,6 +97,7 @@ Containment::~Containment()
|
||||
void Containment::init()
|
||||
{
|
||||
Applet::init();
|
||||
static_cast<Applet *>(this)->d->setupScripting();
|
||||
|
||||
if (d->type == Types::NoContainmentType) {
|
||||
//setContainmentType(Plasma::Types::DesktopContainment);
|
||||
@ -449,6 +450,7 @@ void Containment::addApplet(Applet *applet)
|
||||
}
|
||||
|
||||
applet->init();
|
||||
applet->d->setupScripting();
|
||||
|
||||
if (isNew) {
|
||||
applet->save(*applet->d->mainConfigGroup());
|
||||
|
@ -462,6 +462,15 @@ void AppletPrivate::setupPackage()
|
||||
}
|
||||
}
|
||||
|
||||
void AppletPrivate::setupScripting()
|
||||
{
|
||||
if (script) {
|
||||
if (!script->init() && !failed) {
|
||||
q->setLaunchErrorMessage(i18n("Script initialization failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString AppletPrivate::globalName() const
|
||||
{
|
||||
if (!appletDescription.isValid()) {
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
// put all setup routines for script here. at this point we can assume that
|
||||
// package exists and that we have a script engin
|
||||
void setupPackage();
|
||||
void setupScripting();
|
||||
|
||||
QString globalName() const;
|
||||
void scheduleConstraintsUpdate(Plasma::Types::Constraints c);
|
||||
|
@ -119,63 +119,6 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant
|
||||
});
|
||||
}
|
||||
|
||||
AppletInterface::AppletInterface(Plasma::Applet *a, const QVariantList &args, QQuickItem *parent)
|
||||
: AppletQuickItem(a, parent),
|
||||
m_actionSignals(0),
|
||||
m_configuration(0),
|
||||
m_appletScriptEngine(0),
|
||||
m_toolTipTextFormat(0),
|
||||
m_args(args),
|
||||
m_backgroundHints(Plasma::Types::StandardBackground),
|
||||
m_hideOnDeactivate(true),
|
||||
m_oldKeyboardShortcut(0),
|
||||
m_dummyNativeInterface(0),
|
||||
m_positionBeforeRemoval(QPointF(-1, -1))
|
||||
{
|
||||
qmlRegisterType<QAction>();
|
||||
|
||||
connect(this, &AppletInterface::configNeedsSaving,
|
||||
applet(), &Plasma::Applet::configNeedsSaving);
|
||||
connect(applet(), &Plasma::Applet::immutabilityChanged,
|
||||
this, &AppletInterface::immutabilityChanged);
|
||||
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);
|
||||
|
||||
connect(applet(), &Plasma::Applet::destroyedChanged,
|
||||
this, &AppletInterface::destroyedChanged);
|
||||
|
||||
connect(applet(), &Plasma::Applet::titleChanged,
|
||||
this, &AppletInterface::titleChanged);
|
||||
|
||||
connect(applet(), &Plasma::Applet::iconChanged,
|
||||
this, &AppletInterface::iconChanged);
|
||||
|
||||
connect(applet(), &Plasma::Applet::busyChanged,
|
||||
this, &AppletInterface::busyChanged);
|
||||
|
||||
if (appletScript()) {
|
||||
connect(appletScript(), &DeclarativeAppletScript::formFactorChanged,
|
||||
this, &AppletInterface::formFactorChanged);
|
||||
connect(appletScript(), &DeclarativeAppletScript::locationChanged,
|
||||
this, &AppletInterface::locationChanged);
|
||||
connect(appletScript(), &DeclarativeAppletScript::contextChanged,
|
||||
this, &AppletInterface::contextChanged);
|
||||
}
|
||||
|
||||
if (applet()->containment()) {
|
||||
connect(applet()->containment(), &Plasma::Containment::screenChanged,
|
||||
this, &ContainmentInterface::screenChanged);
|
||||
}
|
||||
}
|
||||
|
||||
AppletInterface::~AppletInterface()
|
||||
{
|
||||
}
|
||||
|
@ -229,7 +229,6 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
|
||||
|
||||
public:
|
||||
AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = 0);
|
||||
AppletInterface(Plasma::Applet *applet, const QVariantList &args = QVariantList(), QQuickItem *parent = 0);
|
||||
~AppletInterface();
|
||||
|
||||
//API not intended for the QML part
|
||||
|
@ -758,10 +758,9 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet)
|
||||
// qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject
|
||||
// << "Applet: " << applet << applet->title() << appletGraphicObject;
|
||||
|
||||
//Every applet should have a graphics object, otherwise don't disaplay anything
|
||||
if (!appletGraphicObject) {
|
||||
appletGraphicObject = new AppletInterface(applet, QVariantList(), this);
|
||||
applet->setProperty("_plasma_graphicObject", QVariant::fromValue(appletGraphicObject));
|
||||
static_cast<AppletInterface *>(appletGraphicObject)->init();
|
||||
return;
|
||||
}
|
||||
|
||||
if (contGraphicObject) {
|
||||
|
Loading…
Reference in New Issue
Block a user