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
31 property bool searchEntryEnabled: false
32 property ListModel searchHistory: SearchHistoryModel
33 property alias searchQuery: searchTextField.text
34 property bool searchInProgress: false
36 property alias bottomItem: bottomContainer.children
38 // TODO We should use foreground for the icons
39 // of the toolbar but unfortunately Action does not have
40 // the keyColor property as Icon does :-/
41 property var styleTool: QtObject {
42 readonly property color foreground: "grey"
43 readonly property url headerLogo: ""
48 onStyleToolChanged: refreshLogo()
50 function triggerSearch() {
51 if (searchEntryEnabled) {
52 headerContainer.showSearch = true;
53 searchTextField.forceActiveFocus();
57 function resetSearch(keepFocus) {
59 searchHistory.addQuery(searchTextField.text);
64 searchTextField.text = "";
65 if (headerContainer.popover != null) {
66 PopupUtils.close(headerContainer.popover);
71 searchTextField.focus = false;
72 if (!searchTextField.text) {
73 headerContainer.showSearch = false;
77 function openSearchHistory() {
78 if (openSearchAnimation.running) {
79 openSearchAnimation.openSearchHistory = true;
80 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
81 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
83 "contentWidth": searchTextField.width,
84 "edgeMargins": units.gu(1)
90 function refreshLogo() {
91 if (styleTool.headerLogo != "") {
92 header.contents = imageComponent.createObject();
93 } else if (header.contents) {
94 header.contents.destroy();
95 header.contents = null;
101 onHeaderLogoChanged: root.refreshLogo()
105 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
106 visible: headerContainer.showSearch
108 if (headerContainer.popover) {
109 PopupUtils.close(headerContainer.popover);
111 if (!searchTextField.text) {
112 headerContainer.showSearch = false;
114 searchTextField.focus = false;
115 mouse.accepted = false;
121 objectName: "headerContainer"
123 anchors { left: parent.left; top: parent.top; right: parent.right }
124 height: units.gu(6.5)
125 contentHeight: headersColumn.height
127 contentY: showSearch ? 0 : height
129 property bool showSearch: false
130 property var popover: null
132 Behavior on contentY {
133 UbuntuNumberAnimation {
134 id: openSearchAnimation
135 property bool openSearchHistory: false
138 if (!running && openSearchAnimation.openSearchHistory) {
139 openSearchAnimation.openSearchHistory = false;
140 root.openSearchHistory();
148 anchors { left: parent.left; right: parent.right }
152 anchors { left: parent.left; right: parent.right }
153 height: headerContainer.height
154 contentHeight: height
156 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
157 property var styledItem: searchHeader
158 property string title
159 property var config: PageHeadConfiguration {
164 headerContainer.showSearch = false;
168 property var contents: TextField {
170 hasClearButton: false
173 leftMargin: units.gu(1)
174 topMargin: units.gu(1)
175 bottomMargin: units.gu(1)
176 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
179 secondaryItem: AbstractButton {
180 height: searchTextField.height
182 enabled: searchTextField.text.length > 0
185 objectName: "clearIcon"
187 anchors.margins: units.gu(.75)
188 source: "image://theme/clear"
189 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
191 Behavior on opacity {
192 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
197 id: searchActivityIndicator
198 objectName: "searchIndicator"
200 anchors.margins: units.gu(.75)
201 running: root.searchInProgress
202 opacity: running ? 1 : 0
203 Behavior on opacity {
204 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
209 root.resetSearch(true);
210 root.openSearchHistory();
214 onActiveFocusChanged: {
216 root.openSearchHistory();
224 objectName: "pageHeader"
225 anchors { left: parent.left; right: parent.right }
226 height: headerContainer.height
227 contentHeight: height
229 textColor: root.styleTool.foreground
230 property var styledItem: header
231 property string title: root.title
232 property var config: PageHeadConfiguration {
235 visible: root.showBackButton
244 visible: root.searchEntryEnabled
246 headerContainer.showSearch = true;
247 searchTextField.forceActiveFocus();
253 property var contents: null
254 Component.onCompleted: root.refreshLogo()
260 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
263 objectName: "titleImage"
265 source: root.styleTool.headerLogo
266 fillMode: Image.PreserveAspectFit
267 horizontalAlignment: Image.AlignLeft
268 sourceSize.height: height
282 Component.onDestruction: {
283 headerContainer.popover = null;
298 showDivider: index < recentSearches.count - 1
301 searchHistory.addQuery(text);
302 searchTextField.text = text;
303 PopupUtils.close(popover);
314 top: headerContainer.bottom
317 bottom: bottomContainer.top
320 source: "graphics/PageHeaderBaseDivider.sci"
329 bottom: parent.bottom
331 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