Files

60 lines
1.6 KiB
QML
Raw Permalink Normal View History

import QtQuick
import QtQuick.Controls
import Flora
Button {
id: b
property string tip: ""
property bool bold: false
property bool accent: false
signal tapped()
implicitWidth: b.text.length > 2 ? 36 : 30
implicitHeight: 26
font.bold: bold
font.pixelSize: 13
palette.button: Theme.toolbarBg
palette.buttonText: Theme.text
palette.highlight: Theme.accent
// фон под тему
background: Rectangle {
color: b.pressed ? Theme.surfaceSelected : b.hovered ? Theme.surfaceHover : "transparent"
radius: 6
border.color: b.pressed ? Theme.accent : "transparent"
}
contentItem: Label {
text: b.text
font: b.font
color: b.accent ? Theme.accent : (b.enabled ? Theme.text : Theme.textFaint)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
// особый стиль для цветных А
Rectangle {
visible: b.accent
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 6; height: 3
radius: 1
color: Theme.warningText
opacity: 0.9
}
Rectangle {
visible: b.bold && !b.accent
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 6; height: 3
radius: 1
color: Theme.accent
opacity: 0.9
}
}
ToolTip.visible: hovered && tip.length > 0
ToolTip.text: tip
ToolTip.delay: 600
onClicked: b.tapped()
}