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()
48 function triggerSearch() {
49 if (searchEntryEnabled) {
50 headerContainer.showSearch = true;
51 searchTextField.forceActiveFocus();
55 function resetSearch(keepFocus) {
57 searchHistory.addQuery(searchTextField.text);
62 searchTextField.text = "";
63 if (headerContainer.popover != null) {
64 PopupUtils.close(headerContainer.popover);
69 searchTextField.focus = false;
70 if (!searchTextField.text) {
71 headerContainer.showSearch = false;
75 function openSearchHistory() {
76 if (openSearchAnimation.running) {
77 openSearchAnimation.openSearchHistory = true;
78 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
79 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
81 "contentWidth": searchTextField.width,
82 "edgeMargins": units.gu(1)
88 function refreshLogo() {
89 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
90 header.contents = imageComponent.createObject();
91 } else if (header.contents) {
92 header.contents.destroy();
93 header.contents = null;
98 target: root.scopeStyle
99 onHeaderLogoChanged: root.refreshLogo()
103 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
104 visible: headerContainer.showSearch
106 if (headerContainer.popover) {
107 PopupUtils.close(headerContainer.popover);
109 if (!searchTextField.text) {
110 headerContainer.showSearch = false;
112 searchTextField.focus = false;
113 mouse.accepted = false;
119 objectName: "headerContainer"
121 anchors { left: parent.left; top: parent.top; right: parent.right }
122 height: units.gu(6.5)
123 contentHeight: headersColumn.height
125 contentY: showSearch ? 0 : height
127 property bool showSearch: false
128 property var popover: null
131 objectName: "headerBackground"
132 style: scopeStyle.headerBackground
135 Behavior on contentY {
136 UbuntuNumberAnimation {
137 id: openSearchAnimation
138 property bool openSearchHistory: false
141 if (!running && openSearchAnimation.openSearchHistory) {
142 openSearchAnimation.openSearchHistory = false;
143 root.openSearchHistory();
151 anchors { left: parent.left; right: parent.right }
155 anchors { left: parent.left; right: parent.right }
156 height: headerContainer.height
157 contentHeight: height
159 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
160 property var styledItem: searchHeader
161 property string title
162 property var config: PageHeadConfiguration {
167 headerContainer.showSearch = false;
171 property var contents: TextField {
173 objectName: "searchTextField"
174 hasClearButton: false
177 leftMargin: units.gu(1)
178 topMargin: units.gu(1)
179 bottomMargin: units.gu(1)
180 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
183 secondaryItem: AbstractButton {
184 height: searchTextField.height
186 enabled: searchTextField.text.length > 0
189 objectName: "clearIcon"
191 anchors.margins: units.gu(.75)
192 source: "image://theme/clear"
193 opacity: searchTextField.text.length > 0
195 Behavior on opacity {
196 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
201 root.resetSearch(true);
202 root.openSearchHistory();
206 onActiveFocusChanged: {
208 root.openSearchHistory();
216 objectName: "innerPageHeader"
217 anchors { left: parent.left; right: parent.right }
218 height: headerContainer.height
219 contentHeight: height
221 textColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
222 property var styledItem: header
223 property string title: root.title
224 property var config: PageHeadConfiguration {
227 visible: root.showBackButton
236 visible: root.searchEntryEnabled
238 headerContainer.showSearch = true;
239 searchTextField.forceActiveFocus();
245 property var contents: null
246 Component.onCompleted: root.refreshLogo()
252 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
255 objectName: "titleImage"
257 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
258 fillMode: Image.PreserveAspectFit
259 horizontalAlignment: Image.AlignLeft
260 sourceSize.height: height
274 Component.onDestruction: {
275 headerContainer.popover = null;
290 showDivider: index < recentSearches.count - 1
293 searchHistory.addQuery(text);
294 searchTextField.text = text;
295 PopupUtils.close(popover);
306 top: headerContainer.bottom
309 bottom: bottomContainer.top
321 bottom: parent.bottom
323 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