2023-10-02 09:20:35 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-06-03 11:26:02 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2018-06-26 13:53:07 +00:00
|
|
|
|
2020-12-01 12:57:32 +00:00
|
|
|
import QtQuick
|
2021-09-14 08:36:23 +00:00
|
|
|
import QtQuick.Controls
|
2018-06-26 13:53:07 +00:00
|
|
|
|
2023-10-31 13:48:04 +00:00
|
|
|
RoundButton {
|
2018-06-26 13:53:07 +00:00
|
|
|
id: button
|
2023-10-31 13:48:04 +00:00
|
|
|
implicitWidth: 38
|
|
|
|
implicitHeight: 38
|
|
|
|
radius: buttonRadius
|
2023-10-02 09:20:35 +00:00
|
|
|
|
2018-06-26 13:53:07 +00:00
|
|
|
property bool dimmable: false
|
|
|
|
property bool dimmed: false
|
2023-10-31 13:48:04 +00:00
|
|
|
readonly property int fontSize: 22
|
|
|
|
readonly property int buttonRadius: 8
|
|
|
|
property color textColor: "#FFFFFF"
|
|
|
|
property color accentColor: "#2CDE85"
|
|
|
|
readonly property color backgroundColor: "#222222"
|
|
|
|
readonly property color borderColor: "#A9A9A9"
|
|
|
|
|
|
|
|
function getBackgroundColor() {
|
|
|
|
if (button.dimmable && button.dimmed)
|
|
|
|
return backgroundColor
|
|
|
|
if (button.pressed)
|
|
|
|
return accentColor
|
|
|
|
return backgroundColor
|
|
|
|
}
|
|
|
|
|
|
|
|
function getBorderColor() {
|
|
|
|
if (button.dimmable && button.dimmed)
|
|
|
|
return borderColor
|
|
|
|
if (button.pressed || button.hovered)
|
|
|
|
return accentColor
|
|
|
|
return borderColor
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTextColor() {
|
|
|
|
if (button.dimmable && button.dimmed)
|
|
|
|
return Qt.darker(textColor)
|
|
|
|
if (button.pressed)
|
|
|
|
return backgroundColor
|
|
|
|
if (button.hovered)
|
|
|
|
return accentColor
|
|
|
|
return textColor
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
radius: button.buttonRadius
|
|
|
|
color: getBackgroundColor()
|
|
|
|
border.color: getBorderColor()
|
|
|
|
}
|
2018-06-26 13:53:07 +00:00
|
|
|
|
2021-09-14 08:36:23 +00:00
|
|
|
contentItem: Text {
|
|
|
|
text: button.text
|
2023-10-31 13:48:04 +00:00
|
|
|
font.pixelSize: button.fontSize
|
2022-11-10 14:06:08 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2023-10-31 13:48:04 +00:00
|
|
|
color: getTextColor()
|
2021-09-14 08:36:23 +00:00
|
|
|
Behavior on color {
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 120
|
|
|
|
easing.type: Easing.OutElastic
|
|
|
|
}
|
|
|
|
}
|
2018-06-26 13:53:07 +00:00
|
|
|
}
|
|
|
|
}
|