ConfigView::configPages() is a list of dialogs

returns a list of data to create the pages: a title, an icon and a component
This commit is contained in:
Marco Martin 2013-02-22 20:58:54 +01:00
parent 949d114eec
commit 75ddf58938
3 changed files with 62 additions and 19 deletions

View File

@ -43,16 +43,35 @@ 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"))));
QVariantMap page;
page["title"] = i18n("General");
if (m_appletInterface->applet()->icon().isEmpty()) {
page["icon"] = "configure";
} else {
page["icon"] = m_appletInterface->applet()->icon();
}
page["component"] = QVariant::fromValue(new QQmlComponent(engine(), QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "ConfigGeneral.qml")), this));
m_configPages << page;
engine()->rootContext()->setContextProperty("plasmoid", interface);
engine()->rootContext()->setContextProperty("configDialog", this);
setSource(QUrl::fromLocalFile(m_appletInterface->applet()->containment()->corona()->package().filePath("ui", "Configuration.qml")));
if (rootObject()) {
engine()->rootContext()->setContextProperty("plasmoid", interface);
rootObject()->metaObject()->invokeMethod(rootObject(), "addConfigPage", Q_ARG(QVariant, QUrl::fromLocalFile(m_appletInterface->applet()->package().filePath("ui", "ConfigGeneral.qml"))));
}
}
ConfigView::~ConfigView()
{
}
QVariantList ConfigView::configPages() const
{
return m_configPages;
}
#include "moc_configview.cpp"

View File

@ -22,19 +22,24 @@
#include <QQuickView>
#include <QJSValue>
class AppletInterface;
class ConfigView : public QQuickView
{
Q_OBJECT
Q_PROPERTY(QVariantList configPages READ configPages CONSTANT)
public:
ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0);
virtual ~ConfigView();
QVariantList configPages() const;
private:
AppletInterface *m_appletInterface;
QVariantList m_configPages;
};
#endif // multiple inclusion guard

View File

@ -33,6 +33,7 @@ Rectangle {
main.source = url
}
Column {
anchors.fill: parent
Row {
@ -54,21 +55,39 @@ Rectangle {
Column {
id: categoriesColumn
width: parent.width
Column {
anchors {
left: parent.left
right: parent.right
}
PlasmaCore.IconItem {
anchors.horizontalCenter: parent.horizontalCenter
width: theme.IconSizeHuge
height: width
source: "preferences-desktop-keyboard"
}
PlasmaComponents.Label {
text: "Keyboard shortcut"
wrapMode: Text.Wrap
horizontalAlignment: Text.alignHCenter
Repeater {
model: configDialog.configPages.length
delegate: MouseArea {
anchors {
left: parent.left
right: parent.right
}
width: childrenRect.width
height: childrenRect.height
Column {
anchors {
left: parent.left
right: parent.right
}
PlasmaCore.IconItem {
anchors.horizontalCenter: parent.horizontalCenter
width: theme.IconSizeHuge
height: width
source: configDialog.configPages[modelData].icon
}
PlasmaComponents.Label {
anchors {
left: parent.left
right: parent.right
}
text: configDialog.configPages[modelData].title
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
}
}
onClicked: {
main.sourceComponent = configDialog.configPages[modelData].component
}
}
}
}