2020-08-25 11:15:18 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import QtQml 2.14
|
|
|
|
import "../../imports"
|
|
|
|
import "../../shared"
|
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
property string state: "default"
|
|
|
|
property string size: "large"
|
|
|
|
id: control
|
|
|
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
2020-08-28 11:39:23 +00:00
|
|
|
implicitWidth: {
|
|
|
|
switch(size) {
|
|
|
|
case "large":
|
|
|
|
return 44
|
|
|
|
case "medium":
|
|
|
|
return 40
|
|
|
|
case "small":
|
|
|
|
return 32
|
|
|
|
default:
|
|
|
|
return 44
|
|
|
|
}
|
|
|
|
}
|
|
|
|
implicitHeight: implicitWidth
|
2020-08-25 11:15:18 +00:00
|
|
|
|
|
|
|
enabled: state === "default"
|
|
|
|
|
2020-08-28 11:39:23 +00:00
|
|
|
icon.height: {
|
|
|
|
switch(size) {
|
|
|
|
case "large":
|
|
|
|
return 20
|
|
|
|
case "medium":
|
|
|
|
return 14
|
|
|
|
case "small":
|
|
|
|
return 12
|
|
|
|
default:
|
|
|
|
return 20
|
|
|
|
}
|
|
|
|
}
|
|
|
|
icon.width: {
|
|
|
|
switch(size) {
|
|
|
|
case "large":
|
|
|
|
return 20
|
|
|
|
case "medium":
|
|
|
|
return 14
|
|
|
|
case "small":
|
|
|
|
return 12
|
|
|
|
default:
|
|
|
|
return 20
|
|
|
|
}
|
|
|
|
}
|
|
|
|
icon.color: size === "medium" || size === "small" ?
|
2020-08-25 11:15:18 +00:00
|
|
|
!enabled ?
|
|
|
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
|
|
|
Style.current.roundedButtonSecondaryForegroundColor
|
|
|
|
:
|
|
|
|
!enabled ?
|
|
|
|
Style.current.roundedButtonDisabledForegroundColor :
|
|
|
|
Style.current.roundedButtonForegroundColor
|
|
|
|
|
2020-08-28 11:39:23 +00:00
|
|
|
onIconChanged: {
|
|
|
|
icon.source = icon.name ? "../../app/img/" + icon.name + ".svg" : ""
|
|
|
|
}
|
|
|
|
|
2020-08-25 11:15:18 +00:00
|
|
|
background: Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
color: {
|
2020-08-28 11:39:23 +00:00
|
|
|
if (size === "medium" || size == "small") {
|
2020-08-25 11:15:18 +00:00
|
|
|
return !enabled ? Style.current.roundedButtonSecondaryDisabledBackgroundColor :
|
|
|
|
hovered ? Style.current.roundedButtonSecondaryHoveredBackgroundColor :
|
|
|
|
Style.current.roundedButtonSecondaryBackgroundColor
|
|
|
|
}
|
|
|
|
return !enabled ?
|
|
|
|
Style.current.roundedButtonDisabledBackgroundColor :
|
|
|
|
Style.current.roundedButtonBackgroundColor
|
|
|
|
}
|
|
|
|
radius: parent.width / 2
|
|
|
|
}
|
|
|
|
|
2020-08-25 12:24:18 +00:00
|
|
|
contentItem: Item {
|
|
|
|
anchors.fill: parent
|
2020-08-25 11:15:18 +00:00
|
|
|
|
2020-08-25 12:24:18 +00:00
|
|
|
Image {
|
|
|
|
id: iconImg
|
|
|
|
visible: false
|
|
|
|
source: control.icon.source
|
|
|
|
height: control.icon.height
|
|
|
|
width: control.icon.width
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
|
|
|
|
2020-09-06 01:18:50 +00:00
|
|
|
Component {
|
|
|
|
id: loadingComponent
|
|
|
|
LoadingImage {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
2020-08-25 12:24:18 +00:00
|
|
|
id: loadingIndicator
|
2020-09-06 01:18:50 +00:00
|
|
|
active: control.state === "pending"
|
|
|
|
sourceComponent: loadingComponent
|
2020-08-28 11:39:23 +00:00
|
|
|
height: size === "small" ? 14 : 18
|
2020-08-25 12:24:18 +00:00
|
|
|
width: loadingIndicator.height
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2020-09-06 01:18:50 +00:00
|
|
|
|
2020-08-25 12:24:18 +00:00
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: iconImg
|
|
|
|
visible: control.state === "default"
|
|
|
|
source: iconImg
|
2020-08-28 11:39:23 +00:00
|
|
|
color: control.size === "medium" || control.size === "small" ?
|
2020-08-25 12:24:18 +00:00
|
|
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
|
|
|
Style.current.roundedButtonDisabledForegroundColor
|
|
|
|
antialiasing: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
id: loadingOverlay
|
|
|
|
visible: control.state === "pending"
|
|
|
|
anchors.fill: loadingIndicator
|
|
|
|
source: loadingIndicator
|
2020-08-28 11:39:23 +00:00
|
|
|
color: control.size === "medium" || control.size === "small" ?
|
2020-08-25 12:24:18 +00:00
|
|
|
Style.current.roundedButtonSecondaryDisabledForegroundColor :
|
|
|
|
Style.current.roundedButtonDisabledForegroundColor
|
|
|
|
antialiasing: true
|
|
|
|
|
2020-09-06 01:18:50 +00:00
|
|
|
|
2020-08-25 11:15:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onPressed: mouse.accepted = false
|
|
|
|
}
|
|
|
|
}
|