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 showSignatureLine: bottomBorder.visible
37 property alias bottomItem: bottomContainer.children
38 property int paginationCount: 0
39 property int paginationIndex: -1
41 // TODO We should use foreground for the icons
42 // of the toolbar but unfortunately Action does not have
43 // the keyColor property as Icon does :-/
44 property var scopeStyle: null
48 onScopeStyleChanged: refreshLogo()
49 onSearchQueryChanged: {
50 // Make sure we are at the search page if the search query changes behind our feet
52 headerContainer.showSearch = true;
56 function triggerSearch() {
57 if (searchEntryEnabled) {
58 headerContainer.showSearch = true;
59 searchTextField.forceActiveFocus();
63 function closePopup() {
64 if (headerContainer.popover != null) {
65 PopupUtils.close(headerContainer.popover);
69 function resetSearch(keepFocus) {
71 searchHistory.addQuery(searchTextField.text);
76 searchTextField.text = "";
81 searchTextField.focus = false;
82 if (!searchTextField.text) {
83 headerContainer.showSearch = false;
87 function openSearchHistory() {
88 if (openSearchAnimation.running) {
89 openSearchAnimation.openSearchHistory = true;
90 } else if (root.searchHistory.count > 0 && headerContainer.popover == null) {
91 headerContainer.popover = PopupUtils.open(popoverComponent, searchTextField,
93 "contentWidth": searchTextField.width,
94 "edgeMargins": units.gu(1)
100 function refreshLogo() {
101 if (scopeStyle ? scopeStyle.headerLogo != "" : false) {
102 header.contents = imageComponent.createObject();
103 } else if (header.contents) {
104 header.contents.destroy();
105 header.contents = null;
110 target: root.scopeStyle
111 onHeaderLogoChanged: root.refreshLogo()
115 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
116 visible: headerContainer.showSearch
119 if (!searchTextField.text) {
120 headerContainer.showSearch = false;
122 searchTextField.focus = false;
123 mouse.accepted = false;
129 objectName: "headerContainer"
130 clip: contentY < height
131 anchors { left: parent.left; top: parent.top; right: parent.right }
132 height: units.gu(6.5)
133 contentHeight: headersColumn.height
135 contentY: showSearch ? 0 : height
137 property bool showSearch: false
138 property var popover: null
141 objectName: "headerBackground"
142 style: scopeStyle.headerBackground
145 Behavior on contentY {
146 UbuntuNumberAnimation {
147 id: openSearchAnimation
148 property bool openSearchHistory: false
151 if (!running && openSearchAnimation.openSearchHistory) {
152 openSearchAnimation.openSearchHistory = false;
153 root.openSearchHistory();
161 anchors { left: parent.left; right: parent.right }
165 anchors { left: parent.left; right: parent.right }
166 height: headerContainer.height
167 contentHeight: height
168 opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
170 // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
171 property var styledItem: searchHeader
172 property string title
173 property var config: PageHeadConfiguration {
174 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
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
208 Behavior on opacity {
209 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
214 root.resetSearch(true);
215 root.openSearchHistory();
219 onActiveFocusChanged: {
221 root.openSearchHistory();
235 objectName: "innerPageHeader"
236 anchors { left: parent.left; right: parent.right }
237 height: headerContainer.height
238 contentHeight: height
239 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
241 property var styledItem: header
242 property string title: root.title
243 property var config: PageHeadConfiguration {
244 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : "grey"
247 visible: root.showBackButton
257 visible: root.searchEntryEnabled
259 headerContainer.showSearch = true;
260 searchTextField.forceActiveFocus();
266 property var contents: null
267 Component.onCompleted: root.refreshLogo()
273 anchors { fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1) }
276 objectName: "titleImage"
278 source: root.scopeStyle ? root.scopeStyle.headerLogo : ""
279 fillMode: Image.PreserveAspectFit
280 horizontalAlignment: Image.AlignLeft
281 sourceSize.height: height
290 spacing: units.gu(.5)
292 objectName: "paginationRepeater"
293 model: root.paginationCount
295 objectName: "paginationDots_" + index
298 source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
302 top: headerContainer.bottom
303 horizontalCenter: headerContainer.horizontalCenter
304 topMargin: units.gu(.5)
314 Component.onDestruction: {
315 headerContainer.popover = null;
327 objectName: "recentSearches"
331 showDivider: index < recentSearches.count - 1
334 searchHistory.addQuery(text);
335 searchTextField.text = text;
348 top: headerContainer.bottom
351 bottom: bottomContainer.top
354 source: "graphics/PageHeaderBaseDivider.sci"
363 bottom: parent.bottom
365 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