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()
48 onSearchQueryChanged: {
49 // Make sure we are at the search page if the search query changes behind our feet
51 headerContainer.showSearch = true;
55 function triggerSearch() {
56 if (searchEntryEnabled) {
57 headerContainer.showSearch = true;
58 searchTextField.forceActiveFocus();
62 function closePopup() {
63 if (headerContainer.popover != null) {
64 PopupUtils.close(headerContainer.popover);
68 function resetSearch(keepFocus) {
70 searchHistory.addQuery(searchTextField.text);
75 searchTextField.text = "";
80 searchTextField.focus = false;
81 if (!searchTextField.text) {
82 headerContainer.showSearch = false;
86 function openSearchHistory() {
87 if (openSearchAnimation.running) {
88 openSearchAnimation.openSearchHistory = true;
89 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
90 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
92 "contentWidth": searchTextField.width,
93 "edgeMargins": units.gu(1)
99 function refreshLogo() {
100 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
101 header.contents = imageComponent.createObject();
102 } else if (header.contents) {
103 header.contents.destroy();
104 header.contents = null;
109 target: root.scopeStyle
110 onHeaderLogoChanged: root.refreshLogo()
114 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
115 visible: headerContainer.showSearch
118 if (!searchTextField.text) {
119 headerContainer.showSearch = false;
121 searchTextField.focus = false;
122 mouse.accepted = false;
128 objectName: "headerContainer"
129 clip: openSearchAnimation.running
130 anchors { left: parent.left; top: parent.top; right: parent.right }
131 height: units.gu(6.5)
132 contentHeight: headersColumn.height
134 contentY: showSearch ? 0 : height
136 property bool showSearch: false
137 property var popover: null
140 objectName: "headerBackground"
141 style: scopeStyle.headerBackground
144 Behavior on contentY {
145 UbuntuNumberAnimation {
146 id: openSearchAnimation
147 property bool openSearchHistory: false
150 if (!running && openSearchAnimation.openSearchHistory) {
151 openSearchAnimation.openSearchHistory = false;
152 root.openSearchHistory();
160 anchors { left: parent.left; right: parent.right }
164 anchors { left: parent.left; right: parent.right }
165 height: headerContainer.height
166 contentHeight: height
167 opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
169 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
170 property var styledItem: searchHeader
171 property string title
172 property var config: PageHeadConfiguration {
177 headerContainer.showSearch = false;
181 property var contents: TextField {
183 objectName: "searchTextField"
184 hasClearButton: false
187 leftMargin: units.gu(1)
188 topMargin: units.gu(1)
189 bottomMargin: units.gu(1)
190 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
193 secondaryItem: AbstractButton {
194 height: searchTextField.height
196 enabled: searchTextField.text.length > 0
199 objectName: "clearIcon"
201 anchors.margins: units.gu(.75)
202 source: "image://theme/clear"
203 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
205 Behavior on opacity {
206 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
211 id: searchActivityIndicator
212 objectName: "searchIndicator"
214 anchors.margins: units.gu(.75)
215 running: root.searchInProgress
216 opacity: running ? 1 : 0
217 Behavior on opacity {
218 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
223 root.resetSearch(true);
224 root.openSearchHistory();
228 onActiveFocusChanged: {
230 root.openSearchHistory();
244 objectName: "innerPageHeader"
245 anchors { left: parent.left; right: parent.right }
246 height: headerContainer.height
247 contentHeight: height
248 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
250 textColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
251 property var styledItem: header
252 property string title: root.title
253 property var config: PageHeadConfiguration {
256 visible: root.showBackButton
266 visible: root.searchEntryEnabled
268 headerContainer.showSearch = true;
269 searchTextField.forceActiveFocus();
275 property var contents: null
276 Component.onCompleted: root.refreshLogo()
282 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
285 objectName: "titleImage"
287 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
288 fillMode: Image.PreserveAspectFit
289 horizontalAlignment: Image.AlignLeft
290 sourceSize.height: height
304 Component.onDestruction: {
305 headerContainer.popover = null;
317 objectName: "recentSearches"
321 showDivider: index < recentSearches.count - 1
324 searchHistory.addQuery(text);
325 searchTextField.text = text;
338 top: headerContainer.bottom
341 bottom: bottomContainer.top
344 source: "graphics/PageHeaderBaseDivider.sci"
353 bottom: parent.bottom
355 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