status-desktop/ui/app/AppLayouts/Profile/Sections/DevicesContainer.qml

226 lines
7.1 KiB
QML
Raw Normal View History

2020-07-03 16:54:27 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../../../../imports"
import "../../../../shared"
Item {
id: syncContainer
2020-07-03 19:46:06 +00:00
property bool isSyncing: false
2020-07-03 16:54:27 +00:00
width: 200
height: 200
Layout.fillHeight: true
Layout.fillWidth: true
StyledText {
id: sectionTitle
//% "Devices"
text: qsTrId("devices")
2020-07-03 16:54:27 +00:00
anchors.left: parent.left
anchors.leftMargin: 24
anchors.top: parent.top
anchors.topMargin: 24
font.weight: Font.Bold
font.pixelSize: 20
}
Item {
id: firstTimeSetup
anchors.left: syncContainer.left
2020-07-03 19:46:06 +00:00
anchors.leftMargin: Style.current.padding
2020-07-03 16:54:27 +00:00
anchors.top: sectionTitle.bottom
2020-07-03 19:46:06 +00:00
anchors.topMargin: Style.current.padding
2020-07-03 16:54:27 +00:00
anchors.right: syncContainer.right
2020-07-03 19:46:06 +00:00
anchors.rightMargin: Style.current.padding
2020-07-03 16:54:27 +00:00
visible: !profileModel.deviceSetup
StyledText {
id: deviceNameLbl
//% "Please set a name for your device."
text: qsTrId("pairing-please-set-a-name")
2020-07-03 16:54:27 +00:00
font.pixelSize: 14
}
Input {
id: deviceNameTxt
//% "Specify a name"
placeholderText: qsTrId("specify-name")
2020-07-03 16:54:27 +00:00
anchors.top: deviceNameLbl.bottom
2020-07-03 19:46:06 +00:00
anchors.topMargin: Style.current.padding
2020-07-03 16:54:27 +00:00
}
StyledButton {
anchors.top: deviceNameTxt.bottom
anchors.topMargin: 10
anchors.right: deviceNameTxt.right
//% "Continue"
label: qsTrId("continue")
2020-07-03 16:54:27 +00:00
disabled: deviceNameTxt.text === ""
onClicked : profileModel.setDeviceName(deviceNameTxt.text.trim())
}
}
2020-07-03 19:46:06 +00:00
Item {
2020-07-04 00:42:44 +00:00
id: advertiseDeviceItem
2020-07-03 19:46:06 +00:00
anchors.left: syncContainer.left
anchors.leftMargin: Style.current.padding
anchors.top: sectionTitle.bottom
anchors.topMargin: Style.current.padding
anchors.right: syncContainer.right
anchors.rightMargin: Style.current.padding
visible: profileModel.deviceSetup
2020-07-04 00:42:44 +00:00
height: childrenRect.height
2020-07-03 19:46:06 +00:00
Rectangle {
id: advertiseDevice
height: childrenRect.height
width: 500
anchors.left: parent.left
anchors.right: parent.right
SVGImage {
id: advertiseImg
height: 32
width: 32
anchors.left: parent.left
fillMode: Image.PreserveAspectFit
source: "/app/img/messageActive.svg"
}
StyledText {
id: advertiseDeviceTitle
//% "Advertise device"
text: qsTrId("pair-this-device")
2020-07-03 19:46:06 +00:00
font.pixelSize: 18
font.weight: Font.Bold
color: Style.current.blue
anchors.left: advertiseImg.right
anchors.leftMargin: Style.current.padding
}
StyledText {
id: advertiseDeviceDesk
//% "Pair your devices to sync contacts and chats between them"
text: qsTrId("pair-this-device-description")
2020-07-03 19:46:06 +00:00
font.pixelSize: 14
anchors.top: advertiseDeviceTitle.bottom
anchors.topMargin: 6
anchors.left: advertiseImg.right
anchors.leftMargin: Style.current.padding
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: profileModel.advertiseDevice()
}
}
StyledText {
anchors.top: advertiseDevice.bottom
anchors.topMargin: Style.current.padding
//% "Learn more"
text: qsTrId("learn-more")
2020-07-03 19:46:06 +00:00
font.pixelSize: 16
color: Style.current.blue
anchors.left: parent.left
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
2020-07-14 09:39:14 +00:00
onClicked: Qt.openUrlExternally("https://status.im/user_guides/pairing_devices.html")
2020-07-03 19:46:06 +00:00
}
}
}
2020-07-04 00:42:44 +00:00
Item {
id: deviceListItem
anchors.left: syncContainer.left
anchors.leftMargin: Style.current.padding
anchors.top: advertiseDeviceItem.bottom
anchors.topMargin: Style.current.padding * 2
anchors.bottom: syncAllBtn.top
anchors.bottomMargin: Style.current.padding
anchors.right: syncContainer.right
anchors.rightMargin: Style.current.padding
visible: profileModel.deviceSetup
StyledText {
id: deviceListLbl
text: qsTr("Paired devices")
font.pixelSize: 16
font.weight: Font.Bold
}
ListView {
id: listView
anchors.bottom: parent.bottom
anchors.top: deviceListLbl.bottom
anchors.topMargin: Style.current.padding
spacing: 5
anchors.right: syncContainer.right
anchors.left: syncContainer.left
delegate: Item {
height: childrenRect.height
SVGImage {
id: enabledIcon
source: "/app/img/" + (devicePairedSwitch.checked ? "messageActive.svg" : "message.svg")
height: 24
width: 24
}
StyledText {
id: deviceItemLbl
text: {
let deviceId = model.installationId.split("-")[0].substr(0, 5)
let labelText = `${model.name || qsTr("No info")} (${model.isUserDevice ? qsTr("you") + ", ": ""}${deviceId})`;
return labelText;
}
elide: Text.ElideRight
font.pixelSize: 14
anchors.left: enabledIcon.right
anchors.leftMargin: Style.current.padding
}
Switch {
id: devicePairedSwitch
visible: !model.isUserDevice
checked: model.isEnabled
anchors.left: deviceItemLbl.right
anchors.leftMargin: Style.current.padding
anchors.top: deviceItemLbl.top
onClicked: profileModel.enableInstallation(model.installationId, devicePairedSwitch)
}
}
model: profileModel.deviceList
}
}
2020-07-03 16:54:27 +00:00
StyledButton {
2020-07-03 19:46:06 +00:00
id: syncAllBtn
2020-07-03 16:54:27 +00:00
anchors.bottom: syncContainer.bottom
2020-07-03 19:46:06 +00:00
anchors.bottomMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter
label: isSyncing ?
//% "Syncing..."
qsTrId("sync-in-progress") :
//% "Sync all devices"
qsTrId("sync-all-devices")
2020-07-03 19:46:06 +00:00
disabled: isSyncing
2020-07-03 16:54:27 +00:00
onClicked : {
2020-07-03 19:46:06 +00:00
isSyncing = true;
profileModel.syncAllDevices()
// Currently we don't know how long it takes, so we just disable for 10s, to avoid spamming
timer.setTimeout(function(){
isSyncing = false
}, 10000);
}
}
Timer {
id: timer
2020-07-03 16:54:27 +00:00
}
}