[ui] Update MaterialToolButton style

* flatten the button 
* color its icon when checked
This commit is contained in:
Yann Lanthony 2019-09-11 10:22:35 +02:00
parent 1c873508ef
commit b9999c01eb
No known key found for this signature in database
GPG key ID: 519FAE6DF7A70642
3 changed files with 27 additions and 17 deletions

View file

@ -37,35 +37,28 @@ Item {
background: Rectangle { color: Qt.darker(Colors.sysPalette.window, 1.2) } background: Rectangle { color: Qt.darker(Colors.sysPalette.window, 1.2) }
Column { Column {
height: parent.height height: parent.height
ToolButton { spacing: 1
MaterialToolButton {
text: MaterialIcons.refresh text: MaterialIcons.refresh
ToolTip.text: "Reload" ToolTip.text: "Reload"
ToolTip.visible: hovered
font.family: MaterialIcons.fontFamily
onClicked: loadSource() onClicked: loadSource()
} }
ToolButton { MaterialToolButton {
text: MaterialIcons.vertical_align_top text: MaterialIcons.vertical_align_top
ToolTip.text: "Scroll to Top" ToolTip.text: "Scroll to Top"
ToolTip.visible: hovered
font.family: MaterialIcons.fontFamily
onClicked: textView.positionViewAtBeginning() onClicked: textView.positionViewAtBeginning()
} }
ToolButton { MaterialToolButton {
id: autoscroll id: autoscroll
text: MaterialIcons.vertical_align_bottom text: MaterialIcons.vertical_align_bottom
ToolTip.text: "Scroll to Bottom" ToolTip.text: "Scroll to Bottom"
ToolTip.visible: hovered
font.family: MaterialIcons.fontFamily
onClicked: textView.positionViewAtEnd() onClicked: textView.positionViewAtEnd()
checkable: false checkable: false
checked: textView.atYEnd checked: textView.atYEnd
} }
ToolButton { MaterialToolButton {
text: MaterialIcons.assignment text: MaterialIcons.assignment
ToolTip.text: "Copy" ToolTip.text: "Copy"
ToolTip.visible: hovered
font.family: MaterialIcons.fontFamily
onClicked: copySubMenu.open() onClicked: copySubMenu.open()
Menu { Menu {
id: copySubMenu id: copySubMenu
@ -88,11 +81,9 @@ Item {
} }
} }
} }
ToolButton { MaterialToolButton {
text: MaterialIcons.open_in_new text: MaterialIcons.open_in_new
ToolTip.text: "Open Externally" ToolTip.text: "Open Externally"
ToolTip.visible: hovered
font.family: MaterialIcons.fontFamily
enabled: root.source !== "" enabled: root.source !== ""
onClicked: Qt.openUrlExternally(root.source) onClicked: Qt.openUrlExternally(root.source)
} }

View file

@ -35,9 +35,11 @@ Panel {
text: MaterialIcons.more_vert text: MaterialIcons.more_vert
font.pointSize: 11 font.pointSize: 11
padding: 2 padding: 2
onClicked: graphEditorMenu.open() checkable: true
checked: galleryMenu.visible
onClicked: galleryMenu.open()
Menu { Menu {
id: graphEditorMenu id: galleryMenu
y: parent.height y: parent.height
x: -width + parent.width x: -width + parent.width
MenuItem { MenuItem {

View file

@ -12,4 +12,21 @@ ToolButton {
font.pointSize: 13 font.pointSize: 13
ToolTip.visible: ToolTip.text && hovered ToolTip.visible: ToolTip.text && hovered
ToolTip.delay: 100 ToolTip.delay: 100
Component.onCompleted: {
contentItem.color = Qt.binding(function() { return checked ? palette.highlight : palette.text })
}
background: Rectangle {
color: {
if(pressed || checked || hovered)
{
if(pressed || checked)
return Qt.darker(parent.palette.base, 1.3)
if(hovered)
return Qt.darker(parent.palette.base, 0.6)
}
return "transparent";
}
border.color: checked ? Qt.darker(parent.palette.base, 1.4) : "transparent"
}
} }