on xenial help sign in
Enable/disable running apps height animation in a less error prone way.

Approved by PS Jenkins bot, Michał Sawicz.

commitabc9e694111afcf0211f80850b9e741cf088ca7c authorAlbert Astals <albert.astals@canonical.com> dateThu 3 Oct 2013, 11:48 (13 years ago) parent5623a70addd978
4 files changed+29−6
Dash/Apps/RunningApplicationsGrid.qml+17−2 Dash/DashApps.qml+1 Dash/GenericScopeView.qml+11 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp−4
Dash/Apps/RunningApplicationsGrid.qml+17−2
@@ -22,6 +22,8 @@ ResponsiveFlowView {
2222 clip: true
2323
2424 signal updateScreenshots
25+ property alias enableHeightBehavior: heightBehaviour.enabled
26+ property bool enableHeightBehaviorOnNextCreation: firstModel.count + secondModel.count == 0
2527
2628 Connections {
2729 target: shell
@@ -30,11 +32,24 @@ ResponsiveFlowView {
3032 }
3133
3234 Behavior on height {
33− // FIXME Rethink how we pass down properties from the LVWPH to the interested parties
34− enabled: culled === undefined || !culled;
35+ id: heightBehaviour
36+ enabled: false
3537 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
3638 }
3739
40+ Connections {
41+ target: root.firstModel
42+ onCountChanged: {
43+ heightBehaviour.enabled = true;
44+ }
45+ }
46+ Connections {
47+ target: root.secondModel
48+ onCountChanged: {
49+ heightBehaviour.enabled = true;
50+ }
51+ }
52+
3853 property bool canEnableTerminationMode: true
3954
4055 onCanEnableTerminationModeChanged: {
Dash/DashApps.qml+1
@@ -52,5 +52,6 @@ GenericScopeView {
5252
5353 onScopeChanged: {
5454 scopeView.scope.categories.overrideResults("recent", runningApplicationsModel);
55+ enableHeightBehaviorOnNextCreation = (mainStageApplicationsModel.count + sideStageApplicationModel.count == 0)
5556 }
5657}
Dash/GenericScopeView.qml+11
@@ -22,6 +22,7 @@ import "../Components/ListItems" as ListItems
2222ScopeView {
2323 id: scopeView
2424 readonly property alias previewShown: previewLoader.onScreen
25+ property bool enableHeightBehaviorOnNextCreation: false
2526
2627 onIsCurrentChanged: {
2728 pageHeader.resetSearch();
@@ -88,6 +89,10 @@ ScopeView {
8889 source: getRenderer(model.renderer, model.contentType)
8990
9091 onLoaded: {
92+ if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
93+ item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
94+ scopeView.enableHeightBehaviorOnNextCreation = false;
95+ }
9196 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
9297 // TODO: the running apps grid doesn't support standard scope results model yet
9398 item.firstModel = Qt.binding(function() { return results.firstModel })
@@ -104,6 +109,12 @@ ScopeView {
104109 }
105110 }
106111
112+ Component.onDestruction: {
113+ if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
114+ scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
115+ }
116+ }
117+
107118 Connections {
108119 target: rendererLoader.item
109120 onClicked: {
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp−4
@@ -139,9 +139,6 @@ void ListViewWithPageHeader::ListItem::setCulled(bool culled)
139139 QQuickItemPrivate::get(m_item)->setCulled(culled);
140140 if (m_sectionItem)
141141 QQuickItemPrivate::get(m_sectionItem)->setCulled(culled);
142−
143− QQmlContext *itemContext = QQmlEngine::contextForObject(m_item)->parentContext();
144− itemContext->setContextProperty(QLatin1String("culled"), QVariant::fromValue<bool>(culled));
145142}
146143
147144ListViewWithPageHeader::ListViewWithPageHeader()
@@ -855,7 +852,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
855852 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
856853 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
857854 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
858− context->setContextProperty(QLatin1String("culled"), QVariant::fromValue<bool>(false));
859855 if (modelIndex == m_asyncRequestedIndex) {
860856 createItem(modelIndex, false);
861857 refill();