experiment with AppletInterface to be attached
Plasmoid.title etc would be attached properties to the root object instead of being a component itself
This commit is contained in:
parent
87a7db3063
commit
866fe43120
@ -19,14 +19,18 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.components 2.0
|
||||
import org.kde.shell 2.0
|
||||
|
||||
Item {
|
||||
property int minimumWidth: 300
|
||||
property int minimumHeight: 400
|
||||
|
||||
AppletInterface.title: "bah"
|
||||
|
||||
ToolBar {
|
||||
id: toolBar
|
||||
z: 10
|
||||
//AppletInterface.title: "bah"
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
|
@ -52,6 +52,8 @@
|
||||
|
||||
Q_DECLARE_METATYPE(AppletInterface*)
|
||||
|
||||
QHash<QObject *, AppletInterface *> AppletInterface::s_rootObjects = QHash<QObject *, AppletInterface *>();
|
||||
|
||||
AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *parent)
|
||||
: QQuickItem(parent),
|
||||
m_appletScriptEngine(script),
|
||||
@ -96,6 +98,7 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, QQuickItem *pa
|
||||
|
||||
AppletInterface::~AppletInterface()
|
||||
{
|
||||
s_rootObjects.remove(m_qmlObject->engine());
|
||||
}
|
||||
|
||||
void AppletInterface::init()
|
||||
@ -109,6 +112,8 @@ void AppletInterface::init()
|
||||
//use our own custom network access manager that will access Plasma packages and to manage security (i.e. deny access to remote stuff when the proper extension isn't enabled
|
||||
QQmlEngine *engine = m_qmlObject->engine();
|
||||
|
||||
s_rootObjects[m_qmlObject->engine()] = this;
|
||||
|
||||
//Hook generic url resolution to the applet package as well
|
||||
//TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick?
|
||||
PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, m_appletScriptEngine->package());
|
||||
|
@ -237,7 +237,15 @@ public:
|
||||
* DEPRECATED: use plasmoid.configuration instead
|
||||
*/
|
||||
Q_INVOKABLE void writeConfig(const QString &entry, const QVariant &value);
|
||||
|
||||
|
||||
static AppletInterface *qmlAttachedProperties(QObject *object)
|
||||
{
|
||||
if (!object->parent() && s_rootObjects.contains(QtQml::qmlEngine(object))) {
|
||||
return s_rootObjects.value(QtQml::qmlEngine(object));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//PROPERTY ACCESSORS-------------------------------------------------------------------
|
||||
QString icon() const;
|
||||
@ -361,6 +369,10 @@ private:
|
||||
bool m_expanded : 1;
|
||||
bool m_hideOnDeactivate : 1;
|
||||
friend class ContainmentInterface;
|
||||
|
||||
static QHash<QObject *, AppletInterface *> s_rootObjects;
|
||||
};
|
||||
|
||||
QML_DECLARE_TYPEINFO(AppletInterface, QML_HAS_ATTACHED_PROPERTIES)
|
||||
|
||||
#endif
|
||||
|
@ -54,7 +54,9 @@ DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariant
|
||||
: Plasma::AppletScript(parent),
|
||||
m_interface(0)
|
||||
{
|
||||
qmlRegisterType<AppletInterface>();
|
||||
//qmlRegisterType<AppletInterface>();
|
||||
qmlRegisterUncreatableType<AppletInterface>("org.kde.shell", 2, 0, "AppletInterface",
|
||||
QLatin1String("Do not create objects of type AppletInterface"));
|
||||
qmlRegisterType<KDeclarative::ConfigPropertyMap>();
|
||||
Q_UNUSED(args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user