Warning, /network/neochat/src/qml/InviteUserPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org> 0002 // SPDX-License-Identifier: GPL-3.0-only 0003 0004 import QtQuick 0005 import QtQuick.Controls as QQC2 0006 import QtQuick.Layouts 0007 0008 import org.kde.kirigami as Kirigami 0009 import org.kde.kirigamiaddons.delegates as Delegates 0010 import org.kde.kirigamiaddons.labs.components as KirigamiComponents 0011 0012 import org.kde.neochat 0013 0014 Kirigami.ScrollablePage { 0015 id: root 0016 0017 property NeoChatRoom room 0018 0019 title: i18n("Invite a User") 0020 0021 actions: [ 0022 Kirigami.Action { 0023 icon.name: "dialog-close" 0024 text: i18nc("@action", "Cancel") 0025 onTriggered: root.closeDialog() 0026 } 0027 ] 0028 header: RowLayout { 0029 Layout.fillWidth: true 0030 Layout.margins: Kirigami.Units.largeSpacing 0031 0032 Kirigami.SearchField { 0033 id: identifierField 0034 property bool isUserId: text.match(/@(.+):(.+)/g) 0035 Layout.fillWidth: true 0036 0037 placeholderText: i18n("Find a user...") 0038 onAccepted: userDictListModel.search() 0039 } 0040 0041 QQC2.Button { 0042 visible: identifierField.isUserId 0043 0044 text: i18n("Add") 0045 highlighted: true 0046 0047 onClicked: { 0048 room.inviteToRoom(identifierField.text); 0049 } 0050 } 0051 } 0052 0053 ListView { 0054 id: userDictListView 0055 0056 clip: true 0057 0058 model: UserDirectoryListModel { 0059 id: userDictListModel 0060 0061 connection: root.room.connection 0062 searchText: identifierField.text 0063 } 0064 0065 Kirigami.PlaceholderMessage { 0066 anchors.centerIn: parent 0067 0068 visible: userDictListView.count < 1 0069 0070 text: i18n("No users available") 0071 } 0072 0073 delegate: Delegates.RoundedItemDelegate { 0074 id: delegate 0075 0076 required property string userId 0077 required property string displayName 0078 required property url avatarUrl 0079 0080 property bool inRoom: room && room.containsUser(userId) 0081 0082 text: displayName 0083 0084 contentItem: RowLayout { 0085 KirigamiComponents.Avatar { 0086 Layout.preferredWidth: Kirigami.Units.iconSizes.medium 0087 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0088 source: delegate.avatarUrl 0089 name: delegate.displayName 0090 } 0091 0092 Delegates.SubtitleContentItem { 0093 itemDelegate: delegate 0094 subtitle: delegate.userId 0095 labelItem.textFormat: Text.PlainText 0096 } 0097 0098 QQC2.ToolButton { 0099 id: inviteButton 0100 icon.name: "document-send" 0101 text: i18n("Send invitation") 0102 checkable: true 0103 checked: inRoom 0104 opacity: inRoom ? 0.5 : 1 0105 0106 onToggled: { 0107 if (inRoom) { 0108 checked = true; 0109 } else { 0110 room.inviteToRoom(delegate.userId); 0111 applicationWindow().pageStack.layers.pop(); 0112 } 0113 } 0114 0115 QQC2.ToolTip.text: !inRoom ? text : i18n("User is either already a member or has been invited") 0116 QQC2.ToolTip.visible: inviteButton.hovered 0117 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0118 } 0119 } 0120 } 0121 } 0122 }