on xenial help sign in
Add support for scope favoriting
commit1811a8e50ae8bdb5edf74994396fe4cabc1b8022 authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 18 Aug 2014, 21:08 (12 years ago) parenta58769f
3 files changed+35−4
qml/Dash/DashContent.qml+17 qml/Dash/GenericScopeView.qml+3−1 qml/Dash/PageHeader.qml+15−3
qml/Dash/DashContent.qml+17
@@ -112,6 +112,23 @@ Item {
112112 onMovementStarted: currentItem.item.showHeader();
113113 clip: parent.x != 0
114114
115+ // TODO QTBUG-40846 and QTBUG-40848
116+ // The remove transition doesn't happen when removing the last item
117+ // And can't work around it because index is reset to -1 regardless of
118+ // ListView.delayRemove
119+
120+ remove: Transition {
121+ SequentialAnimation {
122+ PropertyAction { property: "layer.enabled"; value: true }
123+ PropertyAction { property: "ListView.delayRemove"; value: true }
124+ PropertyAnimation { properties: "opacity"; to: 0; duration: UbuntuAnimation.SnapDuration }
125+ PropertyAction { property: "ListView.delayRemove"; value: false }
126+ }
127+ }
128+ removeDisplaced: Transition {
129+ PropertyAnimation { property: "x"; duration: UbuntuAnimation.SnapDecision }
130+ }
131+
115132 // If the number of items is less than the current index, then need to reset to another item.
116133 onCountChanged: {
117134 if (count > 0) {
qml/Dash/GenericScopeView.qml+3−1
@@ -426,6 +426,8 @@ FocusScope {
426426 showBackButton: scopeView.hasBackAction
427427 searchEntryEnabled: true
428428 settingsEnabled: scopeView.scope ? scopeView.scope.settings && scopeView.scope.settings.count > 0 : false
429+ favoriteEnabled: scopeView.scope && scopeView.scope.id !== "clickscope"
430+ scope: scopeView.scope
429431 scopeStyle: scopeView.scopeStyle
430432 paginationCount: scopeView.paginationCount
431433 paginationIndex: scopeView.paginationIndex
@@ -440,8 +442,8 @@ FocusScope {
440442 }
441443
442444 onBackClicked: scopeView.backClicked()
443−
444445 onSettingsClicked: subPageLoader.openSubPage("settings")
446+ onFavoriteClicked: scopeView.scope.favorite = !scopeView.scope.favorite
445447 }
446448 }
447449 }
qml/Dash/PageHeader.qml+15−3
@@ -32,6 +32,7 @@ Item {
3232
3333 property bool searchEntryEnabled: false
3434 property bool settingsEnabled: false
35+ property bool favoriteEnabled: false
3536 property ListModel searchHistory: SearchHistoryModel
3637 property alias searchQuery: searchTextField.text
3738 property alias searchHint: searchTextField.placeholderText
@@ -41,13 +42,12 @@ Item {
4142 property int paginationCount: 0
4243 property int paginationIndex: -1
4344
44− // TODO We should use foreground for the icons
45− // of the toolbar but unfortunately Action does not have
46− // the keyColor property as Icon does :-/
45+ property var scope: null
4746 property var scopeStyle: null
4847
4948 signal backClicked()
5049 signal settingsClicked()
50+ signal favoriteClicked()
5151
5252 onScopeStyleChanged: refreshLogo()
5353 onSearchQueryChanged: {
@@ -257,6 +257,7 @@ Item {
257257 actions: [
258258 Action {
259259 objectName: "search"
260+ text: i18n.tr("Search")
260261 iconName: "search"
261262 visible: root.searchEntryEnabled
262263 onTriggered: {
@@ -266,12 +267,23 @@ Item {
266267 },
267268 Action {
268269 objectName: "settings"
270+ text: i18n.tr("Settings")
269271 iconName: "settings"
270272 visible: root.settingsEnabled
271273 onTriggered: {
272274 root.settingsClicked()
273275 }
276+ },
277+ Action {
278+ objectName: "favorite"
279+ text: root.scope && root.scope.favorite ? i18n.tr("Remove from Dash") : i18n.tr("Add to Dash")
280+ iconName: root.scope && root.scope.favorite ? "starred" : "non-starred"
281+ visible: root.favoriteEnabled
282+ onTriggered: {
283+ root.favoriteClicked()
284+ }
274285 }
286+
275287 ]
276288 }
277289