Make it possible to choose wallpapers without config

Wallpapers don't necessarily have config UIs, so we need to take a bit
of care that we don't try to load them. Just hide the pagestack instead.
This commit is contained in:
Sebastian Kügler 2013-03-28 03:52:15 +01:00
parent 40ac6a5f0c
commit 41aaa5a904
3 changed files with 25 additions and 18 deletions

View File

@ -31,23 +31,20 @@ MouseArea {
//BEGIN properties //BEGIN properties
width: childrenRect.width width: childrenRect.width
height: childrenRect.height height: childrenRect.height
property bool current: main.sourceFile == model.source property bool current: categoriesView.currentIndex == index
//END properties //END properties
//BEGIN connections //BEGIN connections
onClicked: { onClicked: {
print("model source: " + model.source + " " + main.sourceFile);
if (delegate.current) { if (delegate.current) {
return return
} else { } else {
categoriesView.currentIndex = index;
main.sourceFile = model.source main.sourceFile = model.source
root.restoreConfig() root.restoreConfig()
} }
} }
onCurrentChanged: {
if (current) {
categoriesView.currentItem = delegate
}
}
//END connections //END connections
//BEGIN UI components //BEGIN UI components

View File

@ -85,8 +85,8 @@ Rectangle {
main.sourceFile = globalConfigModel.get(0).source main.sourceFile = globalConfigModel.get(0).source
} }
root.restoreConfig() root.restoreConfig()
root.width = mainColumn.implicitWidth // root.width = mainColumn.implicitWidth
root.height = mainColumn.implicitHeight // root.height = mainColumn.implicitHeight
} }
//END connections //END connections
@ -183,13 +183,14 @@ Rectangle {
id: pageSizeSync id: pageSizeSync
interval: 100 interval: 100
onTriggered: { onTriggered: {
root.width = mainColumn.implicitWidth // root.width = mainColumn.implicitWidth
root.height = mainColumn.implicitHeight // root.height = mainColumn.implicitHeight
} }
} }
onImplicitWidthChanged: pageSizeSync.restart() onImplicitWidthChanged: pageSizeSync.restart()
onImplicitHeightChanged: pageSizeSync.restart() onImplicitHeightChanged: pageSizeSync.restart()
onSourceFileChanged: { onSourceFileChanged: {
print("Source file changed in flickable" + sourceFile);
replace(Qt.resolvedUrl(sourceFile)) replace(Qt.resolvedUrl(sourceFile))
/* /*
* This is not needed on a desktop shell that has ok/apply/cancel buttons, i'll leave it here only for future reference until we have a prototype for the active shell. * This is not needed on a desktop shell that has ok/apply/cancel buttons, i'll leave it here only for future reference until we have a prototype for the active shell.

View File

@ -18,11 +18,12 @@
import QtQuick 2.0 import QtQuick 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.configuration 2.0 import org.kde.plasma.configuration 2.0
Column { Column {
id: root id: root
PlasmaComponents.Label { PlasmaExtras.Title {
text: "Plugins" text: "Plugins"
} }
@ -54,7 +55,7 @@ Column {
} }
height: 100 height: 100
orientation: ListView.Horizontal orientation: ListView.Horizontal
model: configDialog.wallpaperConfigModel model: configDialog.wallpaperConfigModel
delegate: ConfigCategoryDelegate { delegate: ConfigCategoryDelegate {
id: delegate id: delegate
@ -67,14 +68,16 @@ Column {
width: 64 width: 64
onClicked: { onClicked: {
configDialog.currentWallpaper = model.pluginName configDialog.currentWallpaper = model.pluginName
if (delegate.current) { if (categoriesView.currentIndex == index) {
return return
} else { } else {
categoriesView.currentIndex = index;
main.sourceFile = model.source main.sourceFile = model.source
root.restoreConfig() root.restoreConfig()
} }
} }
onCurrentChanged: { onCurrentChanged: {
categoriesView.currentIndex = index
if (current) { if (current) {
categoriesView.currentIndex = index categoriesView.currentIndex = index
} }
@ -94,10 +97,10 @@ Column {
interval: 100 interval: 100
property variant pendingCurrent property variant pendingCurrent
onTriggered: { onTriggered: {
if (pendingCurrent) { if (pendingCurrent && pen) {
categoriesView.currentIndex = pendingCurrent.index
main.sourceFile = pendingCurrent.source main.sourceFile = pendingCurrent.source
root.restoreConfig() root.restoreConfig()
categoriesView.currentIndex = pendingCurrent.index
} }
} }
} }
@ -109,9 +112,15 @@ Column {
height: implicitHeight height: implicitHeight
property string sourceFile property string sourceFile
onSourceFileChanged: { onSourceFileChanged: {
replace(Qt.resolvedUrl(sourceFile)) if (sourceFile != "") {
root.width = mainColumn.implicitWidth main.opacity = 1;
root.height = mainColumn.implicitHeight replace(Qt.resolvedUrl(sourceFile))
root.width = mainColumn.implicitWidth
root.height = mainColumn.implicitHeight
} else {
main.opacity = 0
}
} }
Behavior on opacity { NumberAnimation {} }
} }
} }