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 bool searchInProgress: false
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 {
179 headerContainer.showSearch = false;
183 property var contents: TextField {
185 objectName: "searchTextField"
186 inputMethodHints: Qt.ImhNoPredictiveText
187 hasClearButton: false
190 leftMargin: units.gu(1)
191 topMargin: units.gu(1)
192 bottomMargin: units.gu(1)
193 rightMargin: root.width > units.gu(60) ? root.width - units.gu(40) : units.gu(1)
196 secondaryItem: AbstractButton {
197 height: searchTextField.height
199 enabled: searchTextField.text.length > 0
202 objectName: "clearIcon"
204 anchors.margins: units.gu(.75)
205 source: "image://theme/clear"
206 opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
208 Behavior on opacity {
209 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
214 id: searchActivityIndicator
215 objectName: "searchIndicator"
217 anchors.margins: units.gu(.75)
218 running: root.searchInProgress
219 opacity: running ? 1 : 0
220 Behavior on opacity {
221 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
226 root.resetSearch(true);
227 root.openSearchHistory();
231 onActiveFocusChanged: {
233 root.openSearchHistory();
247 objectName: "innerPageHeader"
248 anchors { left: parent.left; right: parent.right }
249 height: headerContainer.height
250 contentHeight: height
251 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
253 textColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
254 property var styledItem: header
255 property string title: root.title
256 property var config: PageHeadConfiguration {
259 visible: root.showBackButton
269 visible: root.searchEntryEnabled
271 headerContainer.showSearch = true;
272 searchTextField.forceActiveFocus();
278 property var contents: null
279 Component.onCompleted: root.refreshLogo()
285 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
288 objectName: "titleImage"
290 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
291 fillMode: Image.PreserveAspectFit
292 horizontalAlignment: Image.AlignLeft
293 sourceSize.height: height
302 spacing: units.gu(.5)
304 objectName: "paginationRepeater"
305 model: root.paginationCount
307 objectName: "paginationDots_" + index
310 source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
314 top: headerContainer.bottom
315 horizontalCenter: headerContainer.horizontalCenter
316 topMargin: units.gu(.5)
326 Component.onDestruction: {
327 headerContainer.popover = null;
339 objectName: "recentSearches"
343 showDivider: index < recentSearches.count - 1
346 searchHistory.addQuery(text);
347 searchTextField.text = text;
360 top: headerContainer.bottom
363 bottom: bottomContainer.top
366 source: "graphics/PageHeaderBaseDivider.sci"
375 bottom: parent.bottom
377 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