2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-08-20 17:41:24 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: button
|
2019-12-02 04:40:01 -04:00
|
|
|
enabled: ! button.loading
|
2019-08-21 04:39:07 -04:00
|
|
|
spacing: theme.spacing
|
2020-05-01 00:55:34 -04:00
|
|
|
topPadding: padded ? spacing / (circle ? 1.75 : 2) : 0
|
2019-08-27 14:21:10 -04:00
|
|
|
bottomPadding: topPadding
|
2019-12-02 04:40:01 -04:00
|
|
|
leftPadding: padded ? spacing / (circle ? 1.5 : 1) : 0
|
2019-09-03 03:04:57 -04:00
|
|
|
rightPadding: leftPadding
|
2019-08-30 18:10:25 -04:00
|
|
|
|
2019-08-28 16:30:48 -04:00
|
|
|
icon.color: theme.icons.colorize
|
2019-08-21 15:45:13 -04:00
|
|
|
|
2019-09-09 11:20:59 -04:00
|
|
|
// Must be explicitely set to display correctly on KDE
|
|
|
|
implicitWidth: Math.max(
|
|
|
|
implicitBackgroundWidth + leftInset + rightInset,
|
|
|
|
implicitContentWidth + leftPadding + rightPadding
|
|
|
|
)
|
|
|
|
implicitHeight: Math.max(
|
|
|
|
implicitBackgroundHeight + topInset + bottomInset,
|
|
|
|
implicitContentHeight + topPadding + bottomPadding
|
|
|
|
)
|
2019-08-30 17:37:13 -04:00
|
|
|
|
2019-09-14 17:39:17 -04:00
|
|
|
// Prevent button from gaining focus and being highlighted on click
|
|
|
|
focusPolicy: Qt.TabFocus
|
|
|
|
|
2019-12-11 11:44:59 -04:00
|
|
|
background: HButtonBackground {
|
|
|
|
button: button
|
|
|
|
buttonTheme: theme.controls.button
|
2020-03-07 11:11:32 -04:00
|
|
|
radius: circle ? height : enableRadius ? theme.radius : 0
|
2019-12-11 11:44:59 -04:00
|
|
|
color: backgroundColor
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: HButtonContent {
|
|
|
|
id: contentItem
|
|
|
|
button: button
|
|
|
|
buttonTheme: theme.controls.button
|
|
|
|
}
|
|
|
|
|
2020-06-05 05:42:12 -04:00
|
|
|
Keys.onReturnPressed: if (enabled) clicked()
|
|
|
|
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
|
|
|
activeFocusOnTab: true
|
|
|
|
|
2019-08-20 17:41:24 -04:00
|
|
|
|
2019-08-21 15:45:13 -04:00
|
|
|
readonly property alias iconItem: contentItem.icon
|
|
|
|
readonly property alias label: contentItem.label
|
2019-08-20 17:41:24 -04:00
|
|
|
|
|
|
|
property color backgroundColor: theme.controls.button.background
|
2020-06-23 09:09:30 -04:00
|
|
|
property color focusLineColor:
|
|
|
|
Qt.colorEqual(icon.color, theme.icons.colorize) ?
|
|
|
|
theme.controls.button.focusedBorder :
|
|
|
|
icon.color
|
|
|
|
|
2019-11-11 09:12:31 -04:00
|
|
|
property bool disableWhileLoading: true
|
2019-08-20 17:41:24 -04:00
|
|
|
property bool loading: false
|
|
|
|
property bool circle: false
|
2019-12-02 04:40:01 -04:00
|
|
|
property bool padded: true
|
2020-03-07 11:11:32 -04:00
|
|
|
property bool enableRadius: false
|
2019-08-20 17:41:24 -04:00
|
|
|
|
2019-08-22 09:27:26 -04:00
|
|
|
property HToolTip toolTip: HToolTip {
|
|
|
|
id: toolTip
|
|
|
|
visible: text && hovered
|
|
|
|
}
|
|
|
|
|
2019-08-20 17:41:24 -04:00
|
|
|
|
2019-12-11 11:44:59 -04:00
|
|
|
Binding on enabled {
|
2019-11-22 04:50:40 -04:00
|
|
|
when: disableWhileLoading && button.loading
|
2019-11-11 09:12:31 -04:00
|
|
|
value: false
|
|
|
|
}
|
2019-08-20 17:41:24 -04:00
|
|
|
}
|