feat: set device name
This commit is contained in:
parent
49e76d17bf
commit
a4b9eedd5e
|
@ -7,6 +7,7 @@ import ../../status/libstatus/settings as status_settings
|
|||
import ../../status/profile/[profile, mailserver]
|
||||
import ../../status/[status, contacts]
|
||||
import ../../status/chat as status_chat
|
||||
import ../../status/devices
|
||||
import ../../status/chat/chat
|
||||
import view
|
||||
import chronicles
|
||||
|
@ -39,6 +40,7 @@ proc init*(self: ProfileController, account: Account) =
|
|||
profile.appearance = appearance
|
||||
profile.id = pubKey
|
||||
|
||||
self.view.setDeviceSetup(devices.isDeviceSetup())
|
||||
self.view.setNewProfile(profile)
|
||||
self.view.setMnemonic(mnemonic)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import ../../status/profile as status_profile
|
|||
import ../../status/contacts as status_contacts
|
||||
import ../../status/accounts as status_accounts
|
||||
import ../../status/status
|
||||
import ../../status/devices
|
||||
import ../../status/chat/chat
|
||||
import qrcode/qrcode
|
||||
|
||||
|
@ -15,6 +16,7 @@ QtObject:
|
|||
contactList*: ContactList
|
||||
mnemonic: string
|
||||
status*: Status
|
||||
isDeviceSetup: bool
|
||||
|
||||
proc setup(self: ProfileView) =
|
||||
self.QObject.setup
|
||||
|
@ -33,6 +35,7 @@ QtObject:
|
|||
result.contactList = newContactList()
|
||||
result.mnemonic = ""
|
||||
result.status = status
|
||||
result.isDeviceSetup = false
|
||||
result.setup
|
||||
|
||||
proc addMailServerToList*(self: ProfileView, mailserver: MailServer) =
|
||||
|
@ -101,3 +104,25 @@ QtObject:
|
|||
proc changeTheme*(self: ProfileView, theme: int) {.slot.} =
|
||||
self.profile.setAppearance(theme)
|
||||
self.status.saveSetting("appearance", $theme)
|
||||
|
||||
proc isDeviceSetup*(self: ProfileView): bool {.slot} =
|
||||
result = self.isDeviceSetup
|
||||
|
||||
proc deviceSetupChanged*(self: ProfileView) {.signal.}
|
||||
|
||||
proc setDeviceSetup*(self: ProfileView, isSetup: bool) {.slot} =
|
||||
self.isDeviceSetup = isSetup
|
||||
self.deviceSetupChanged()
|
||||
|
||||
QtProperty[bool] deviceSetup:
|
||||
read = isDeviceSetup
|
||||
notify = deviceSetupChanged
|
||||
|
||||
proc setDeviceName*(self: ProfileView, deviceName: string) {.slot.} =
|
||||
devices.setDeviceName(deviceName)
|
||||
self.isDeviceSetup = true
|
||||
self.deviceSetupChanged()
|
||||
|
||||
proc syncAllDevices*(self: ProfileView) {.slot.} =
|
||||
discard
|
||||
#devices.syncAllDevices()
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import system
|
||||
import libstatus/settings
|
||||
import libstatus/installations
|
||||
import json
|
||||
|
||||
proc setDeviceName*(name: string) =
|
||||
discard getSettings()
|
||||
discard setInstallationMetadata(getSetting[string]("installation-id", "", true), name, hostOs)
|
||||
|
||||
proc isDeviceSetup*():bool =
|
||||
discard getSettings()
|
||||
let installationId = getSetting[string]("installation-id", "", true)
|
||||
let responseResult = parseJSON($getOurInstallations())["result"]
|
||||
if responseResult.kind == JNull:
|
||||
return false
|
||||
for installation in responseResult:
|
||||
if installation["id"].getStr == installationId:
|
||||
return installation["metadata"].kind != JNull
|
||||
result = false
|
||||
|
||||
proc syncAllDevices*() =
|
||||
discard
|
|
@ -0,0 +1,9 @@
|
|||
import json, core, utils, system
|
||||
|
||||
proc setInstallationMetadata*(installationId: string, deviceName: string, deviceType: string): string =
|
||||
result = callPrivateRPC("setInstallationMetadata".prefix, %* [installationId, {"name": deviceName, "deviceType": deviceType}])
|
||||
# TODO: handle errors
|
||||
|
||||
proc getOurInstallations*(): string =
|
||||
result = callPrivateRPC("getOurInstallations".prefix, %* [])
|
||||
echo result
|
|
@ -101,6 +101,31 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
TabButton {
|
||||
id: devicesTabButton
|
||||
width: profileTabBar.w
|
||||
height: profileTabBar.btnheight
|
||||
visible: true
|
||||
text: ""
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
anchors.top: privacyTabButton.bottom
|
||||
anchors.topMargin: 0
|
||||
background: Rectangle {
|
||||
color: Theme.transparent
|
||||
}
|
||||
|
||||
StyledText {
|
||||
color: "#000000"
|
||||
text: qsTr("Devices")
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 72
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.weight: profileScreenButtons.currentIndex === 3 ? Font.Bold : Font.Medium
|
||||
font.pixelSize: 14
|
||||
}
|
||||
}
|
||||
|
||||
TabButton {
|
||||
id: syncTabButton
|
||||
width: profileTabBar.w
|
||||
|
@ -109,7 +134,7 @@ Rectangle {
|
|||
text: ""
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 0
|
||||
anchors.top: privacyTabButton.bottom
|
||||
anchors.top: devicesTabButton.bottom
|
||||
anchors.topMargin: 0
|
||||
background: Rectangle {
|
||||
color: Style.current.transparent
|
||||
|
|
|
@ -42,6 +42,8 @@ SplitView {
|
|||
|
||||
PrivacyContainer {}
|
||||
|
||||
DevicesContainer {}
|
||||
|
||||
SyncContainer {}
|
||||
|
||||
LanguageContainer {}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import "../../../../imports"
|
||||
import "../../../../shared"
|
||||
|
||||
Item {
|
||||
id: syncContainer
|
||||
width: 200
|
||||
height: 200
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
StyledText {
|
||||
id: sectionTitle
|
||||
text: qsTr("Devices")
|
||||
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
|
||||
anchors.leftMargin: Theme.padding
|
||||
anchors.top: sectionTitle.bottom
|
||||
anchors.topMargin: Theme.padding
|
||||
anchors.right: syncContainer.right
|
||||
anchors.rightMargin: Theme.padding
|
||||
visible: !profileModel.deviceSetup
|
||||
|
||||
StyledText {
|
||||
id: deviceNameLbl
|
||||
text: qsTr("Please set a name for your device.")
|
||||
font.pixelSize: 14
|
||||
}
|
||||
|
||||
Input {
|
||||
id: deviceNameTxt
|
||||
placeholderText: qsTr("Specify a name")
|
||||
anchors.top: deviceNameLbl.bottom
|
||||
anchors.topMargin: Theme.padding
|
||||
}
|
||||
|
||||
StyledButton {
|
||||
visible: !selectChatMembers
|
||||
anchors.top: deviceNameTxt.bottom
|
||||
anchors.topMargin: 10
|
||||
anchors.right: deviceNameTxt.right
|
||||
label: qsTr("Continue")
|
||||
disabled: deviceNameTxt.text === ""
|
||||
onClicked : profileModel.setDeviceName(deviceNameTxt.text.trim())
|
||||
}
|
||||
}
|
||||
|
||||
StyledButton {
|
||||
anchors.bottom: syncContainer.bottom
|
||||
anchors.bottomMargin: Theme.padding
|
||||
anchors.right: deviceNameTxt.right
|
||||
label: qsTr("Sync all devices")
|
||||
onClicked : {
|
||||
console.log("TODO")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ EnsContainer 1.0 EnsContainer.qml
|
|||
ContactsContainer 1.0 ContactsContainer.qml
|
||||
PrivacyContainer 1.0 PrivacyContainer.qml
|
||||
SyncContainer 1.0 SyncContainer.qml
|
||||
DevicesContainer 1.0 DevicesContainer.qml
|
||||
LanguageContainer 1.0 LanguageContainer.qml
|
||||
NotificationsContainer 1.0 NotificationsContainer.qml
|
||||
AdvancedContainer 1.0 AdvancedContainer.qml
|
||||
|
|
|
@ -134,6 +134,7 @@ DISTFILES += \
|
|||
app/AppLayouts/Profile/Sections/PrivacyContainer.qml \
|
||||
app/AppLayouts/Profile/Sections/SignoutContainer.qml \
|
||||
app/AppLayouts/Profile/Sections/SyncContainer.qml \
|
||||
app/AppLayouts/Profile/Sections/DevicesContainer.qml \
|
||||
app/AppLayouts/Profile/Sections/qmldir \
|
||||
app/AppLayouts/Profile/qmldir \
|
||||
app/AppLayouts/Wallet/LeftTab.qml \
|
||||
|
|
Loading…
Reference in New Issue