2023-04-17 09:35:44 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml 2.15
|
|
|
|
|
2023-06-30 12:34:42 +00:00
|
|
|
import AppLayouts.Communities.popups 1.0
|
2023-04-17 09:35:44 +00:00
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import Storybook 1.0
|
|
|
|
|
|
|
|
SplitView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
orientation: Qt.Vertical
|
|
|
|
|
|
|
|
Logs { id: logs }
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: members
|
|
|
|
|
|
|
|
property int counter: 0
|
|
|
|
|
|
|
|
function addMember() {
|
|
|
|
const i = counter++
|
|
|
|
const key = `pub_key_${i}`
|
|
|
|
|
|
|
|
const firstLetters = ["a", "b", "c", "d"]
|
|
|
|
const firstLetterIdx = Math.min(Math.floor(i / firstLetters.length),
|
|
|
|
firstLetters.length - 1)
|
|
|
|
const firstLetter = firstLetters[firstLetterIdx]
|
|
|
|
|
|
|
|
append({
|
|
|
|
alias: "",
|
|
|
|
colorId: "1",
|
|
|
|
displayName: `${firstLetter}contact ${i}`,
|
|
|
|
ensName: "",
|
|
|
|
icon: "",
|
|
|
|
isContact: true,
|
|
|
|
localNickname: "",
|
|
|
|
onlineStatus: 1,
|
|
|
|
pubKey: key,
|
2024-10-29 12:54:11 +00:00
|
|
|
compressedPubKey: "compressed_" + key,
|
2023-04-17 09:35:44 +00:00
|
|
|
isVerified: true,
|
2023-08-15 11:18:17 +00:00
|
|
|
isUntrustworthy: false,
|
|
|
|
airdropAddress: `0x${firstLetter}${i}`
|
2023-04-17 09:35:44 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
for (let i = 0; i < 33; i++)
|
|
|
|
addMember()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
id: container
|
|
|
|
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
SplitView.fillHeight: true
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: startRect
|
|
|
|
|
|
|
|
border.color: "green"
|
|
|
|
color: "lightgreen"
|
|
|
|
border.width: 3
|
|
|
|
width: 50
|
|
|
|
height: width
|
|
|
|
|
|
|
|
x: 70
|
|
|
|
y: 70
|
|
|
|
|
|
|
|
radius: width / 2
|
|
|
|
|
|
|
|
Drag.active: dragArea.drag.active
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: dragArea
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
drag.target: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
MembersDropdown {
|
|
|
|
id: membersDropdown
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
closePolicy: Popup.NoAutoClose
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: members
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
|
|
|
enabled: membersDropdown.searchText !== ""
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
function matchesAlias(name, filter) {
|
|
|
|
return name.split(" ").some(p => p.startsWith(filter))
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
expression: {
|
|
|
|
membersDropdown.searchText
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
const filter = membersDropdown.searchText.toLowerCase()
|
|
|
|
return matchesAlias(model.alias.toLowerCase(), filter)
|
|
|
|
|| model.displayName.toLowerCase().includes(filter)
|
|
|
|
|| model.ensName.toLowerCase().includes(filter)
|
|
|
|
|| model.localNickname.toLowerCase().includes(filter)
|
|
|
|
|| model.pubKey.toLowerCase().includes(filter)
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
onBackButtonClicked: {
|
|
|
|
logs.logEvent("MembersDropdown::backButtonClicked")
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
onAddButtonClicked: {
|
|
|
|
logs.logEvent("MembersDropdown::addButtonClicked, keys: "
|
|
|
|
+ [...membersDropdown.selectedKeys])
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
|
|
|
|
Component.onCompleted: open()
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LogsAndControlsPanel {
|
|
|
|
SplitView.minimumHeight: 100
|
2023-05-11 10:44:47 +00:00
|
|
|
SplitView.preferredHeight: 320
|
2023-04-17 09:35:44 +00:00
|
|
|
|
|
|
|
logsView.logText: logs.logText
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
ColumnLayout {
|
2023-04-17 09:35:44 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RowLayout {
|
|
|
|
RadioButton {
|
|
|
|
id: addModeRadioButton
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
text: "add mode"
|
|
|
|
checked: true
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown
|
|
|
|
property: "mode"
|
|
|
|
value: addModeRadioButton.checked
|
|
|
|
? MembersDropdown.Mode.Add
|
|
|
|
: MembersDropdown.Mode.Update
|
2023-04-28 09:40:58 +00:00
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
}
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RadioButton {
|
|
|
|
text: "update mode"
|
|
|
|
}
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
CheckBox {
|
|
|
|
id: forceButtonDisabledCheckBox
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
text: "force button disabled"
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown
|
|
|
|
property: "forceButtonDisabled"
|
|
|
|
value: forceButtonDisabledCheckBox.checked
|
2023-04-28 09:40:58 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
}
|
2023-04-28 09:40:58 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RowLayout {
|
|
|
|
Label {
|
|
|
|
text: "maximum list height:"
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Slider {
|
|
|
|
id: maxListHeightSlider
|
|
|
|
from: 100
|
|
|
|
to: 500
|
|
|
|
stepSize: 1
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
value = membersDropdown.maximumListHeight
|
|
|
|
membersDropdown.maximumListHeight
|
|
|
|
= Qt.binding(() => value)
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Label {
|
|
|
|
text: maxListHeightSlider.value
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RowLayout {
|
|
|
|
Label {
|
|
|
|
text: "margins:"
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Slider {
|
|
|
|
id: marginsSlider
|
|
|
|
from: -1
|
|
|
|
to: 50
|
|
|
|
stepSize: 1
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
value = membersDropdown.margins
|
|
|
|
membersDropdown.margins = Qt.binding(() => value)
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Label {
|
|
|
|
text: marginsSlider.value
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RowLayout {
|
|
|
|
Label {
|
|
|
|
text: "bottom inset:"
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Slider {
|
|
|
|
id: bottomInsetSlider
|
|
|
|
from: 0
|
|
|
|
to: 50
|
|
|
|
stepSize: 1
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
value = membersDropdown.bottomInset
|
|
|
|
membersDropdown.bottomInset = Qt.binding(() => value)
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Label {
|
|
|
|
text: bottomInsetSlider.value
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
RowLayout {
|
|
|
|
RadioButton {
|
|
|
|
id: anchorToItemRadioButton
|
|
|
|
text: "anchor to item"
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
checked: true
|
|
|
|
}
|
|
|
|
RadioButton {
|
|
|
|
id: anchorToOverlayRadioButton
|
|
|
|
text: "anchor to overlay"
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown
|
|
|
|
property: "parent"
|
|
|
|
value: anchorToItemRadioButton.checked
|
|
|
|
? startRect : membersDropdown.Overlay.overlay
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown.anchors
|
|
|
|
when: anchorToOverlayRadioButton.checked
|
|
|
|
property: "centerIn"
|
|
|
|
value: membersDropdown.parent
|
|
|
|
restoreMode: Binding.RestoreBindingOrValue
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown
|
|
|
|
property: "x"
|
|
|
|
value: anchorToItemRadioButton.checked
|
|
|
|
? startRect.width / 2 : 0
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
|
2024-10-29 12:54:11 +00:00
|
|
|
Binding {
|
|
|
|
target: membersDropdown
|
|
|
|
property: "y"
|
|
|
|
value: anchorToItemRadioButton.checked
|
|
|
|
? startRect.height / 2 : 0
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-29 12:54:11 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: `selected members: ${[...membersDropdown.selectedKeys]}`
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
}
|
2023-04-17 09:35:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-31 12:21:14 +00:00
|
|
|
|
|
|
|
// category: Popups
|
2023-10-03 11:56:30 +00:00
|
|
|
|
|
|
|
// https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22647-498410
|
|
|
|
// https://www.figma.com/file/17fc13UBFvInrLgNUKJJg5/Kuba%E2%8E%9CDesktop?node-id=22642-497015
|