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 + units.gu(2) + bottomContainer.height
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
37 property alias bottomItem: bottomContainer.children
39 // TODO We should use foreground for the icons
40 // of the toolbar but unfortunately Action does not have
41 // the keyColor property as Icon does :-/
42 property var scopeStyle: null
46 onScopeStyleChanged: refreshLogo()
47 onSearchQueryChanged: {
48 // Make sure we are at the search page if the search query changes behind our feet
50 headerContainer.showSearch = true;
54 function triggerSearch() {
55 if (searchEntryEnabled) {
56 headerContainer.showSearch = true;
57 searchTextField.forceActiveFocus();
61 function closePopup() {
62 if (headerContainer.popover != null) {
63 PopupUtils.close(headerContainer.popover);
67 function resetSearch(keepFocus) {
69 searchHistory.addQuery(searchTextField.text);
74 searchTextField.text = "";
79 searchTextField.focus = false;
80 if (!searchTextField.text) {
81 headerContainer.showSearch = false;
85 function openSearchHistory() {
86 if (openSearchAnimation.running) {
87 openSearchAnimation.openSearchHistory = true;
88 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
89 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
91 "contentWidth": searchTextField.width,
92 "edgeMargins": units.gu(1)
98 function refreshLogo() {
99 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
100 header.contents = imageComponent.createObject();
101 } else if (header.contents) {
102 header.contents.destroy();
103 header.contents = null;
108 target: root.scopeStyle
109 onHeaderLogoChanged: root.refreshLogo()
113 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
114 visible: headerContainer.showSearch
117 if (!searchTextField.text) {
118 headerContainer.showSearch = false;
120 searchTextField.focus = false;
121 mouse.accepted = false;
127 objectName: "headerContainer"
128 clip: openSearchAnimation.running
129 anchors { left: parent.left; top: parent.top; right: parent.right }
130 height: units.gu(6.5)
131 contentHeight: headersColumn.height
133 contentY: showSearch ? 0 : height
135 property bool showSearch: false
136 property var popover: null
139 objectName: "headerBackground"
140 style: scopeStyle.headerBackground
143 Behavior on contentY {
144 UbuntuNumberAnimation {
145 id: openSearchAnimation
146 property bool openSearchHistory: false
149 if (!running && openSearchAnimation.openSearchHistory) {
150 openSearchAnimation.openSearchHistory = false;
151 root.openSearchHistory();
159 anchors { left: parent.left; right: parent.right }
163 anchors { left: parent.left; right: parent.right }
164 height: headerContainer.height
165 contentHeight: height
166 opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
168 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
169 property var styledItem: searchHeader
170 property string title
171 property var config: PageHeadConfiguration {
176 headerContainer.showSearch = false;
180 property var contents: TextField {
182 objectName: "searchTextField"
183 inputMethodHints: Qt.ImhNoPredictiveText
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
265 visible: root.searchEntryEnabled
267 headerContainer.showSearch = true;
268 searchTextField.forceActiveFocus();
274 property var contents: null
275 Component.onCompleted: root.refreshLogo()
281 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
284 objectName: "titleImage"
286 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
287 fillMode: Image.PreserveAspectFit
288 horizontalAlignment: Image.AlignLeft
289 sourceSize.height: height
303 Component.onDestruction: {
304 headerContainer.popover = null;
316 objectName: "recentSearches"
320 showDivider: index < recentSearches.count - 1
323 searchHistory.addQuery(text);
324 searchTextField.text = text;
337 top: headerContainer.bottom
340 bottom: bottomContainer.top
343 source: "graphics/PageHeaderBaseDivider.sci"
352 bottom: parent.bottom
354 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