2020-07-03 16:54:27 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-04-13 15:12:39 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2020-07-03 16:54:27 +00:00
|
|
|
import "../../../../shared"
|
2021-10-14 11:07:19 +00:00
|
|
|
import "../../../../shared/controls"
|
2021-10-14 12:14:11 +00:00
|
|
|
import "../../../../shared/panels"
|
2020-09-17 16:42:59 +00:00
|
|
|
import "../../../../shared/status"
|
2020-07-03 16:54:27 +00:00
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
id: root
|
2020-07-03 19:46:06 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
property var store
|
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
|
2021-04-08 15:44:58 +00:00
|
|
|
clip: true
|
2020-07-03 16:54:27 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: firstTimeSetup
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.left: root.left
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-03-24 17:44:35 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 24
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.right: root.right
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-10-06 09:16:39 +00:00
|
|
|
visible: !root.store.devicesSetup
|
2020-07-03 16:54:27 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-03 16:54:27 +00:00
|
|
|
id: deviceNameLbl
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "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
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "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
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
// TODO: replace with StatusQ component
|
2021-01-28 11:04:10 +00:00
|
|
|
StatusButton {
|
2020-07-03 16:54:27 +00:00
|
|
|
anchors.top: deviceNameTxt.bottom
|
|
|
|
anchors.topMargin: 10
|
|
|
|
anchors.right: deviceNameTxt.right
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Continue"
|
2021-01-28 11:04:10 +00:00
|
|
|
text: qsTrId("continue")
|
|
|
|
enabled: deviceNameTxt.text !== ""
|
2021-10-06 09:16:39 +00:00
|
|
|
onClicked : root.store.setDeviceName(deviceNameTxt.text.trim())
|
2020-07-03 16:54:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:46:06 +00:00
|
|
|
Item {
|
2020-07-04 00:42:44 +00:00
|
|
|
id: advertiseDeviceItem
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.left: root.left
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-03-30 19:08:25 +00:00
|
|
|
anchors.top: parent.top
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.right: root.right
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-10-06 09:16:39 +00:00
|
|
|
visible: root.store.devicesSetup
|
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
|
2020-07-14 22:57:49 +00:00
|
|
|
color: Style.current.transparent
|
2020-07-03 19:46:06 +00:00
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: advertiseImg
|
|
|
|
height: 32
|
|
|
|
width: 32
|
|
|
|
anchors.left: parent.left
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("messageActive")
|
2021-04-13 15:12:39 +00:00
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.blue
|
|
|
|
}
|
2020-07-03 19:46:06 +00:00
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-03 19:46:06 +00:00
|
|
|
id: advertiseDeviceTitle
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Advertise device"
|
|
|
|
text: qsTrId("pair-this-device")
|
2020-07-03 19:46:06 +00:00
|
|
|
font.pixelSize: 18
|
|
|
|
font.weight: Font.Bold
|
2021-10-06 09:16:39 +00:00
|
|
|
color: Theme.palette.primaryColor1
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.left: advertiseImg.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-03 19:46:06 +00:00
|
|
|
id: advertiseDeviceDesk
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "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
|
2021-10-06 09:16:39 +00:00
|
|
|
onClicked: root.store.advertiseDevice()
|
2020-07-03 19:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.top: advertiseDevice.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Learn more"
|
|
|
|
text: qsTrId("learn-more")
|
2020-07-03 19:46:06 +00:00
|
|
|
font.pixelSize: 16
|
2021-10-06 09:16:39 +00:00
|
|
|
color: Theme.palette.primaryColor1
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
2020-12-29 20:33:54 +00:00
|
|
|
onClicked: appMain.openLink("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
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.left: root.left
|
2020-07-04 00:42:44 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: advertiseDeviceItem.bottom
|
|
|
|
anchors.topMargin: Style.current.padding * 2
|
|
|
|
anchors.bottom: syncAllBtn.top
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.right: root.right
|
2020-07-04 00:42:44 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-10-06 09:16:39 +00:00
|
|
|
visible: root.store.devicesSetup
|
2020-07-04 00:42:44 +00:00
|
|
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-04 00:42:44 +00:00
|
|
|
id: deviceListLbl
|
2020-07-16 15:20:29 +00:00
|
|
|
//% "Paired devices"
|
|
|
|
text: qsTrId("paired-devices")
|
2020-07-04 00:42:44 +00:00
|
|
|
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
|
2020-07-21 21:03:22 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2021-10-06 09:16:39 +00:00
|
|
|
// TODO: replace with StatusQ component
|
2020-07-04 00:42:44 +00:00
|
|
|
delegate: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
SVGImage {
|
|
|
|
id: enabledIcon
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg(devicePairedSwitch.checked ? "messageActive" : "message")
|
2020-07-04 00:42:44 +00:00
|
|
|
height: 24
|
|
|
|
width: 24
|
2021-04-13 15:12:39 +00:00
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
|
|
|
color: Style.current.blue
|
|
|
|
}
|
2020-07-04 00:42:44 +00:00
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2020-07-04 00:42:44 +00:00
|
|
|
id: deviceItemLbl
|
|
|
|
text: {
|
|
|
|
let deviceId = model.installationId.split("-")[0].substr(0, 5)
|
2020-07-16 15:20:29 +00:00
|
|
|
//% "No info"
|
2021-02-18 16:36:05 +00:00
|
|
|
let labelText = `${model.name || qsTrId("pairing-no-info")} ` +
|
|
|
|
//% "you"
|
|
|
|
`(${model.isUserDevice ? qsTrId("you") + ", ": ""}${deviceId})`;
|
2020-07-04 00:42:44 +00:00
|
|
|
return labelText;
|
|
|
|
}
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: 14
|
|
|
|
anchors.left: enabledIcon.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
}
|
2020-09-17 16:42:59 +00:00
|
|
|
StatusSwitch {
|
2020-07-04 00:42:44 +00:00
|
|
|
id: devicePairedSwitch
|
|
|
|
visible: !model.isUserDevice
|
|
|
|
checked: model.isEnabled
|
|
|
|
anchors.left: deviceItemLbl.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: deviceItemLbl.top
|
2021-10-06 09:16:39 +00:00
|
|
|
onClicked: root.store.enableDeviceInstallation(model.installationId, devicePairedSwitch)
|
2020-07-04 00:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
model: root.store.devicesList
|
2020-07-04 00:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
// TODO: replace with StatusQ component
|
2021-01-28 11:04:10 +00:00
|
|
|
StatusButton {
|
2020-07-03 19:46:06 +00:00
|
|
|
id: syncAllBtn
|
2021-10-06 09:16:39 +00:00
|
|
|
anchors.bottom: root.bottom
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-01-28 11:04:10 +00:00
|
|
|
text: isSyncing ?
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Syncing..."
|
|
|
|
qsTrId("sync-in-progress") :
|
|
|
|
//% "Sync all devices"
|
|
|
|
qsTrId("sync-all-devices")
|
2021-01-28 11:04:10 +00:00
|
|
|
enabled: !isSyncing
|
2020-07-03 16:54:27 +00:00
|
|
|
onClicked : {
|
2020-07-03 19:46:06 +00:00
|
|
|
isSyncing = true;
|
2021-10-06 09:16:39 +00:00
|
|
|
root.store.syncAllDevices()
|
2020-07-03 19:46:06 +00:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|