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
|
2021-10-20 10:03:09 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
2020-07-03 16:54:27 +00:00
|
|
|
|
2021-12-30 12:39:47 +00:00
|
|
|
import "../stores"
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2021-10-06 09:16:39 +00:00
|
|
|
id: root
|
2020-07-03 19:46:06 +00:00
|
|
|
|
2021-12-30 12:39:47 +00:00
|
|
|
property DevicesStore devicesStore
|
2021-12-27 11:04:10 +00:00
|
|
|
|
2020-07-03 19:46:06 +00:00
|
|
|
property bool isSyncing: false
|
|
|
|
|
2020-07-03 16:54:27 +00:00
|
|
|
Item {
|
2022-05-07 11:45:15 +00:00
|
|
|
width: root.contentWidth
|
2022-05-11 19:29:33 +00:00
|
|
|
height: parent.height
|
2020-07-03 16:54:27 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Item {
|
|
|
|
id: firstTimeSetup
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.left: parent.left
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: parent.top
|
2020-07-03 19:46:06 +00:00
|
|
|
anchors.right: parent.right
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
visible: !root.devicesStore.isDeviceSetup
|
|
|
|
height: visible ? childrenRect.height : 0
|
2020-07-03 19:46:06 +00:00
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: deviceNameLbl
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Please set a name for your device.")
|
2020-07-03 19:46:06 +00:00
|
|
|
font.pixelSize: 14
|
2021-11-01 09:19:54 +00:00
|
|
|
color: Theme.palette.directColor1
|
2020-07-03 19:46:06 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Input {
|
|
|
|
id: deviceNameTxt
|
2022-07-25 13:22:09 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.top: deviceNameLbl.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-07-25 13:22:09 +00:00
|
|
|
placeholderText: qsTr("Specify a name")
|
2020-07-03 19:46:06 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// TODO: replace with StatusQ component
|
|
|
|
StatusButton {
|
|
|
|
anchors.top: deviceNameTxt.bottom
|
|
|
|
anchors.topMargin: 10
|
|
|
|
anchors.right: deviceNameTxt.right
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Continue")
|
2022-05-07 11:45:15 +00:00
|
|
|
enabled: deviceNameTxt.text !== ""
|
|
|
|
onClicked : root.devicesStore.setName(deviceNameTxt.text.trim())
|
2020-07-03 19:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-04 00:42:44 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Item {
|
|
|
|
id: advertiseDeviceItem
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: firstTimeSetup.visible ? firstTimeSetup.bottom : parent.top
|
2020-07-04 00:42:44 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2020-07-21 21:03:22 +00:00
|
|
|
anchors.right: parent.right
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
visible: root.devicesStore.isDeviceSetup
|
|
|
|
height: visible ? childrenRect.height : 0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: advertiseDevice
|
2020-07-04 00:42:44 +00:00
|
|
|
height: childrenRect.height
|
2022-05-07 11:45:15 +00:00
|
|
|
width: 500
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
color: Style.current.transparent
|
|
|
|
|
2020-07-04 00:42:44 +00:00
|
|
|
SVGImage {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: advertiseImg
|
|
|
|
height: 32
|
|
|
|
width: 32
|
|
|
|
anchors.left: parent.left
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: Style.svg("messageActive")
|
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
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: advertiseDeviceTitle
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Advertise device")
|
2022-05-07 11:45:15 +00:00
|
|
|
font.pixelSize: 18
|
|
|
|
font.weight: Font.Bold
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
anchors.left: advertiseImg.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
StatusBaseText {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: advertiseDeviceDesk
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Pair your devices to sync contacts and chats between them")
|
2020-07-04 00:42:44 +00:00
|
|
|
font.pixelSize: 14
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.top: advertiseDeviceTitle.bottom
|
|
|
|
anchors.topMargin: 6
|
|
|
|
anchors.left: advertiseImg.right
|
2020-07-04 00:42:44 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-11-01 09:19:54 +00:00
|
|
|
color: Theme.palette.directColor1
|
2020-07-04 00:42:44 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: root.devicesStore.advertise()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.top: advertiseDevice.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Learn more")
|
2022-05-07 11:45:15 +00:00
|
|
|
font.pixelSize: 16
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
anchors.left: parent.left
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: Global.openLink("https://status.im/user_guides/pairing_devices.html")
|
2020-07-04 00:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Item {
|
|
|
|
id: deviceListItem
|
2022-05-11 19:29:33 +00:00
|
|
|
anchors.left: parent.left
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: advertiseDeviceItem.visible ? advertiseDeviceItem.bottom : parent.top
|
|
|
|
anchors.topMargin: Style.current.padding * 2
|
2022-05-11 19:29:33 +00:00
|
|
|
anchors.right: parent.right
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2022-05-11 19:29:33 +00:00
|
|
|
height: childrenRect.height
|
2022-05-07 11:45:15 +00:00
|
|
|
visible: root.devicesStore.isDeviceSetup
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: deviceListLbl
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Paired devices")
|
2022-05-07 11:45:15 +00:00
|
|
|
font.pixelSize: 16
|
|
|
|
font.weight: Font.Bold
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: listView
|
|
|
|
anchors.top: deviceListLbl.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-05-11 19:29:33 +00:00
|
|
|
// This is a placeholder fix to the display. This whole page will be redesigned
|
|
|
|
height: 300
|
2022-05-07 11:45:15 +00:00
|
|
|
spacing: 5
|
2022-05-11 19:29:33 +00:00
|
|
|
width: parent.width
|
2022-05-07 11:45:15 +00:00
|
|
|
// TODO: replace with StatusQ component
|
|
|
|
delegate: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
SVGImage {
|
|
|
|
id: enabledIcon
|
2022-05-11 19:29:33 +00:00
|
|
|
source: Style.svg("messageActive")
|
2022-05-07 11:45:15 +00:00
|
|
|
height: 24
|
|
|
|
width: 24
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
source: parent
|
2022-05-11 19:29:33 +00:00
|
|
|
color: devicePairedSwitch.checked ? Style.current.blue : Style.current.darkGrey
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: deviceItemLbl
|
|
|
|
text: {
|
|
|
|
let deviceId = model.installationId.split("-")[0].substr(0, 5)
|
2022-04-04 11:26:30 +00:00
|
|
|
let labelText = `${model.name || qsTr("No info")} ` +
|
|
|
|
`(${model.isCurrentDevice ? qsTr("you") + ", ": ""}${deviceId})`;
|
2022-05-07 11:45:15 +00:00
|
|
|
return labelText;
|
|
|
|
}
|
|
|
|
elide: Text.ElideRight
|
|
|
|
font.pixelSize: 14
|
|
|
|
anchors.left: enabledIcon.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
StatusSwitch {
|
|
|
|
id: devicePairedSwitch
|
|
|
|
visible: !model.isCurrentDevice
|
|
|
|
checked: model.enabled
|
|
|
|
anchors.left: deviceItemLbl.right
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: deviceItemLbl.top
|
|
|
|
onClicked: root.devicesStore.enableDevice(model.installationId, devicePairedSwitch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
model: root.devicesStore.devicesModel
|
|
|
|
}
|
2022-05-11 19:29:33 +00:00
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: syncAllBtn
|
|
|
|
anchors.top: listView.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
// anchors.bottom: parent.bottom
|
|
|
|
// anchors.bottomMargin: Style.current.padding
|
|
|
|
anchors.horizontalCenter: listView.horizontalCenter
|
|
|
|
|
|
|
|
text: isSyncing ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Syncing...") :
|
|
|
|
qsTr("Sync all devices")
|
2022-05-11 19:29:33 +00:00
|
|
|
enabled: !isSyncing
|
|
|
|
onClicked : {
|
|
|
|
isSyncing = true;
|
|
|
|
root.devicesStore.syncAll()
|
|
|
|
// Currently we don't know how long it takes, so we just disable for 10s, to avoid spamming
|
|
|
|
timer.setTimeout(function(){
|
|
|
|
isSyncing = false
|
|
|
|
}, 10000);
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-03 16:54:27 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
}
|
|
|
|
}
|
2020-07-03 16:54:27 +00:00
|
|
|
}
|