2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
2020-07-08 11:33:05 -04:00
|
|
|
import "../../../.."
|
|
|
|
import "../../../../Base"
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2019-05-12 21:36:08 -04:00
|
|
|
HColumnLayout {
|
2020-03-17 16:39:29 -04:00
|
|
|
readonly property alias keybindFocusItem: filterField
|
2020-05-10 14:58:59 -04:00
|
|
|
readonly property var modelSyncId:
|
2020-09-13 12:47:25 -04:00
|
|
|
[chat.userRoomId[0], chat.userRoomId[1], "filtered_members"]
|
2020-03-17 16:39:29 -04:00
|
|
|
|
2020-07-14 03:00:10 -04:00
|
|
|
readonly property alias viewDepth: stackView.depth
|
2020-07-14 03:14:05 -04:00
|
|
|
readonly property alias filterField: filterField
|
2020-07-14 03:00:10 -04:00
|
|
|
|
2020-07-12 00:25:57 -04:00
|
|
|
|
2020-09-03 17:59:48 -04:00
|
|
|
Connections {
|
|
|
|
target: pageLoader
|
|
|
|
|
|
|
|
function onAboutToRecycle() {
|
|
|
|
stackView.pop(stackView.initialItem)
|
|
|
|
filterField.reset()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-08 11:33:05 -04:00
|
|
|
HStackView {
|
|
|
|
id: stackView
|
2019-05-12 13:17:42 -04:00
|
|
|
|
2020-07-08 11:33:05 -04:00
|
|
|
background: Rectangle {
|
|
|
|
color: theme.chat.roomPane.listView.background
|
|
|
|
}
|
2020-05-10 14:58:59 -04:00
|
|
|
|
2020-07-08 11:33:05 -04:00
|
|
|
initialItem: HListView {
|
|
|
|
id: memberList
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
model: ModelStore.get(modelSyncId)
|
|
|
|
|
|
|
|
delegate: MemberDelegate {
|
|
|
|
id: member
|
|
|
|
width: memberList.width
|
2020-08-21 11:19:42 -04:00
|
|
|
colorName: hovered || memberList.currentIndex === model.index
|
2020-07-08 11:33:05 -04:00
|
|
|
|
|
|
|
onLeftClicked: stackView.push(
|
|
|
|
"MemberProfile.qml",
|
|
|
|
{
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
2020-07-13 18:44:20 -04:00
|
|
|
ownPowerLevel:
|
|
|
|
Qt.binding(() => chat.roomInfo.own_power_level),
|
|
|
|
canSetPowerLevels: Qt.binding(() =>
|
2020-07-16 18:11:37 -04:00
|
|
|
chat.userInfo.presence !== "offline" &&
|
2020-07-13 18:44:20 -04:00
|
|
|
chat.roomInfo.can_set_power_levels
|
|
|
|
),
|
2020-07-08 11:33:05 -04:00
|
|
|
member: model,
|
|
|
|
stackView: stackView,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2020-07-09 14:53:01 -04:00
|
|
|
|
2020-08-19 07:36:43 -04:00
|
|
|
Keys.onTabPressed: memberList.incrementCurrentIndex()
|
|
|
|
Keys.onBacktabPressed: memberList.decrementCurrentIndex()
|
|
|
|
|
2020-07-09 14:53:01 -04:00
|
|
|
Keys.onEnterPressed: Keys.onReturnPressed(event)
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
currentItem.leftClicked()
|
|
|
|
currentItem.clicked()
|
|
|
|
}
|
2020-07-09 21:40:33 -04:00
|
|
|
|
|
|
|
Keys.onMenuPressed:
|
|
|
|
if (currentItem) currentItem.doRightClick(false)
|
2020-04-15 16:54:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2019-05-12 13:17:42 -04:00
|
|
|
}
|
2019-05-16 15:39:44 -04:00
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
Rectangle {
|
|
|
|
color: theme.chat.roomPane.bottomBar.background
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-07-14 04:54:23 -04:00
|
|
|
Layout.preferredHeight: childrenRect.height
|
2019-05-16 15:39:44 -04:00
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
HRowLayout {
|
2020-07-14 04:54:23 -04:00
|
|
|
width: parent.width
|
|
|
|
layoutDirection:
|
|
|
|
expandButton.visible ? Qt.RightToLeft : Qt.LeftToRight
|
2019-12-10 16:29:49 -04:00
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
HTextField {
|
|
|
|
id: filterField
|
2019-08-21 12:17:12 -04:00
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
backgroundColor:
|
|
|
|
theme.chat.roomPane.bottomBar.filterMembers.background
|
|
|
|
bordered: false
|
|
|
|
opacity: width >= 16 * theme.uiScale ? 1 : 0
|
2019-12-04 09:08:38 -04:00
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
Layout.fillWidth: true
|
2019-08-22 09:27:26 -04:00
|
|
|
|
2020-03-13 10:34:37 -04:00
|
|
|
// FIXME: fails to display sometimes for some reason if
|
|
|
|
// declared normally
|
|
|
|
Component.onCompleted: placeholderText = qsTr("Filter members")
|
|
|
|
|
2020-07-08 11:33:05 -04:00
|
|
|
onTextChanged: {
|
|
|
|
stackView.pop(stackView.initialItem)
|
2020-08-20 12:21:47 -04:00
|
|
|
py.callCoro("set_string_filter", [modelSyncId, text])
|
2020-07-08 11:33:05 -04:00
|
|
|
}
|
2020-05-10 14:58:59 -04:00
|
|
|
|
2020-07-10 12:20:02 -04:00
|
|
|
onActiveFocusChanged: {
|
|
|
|
if (
|
|
|
|
! activeFocus &&
|
|
|
|
stackView.depth === 1 &&
|
|
|
|
stackView.currentItem.currentIndex === 0
|
|
|
|
) {
|
|
|
|
stackView.currentItem.currentIndex = -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 21:55:28 -04:00
|
|
|
|
2020-07-09 14:53:01 -04:00
|
|
|
Keys.forwardTo: [stackView.currentItem]
|
|
|
|
Keys.priority: Keys.AfterItem
|
|
|
|
|
2020-05-14 02:24:28 -04:00
|
|
|
Keys.onEscapePressed: {
|
2020-07-09 21:55:28 -04:00
|
|
|
if (stackView.depth === 1)
|
|
|
|
stackView.currentItem.currentIndex = -1
|
|
|
|
|
2020-05-14 02:24:28 -04:00
|
|
|
roomPane.toggleFocus()
|
|
|
|
if (window.settings.clearMemberFilterOnEscape) text = ""
|
|
|
|
}
|
|
|
|
|
2020-03-13 01:09:04 -04:00
|
|
|
Behavior on opacity { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
|
2020-07-14 04:54:23 -04:00
|
|
|
HColumnLayout {
|
|
|
|
HButton {
|
|
|
|
id: inviteButton
|
|
|
|
icon.name: "room-send-invite"
|
|
|
|
backgroundColor:
|
|
|
|
theme.chat.roomPane.bottomBar.inviteButton.background
|
|
|
|
enabled:
|
|
|
|
chat.userInfo.presence !== "offline" &&
|
|
|
|
chat.roomInfo.can_invite
|
|
|
|
|
|
|
|
toolTip.text:
|
|
|
|
enabled ?
|
|
|
|
qsTr("Invite members to this room") :
|
|
|
|
qsTr("No permission to invite members to this room")
|
|
|
|
|
2020-08-03 01:26:35 -04:00
|
|
|
onClicked: window.makePopup(
|
2020-07-14 04:54:23 -04:00
|
|
|
"Popups/InviteToRoomPopup.qml",
|
|
|
|
{
|
|
|
|
userId: chat.userId,
|
|
|
|
roomId: chat.roomId,
|
|
|
|
roomName: chat.roomInfo.display_name,
|
|
|
|
invitingAllowed:
|
|
|
|
Qt.binding(() => inviteButton.enabled),
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
Layout.preferredHeight: filterField.implicitHeight
|
|
|
|
|
|
|
|
HShortcut {
|
|
|
|
sequences: window.settings.keys.inviteToRoom
|
|
|
|
onActivated:
|
|
|
|
if (inviteButton.enabled) inviteButton.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: expandButton
|
|
|
|
icon.name: "room-pane-expand-search"
|
|
|
|
backgroundColor: inviteButton.backgroundColor
|
|
|
|
toolTip.text: qsTr("Expand search")
|
|
|
|
visible: Layout.preferredHeight > 0
|
|
|
|
|
|
|
|
// Will trigger roomPane.requireDefaultSize
|
|
|
|
onClicked: filterField.forceActiveFocus()
|
2020-03-13 01:09:04 -04:00
|
|
|
|
2020-07-14 04:54:23 -04:00
|
|
|
Layout.preferredHeight:
|
|
|
|
filterField.width < 32 * theme.uiScale ?
|
|
|
|
filterField.implicitHeight :
|
|
|
|
0
|
2020-03-28 12:40:11 -04:00
|
|
|
|
2020-07-14 04:54:23 -04:00
|
|
|
Behavior on Layout.preferredHeight { HNumberAnimation {} }
|
2020-03-28 12:40:11 -04:00
|
|
|
}
|
2020-03-13 01:09:04 -04:00
|
|
|
}
|
2019-08-22 09:27:26 -04:00
|
|
|
}
|
2019-05-16 15:39:44 -04:00
|
|
|
}
|
2019-05-12 13:17:42 -04:00
|
|
|
}
|