Debian Codegraph @

src/imports/Components/Themes/Ambiance/2.0/OverflowPanel.qml

raw
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.Popups
19 import Lomiri.Components
20 import Lomiri.Components.ListItems as ListItem
21
22 /*!
23 \internal
24 */
25 ActionSelectionPopover {
26 id: overflow
27
28 // clicks next to the overflow panel must only close the panel,
29 // not trigger additional events.
30 grabDismissAreaEvents: true
31
32 /*!
33 The background color of the tabs panel and the actions overflow panel.
34 */
35 property color backgroundColor: theme.palette.normal.background
36
37 /*!
38 The background color of the tapped item in the panel.
39 */
40 property color highlightColor: theme.palette.highlighted.background
41
42 /*!
43 The foreground color (icon and text) of actions in the panel.
44 */
45 property color foregroundColor: theme.palette.normal.backgroundText
46
47 /*!
48 The foreground color (icon and text) of disabled actions in the panel.
49 */
50 property color disabledForegroundColor: theme.palette.disabled.backgroundText
51
52 property bool square: true
53 callerMargin: -units.gu(1) + units.dp(4)
54 contentWidth: units.gu(20)
55
56 Binding {
57 target: overflow.__foreground.__styleInstance
58 property: "color"
59 value: overflow.backgroundColor
60 when: overflow.__foreground &&
61 overflow.__foreground.__styleInstance
62 }
63
64 delegate: AbstractButton {
65 id: actionButton
66
67 // close after triggering the action.
68 onClicked: overflow.hide()
69
70 implicitHeight: units.gu(6) + bottomDividerLine.height
71 width: parent ? parent.width : units.gu(31)
72
73 Rectangle {
74 visible: parent.pressed
75 anchors {
76 left: parent.left
77 right: parent.right
78 top: parent.top
79 }
80 height: parent.height - bottomDividerLine.height
81 color: overflow.highlightColor
82 }
83
84 Icon {
85 id: actionIcon
86 visible: "" !== action.iconSource.toString()
87 source: action.iconSource
88 color: enabled ? overflow.foregroundColor
89 : overflow.disabledForegroundColor
90 anchors {
91 verticalCenter: parent.verticalCenter
92 verticalCenterOffset: units.dp(-1)
93 left: parent.left
94 leftMargin: units.gu(2)
95 }
96 width: units.gu(2)
97 height: units.gu(2)
98 }
99
100 Label {
101 anchors {
102 verticalCenter: parent.verticalCenter
103 verticalCenterOffset: units.dp(-1)
104 left: actionIcon.visible ? actionIcon.right : parent.left
105 leftMargin: units.gu(2)
106 right: parent.right
107 }
108 // In the tabs overflow panel there are no icons, and the font-size
109 // is medium as opposed to the small font-size in the actions overflow panel.
110 textSize: actionIcon.visible ? Label.Small : Label.Medium
111 elide: Text.ElideRight
112 text: action.text
113 color: enabled ? overflow.foregroundColor
114 : overflow.disabledForegroundColor
115 }
116
117 // The value of showDivider is automatically set by ActionSelectionPopover.
118 property bool showDivider
119 ListItem.ThinDivider {
120 id: bottomDividerLine
121 anchors.bottom: parent.bottom
122 visible: actionButton.showDivider
123 }
124 }
125 }