experiment with ConditionalLoader

This commit is contained in:
Marco Martin 2013-09-03 13:11:12 +02:00
parent f6c661f297
commit 9289405991
2 changed files with 43 additions and 30 deletions

View File

@ -635,6 +635,7 @@ void AppletInterface::compactRepresentationCheck()
if (m_qmlObject->rootObject()->property("minimumWidth").canConvert<qreal>()) {
minHint.setWidth(m_qmlObject->rootObject()->property("minimumWidth").toReal());
}
if (m_qmlObject->rootObject()->property("minimumHeight").canConvert<qreal>()) {
minHint.setHeight(m_qmlObject->rootObject()->property("minimumHeight").toReal());
}

View File

@ -20,6 +20,7 @@ import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
Rectangle {
id: root
@ -40,39 +41,50 @@ Rectangle {
}
}
Column {
id: column
anchors.centerIn: parent
Text {
text: i18n("I'm an applet")
}
PlasmaComponents.Button {
text: i18n("Background")
checked: plasmoid.backgroundHints == 1
onClicked: {
print("Background hints: " + plasmoid.backgroundHints)
if (plasmoid.backgroundHints == 0) {
plasmoid.backgroundHints = 1//TODO: make work "StandardBackground"
root.color = "transparent"
} else {
plasmoid.backgroundHints = 0//TODO: make work "NoBackground"
root.color = "darkgreen"
PlasmaExtras.ConditionalLoader {
anchors.fill: parent
when: plasmoid.expanded
source: Component {
Item {
Column {
id: column
anchors.centerIn: parent
Text {
text: i18n("I'm an applet")
}
PlasmaComponents.Button {
text: i18n("Background")
checked: plasmoid.backgroundHints == 1
onClicked: {
print("Background hints: " + plasmoid.backgroundHints)
if (plasmoid.backgroundHints == 0) {
plasmoid.backgroundHints = 1//TODO: make work "StandardBackground"
root.color = "transparent"
} else {
plasmoid.backgroundHints = 0//TODO: make work "NoBackground"
root.color = "darkgreen"
}
}
}
PlasmaComponents.Button {
text: i18n("Busy")
checked: plasmoid.busy
onClicked: {
plasmoid.busy = !plasmoid.busy
}
}
TextInput {
width: 100
height: 22
text: plasmoid.configuration.Test
onTextChanged: plasmoid.configuration.Test = text
}
Component.onCompleted: {
print("Conditional component of test applet loaded")
}
}
}
}
PlasmaComponents.Button {
text: i18n("Busy")
checked: plasmoid.busy
onClicked: {
plasmoid.busy = !plasmoid.busy
}
}
TextInput {
width: 100
height: 22
text: plasmoid.configuration.Test
onTextChanged: plasmoid.configuration.Test = text
}
}
Component.onCompleted: {
print("Test Applet loaded")