Files
amnezia-client/client/ui/qml/Components/ConnectButton.qml
T

87 lines
2.0 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2023-05-14 21:11:19 +08:00
import ConnectionState 1.0
Button {
id: root
2023-06-05 22:40:35 +08:00
Connections {
target: ConnectionController
function onConnectionErrorOccurred(errorMessage) {
PageController.showErrorMessage(errorMessage)
}
}
text: ConnectionController.connectionStateText
2023-05-14 21:11:19 +08:00
2023-06-05 22:40:35 +08:00
background: Item {
clip: true
2023-06-05 22:40:35 +08:00
implicitHeight: border.implicitHeight
implicitWidth: border.implicitWidth
2023-06-05 22:40:35 +08:00
Image {
id: border
source: {
if (ConnectionController.isConnectionInProgress) {
return "/images/connectionProgress.svg"
} else if (ConnectionController.isConnected) {
return "/images/connectionOff.svg"
} else {
return "/images/connectionOn.svg"
}
}
2023-06-05 22:40:35 +08:00
RotationAnimator {
id: connectionProccess
target: border
running: ConnectionController.isConnectionInProgress
2023-06-05 22:40:35 +08:00
from: 0
to: 360
loops: Animation.Infinite
duration: 1250
}
Behavior on source {
PropertyAnimation { duration: 200 }
}
2023-05-14 21:11:19 +08:00
}
2023-06-05 22:40:35 +08:00
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
enabled: false
2023-05-14 21:11:19 +08:00
}
}
contentItem: Text {
height: 24
font.family: "PT Root UI VF"
font.weight: 700
font.pixelSize: 20
color: "#D7D8DB"
text: root.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: {
if (ConnectionController.isConnectionInProgress) {
ConnectionController.closeConnection()
} else if (ConnectionController.isConnected) {
ConnectionController.closeConnection()
} else {
ConnectionController.openConnection()
2023-05-14 21:11:19 +08:00
}
}
}