Changeset View
Changeset View
Standalone View
Standalone View
src/controls/private/PrivateActionToolButton.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.7 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 2.2 as Controls | 22 | import QtQuick.Controls 2.4 as Controls | ||
23 | import org.kde.kirigami 2.4 | 23 | import org.kde.kirigami 2.4 | ||
24 | 24 | | |||
25 | Controls.ToolButton { | 25 | Controls.ToolButton { | ||
26 | id: control | 26 | id: control | ||
27 | 27 | | |||
28 | signal menuAboutToShow | 28 | signal menuAboutToShow | ||
29 | 29 | | |||
30 | implicitWidth: menuArrow.visible || (showText && ( kirigamiAction ? kirigamiAction.text.length > 0 : text.length > 0)) | 30 | implicitWidth: menuArrow.visible || (showText && ( kirigamiAction ? kirigamiAction.text.length > 0 : text.length > 0)) | ||
31 | ? Math.max(layout.implicitWidth + Units.largeSpacing*2, background.implicitWidth) | 31 | ? Math.max(layout.implicitWidth + Units.largeSpacing*2, background.implicitWidth) | ||
32 | : implicitHeight | 32 | : implicitHeight | ||
33 | implicitHeight: background.implicitHeight | 33 | implicitHeight: background.implicitHeight | ||
34 | 34 | | |||
35 | Theme.colorSet: Theme.Button | 35 | Theme.colorSet: Theme.Button | ||
36 | Theme.inherit: kirigamiAction && kirigamiAction.icon.color.a === 0 | 36 | Theme.inherit: kirigamiAction && kirigamiAction.icon.color.a === 0 | ||
37 | Theme.backgroundColor: kirigamiAction && kirigamiAction.icon.color.a ? kirigamiAction.icon.color : undefined | 37 | Theme.backgroundColor: kirigamiAction && kirigamiAction.icon.color.a ? kirigamiAction.icon.color : undefined | ||
38 | Theme.textColor: kirigamiAction && !flat && kirigamiAction.icon.color.a ? Theme.highlightedTextColor : undefined | 38 | Theme.textColor: kirigamiAction && !flat && kirigamiAction.icon.color.a ? Theme.highlightedTextColor : undefined | ||
39 | 39 | | |||
40 | hoverEnabled: true | 40 | hoverEnabled: true | ||
41 | flat: !control.kirigamiAction || !control.kirigamiAction.icon.color.a | 41 | flat: !control.kirigamiAction || !control.kirigamiAction.icon.color.a | ||
42 | //TODO: replace with upstream action when we depend on Qt 5.10 | 42 | //TODO: replace with upstream action when we depend on Qt 5.10 | ||
43 | //TODO: upstream action makes the style to re-draw the content, it'd be ideal except for the custom dropDown icon needed for actionsMenu | 43 | //TODO: upstream action makes the style to re-draw the content, it'd be ideal except for the custom dropDown icon needed for actionsMenu | ||
44 | property QtObject kirigamiAction | 44 | property Controls.Action kirigamiAction | ||
45 | property bool showText: true | 45 | property bool showText: true | ||
46 | property bool showMenuArrow: true | 46 | property bool showMenuArrow: true | ||
47 | property alias menu: menu | 47 | property alias menu: menu | ||
48 | 48 | | |||
49 | //we need our own text delegate | 49 | //we need our own text delegate | ||
50 | text: "" | 50 | text: "" | ||
51 | checkable: (kirigamiAction && kirigamiAction.checkable) || (menu.actions && menu.actions.length > 0) | 51 | checkable: (kirigamiAction && kirigamiAction.checkable) || (menu.actions && menu.actions.length > 0) | ||
52 | checked: (kirigamiAction && kirigamiAction.checked) | 52 | checked: (kirigamiAction && kirigamiAction.checked) | ||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |