2 * Copyright (C) 2016 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/>.
18 import QtQuick.Layouts 1.1
19 import QtMultimedia 5.0
20 import Ubuntu.Components 1.3
21 import Ubuntu.Components.ListItems 1.3 as ListItem
26 property alias component: loader.sourceComponent
28 signal actionClicked(string action)
29 signal viewModeClicked
31 property list<Action> userActions
32 property Action viewAction
34 property color iconColor
35 property color backgroundColor
41 verticalCenter: parent.verticalCenter
48 Layout.preferredWidth: units.gu(3)
49 Layout.preferredHeight: units.gu(3)
50 Layout.alignment: Qt.AlignVCenter
51 enabled: action && action.enabled
55 iconName: "navigation-menu"
56 onTriggered: userActionsPopup.createObject(root, { "anchors.bottom": root.top })
60 switch (userActions.length) {
64 return userActions[0];
72 visible: actionButton.action && actionButton.action.iconSource !== "" || false
73 source: actionButton.action ? actionButton.action.iconSource : ""
75 opacity: actionButton.action && actionButton.action.enabled ? 1.0 : 0.5
81 Layout.fillWidth: true
82 Layout.preferredHeight: units.gu(3)
86 objectName: "viewActionButton"
87 Layout.preferredWidth: units.gu(3)
88 Layout.preferredHeight: units.gu(3)
89 Layout.alignment: Qt.AlignVCenter
90 enabled: viewAction.enabled
95 visible: viewAction.iconSource !== ""
96 source: viewAction.iconSource
98 opacity: viewAction.enabled ? 1.0 : 0.5
108 color: root.backgroundColor
109 width: userActionsColumn.width
110 height: userActionsColumn.height
114 acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
116 propagateComposedEvents: false
117 onWheel: wheel.accepted = true
119 onPressed: popup.destroy()
123 id: userActionsColumn
133 onClicked: popup.destroy()
135 implicitHeight: units.gu(4) + bottomDividerLine.height
136 width: parent ? parent.width : units.gu(31)
139 visible: parent.pressed
145 height: parent.height - bottomDividerLine.height
151 visible: "" !== action.iconSource
152 source: action.iconSource
153 color: root.iconColor
155 verticalCenter: parent.verticalCenter
156 verticalCenterOffset: units.dp(-1)
158 leftMargin: units.gu(2)
162 opacity: action.enabled ? 1.0 : 0.5
167 verticalCenter: parent.verticalCenter
168 verticalCenterOffset: units.dp(-1)
169 left: actionIcon.visible ? actionIcon.right : parent.left
170 leftMargin: units.gu(2)
173 // In the tabs overflow panel there are no icons, and the font-size
174 // is medium as opposed to the small font-size in the actions overflow panel.
175 fontSize: actionIcon.visible ? "small" : "medium"
176 elide: Text.ElideRight
178 color: root.iconColor
179 opacity: action.enabled ? 1.0 : 0.5
182 ListItem.ThinDivider {
183 id: bottomDividerLine
184 anchors.bottom: parent.bottom
185 visible: index !== actionRepeater.count - 1