on xenial help sign in
Do the enable/disable height animation in a different way
commit17bf1b9f73beea12bb171d174d738c2b876b3c0f authorAlbert Astals <albert.astals@canonical.com> dateWed 2 Oct 2013, 11:18 (13 years ago) parente2b8b01
4 files changed+30−6
Dash/Apps/RunningApplicationsGrid.qml+16−2 Dash/DashApps.qml+2 Dash/GenericScopeView.qml+12 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp−4
Dash/Apps/RunningApplicationsGrid.qml+16−2
@@ -22,6 +22,7 @@ ResponsiveFlowView {
2222 clip: true
2323
2424 signal updateScreenshots
25+ property alias enableHeightBehavior: heightBehaviour.enabled
2526
2627 Connections {
2728 target: shell
@@ -30,11 +31,24 @@ ResponsiveFlowView {
3031 }
3132
3233 Behavior on height {
33− // FIXME Rethink how we pass down properties from the LVWPH to the interested parties
34− enabled: culled === undefined || !culled;
34+ id: heightBehaviour
35+ enabled: false
3536 NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
3637 }
3738
39+ Connections {
40+ target: root.firstModel
41+ onCountChanged: {
42+ heightBehaviour.enabled = true;
43+ }
44+ }
45+ Connections {
46+ target: root.secondModel
47+ onCountChanged: {
48+ heightBehaviour.enabled = true;
49+ }
50+ }
51+
3852 property bool canEnableTerminationMode: true
3953
4054 onCanEnableTerminationModeChanged: {
Dash/DashApps.qml+2
@@ -28,6 +28,7 @@ GenericScopeView {
2828 // FIXME: a way to aggregate these models would be ideal
2929 property var mainStageApplicationsModel: shell.applicationManager.mainStageApplications
3030 property var sideStageApplicationModel: shell.applicationManager.sideStageApplications
31+ property bool enableHeightBehavior: false
3132
3233 ListModel {
3334 id: dummyVisibilityModifier
@@ -51,5 +52,6 @@ GenericScopeView {
5152
5253 onScopeChanged: {
5354 scopeView.scope.categories.overrideResults("recent", runningApplicationsModel);
55+ enableHeightBehavior = (mainStageApplicationsModel.count + sideStageApplicationModel.count == 0)
5456 }
5557}
Dash/GenericScopeView.qml+12
@@ -87,6 +87,8 @@ ScopeView {
8787 onLoaded: {
8888 if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
8989 // TODO: the running apps grid doesn't support standard scope results model yet
90+ item.enableHeightBehavior = enableHeightBehavior;
91+ enableHeightBehavior = false;
9092 item.firstModel = Qt.binding(function() { return results.firstModel })
9193 item.secondModel = Qt.binding(function() { return results.secondModel })
9294 } else {
@@ -101,6 +103,16 @@ ScopeView {
101103 }
102104 }
103105
106+ Component.onDestruction: {
107+ if (source.toString().indexOf("Apps/RunningApplicationsGrid.qml") != -1) {
108+ if (results) {
109+ enableHeightBehavior = (results.firstModel.count + results.secondModel.count == 0)
110+ } else {
111+ enableHeightBehavior = true
112+ }
113+ }
114+ }
115+
104116 Connections {
105117 target: rendererLoader.item
106118 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()
@@ -852,7 +849,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
852849 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
853850 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
854851 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
855− context->setContextProperty(QLatin1String("culled"), QVariant::fromValue<bool>(false));
856852 if (modelIndex == m_asyncRequestedIndex) {
857853 createItem(modelIndex, false);
858854 refill();