| 1 |
/* |
| 2 |
* Copyright 2015 Canonical Ltd. |
| 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/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components |
| 19 |
import Lomiri.Components.Popups |
| 20 |
|
| 21 |
ActionSelectionPopover { |
| 22 |
id: popover |
| 23 |
objectName: 'listItemContextMenu' |
| 24 |
contentWidth: units.gu(25) |
| 25 |
|
| 26 |
delegate: ListItem { |
| 27 |
visible: action.visible |
| 28 |
contentItem.anchors { |
| 29 |
leftMargin: units.gu(2) |
| 30 |
rightMargin: units.gu(2) |
| 31 |
topMargin: units.gu(0.5) |
| 32 |
bottomMargin: units.gu(0.5) |
| 33 |
} |
| 34 |
divider.visible: action !== actions[actions.length - 1] |
| 35 |
|
| 36 |
Label { |
| 37 |
anchors.verticalCenter: parent.verticalCenter |
| 38 |
text: action.text |
| 39 |
color: theme.palette.normal.backgroundText |
| 40 |
} |
| 41 |
|
| 42 |
onClicked: popover.hide() |
| 43 |
} |
| 44 |
|
| 45 |
function mergeActions(to, from) { |
| 46 |
if (from == null) |
| 47 |
return; |
| 48 |
|
| 49 |
var actions = from.actions; |
| 50 |
for (var i in actions) { |
| 51 |
var action = actions[i]; |
| 52 |
if (!action.text) |
| 53 |
action.text = action.iconName; |
| 54 |
to.push(actions[i]); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
onCallerChanged: { |
| 59 |
var all = []; |
| 60 |
mergeActions(all, caller.leadingActions); |
| 61 |
mergeActions(all, caller.trailingActions); |
| 62 |
actions = all; |
| 63 |
} |
| 64 |
|
| 65 |
// Hide the arrow |
| 66 |
Binding { |
| 67 |
target: __foreground |
| 68 |
property: "direction" |
| 69 |
value: "none" |
| 70 |
} |
| 71 |
} |