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
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
130 objectName: "headerBackground"
131 style: scopeStyle.headerBackground
134 Behavior on contentY {
135 UbuntuNumberAnimation {
136 id: openSearchAnimation
137 property bool openSearchHistory: false
140 if (!running && openSearchAnimation.openSearchHistory) {
141 openSearchAnimation.openSearchHistory = false;
142 root.openSearchHistory();
150 anchors { left: parent.left; right: parent.right }
154 anchors { left: parent.left; right: parent.right }
155 height: headerContainer.height
156 contentHeight: height
158 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
159 property var styledItem: searchHeader
160 property string title
161 property var config: PageHeadConfiguration {
166 headerContainer.showSearch = false;
170 property var contents: TextField {
172 objectName: "searchTextField"
173 hasClearButton: false
176 leftMargin: units.gu(1)
177 topMargin: units.gu(1)
178 bottomMargin: units.gu(1)
179 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
182 secondaryItem: AbstractButton {
183 height: searchTextField.height
185 enabled: searchTextField.text.length > 0
188 objectName: "clearIcon"
190 anchors.margins: units.gu(.75)
191 source: "image://theme/clear"
192 opacity: searchTextField.text.length > 0
194 Behavior on opacity {
195 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
200 root.resetSearch(true);
201 root.openSearchHistory();
205 onActiveFocusChanged: {
207 root.openSearchHistory();
215 objectName: "innerPageHeader"
216 anchors { left: parent.left; right: parent.right }
217 height: headerContainer.height
218 contentHeight: height
220 textColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
221 property var styledItem: header
222 property string title: root.title
223 property var config: PageHeadConfiguration {
226 visible: root.showBackButton
235 visible: root.searchEntryEnabled
237 headerContainer.showSearch = true;
238 searchTextField.forceActiveFocus();
244 property var contents: null
245 Component.onCompleted: root.refreshLogo()
251 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
254 objectName: "titleImage"
256 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
257 fillMode: Image.PreserveAspectFit
258 horizontalAlignment: Image.AlignLeft
259 sourceSize.height: height
273 Component.onDestruction: {
274 headerContainer.popover = null;
289 showDivider: index < recentSearches.count - 1
292 searchHistory.addQuery(text);
293 searchTextField.text = text;
294 PopupUtils.close(popover);
305 top: headerContainer.bottom
308 bottom: bottomContainer.top
320 bottom: parent.bottom
322 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