make the config.qml object a "model"
This commit is contained in:
parent
56d73373ac
commit
de8644af69
@ -45,17 +45,14 @@ ConfigView::ConfigView(AppletInterface *interface, QWindow *parent)
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
|
||||
|
||||
//rootObject()->metaObject()->invokeMethod(rootObject(), "addConfigPage", Q_ARG(QVariant, QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "ConfigGeneral.qml"))));
|
||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "config.qml")), this);
|
||||
|
||||
QVariantMap page;
|
||||
page["title"] = i18n("General");
|
||||
if (m_appletInterface->applet()->icon().isEmpty()) {
|
||||
page["icon"] = "configure";
|
||||
} else {
|
||||
page["icon"] = m_appletInterface->applet()->icon();
|
||||
QObject *configObject = component->create(engine()->rootContext());
|
||||
if (configObject) {
|
||||
m_configPages = configObject->property("modules").value<QQmlListProperty<QObject> >();
|
||||
}
|
||||
page["component"] = QVariant::fromValue(new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "ConfigGeneral.qml")), this));
|
||||
m_configPages << page;
|
||||
|
||||
delete component;
|
||||
|
||||
engine()->rootContext()->setContextProperty("plasmoid", interface);
|
||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||
@ -67,7 +64,7 @@ ConfigView::~ConfigView()
|
||||
}
|
||||
|
||||
|
||||
QVariantList ConfigView::configPages() const
|
||||
QQmlListProperty<QObject> ConfigView::configPages() const
|
||||
{
|
||||
return m_configPages;
|
||||
}
|
||||
|
@ -23,26 +23,27 @@
|
||||
|
||||
#include <QQuickView>
|
||||
#include <QJSValue>
|
||||
#include <QQmlListProperty>
|
||||
|
||||
class AppletInterface;
|
||||
|
||||
class ConfigView : public QQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariantList configPages READ configPages CONSTANT)
|
||||
Q_PROPERTY(QQmlListProperty<QObject> configPages READ configPages CONSTANT)
|
||||
|
||||
public:
|
||||
ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0);
|
||||
virtual ~ConfigView();
|
||||
|
||||
QVariantList configPages() const;
|
||||
QQmlListProperty<QObject> configPages() const;
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent *ev);
|
||||
|
||||
private:
|
||||
AppletInterface *m_appletInterface;
|
||||
QVariantList m_configPages;
|
||||
QQmlListProperty<QObject> m_configPages;
|
||||
};
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
@ -21,8 +21,16 @@ import QtQuick 2.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
|
||||
Item {
|
||||
QtObject {
|
||||
|
||||
property list<QtObject> modules: [
|
||||
QtObject {
|
||||
property string name: "General"
|
||||
property string icon: "plasma"
|
||||
property Component component: Component {
|
||||
Item {
|
||||
id: iconsPage
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
property alias cfg_Test: testConfigField.text
|
||||
@ -39,4 +47,8 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user