Meshroom/meshroom/ui/qml/MaterialIcons/MaterialToolLabelButton.qml
2023-07-03 12:11:29 +02:00

51 lines
1.4 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.11
/**
* MaterialToolButton is a standard ToolButton using MaterialIcons font.
* It also shows up its tooltip when hovered.
*/
ToolButton {
id: control
property alias iconText: icon.text
property alias iconSize: icon.font.pointSize
property alias label: labelItem.text
padding: 0
ToolTip.visible: ToolTip.text && hovered
ToolTip.delay: 100
width: childrenRect.width
height: childrenRect.height
contentItem: RowLayout {
Layout.margins: 0
Label {
id: icon
font.family: MaterialIcons.fontFamily
font.pointSize: 13
padding: 0
text: ""
color: (checked ? palette.highlight : palette.text)
}
Label {
id: labelItem
text: ""
padding: 0
color: (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"
}
}