68.1.4
by Nick Dedekind
Added standard menu |
1 |
/*
|
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
2 |
* Copyright 2013-2016 Canonical Ltd.
|
68.1.4
by Nick Dedekind
Added standard menu |
3 |
*
|
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.
|
|
7 |
*
|
|
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.
|
|
12 |
*
|
|
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/>.
|
|
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
15 |
*
|
16 |
* Author: Marco Trevisan <marco.trevisan@canonical.com>
|
|
68.1.4
by Nick Dedekind
Added standard menu |
17 |
*/
|
18 |
||
103.1.1
by Albert Astals Cid
Standarize QtQuick and Ubuntu.Components.Listitems imports |
19 |
import QtQuick 2.4 |
89.1.1
by Daniel d'Andrada
Avoid creating a deluge of deprecation warnings |
20 |
import Ubuntu.Components 1.3 |
146.4.29
by Marco Trevisan (Treviño)
Menus: add Style submodule to contain styled components |
21 |
import Ubuntu.Settings.Menus.Style 0.1 |
68.1.4
by Nick Dedekind
Added standard menu |
22 |
|
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
23 |
ListItem { |
68.1.4
by Nick Dedekind
Added standard menu |
24 |
id: menu
|
25 |
||
146.4.39
by Marco Trevisan (Treviño)
BaseMenu: set pointerMode to false by default |
26 |
property bool pointerMode: false |
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
27 |
property bool highlightWhenPressed: true |
146.4.35
by Marco Trevisan (Treviño)
BaseMenu: only enable implicitHeight binding when menuHeight is set to a valid value |
28 |
property real menuHeight: -1 |
146.4.29
by Marco Trevisan (Treviño)
Menus: add Style submodule to contain styled components |
29 |
property BaseStyle menuStyle: pointerMode ? PointerStyle : TouchStyle |
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
30 |
property alias backColor: menu.color |
146.4.46
by Marco Trevisan (Treviño)
BaseStyle: use proper name for foregroud color |
31 |
property color foregroundColor: menuStyle.foregroundColor |
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
32 |
|
146.3.80
by Marco Trevisan (Treviño)
BaseMenu: no need to connect to function in onCompleted, we can override anyway |
33 |
// This is for retro-compatibility with ListItem.Empty, adding support to override the callback
|
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
34 |
signal triggered(var value) |
146.3.33
by Marco Trevisan (Treviño)
BaseMenu: make onClicked signal callback overrideable |
35 |
function onClickedCallback() { triggered(null) } |
146.3.80
by Marco Trevisan (Treviño)
BaseMenu: no need to connect to function in onCompleted, we can override anyway |
36 |
onClicked: onClickedCallback() |
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
37 |
|
38 |
property bool removable: false |
|
39 |
property bool confirmRemoval: true |
|
40 |
onConfirmRemovalChanged: console.error(menu+": confirmRemoval property is deprecated") |
|
41 |
signal itemRemoved() |
|
42 |
||
146.4.27
by Marco Trevisan (Treviño)
BaseMenu: separate property definition and initialization |
43 |
divider.visible: false |
146.4.35
by Marco Trevisan (Treviño)
BaseMenu: only enable implicitHeight binding when menuHeight is set to a valid value |
44 |
|
146.4.42
by Marco Trevisan (Treviño)
BaseMenu: bind ListItem height to menuHeight or it won't work because of bug #1630683 |
45 |
// FIXME: this is should use implicitHeight, but we can't yet due to lp:1630683
|
46 |
Binding on height { |
|
146.4.35
by Marco Trevisan (Treviño)
BaseMenu: only enable implicitHeight binding when menuHeight is set to a valid value |
47 |
when: menuHeight >= 0 |
146.4.37
by Marco Trevisan (Treviño)
BaseMenu: add minimumMenu height on style |
48 |
value: Math.max(menuStyle.minimumHeight, menuHeight) + (divider.visible ? divider.height : 0) |
146.4.35
by Marco Trevisan (Treviño)
BaseMenu: only enable implicitHeight binding when menuHeight is set to a valid value |
49 |
}
|
146.4.27
by Marco Trevisan (Treviño)
BaseMenu: separate property definition and initialization |
50 |
|
51 |
Binding on highlightColor { |
|
52 |
when: !highlightWhenPressed |
|
53 |
value: backColor |
|
54 |
}
|
|
55 |
||
56 |
Binding on highlightColor { |
|
57 |
when: highlightWhenPressed && menuStyle |
|
58 |
value: menuStyle.highlightColor |
|
59 |
}
|
|
60 |
||
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
61 |
ListItemActions { |
62 |
id: removeAction
|
|
63 |
actions: [ |
|
64 |
Action { |
|
146.3.73
by Marco Trevisan (Treviño)
Menus: fix various tests failures |
65 |
objectName: "removeAction" |
146.3.4
by Marco Trevisan (Treviño)
StandardMenu: reimplement it by using ListItem and ListItemLayout |
66 |
iconName: "delete" |
67 |
onTriggered: removeItemAnimation.start(); |
|
68 |
}
|
|
69 |
]
|
|
70 |
||
71 |
SequentialAnimation { |
|
72 |
id: removeItemAnimation
|
|
73 |
||
74 |
running: false |
|
75 |
UbuntuNumberAnimation { |
|
76 |
target: menu |
|
77 |
property: "height" |
|
78 |
to: 0 |
|
79 |
}
|
|
80 |
ScriptAction { |
|
81 |
script: { |
|
82 |
itemRemoved() |
|
83 |
}
|
|
84 |
}
|
|
85 |
}
|
|
86 |
}
|
|
87 |
||
88 |
leadingActions: removable ? removeAction : null |
|
146.3.110
by Marco Trevisan (Treviño)
BaseMenu, SimpleMessageMenu: enable clipping if there are trailing or leading actions |
89 |
clip: leadingActions || trailingActions |
68.1.4
by Nick Dedekind
Added standard menu |
90 |
}
|