2 * Copyright 2013 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
22import Ubuntu.Components 0.1 as Components
23import Unity.Indicators 0.1 as Indicators
29 property bool contentActive: false
30 property string title: rootActionState.title
31 property alias emptyText: emptyLabel.text
32 property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
34 Indicators.UnityMenuModelStack {
36 head: contentActive ? main.menuModel : null
41 model: menuStack.tail ? menuStack.tail : null
45 bottomMargin: Qt.inputMethod.visible ? (Qt.inputMethod.keyboardRectangle.height - main.anchors.bottomMargin) : 0
47 Behavior on bottomMargin {
50 easing.type: Easing.OutQuad
53 // TODO - does ever frame.
54 onBottomMarginChanged: {
55 mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
59 // Ensure all delegates are cached in order to improve smoothness of scrolling
62 // Only allow flicking if the content doesn't fit on the page
63 interactive: contentHeight > height
65 property int selectedIndex: -1
66 property bool blockCurrentIndexChange: false
69 if (count == 0 && selectedIndex != -1) {
73 // for highlight following
74 onSelectedIndexChanged: {
75 if (currentIndex != selectedIndex) {
76 var blocked = blockCurrentIndexChange;
77 blockCurrentIndexChange = true;
79 currentIndex = selectedIndex;
81 blockCurrentIndexChange = blocked;
84 // for item addition/removal
85 onCurrentIndexChanged: {
86 if (!blockCurrentIndexChange) {
87 if (selectedIndex != -1 && selectedIndex != currentIndex) {
88 selectedIndex = currentIndex;
100 height: loader.height
107 property int modelIndex: index
114 sourceComponent: factory.load(model)
117 if (model.type === rootMenuType) {
118 menuStack.push(mainMenu.model.submenu(index));
121 if (item.hasOwnProperty("menuSelected")) {
122 item.menuSelected = Qt.binding(function() { return mainMenu.selectedIndex == index; });
123 item.selectMenu.connect(function() { mainMenu.selectedIndex = index; });
124 item.deselectMenu.connect(function() { mainMenu.selectedIndex = -1; });
126 if (item.hasOwnProperty("menu")) {
127 item.menu = Qt.binding(function() { return model; });
132 target: item ? item : null
133 property: "objectName"
142 model: mainMenu.model
147 visible: mainMenu.count == 0
152 topMargin: units.gu(2)
154 wrapMode: Text.WordWrap
155 horizontalAlignment: Text.AlignHCenter
167 if (!contentActive) {
168 contentActive = true;
175 contentActive = false;
181 mainMenu.selectedIndex = -1;
182 mainMenu.positionViewAtBeginning();
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