160 lines
5.0 KiB
QML
Raw Normal View History

2019-12-19 07:46:16 -04:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../../.."
import "../../../../Base"
2019-05-12 13:17:42 -04:00
HColumnLayout {
readonly property alias keybindFocusItem: filterField
readonly property var modelSyncId:
[chat.userId, chat.roomId, "filtered_members"]
HStackView {
id: stackView
2019-05-12 13:17:42 -04:00
background: Rectangle {
color: theme.chat.roomPane.listView.background
}
initialItem: HListView {
id: memberList
clip: true
model: ModelStore.get(modelSyncId)
delegate: MemberDelegate {
id: member
width: memberList.width
onLeftClicked: stackView.push(
"MemberProfile.qml",
{
userId: chat.userId,
roomId: chat.roomId,
ownPowerLevel:
Qt.binding(() => chat.roomInfo.own_power_level),
canSetPowerLevels: Qt.binding(() =>
chat.roomInfo.can_set_power_levels
),
member: model,
stackView: stackView,
},
)
}
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: {
currentItem.leftClicked()
currentItem.clicked()
}
Keys.onMenuPressed:
if (currentItem) currentItem.doRightClick(false)
}
Layout.fillWidth: true
Layout.fillHeight: true
2019-05-12 13:17:42 -04:00
}
2020-03-13 01:09:04 -04:00
Rectangle {
color: theme.chat.roomPane.bottomBar.background
Layout.fillWidth: true
Layout.minimumHeight: theme.baseElementsHeight
Layout.maximumHeight: Layout.minimumHeight
2020-03-13 01:09:04 -04:00
HRowLayout {
anchors.fill: parent
2020-03-13 01:09:04 -04:00
HTextField {
id: filterField
saveName: "memberFilterField"
saveId: chat.roomId
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
Layout.fillHeight: true
// FIXME: fails to display sometimes for some reason if
// declared normally
Component.onCompleted: placeholderText = qsTr("Filter members")
onTextChanged: {
stackView.pop(stackView.initialItem)
py.callCoro("set_substring_filter", [modelSyncId, text])
}
onActiveFocusChanged: {
if (
activeFocus &&
stackView.depth === 1 &&
stackView.currentItem.currentIndex === -1
) {
stackView.currentItem.currentIndex = 0
} else if (
! activeFocus &&
stackView.depth === 1 &&
stackView.currentItem.currentIndex === 0
) {
stackView.currentItem.currentIndex = -1
}
}
Keys.forwardTo: [stackView.currentItem]
Keys.priority: Keys.AfterItem
Keys.onEscapePressed: {
if (stackView.depth === 1)
stackView.currentItem.currentIndex = -1
roomPane.toggleFocus()
if (window.settings.clearMemberFilterOnEscape) text = ""
}
2020-03-13 01:09:04 -04:00
Behavior on opacity { HNumberAnimation {} }
}
HButton {
id: inviteButton
icon.name: "room-send-invite"
backgroundColor:
theme.chat.roomPane.bottomBar.inviteButton.background
2020-07-10 12:41:20 -04:00
enabled:
chat.userInfo.presence !== "offline" &&
chat.roomInfo.can_invite
2020-03-13 01:09:04 -04:00
toolTip.text:
enabled ?
qsTr("Invite members to this room") :
qsTr("No permission to invite members to this room")
onClicked: utils.makePopup(
"Popups/InviteToRoomPopup.qml",
{
userId: chat.userId,
roomId: chat.roomId,
roomName: chat.roomInfo.display_name,
invitingAllowed:
Qt.binding(() => inviteButton.enabled),
},
)
Layout.fillHeight: true
2020-03-28 12:40:11 -04:00
HShortcut {
sequences: window.settings.keys.inviteToRoom
2020-07-10 12:41:20 -04:00
onActivated:
if (inviteButton.enabled) inviteButton.clicked()
2020-03-28 12:40:11 -04:00
}
2020-03-13 01:09:04 -04:00
}
}
}
2019-05-12 13:17:42 -04:00
}