linphone-desktop/tests/ui/modules/Common/Form/ActionButton.qml
2016-10-31 10:53:30 +01:00

48 lines
1,012 B
QML

import QtQuick 2.7
import QtQuick.Controls 2.0
import Common 1.0
// ===================================================================
// An animated (or not) button with image(s).
// ===================================================================
Button {
id: button
property bool useStates: true
property int iconSize
// If `useStates` = true, the used icons are:
// `icon`_pressed, `icon`_hovered and `icon`_normal.
property string icon
function _getIcon () {
if (!useStates) {
return button.icon
}
return button.icon + (
button.down
? '_pressed'
: (button.hovered ? '_hovered' : '_normal')
)
}
background: Rectangle {
color: 'transparent'
}
hoverEnabled: true
// Ugly hack, use current size, ActionBar size,
// or other parent height.
height: iconSize || parent.iconSize || parent.height
width: iconSize || parent.iconSize || parent.height
Icon {
id: icon
anchors.fill: parent
icon: _getIcon()
}
}