Files

192 lines
5.5 KiB
QML
Raw Permalink Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2023-07-04 09:58:19 +09:00
import QtQuick.Shapes
import Qt5Compat.GraphicalEffects
2023-05-14 21:11:19 +08:00
import ConnectionState 1.0
import PageEnum 1.0
2024-07-07 13:42:38 +03:00
import Style 1.0
2023-05-14 21:11:19 +08:00
Button {
id: root
property string defaultButtonColor: AmneziaStyle.color.paleGray
property string progressButtonColor: AmneziaStyle.color.paleGray
property string connectedButtonColor: AmneziaStyle.color.goldenApricot
2024-09-09 14:36:33 +03:00
property bool buttonActiveFocus: activeFocus && (Qt.platform.os !== "android" || SettingsController.isOnTv())
2023-07-04 09:58:19 +09:00
2024-12-31 04:16:52 +01:00
property bool isFocusable: true
Keys.onTabPressed: {
FocusController.nextKeyTabItem()
}
Keys.onBacktabPressed: {
FocusController.previousKeyTabItem()
}
Keys.onUpPressed: {
FocusController.nextKeyUpItem()
}
Keys.onDownPressed: {
FocusController.nextKeyDownItem()
}
Keys.onLeftPressed: {
FocusController.nextKeyLeftItem()
}
Keys.onRightPressed: {
FocusController.nextKeyRightItem()
}
2023-07-04 09:58:19 +09:00
implicitWidth: 190
implicitHeight: 190
text: ConnectionController.connectionStateText
2023-06-05 22:40:35 +08:00
Connections {
target: ConnectionController
function onPreparingConfig() {
PageController.showNotificationMessage(qsTr("Unable to disconnect during configuration preparation"))
2023-06-05 22:40:35 +08:00
}
}
2023-07-04 09:58:19 +09:00
// enabled: !ConnectionController.isConnectionInProgress
2023-06-05 22:40:35 +08:00
background: Item {
2023-07-04 09:58:19 +09:00
implicitWidth: parent.width
implicitHeight: parent.height
transformOrigin: Item.Center
Shape {
id: backgroundCircle
width: parent.implicitWidth
height: parent.implicitHeight
anchors.bottom: parent.bottom
anchors.right: parent.right
layer.enabled: true
layer.samples: 4
layer.smooth: true
2023-07-04 09:58:19 +09:00
layer.effect: DropShadow {
anchors.fill: backgroundCircle
horizontalOffset: 0
verticalOffset: 0
radius: 10
samples: 25
2024-09-09 14:36:33 +03:00
color: root.buttonActiveFocus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.goldenApricot
2023-07-04 09:58:19 +09:00
source: backgroundCircle
}
2024-04-18 17:54:55 +04:00
ShapePath {
2024-07-07 13:42:38 +03:00
fillColor: AmneziaStyle.color.transparent
strokeColor: AmneziaStyle.color.paleGray
2024-09-09 14:36:33 +03:00
strokeWidth: root.buttonActiveFocus ? 1 : 0
2024-04-18 17:54:55 +04:00
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: backgroundCircle.width / 2
centerY: backgroundCircle.height / 2
radiusX: 94
radiusY: 94
startAngle: 0
sweepAngle: 360
}
}
2023-07-04 09:58:19 +09:00
ShapePath {
2024-07-07 13:42:38 +03:00
fillColor: AmneziaStyle.color.transparent
2023-07-04 09:58:19 +09:00
strokeColor: {
if (ConnectionController.isConnectionInProgress) {
return AmneziaStyle.color.darkCharcoal
2023-07-04 09:58:19 +09:00
} else if (ConnectionController.isConnected) {
return connectedButtonColor
} else {
return defaultButtonColor
}
}
2024-09-09 14:36:33 +03:00
strokeWidth: root.buttonActiveFocus ? 2 : 3
2023-07-04 09:58:19 +09:00
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: backgroundCircle.width / 2
centerY: backgroundCircle.height / 2
2024-09-09 14:36:33 +03:00
radiusX: 93 - (root.buttonActiveFocus ? 2 : 0)
radiusY: 93 - (root.buttonActiveFocus ? 2 : 0)
2023-07-04 09:58:19 +09:00
startAngle: 0
sweepAngle: 360
}
}
2023-07-04 09:58:19 +09:00
MouseArea {
anchors.fill: parent
2023-07-04 09:58:19 +09:00
cursorShape: Qt.PointingHandCursor
enabled: false
}
}
Shape {
id: shape
width: parent.implicitWidth
height: parent.implicitHeight
anchors.bottom: parent.bottom
anchors.right: parent.right
layer.enabled: true
layer.samples: 4
visible: ConnectionController.isConnectionInProgress
ShapePath {
2024-07-07 13:42:38 +03:00
fillColor: AmneziaStyle.color.transparent
strokeColor: AmneziaStyle.color.paleGray
2023-07-04 09:58:19 +09:00
strokeWidth: 3
capStyle: ShapePath.RoundCap
PathAngleArc {
centerX: shape.width / 2
centerY: shape.height / 2
radiusX: 93
radiusY: 93
startAngle: 245
sweepAngle: -180
}
}
2023-06-05 22:40:35 +08:00
RotationAnimator {
2023-07-04 09:58:19 +09:00
target: shape
running: ConnectionController.isConnectionInProgress
2023-06-05 22:40:35 +08:00
from: 0
to: 360
loops: Animation.Infinite
2023-07-04 09:58:19 +09:00
duration: 1000
2023-06-05 22:40:35 +08:00
}
2023-05-14 21:11:19 +08:00
}
}
contentItem: Text {
height: 24
font.family: "PT Root UI VF"
font.weight: 700
font.pixelSize: 20
2023-07-04 09:58:19 +09:00
color: ConnectionController.isConnected ? connectedButtonColor : defaultButtonColor
text: root.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: {
2024-02-19 19:54:15 +05:00
ServersModel.setProcessedServerIndex(ServersModel.defaultIndex)
ConnectionController.connectButtonClicked()
}
2024-04-18 17:54:55 +04:00
Keys.onEnterPressed: this.clicked()
Keys.onReturnPressed: this.clicked()
}