feat: Advertise device
This commit is contained in:
parent
a4b9eedd5e
commit
5ee3c6938f
|
@ -124,5 +124,7 @@ QtObject:
|
||||||
self.deviceSetupChanged()
|
self.deviceSetupChanged()
|
||||||
|
|
||||||
proc syncAllDevices*(self: ProfileView) {.slot.} =
|
proc syncAllDevices*(self: ProfileView) {.slot.} =
|
||||||
discard
|
devices.syncAllDevices()
|
||||||
#devices.syncAllDevices()
|
|
||||||
|
proc advertiseDevice*(self: ProfileView) {.slot.} =
|
||||||
|
devices.advertise()
|
||||||
|
|
|
@ -19,4 +19,7 @@ proc isDeviceSetup*():bool =
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
proc syncAllDevices*() =
|
proc syncAllDevices*() =
|
||||||
discard
|
discard syncDevices()
|
||||||
|
|
||||||
|
proc advertise*() =
|
||||||
|
discard sendPairInstallation()
|
||||||
|
|
|
@ -6,4 +6,13 @@ proc setInstallationMetadata*(installationId: string, deviceName: string, device
|
||||||
|
|
||||||
proc getOurInstallations*(): string =
|
proc getOurInstallations*(): string =
|
||||||
result = callPrivateRPC("getOurInstallations".prefix, %* [])
|
result = callPrivateRPC("getOurInstallations".prefix, %* [])
|
||||||
echo result
|
|
||||||
|
proc syncDevices*(): string =
|
||||||
|
# These are not being used at the moment
|
||||||
|
let preferredName = ""
|
||||||
|
let photoPath = ""
|
||||||
|
result = callPrivateRPC("syncDevices".prefix, %* [preferredName, photoPath])
|
||||||
|
|
||||||
|
proc sendPairInstallation*(): string =
|
||||||
|
result = callPrivateRPC("sendPairInstallation".prefix)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ import "../../../../shared"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: syncContainer
|
id: syncContainer
|
||||||
|
|
||||||
|
property bool isSyncing: false
|
||||||
|
|
||||||
width: 200
|
width: 200
|
||||||
height: 200
|
height: 200
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
@ -25,11 +28,11 @@ Item {
|
||||||
Item {
|
Item {
|
||||||
id: firstTimeSetup
|
id: firstTimeSetup
|
||||||
anchors.left: syncContainer.left
|
anchors.left: syncContainer.left
|
||||||
anchors.leftMargin: Theme.padding
|
anchors.leftMargin: Style.current.padding
|
||||||
anchors.top: sectionTitle.bottom
|
anchors.top: sectionTitle.bottom
|
||||||
anchors.topMargin: Theme.padding
|
anchors.topMargin: Style.current.padding
|
||||||
anchors.right: syncContainer.right
|
anchors.right: syncContainer.right
|
||||||
anchors.rightMargin: Theme.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
visible: !profileModel.deviceSetup
|
visible: !profileModel.deviceSetup
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
@ -42,7 +45,7 @@ Item {
|
||||||
id: deviceNameTxt
|
id: deviceNameTxt
|
||||||
placeholderText: qsTr("Specify a name")
|
placeholderText: qsTr("Specify a name")
|
||||||
anchors.top: deviceNameLbl.bottom
|
anchors.top: deviceNameLbl.bottom
|
||||||
anchors.topMargin: Theme.padding
|
anchors.topMargin: Style.current.padding
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledButton {
|
StyledButton {
|
||||||
|
@ -56,13 +59,101 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
text: qsTr("Advertise device")
|
||||||
|
font.pixelSize: 18
|
||||||
|
font.weight: Font.Bold
|
||||||
|
color: Style.current.blue
|
||||||
|
anchors.left: advertiseImg.right
|
||||||
|
anchors.leftMargin: Style.current.padding
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: advertiseDeviceDesk
|
||||||
|
text: qsTr("Pair your devices to sync contacts and chats between them")
|
||||||
|
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
|
||||||
|
text: qsTr("Learn more")
|
||||||
|
font.pixelSize: 16
|
||||||
|
color: Style.current.blue
|
||||||
|
anchors.left: parent.left
|
||||||
|
MouseArea {
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: Qt.openUrlExternally("https://status.im/tutorials/pairing.html")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StyledButton {
|
StyledButton {
|
||||||
|
id: syncAllBtn
|
||||||
anchors.bottom: syncContainer.bottom
|
anchors.bottom: syncContainer.bottom
|
||||||
anchors.bottomMargin: Theme.padding
|
anchors.bottomMargin: Style.current.padding
|
||||||
anchors.right: deviceNameTxt.right
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
label: qsTr("Sync all devices")
|
label: isSyncing ? qsTr("Syncing...") : qsTr("Sync all devices")
|
||||||
|
disabled: isSyncing
|
||||||
onClicked : {
|
onClicked : {
|
||||||
console.log("TODO")
|
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
|
||||||
|
function setTimeout(cb, delayTime) {
|
||||||
|
timer.interval = delayTime;
|
||||||
|
timer.repeat = false;
|
||||||
|
timer.triggered.connect(cb);
|
||||||
|
timer.triggered.connect(function release () {
|
||||||
|
timer.triggered.disconnect(cb); // This is important
|
||||||
|
timer.triggered.disconnect(release); // This is important as well
|
||||||
|
});
|
||||||
|
timer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue