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 scopeStyle: null
45 onScopeStyleChanged: refreshLogo()
47 function triggerSearch() {
48 if (searchEntryEnabled) {
49 headerContainer.showSearch = true;
50 searchTextField.forceActiveFocus();
54 function resetSearch(keepFocus) {
56 searchHistory.addQuery(searchTextField.text);
61 searchTextField.text = "";
62 if (headerContainer.popover != null) {
63 PopupUtils.close(headerContainer.popover);
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 refreshLogo() {
88 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
89 header.contents = imageComponent.createObject();
90 } else if (header.contents) {
91 header.contents.destroy();
92 header.contents = null;
97 target: root.scopeStyle
98 onHeaderLogoChanged: root.refreshLogo()
102 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
103 visible: headerContainer.showSearch
105 if (headerContainer.popover) {
106 PopupUtils.close(headerContainer.popover);
108 if (!searchTextField.text) {
109 headerContainer.showSearch = false;
111 searchTextField.focus = false;
112 mouse.accepted = false;
118 objectName: "headerContainer"
120 anchors { left: parent.left; top: parent.top; right: parent.right }
121 height: units.gu(6.5)
122 contentHeight: headersColumn.height
124 contentY: showSearch ? 0 : height
126 property bool showSearch: false
127 property var popover: null
129 Behavior on contentY {
130 UbuntuNumberAnimation {
131 id: openSearchAnimation
132 property bool openSearchHistory: false
135 if (!running && openSearchAnimation.openSearchHistory) {
136 openSearchAnimation.openSearchHistory = false;
137 root.openSearchHistory();
145 anchors { left: parent.left; right: parent.right }
149 anchors { left: parent.left; right: parent.right }
150 height: headerContainer.height
151 contentHeight: height
153 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
154 property var styledItem: searchHeader
155 property string title
156 property var config: PageHeadConfiguration {
161 headerContainer.showSearch = false;
165 property var contents: TextField {
167 hasClearButton: false
170 leftMargin: units.gu(1)
171 topMargin: units.gu(1)
172 bottomMargin: units.gu(1)
173 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
176 secondaryItem: AbstractButton {
177 height: searchTextField.height
179 enabled: searchTextField.text.length > 0
182 objectName: "clearIcon"
184 anchors.margins: units.gu(.75)
185 source: "image://theme/clear"
186 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
188 Behavior on opacity {
189 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
194 id: searchActivityIndicator
195 objectName: "searchIndicator"
197 anchors.margins: units.gu(.75)
198 running: root.searchInProgress
199 opacity: running ? 1 : 0
200 Behavior on opacity {
201 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
206 root.resetSearch(true);
207 root.openSearchHistory();
211 onActiveFocusChanged: {
213 root.openSearchHistory();
221 objectName: "pageHeader"
222 anchors { left: parent.left; right: parent.right }
223 height: headerContainer.height
224 contentHeight: height
226 textColor: root.scopeStyle ? root.scopeStyle.foreground : "grey"
227 property var styledItem: header
228 property string title: root.title
229 property var config: PageHeadConfiguration {
232 visible: root.showBackButton
241 visible: root.searchEntryEnabled
243 headerContainer.showSearch = true;
244 searchTextField.forceActiveFocus();
250 property var contents: null
251 Component.onCompleted: root.refreshLogo()
257 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
260 objectName: "titleImage"
262 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
263 fillMode: Image.PreserveAspectFit
264 horizontalAlignment: Image.AlignLeft
265 sourceSize.height: height
279 Component.onDestruction: {
280 headerContainer.popover = null;
295 showDivider: index < recentSearches.count - 1
298 searchHistory.addQuery(text);
299 searchTextField.text = text;
300 PopupUtils.close(popover);
311 top: headerContainer.bottom
314 bottom: bottomContainer.top
317 source: "graphics/PageHeaderBaseDivider.sci"
326 bottom: parent.bottom
328 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