on xenial help sign in
Enable/disable running apps height animation in a less error prone way.
abc9e69Albert Astals
Dash/Apps/RunningApplicationsGrid.qml+17−2
@@ -22,6 +22,8 @@ ResponsiveFlowView {
22 clip: true
22 clip: true
23
23
24 signal updateScreenshots
24 signal updateScreenshots
25+ property alias enableHeightBehavior: heightBehaviour.enabled
26+ property bool enableHeightBehaviorOnNextCreation: firstModel.count + secondModel.count == 0
25
27
26 Connections {
28 Connections {
27 target: shell
29 target: shell
@@ -30,11 +32,24 @@ ResponsiveFlowView {
30 }
32 }
31
33
32 Behavior on height {
34 Behavior on height {
33− // FIXME Rethink how we pass down properties from the LVWPH to the interested parties
35+ id: heightBehaviour
34− enabled: culled === undefined || !culled;
36+ enabled: false
35 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
37 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
36 }
38 }
37
39
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+
38 property bool canEnableTerminationMode: true
53 property bool canEnableTerminationMode: true
39
54
40 onCanEnableTerminationModeChanged: {
55 onCanEnableTerminationModeChanged: {
Dash/DashApps.qml+1
@@ -52,5 +52,6 @@ GenericScopeView {
52
52
53 onScopeChanged: {
53 onScopeChanged: {
54 scopeView.scope.categories.overrideResults("recent", runningApplicationsModel);
54 scopeView.scope.categories.overrideResults("recent", runningApplicationsModel);
55+ enableHeightBehaviorOnNextCreation = (mainStageApplicationsModel.count + sideStageApplicationModel.count == 0)
55 }
56 }
56}
57}
Dash/GenericScopeView.qml+11
@@ -22,6 +22,7 @@ import "../Components/ListItems" as ListItems
22ScopeView {
22ScopeView {
23 id: scopeView
23 id: scopeView
24 readonly property alias previewShown: previewLoader.onScreen
24 readonly property alias previewShown: previewLoader.onScreen
25+ property bool enableHeightBehaviorOnNextCreation: false
25
26
26 onIsCurrentChanged: {
27 onIsCurrentChanged: {
27 pageHeader.resetSearch();
28 pageHeader.resetSearch();
@@ -88,6 +89,10 @@ ScopeView {
88 source: getRenderer(model.renderer, model.contentType)
89 source: getRenderer(model.renderer, model.contentType)
89
90
90 onLoaded: {
91 onLoaded: {
92+ if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
93+ item.enableHeightBehavior = scopeView.enableHeightBehaviorOnNextCreation;
94+ scopeView.enableHeightBehaviorOnNextCreation = false;
95+ }
91 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
96 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
92 // TODO: the running apps grid doesn't support standard scope results model yet
97 // TODO: the running apps grid doesn't support standard scope results model yet
93 item.firstModel = Qt.binding(function() { return results.firstModel })
98 item.firstModel = Qt.binding(function() { return results.firstModel })
@@ -104,6 +109,12 @@ ScopeView {
104 }
109 }
105 }
110 }
106
111
112+ Component.onDestruction: {
113+ if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
114+ scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
115+ }
116+ }
117+
107 Connections {
118 Connections {
108 target: rendererLoader.item
119 target: rendererLoader.item
109 onClicked: {
120 onClicked: {
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp−4
@@ -139,9 +139,6 @@ void ListViewWithPageHeader::ListItem::setCulled(bool culled)
139 QQuickItemPrivate::get(m_item)->setCulled(culled);
139 QQuickItemPrivate::get(m_item)->setCulled(culled);
140 if (m_sectionItem)
140 if (m_sectionItem)
141 QQuickItemPrivate::get(m_sectionItem)->setCulled(culled);
141 QQuickItemPrivate::get(m_sectionItem)->setCulled(culled);
142−
143− QQmlContext *itemContext = QQmlEngine::contextForObject(m_item)->parentContext();
144− itemContext->setContextProperty(QLatin1String("culled"), QVariant::fromValue<bool>(culled));
145}
142}
146
143
147ListViewWithPageHeader::ListViewWithPageHeader()
144ListViewWithPageHeader::ListViewWithPageHeader()
@@ -855,7 +852,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
855 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
852 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
856 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
853 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
857 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
854 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
858− context->setContextProperty(QLatin1String("culled"), QVariant::fromValue<bool>(false));
859 if (modelIndex == m_asyncRequestedIndex) {
855 if (modelIndex == m_asyncRequestedIndex) {
860 createItem(modelIndex, false);
856 createItem(modelIndex, false);
861 refill();
857 refill();