2022-11-08 08:36:08 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import AppLayouts.Chat.views 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
2022-11-08 08:36:08 +00:00
|
|
|
|
|
|
|
import Storybook 1.0
|
|
|
|
import utils 1.0
|
2024-10-24 08:41:28 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2022-11-08 08:36:08 +00:00
|
|
|
|
|
|
|
SplitView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
Logs { id: logs }
|
|
|
|
|
|
|
|
property bool globalUtilsReady: false
|
|
|
|
property bool mainModuleReady: false
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function getColorHashAsJson(publicKey) {
|
|
|
|
return JSON.stringify([{colorId: 0, segmentLength: 1},
|
|
|
|
{colorId: 19, segmentLength: 2}])
|
|
|
|
}
|
|
|
|
|
|
|
|
function getColorId(publicKey) {
|
|
|
|
return Math.floor(Math.random() * 10)
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
Utils.globalUtilsInst = this
|
|
|
|
root.globalUtilsReady = true
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onDestruction: {
|
|
|
|
root.globalUtilsReady = false
|
|
|
|
Utils.globalUtilsInst = {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
function getContactDetailsAsJson() {
|
2024-11-28 14:15:34 +00:00
|
|
|
return JSON.stringify({
|
|
|
|
ensVerified: false,
|
|
|
|
isCurrentUser: false,
|
|
|
|
contactRequestState: Constants.ContactRequestState.Mutual
|
|
|
|
})
|
2022-11-08 08:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
Utils.mainModuleInst = this
|
|
|
|
root.mainModuleReady = true
|
|
|
|
}
|
|
|
|
Component.onDestruction: {
|
|
|
|
root.mainModuleReady = false
|
|
|
|
Utils.mainModuleInst = {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-28 14:15:34 +00:00
|
|
|
ListModel {
|
|
|
|
id: contacts
|
2022-11-08 08:36:08 +00:00
|
|
|
|
2024-11-28 14:15:34 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
for(let i=0; i < 20; i++) {
|
|
|
|
append(usersModelEditor.getNewUser(i))
|
2022-11-08 08:36:08 +00:00
|
|
|
}
|
|
|
|
}
|
2024-11-28 14:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ChatStores.RootStore {
|
|
|
|
id: rootStoreMock
|
2022-11-08 08:36:08 +00:00
|
|
|
|
|
|
|
readonly property var contactsStore: QtObject {
|
|
|
|
readonly property var mainModuleInst: null
|
|
|
|
}
|
|
|
|
|
|
|
|
function amIChatAdmin() {
|
|
|
|
return chatAdminSwitch.checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
ChatStores.UsersStore {
|
2022-11-08 08:36:08 +00:00
|
|
|
id: usersStoreMock
|
|
|
|
|
|
|
|
readonly property var usersModel: ListModel {
|
|
|
|
Component.onCompleted: {
|
|
|
|
for(let i=0; i < 4; i++) {
|
|
|
|
append(d.createMemberDict(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property var temporaryModel: ListModel {
|
|
|
|
Component.onCompleted: usersStoreMock.resetTemporaryModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendTemporaryModel(pubKey, displayName) {
|
|
|
|
temporaryModel.append({
|
|
|
|
pubKey: pubKey,
|
|
|
|
displayName: displayName,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeFromTemporaryModel(pubKey) {
|
|
|
|
for(let i = 0; i < temporaryModel.count; i++) {
|
|
|
|
if (temporaryModel.get(i).pubKey === pubKey) {
|
|
|
|
temporaryModel.remove(i, 1)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetTemporaryModel() {
|
|
|
|
temporaryModel.clear()
|
|
|
|
for(let i = 0; i < usersModel.count; i++) {
|
|
|
|
const obj = usersModel.get(i)
|
|
|
|
temporaryModel.append(obj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateGroupMembers() {
|
|
|
|
const users = []
|
|
|
|
for(let i = 0; i < temporaryModel.count; i++) {
|
|
|
|
const obj = temporaryModel.get(i)
|
|
|
|
users.push({
|
|
|
|
pubKey: obj.pubKey,
|
2024-10-29 12:54:11 +00:00
|
|
|
compressedPubKey: "compressed_" + obj.pubKey,
|
2022-11-08 08:36:08 +00:00
|
|
|
displayName: obj.displayName,
|
|
|
|
localNickname: "",
|
|
|
|
alias: "three word name(%1)".arg(obj.pubKey),
|
|
|
|
isVerified: false,
|
|
|
|
isUntrustworthy: false,
|
|
|
|
isContact: true,
|
|
|
|
icon: "",
|
|
|
|
color: "red",
|
|
|
|
onlineStatus: 0,
|
|
|
|
isAdmin: i == 0 ? true : false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
usersModel.clear()
|
|
|
|
usersModel.append(users)
|
|
|
|
|
|
|
|
logs.logEvent("UsersStore::updateGroupMembers")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function createMemberDict(seed: int) {
|
2022-12-06 07:55:50 +00:00
|
|
|
var member = usersModelEditor.getNewUser(seed)
|
2022-11-08 08:36:08 +00:00
|
|
|
member["isAdmin"] = seed === 0
|
|
|
|
return member
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SplitView {
|
|
|
|
orientation: Qt.Vertical
|
|
|
|
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
|
|
|
|
SwipeView {
|
|
|
|
id: swipeView
|
|
|
|
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
|
|
|
|
interactive: false
|
|
|
|
currentIndex: selectorsSwitch.checked
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Loader {
|
|
|
|
active: root.globalUtilsReady && root.mainModuleReady
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
margins: 64
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceComponent: MembersSelectorView {
|
|
|
|
rootStore: rootStoreMock
|
2024-10-24 08:41:28 +00:00
|
|
|
utilsStore: SharedStores.UtilsStore {
|
|
|
|
function isChatKey() {
|
|
|
|
return true
|
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
|
|
|
|
function isCompressedPubKey(publicKey) {
|
|
|
|
return true
|
|
|
|
}
|
2024-10-24 08:41:28 +00:00
|
|
|
}
|
2024-11-28 14:15:34 +00:00
|
|
|
|
|
|
|
contactsModel: contacts
|
2022-11-08 08:36:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Loader {
|
|
|
|
active: root.globalUtilsReady && root.mainModuleReady
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
margins: 64
|
|
|
|
}
|
|
|
|
|
|
|
|
sourceComponent: MembersEditSelectorView {
|
|
|
|
rootStore: rootStoreMock
|
|
|
|
usersStore: usersStoreMock
|
2024-11-28 14:15:34 +00:00
|
|
|
|
|
|
|
contactsModel: contacts
|
2022-11-08 08:36:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LogsAndControlsPanel {
|
|
|
|
id: logsAndControlsPanel
|
|
|
|
|
|
|
|
SplitView.minimumHeight: 100
|
|
|
|
SplitView.preferredHeight: 200
|
|
|
|
|
|
|
|
logsView.logText: logs.logText
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Switch {
|
|
|
|
id: selectorsSwitch
|
|
|
|
text: "members editor"
|
|
|
|
}
|
|
|
|
|
|
|
|
Switch {
|
|
|
|
id: chatAdminSwitch
|
|
|
|
visible: selectorsSwitch.checked
|
|
|
|
text: "chat admin"
|
|
|
|
onCheckedChanged: usersStore.resetTemporaryModel()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
SplitView.minimumWidth: 300
|
|
|
|
SplitView.preferredWidth: 300
|
|
|
|
|
2022-12-06 07:55:50 +00:00
|
|
|
UsersModelEditor {
|
|
|
|
id: usersModelEditor
|
2022-11-08 08:36:08 +00:00
|
|
|
anchors.fill: parent
|
2024-11-28 14:15:34 +00:00
|
|
|
model: contacts
|
2022-11-08 08:36:08 +00:00
|
|
|
|
2024-11-28 14:15:34 +00:00
|
|
|
onRemoveClicked: contacts.remove(index, 1)
|
|
|
|
onRemoveAllClicked: contacts.clear()
|
|
|
|
onAddClicked: contacts.append(usersModelEditor.getNewUser(contacts.count))
|
2022-11-08 08:36:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-31 12:21:14 +00:00
|
|
|
// category: Components
|