2023-03-31 12:07:33 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
2023-04-25 20:19:33 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-03-31 12:07:33 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-04-25 20:19:33 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-03-31 12:07:33 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
|
|
|
|
StatusFlowSelector {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property alias addressesModel: addressesSelectorPanel.model
|
|
|
|
property alias membersModel: membersSelectorPanel.model
|
|
|
|
|
|
|
|
property alias loadingAddresses: addressesSelectorPanel.loading
|
|
|
|
property alias addressesInputText: addressesSelectorPanel.text
|
|
|
|
|
|
|
|
property bool showAddressesInputWhenEmpty: false
|
2023-04-25 21:24:04 +00:00
|
|
|
property int maxNumberOfRecipients: 0
|
|
|
|
property bool infiniteMaxNumberOfRecipients: false
|
2023-04-25 20:19:33 +00:00
|
|
|
|
|
|
|
readonly property int count: addressesSelectorPanel.count +
|
|
|
|
membersSelectorPanel.count
|
|
|
|
|
|
|
|
readonly property bool valid:
|
2023-04-25 21:24:04 +00:00
|
|
|
addressesSelectorPanel.invalidAddressesCount === 0 &&
|
|
|
|
(infiniteMaxNumberOfRecipients || count <= maxNumberOfRecipients)
|
2023-03-31 12:07:33 +00:00
|
|
|
|
|
|
|
signal addAddressesRequested(string addresses)
|
|
|
|
signal removeAddressRequested(int index)
|
|
|
|
signal removeMemberRequested(int index)
|
|
|
|
|
|
|
|
placeholderItem.visible: !addressesSelectorPanel.visible &&
|
|
|
|
!membersSelectorPanel.visible
|
|
|
|
|
|
|
|
title: qsTr("To")
|
2024-10-15 19:26:12 +00:00
|
|
|
icon: Theme.svg("member")
|
2023-04-25 21:24:04 +00:00
|
|
|
flowSpacing: addressesSelectorPanel.visible || membersSelectorPanel.visible
|
|
|
|
? 12 : 6
|
2023-03-31 12:07:33 +00:00
|
|
|
|
|
|
|
placeholderText: qsTr("Example: 12 addresses and 3 members")
|
|
|
|
|
2023-04-25 21:06:12 +00:00
|
|
|
function forceInputFocus() {
|
|
|
|
addressesSelectorPanel.forceInputFocus()
|
|
|
|
}
|
|
|
|
|
2023-03-31 12:07:33 +00:00
|
|
|
function clearAddressesInput() {
|
|
|
|
addressesSelectorPanel.clearInput()
|
|
|
|
}
|
|
|
|
|
|
|
|
function positionAddressesListAtEnd() {
|
|
|
|
addressesSelectorPanel.positionListAtEnd()
|
|
|
|
}
|
|
|
|
|
|
|
|
function positionMembersListAtEnd() {
|
|
|
|
membersSelectorPanel.positionListAtEnd()
|
|
|
|
}
|
|
|
|
|
2023-04-25 20:19:33 +00:00
|
|
|
StatusBaseText {
|
|
|
|
parent: label
|
|
|
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2023-04-25 21:24:04 +00:00
|
|
|
readonly property bool valid: root.infiniteMaxNumberOfRecipients ||
|
|
|
|
root.count <= root.maxNumberOfRecipients
|
2023-04-25 20:19:33 +00:00
|
|
|
|
2023-04-25 21:24:04 +00:00
|
|
|
text: root.count + " / " + (root.infiniteMaxNumberOfRecipients
|
2023-04-25 20:19:33 +00:00
|
|
|
? qsTr("∞ recipients", "infinite number of recipients")
|
2023-04-25 21:24:04 +00:00
|
|
|
: qsTr("%n recipient(s)", "", root.maxNumberOfRecipients))
|
2023-04-25 20:19:33 +00:00
|
|
|
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize + 1
|
|
|
|
color: valid ? Theme.palette.baseColor1 : Theme.palette.dangerColor1
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
|
|
|
|
2023-03-31 12:07:33 +00:00
|
|
|
AddressesSelectorPanel {
|
|
|
|
id: addressesSelectorPanel
|
|
|
|
|
|
|
|
visible: count > 0 || root.showAddressesInputWhenEmpty
|
|
|
|
width: root.availableWidth
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
addAddressesRequested.connect(root.addAddressesRequested)
|
|
|
|
removeAddressRequested.connect(root.removeAddressRequested)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MembersSelectorPanel {
|
|
|
|
id: membersSelectorPanel
|
|
|
|
|
|
|
|
visible: count > 0
|
|
|
|
width: root.availableWidth
|
|
|
|
|
|
|
|
Component.onCompleted: removeMemberRequested.connect(
|
|
|
|
root.removeMemberRequested)
|
|
|
|
}
|
|
|
|
}
|