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 implicitHeight: headerContainer.height + units.gu(2) + bottomContainer.height
28 property bool showBackButton: false
30 property string imageSource
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
41 function triggerSearch() {
42 if (searchEntryEnabled) searchTextField.forceActiveFocus();
45 function resetSearch(keepFocus) {
47 searchHistory.addQuery(searchTextField.text);
52 searchTextField.text = "";
53 if (headerContainer.popover != null) {
54 PopupUtils.close(headerContainer.popover);
59 searchTextField.focus = false;
62 function openSearchHistory() {
63 if (openSearchAnimation.running) {
64 openSearchAnimation.openSearchHistory = true;
65 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
66 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
68 "contentWidth": searchTextField.width,
69 "edgeMargins": units.gu(1)
75 onImageSourceChanged: {
77 header.contents = imageComponent.createObject();
79 header.contents.destroy();
80 header.contents = null;
86 visible: headerContainer.popover !== null
88 PopupUtils.close(headerContainer.popover);
94 objectName: "headerContainer"
96 anchors { left: parent.left; top: parent.top; right: parent.right }
98 contentHeight: headersColumn.height
100 contentY: showSearch ? 0 : height
102 property bool showSearch: false
103 property var popover: null
105 Behavior on contentY {
106 UbuntuNumberAnimation {
107 id: openSearchAnimation
108 property bool openSearchHistory: false
111 if (!running && openSearchAnimation.openSearchHistory) {
112 openSearchAnimation.openSearchHistory = false;
113 root.openSearchHistory();
121 anchors { left: parent.left; right: parent.right }
125 anchors { left: parent.left; right: parent.right }
126 height: headerContainer.height
127 contentHeight: height
129 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
130 property var styledItem: searchHeader
131 property string title
132 property var config: PageHeadConfiguration {
137 headerContainer.showSearch = false;
141 property var contents: TextField {
143 hasClearButton: false
146 leftMargin: units.gu(1)
147 topMargin: units.gu(1)
148 bottomMargin: units.gu(1)
149 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
152 secondaryItem: AbstractButton {
153 height: searchTextField.height
157 objectName: "clearIcon"
159 anchors.margins: units.gu(.75)
160 source: "image://theme/clear"
161 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
163 Behavior on opacity {
164 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
169 id: searchActivityIndicator
170 objectName: "searchIndicator"
172 anchors.margins: units.gu(.75)
173 running: root.searchInProgress
174 opacity: running ? 1 : 0
175 Behavior on opacity {
176 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
181 root.resetSearch(true);
182 root.openSearchHistory();
186 onActiveFocusChanged: {
188 root.openSearchHistory();
196 anchors { left: parent.left; right: parent.right }
197 height: headerContainer.height
198 contentHeight: height
200 // FIXME: Use the theme's color once we're split from the shell
202 property var styledItem: header
203 property string title: root.title
204 property var config: PageHeadConfiguration {
207 visible: root.showBackButton
216 visible: root.searchEntryEnabled
218 headerContainer.showSearch = true;
219 searchTextField.forceActiveFocus();
225 property var contents: null
226 Component.onCompleted: {
227 if (root.imageSource) {
228 header.contents = imageComponent.createObject();
235 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
238 objectName: "titleImage"
240 source: root.imageSource
241 fillMode: Image.PreserveAspectFit
242 horizontalAlignment: Image.AlignLeft
243 sourceSize.height: height
257 Component.onDestruction: {
258 headerContainer.popover = null;
268 Standard { enabled: false; text: i18n.tr("Recent searches") }
275 showDivider: index < recentSearches.count - 1
278 searchHistory.addQuery(text);
279 searchTextField.text = text;
280 PopupUtils.close(popover);
291 top: headerContainer.bottom
294 bottom: bottomContainer.top
297 source: "graphics/PageHeaderBaseDivider.sci"
306 bottom: parent.bottom
308 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