2023-03-14 02:52:16 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtQml.Models 2.14
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import shared.panels 1.0
|
2023-10-03 13:31:54 +00:00
|
|
|
import shared.popups 1.0
|
2023-03-14 02:52:16 +00:00
|
|
|
import shared.controls 1.0
|
|
|
|
import shared.controls.chat 1.0
|
|
|
|
|
2023-03-21 05:10:06 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
2023-03-14 02:52:16 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../controls"
|
|
|
|
import "../../stores"
|
|
|
|
|
|
|
|
SettingsContentBase {
|
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property ProfileStores.DevicesStore devicesStore
|
|
|
|
property ProfileStores.ProfileStore profileStore
|
|
|
|
property ProfileStores.PrivacyStore privacyStore
|
|
|
|
property ProfileStores.AdvancedStore advancedStore
|
2023-10-03 11:44:45 +00:00
|
|
|
|
|
|
|
required property bool isProduction
|
2023-03-14 02:52:16 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2023-03-21 05:10:06 +00:00
|
|
|
id: layout
|
2023-03-14 02:52:16 +00:00
|
|
|
width: root.contentWidth
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property var instructionsModel: [
|
2023-03-21 05:10:06 +00:00
|
|
|
qsTr("Verify your login with password or KeyCard"),
|
|
|
|
qsTr("Reveal a temporary QR and Sync Code") + "*",
|
|
|
|
qsTr("Share that information with your new device"),
|
|
|
|
]
|
2023-03-14 02:52:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
function personalizeDevice(model) {
|
|
|
|
Global.openPopup(personalizeDevicePopup, {
|
|
|
|
"deviceModel": model
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function setupSyncing() {
|
2023-06-29 06:26:03 +00:00
|
|
|
root.devicesStore.generateConnectionStringAndRunSetupSyncingPopup()
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: devicesStore.devicesModule
|
|
|
|
|
2023-06-09 08:40:56 +00:00
|
|
|
function onOpenPopupWithConnectionStringSignal(rawConnectionString) {
|
2023-03-14 02:52:16 +00:00
|
|
|
Global.openPopup(setupSyncingPopup, {
|
2023-06-09 08:40:56 +00:00
|
|
|
rawConnectionString: rawConnectionString,
|
2023-03-14 02:52:16 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2023-03-21 05:10:06 +00:00
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2023-03-14 02:52:16 +00:00
|
|
|
text: qsTr("Devices")
|
2023-03-21 05:10:06 +00:00
|
|
|
font.pixelSize: Constants.settingsSection.subHeaderFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: root.devicesStore.devicesModule.devicesLoading
|
2023-03-21 05:10:06 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2023-03-14 02:52:16 +00:00
|
|
|
text: qsTr("Loading devices...")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: root.devicesStore.devicesModule.devicesLoadingError
|
2023-03-21 05:10:06 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2023-03-14 02:52:16 +00:00
|
|
|
text: qsTr("Error loading devices. Please try again later.")
|
2023-03-21 05:10:06 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
2023-03-21 05:10:06 +00:00
|
|
|
StatusListView {
|
2023-03-14 02:52:16 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: contentHeight
|
|
|
|
|
2023-03-21 05:10:06 +00:00
|
|
|
interactive: false
|
|
|
|
spacing: 0
|
2023-03-14 02:52:16 +00:00
|
|
|
visible: !root.devicesStore.devicesModule.devicesLoading &&
|
2023-03-21 05:10:06 +00:00
|
|
|
!root.devicesStore.devicesModule.devicesLoadingError &&
|
|
|
|
root.devicesStore.isDeviceSetup
|
|
|
|
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.devicesStore.devicesModel
|
2023-06-15 08:53:35 +00:00
|
|
|
sorters: [
|
|
|
|
RoleSorter {
|
|
|
|
roleName: "isCurrentDevice"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
priority: 2
|
|
|
|
},
|
|
|
|
RoleSorter {
|
|
|
|
roleName: "enabled"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
priority: 1 // Higher number === higher priority
|
|
|
|
}
|
|
|
|
]
|
2023-03-21 05:10:06 +00:00
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
|
|
|
|
delegate: StatusSyncDeviceDelegate {
|
|
|
|
width: ListView.view.width
|
|
|
|
deviceName: model.name
|
|
|
|
deviceType: model.deviceType
|
2023-06-15 08:53:35 +00:00
|
|
|
deviceEnabled: model.enabled
|
2023-03-14 02:52:16 +00:00
|
|
|
timestamp: model.timestamp
|
|
|
|
isCurrentDevice: model.isCurrentDevice
|
|
|
|
onSetupSyncingButtonClicked: {
|
2023-06-09 08:40:56 +00:00
|
|
|
d.setupSyncing()
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
2023-06-15 08:53:35 +00:00
|
|
|
if (deviceEnabled)
|
|
|
|
d.personalizeDevice(model)
|
|
|
|
else
|
2023-06-29 06:26:03 +00:00
|
|
|
d.setupSyncing()
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.topMargin: 17
|
|
|
|
|
|
|
|
implicitWidth: instructionsLayout.implicitWidth
|
|
|
|
+ instructionsLayout.anchors.leftMargin
|
|
|
|
+ instructionsLayout.anchors.rightMargin
|
|
|
|
|
|
|
|
implicitHeight: instructionsLayout.implicitHeight
|
|
|
|
+ instructionsLayout.anchors.topMargin
|
|
|
|
+ instructionsLayout.anchors.bottomMargin
|
|
|
|
|
|
|
|
color: Theme.palette.primaryColor3
|
|
|
|
radius: 8
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: instructionsLayout
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
topMargin: 24
|
|
|
|
bottomMargin: 24
|
|
|
|
leftMargin: 16
|
|
|
|
rightMargin: 16
|
|
|
|
}
|
|
|
|
|
|
|
|
spacing: 17
|
|
|
|
|
2024-07-30 16:55:03 +00:00
|
|
|
Item {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
height: syncNewDeviceText.height
|
|
|
|
width: syncNewDeviceText.width
|
2023-03-14 02:52:16 +00:00
|
|
|
Layout.topMargin: -8
|
2024-07-30 16:55:03 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: syncNewDeviceText
|
|
|
|
objectName: "syncNewDeviceTextLabel"
|
|
|
|
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
font.pixelSize: 17
|
|
|
|
font.weight: Font.Bold
|
|
|
|
text: qsTr("Sync a New Device")
|
|
|
|
|
|
|
|
StatusBetaTag {
|
|
|
|
anchors.left: parent.right
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2024-08-03 07:49:14 +00:00
|
|
|
tooltipText: qsTr("Connection problems can happen.<br>If they do, please use the Enter a Seed Phrase feature instead.")
|
2024-07-30 16:55:03 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2023-09-25 12:52:38 +00:00
|
|
|
|
|
|
|
objectName: "syncNewDeviceSubTitleTextLabel"
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: qsTr("You own your data. Sync it among your devices.")
|
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
rows: d.instructionsModel.length
|
|
|
|
flow: GridLayout.TopToBottom
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: d.instructionsModel
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: index + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: d.instructionsModel
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
text: modelData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
2023-09-25 12:52:38 +00:00
|
|
|
|
|
|
|
objectName: "setupSyncingStatusButton"
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
normalColor: Theme.palette.primaryColor1
|
|
|
|
hoverColor: Theme.palette.miscColor1;
|
|
|
|
textColor: Theme.palette.indirectColor1
|
|
|
|
font.weight: Font.Medium
|
|
|
|
text: qsTr("Setup Syncing")
|
|
|
|
onClicked: {
|
|
|
|
d.setupSyncing()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 13
|
|
|
|
text: "* " + qsTr("This is best done in private. The code will grant access to your profile.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-03 13:31:54 +00:00
|
|
|
StatusFlatButton {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("How to get a sync code")
|
|
|
|
icon.name: "info"
|
|
|
|
onClicked: Global.openPopup(getSyncCodeInstructionsPopup)
|
|
|
|
}
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
StatusButton {
|
2023-09-25 12:52:38 +00:00
|
|
|
objectName: "setupSyncBackupDataButton"
|
|
|
|
|
2023-03-14 02:52:16 +00:00
|
|
|
id: backupBtn
|
2023-10-03 11:44:45 +00:00
|
|
|
visible: !root.isProduction
|
2023-03-14 02:52:16 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Backup Data")
|
|
|
|
onClicked : {
|
2023-03-21 05:10:06 +00:00
|
|
|
const lastUpdate = root.privacyStore.backupData() * 1000
|
2023-03-14 02:52:16 +00:00
|
|
|
console.log("Backup done at: ", LocaleUtils.formatDateTime(lastUpdate))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: personalizeDevicePopup
|
|
|
|
|
|
|
|
SyncDeviceCustomizationPopup {
|
2023-10-03 11:44:45 +00:00
|
|
|
destroyOnClose: true
|
2023-03-14 02:52:16 +00:00
|
|
|
devicesStore: root.devicesStore
|
2023-06-14 13:02:57 +00:00
|
|
|
advancedStore: root.advancedStore
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: setupSyncingPopup
|
|
|
|
|
|
|
|
SetupSyncingPopup {
|
2023-10-03 11:44:45 +00:00
|
|
|
destroyOnClose: true
|
2023-03-14 02:52:16 +00:00
|
|
|
devicesStore: root.devicesStore
|
|
|
|
profileStore: root.profileStore
|
|
|
|
}
|
|
|
|
}
|
2023-03-21 05:10:06 +00:00
|
|
|
|
2023-10-03 13:31:54 +00:00
|
|
|
Component {
|
|
|
|
id: getSyncCodeInstructionsPopup
|
|
|
|
GetSyncCodeInstructionsPopup {
|
|
|
|
destroyOnClose: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-21 05:10:06 +00:00
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2023-03-14 02:52:16 +00:00
|
|
|
}
|
|
|
|
}
|