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 + bottomContainer.height + (showSignatureLine ? units.gu(2) : 0)
29 property bool showBackButton: false
32 property bool searchEntryEnabled: false
33 property ListModel searchHistory: SearchHistoryModel
34 property alias searchQuery: searchTextField.text
35 property alias searchHint: searchTextField.placeholderText
36 property alias showSignatureLine: bottomBorder.visible
38 property alias bottomItem: bottomContainer.children
39 property int paginationCount: 0
40 property int paginationIndex: -1
42 // TODO We should use foreground for the icons
43 // of the toolbar but unfortunately Action does not have
44 // the keyColor property as Icon does :-/
45 property var scopeStyle: null
49 onScopeStyleChanged: refreshLogo()
50 onSearchQueryChanged: {
51 // Make sure we are at the search page if the search query changes behind our feet
53 headerContainer.showSearch = true;
57 function triggerSearch() {
58 if (searchEntryEnabled) {
59 headerContainer.showSearch = true;
60 searchTextField.forceActiveFocus();
64 function closePopup() {
65 if (headerContainer.popover != null) {
66 PopupUtils.close(headerContainer.popover);
70 function resetSearch(keepFocus) {
72 searchHistory.addQuery(searchTextField.text);
77 searchTextField.text = "";
82 searchTextField.focus = false;
83 if (!searchTextField.text) {
84 headerContainer.showSearch = false;
88 function openSearchHistory() {
89 if (openSearchAnimation.running) {
90 openSearchAnimation.openSearchHistory = true;
91 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
92 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
94 "contentWidth": searchTextField.width,
95 "edgeMargins": units.gu(1)
101 function refreshLogo() {
102 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
103 header.contents = imageComponent.createObject();
104 } else if (header.contents) {
105 header.contents.destroy();
106 header.contents = null;
111 target: root.scopeStyle
112 onHeaderLogoChanged: root.refreshLogo()
116 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
117 visible: headerContainer.showSearch
120 if (!searchTextField.text) {
121 headerContainer.showSearch = false;
123 searchTextField.focus = false;
124 mouse.accepted = false;
130 objectName: "headerContainer"
131 clip: contentY < height
132 anchors { left: parent.left; top: parent.top; right: parent.right }
133 height: units.gu(6.5)
134 contentHeight: headersColumn.height
136 contentY: showSearch ? 0 : height
138 property bool showSearch: false
139 property var popover: null
142 objectName: "headerBackground"
143 style: scopeStyle.headerBackground
146 Behavior on contentY {
147 UbuntuNumberAnimation {
148 id: openSearchAnimation
149 property bool openSearchHistory: false
152 if (!running && openSearchAnimation.openSearchHistory) {
153 openSearchAnimation.openSearchHistory = false;
154 root.openSearchHistory();
162 anchors { left: parent.left; right: parent.right }
166 anchors { left: parent.left; right: parent.right }
167 height: headerContainer.height
168 contentHeight: height
169 opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
171 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
172 property var styledItem: searchHeader
173 property string title
174 property var config: PageHeadConfiguration {
175 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
180 headerContainer.showSearch = false;
184 property var contents: TextField {
186 objectName: "searchTextField"
187 inputMethodHints: Qt.ImhNoPredictiveText
188 hasClearButton: false
191 leftMargin: units.gu(1)
192 topMargin: units.gu(1)
193 bottomMargin: units.gu(1)
194 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
197 secondaryItem: AbstractButton {
198 height: searchTextField.height
200 enabled: searchTextField.text.length > 0
203 objectName: "clearIcon"
205 anchors.margins: units.gu(.75)
206 source: "image://theme/clear"
207 opacity: searchTextField.text.length > 0
209 Behavior on opacity {
210 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
215 root.resetSearch(true);
216 root.openSearchHistory();
220 onActiveFocusChanged: {
222 root.openSearchHistory();
236 objectName: "innerPageHeader"
237 anchors { left: parent.left; right: parent.right }
238 height: headerContainer.height
239 contentHeight: height
240 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
242 property var styledItem: header
243 property string title: root.title
244 property var config: PageHeadConfiguration {
245 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
248 visible: root.showBackButton
258 visible: root.searchEntryEnabled
260 headerContainer.showSearch = true;
261 searchTextField.forceActiveFocus();
267 property var contents: null
268 Component.onCompleted: root.refreshLogo()
274 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
277 objectName: "titleImage"
279 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
280 fillMode: Image.PreserveAspectFit
281 horizontalAlignment: Image.AlignLeft
282 sourceSize.height: height
291 spacing: units.gu(.5)
293 objectName: "paginationRepeater"
294 model: root.paginationCount
296 objectName: "paginationDots_" + index
299 source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
303 top: headerContainer.bottom
304 horizontalCenter: headerContainer.horizontalCenter
305 topMargin: units.gu(.5)
315 Component.onDestruction: {
316 headerContainer.popover = null;
328 objectName: "recentSearches"
332 showDivider: index < recentSearches.count - 1
335 searchHistory.addQuery(text);
336 searchTextField.text = text;
349 top: headerContainer.bottom
352 bottom: bottomContainer.top
355 source: "graphics/PageHeaderBaseDivider.sci"
364 bottom: parent.bottom
366 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