2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Ubuntu.Components 1.1
19import Ubuntu.Components.Themes.Ambiance 1.1
20import Ubuntu.Components.Popups 1.0
21import Ubuntu.Components.ListItems 1.0
22import "SearchHistoryModel"
26 objectName: "pageHeader"
27 implicitHeight: headerContainer.height + bottomContainer.height + (showSignatureLine ? units.gu(2) : 0)
29 property bool showBackButton: false
32 property bool searchEntryEnabled: false
33 property ListModel searchHistory: SearchHistoryModel
34 property alias searchQuery: searchTextField.text
35 property bool searchInProgress: false
36 property alias showSignatureLine: bottomBorder.visible
38 property alias bottomItem: bottomContainer.children
40 // TODO We should use foreground for the icons
41 // of the toolbar but unfortunately Action does not have
42 // the keyColor property as Icon does :-/
43 property var scopeStyle: null
47 onScopeStyleChanged: refreshLogo()
49 function triggerSearch() {
50 if (searchEntryEnabled) {
51 headerContainer.showSearch = true;
52 searchTextField.forceActiveFocus();
56 function resetSearch(keepFocus) {
58 searchHistory.addQuery(searchTextField.text);
63 searchTextField.text = "";
68 searchTextField.focus = false;
69 if (!searchTextField.text) {
70 headerContainer.showSearch = false;
74 function openSearchHistory() {
75 if (openSearchAnimation.running) {
76 openSearchAnimation.openSearchHistory = true;
77 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
78 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
80 "contentWidth": searchTextField.width,
81 "edgeMargins": units.gu(1)
87 function closeSearchHistory() {
88 if (headerContainer.popover != null) {
89 PopupUtils.close(headerContainer.popover);
93 function refreshLogo() {
94 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
95 header.contents = imageComponent.createObject();
96 } else if (header.contents) {
97 header.contents.destroy();
98 header.contents = null;
103 target: root.scopeStyle
104 onHeaderLogoChanged: root.refreshLogo()
108 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
109 visible: headerContainer.showSearch
111 closeSearchHistory();
112 if (!searchTextField.text) {
113 headerContainer.showSearch = false;
115 searchTextField.focus = false;
116 mouse.accepted = false;
122 objectName: "headerContainer"
124 anchors { left: parent.left; top: parent.top; right: parent.right }
125 height: units.gu(6.5)
126 contentHeight: headersColumn.height
128 contentY: showSearch ? 0 : height
130 property bool showSearch: false
131 property var popover: null
133 Behavior on contentY {
134 UbuntuNumberAnimation {
135 id: openSearchAnimation
136 property bool openSearchHistory: false
139 if (!running && openSearchAnimation.openSearchHistory) {
140 openSearchAnimation.openSearchHistory = false;
141 root.openSearchHistory();
149 anchors { left: parent.left; right: parent.right }
153 anchors { left: parent.left; right: parent.right }
154 height: headerContainer.height
155 contentHeight: height
157 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
158 property var styledItem: searchHeader
159 property string title
160 property var config: PageHeadConfiguration {
165 headerContainer.showSearch = false;
169 property var contents: TextField {
171 objectName: "searchTextField"
172 hasClearButton: false
175 leftMargin: units.gu(1)
176 topMargin: units.gu(1)
177 bottomMargin: units.gu(1)
178 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
181 secondaryItem: AbstractButton {
182 height: searchTextField.height
184 enabled: searchTextField.text.length > 0
187 objectName: "clearIcon"
189 anchors.margins: units.gu(.75)
190 source: "image://theme/clear"
191 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
193 Behavior on opacity {
194 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
199 id: searchActivityIndicator
200 objectName: "searchIndicator"
202 anchors.margins: units.gu(.75)
203 running: root.searchInProgress
204 opacity: running ? 1 : 0
205 Behavior on opacity {
206 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
211 root.resetSearch(true);
212 root.openSearchHistory();
216 onActiveFocusChanged: {
218 root.openSearchHistory();
226 objectName: "innerPageHeader"
227 anchors { left: parent.left; right: parent.right }
228 height: headerContainer.height
229 contentHeight: height
231 textColor: root.scopeStyle ? root.scopeStyle.foreground : "grey"
232 property var styledItem: header
233 property string title: root.title
234 property var config: PageHeadConfiguration {
237 visible: root.showBackButton
247 visible: root.searchEntryEnabled
249 headerContainer.showSearch = true;
250 searchTextField.forceActiveFocus();
256 property var contents: null
257 Component.onCompleted: root.refreshLogo()
263 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
266 objectName: "titleImage"
268 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
269 fillMode: Image.PreserveAspectFit
270 horizontalAlignment: Image.AlignLeft
271 sourceSize.height: height
285 Component.onDestruction: {
286 headerContainer.popover = null;
301 showDivider: index < recentSearches.count - 1
304 searchHistory.addQuery(text);
305 searchTextField.text = text;
306 PopupUtils.close(popover);
317 top: headerContainer.bottom
320 bottom: bottomContainer.top
323 source: "graphics/PageHeaderBaseDivider.sci"
332 bottom: parent.bottom
334 height: childrenRect.height
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list