display first menu option; include channel id
This commit is contained in:
parent
5e2c3c9ca7
commit
aeb8d2958d
|
@ -17,6 +17,7 @@ type
|
||||||
HasMentions = UserRole + 8
|
HasMentions = UserRole + 8
|
||||||
ContentType = UserRole + 9
|
ContentType = UserRole + 9
|
||||||
Muted = UserRole + 10
|
Muted = UserRole + 10
|
||||||
|
Id = UserRole + 11
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
|
@ -69,6 +70,7 @@ QtObject:
|
||||||
of ChannelsRoles.Color: result = newQVariant(chatItem.color)
|
of ChannelsRoles.Color: result = newQVariant(chatItem.color)
|
||||||
of ChannelsRoles.HasMentions: result = newQVariant(chatItem.hasMentions)
|
of ChannelsRoles.HasMentions: result = newQVariant(chatItem.hasMentions)
|
||||||
of ChannelsRoles.Muted: result = newQVariant(chatItem.muted.bool)
|
of ChannelsRoles.Muted: result = newQVariant(chatItem.muted.bool)
|
||||||
|
of ChannelsRoles.Id: result = newQVariant($chatItem.id)
|
||||||
|
|
||||||
method roleNames(self: ChannelsList): Table[int, string] =
|
method roleNames(self: ChannelsList): Table[int, string] =
|
||||||
{
|
{
|
||||||
|
@ -81,7 +83,8 @@ QtObject:
|
||||||
ChannelsRoles.Color.int: "color",
|
ChannelsRoles.Color.int: "color",
|
||||||
ChannelsRoles.HasMentions.int: "hasMentions",
|
ChannelsRoles.HasMentions.int: "hasMentions",
|
||||||
ChannelsRoles.ContentType.int: "contentType",
|
ChannelsRoles.ContentType.int: "contentType",
|
||||||
ChannelsRoles.Muted.int: "muted"
|
ChannelsRoles.Muted.int: "muted",
|
||||||
|
ChannelsRoles.Id.int: "id"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
proc addChatItemToList*(self: ChannelsList, channel: Chat): int =
|
proc addChatItemToList*(self: ChannelsList, channel: Chat): int =
|
||||||
|
|
|
@ -5,6 +5,7 @@ import "../../../../imports"
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
property string chatId: ""
|
||||||
property string name: "channelName"
|
property string name: "channelName"
|
||||||
property string lastMessage: "My latest message\n with a return"
|
property string lastMessage: "My latest message\n with a return"
|
||||||
property string timestamp: "20/2/2020"
|
property string timestamp: "20/2/2020"
|
||||||
|
@ -34,7 +35,7 @@ Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (mouse.button & Qt.RightButton) {
|
if (mouse.button & Qt.RightButton) {
|
||||||
channelContextMenu.openMenu(index, muted, chatType)
|
channelContextMenu.openMenu(index, muted, chatType, name, chatId, identicon)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chatsModel.setActiveChannelByIndex(index)
|
chatsModel.setActiveChannelByIndex(index)
|
||||||
|
@ -179,10 +180,6 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*##^##
|
/*##^##
|
||||||
Designer {
|
Designer {
|
||||||
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
|
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
|
||||||
|
|
|
@ -34,6 +34,7 @@ ScrollView {
|
||||||
hasMentions: model.hasMentions
|
hasMentions: model.hasMentions
|
||||||
contentType: model.contentType
|
contentType: model.contentType
|
||||||
searchStr: chatGroupsContainer.searchStr
|
searchStr: chatGroupsContainer.searchStr
|
||||||
|
chatId: model.id
|
||||||
}
|
}
|
||||||
onCountChanged: {
|
onCountChanged: {
|
||||||
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
||||||
|
@ -51,10 +52,29 @@ ScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfilePopup {
|
||||||
|
id: profilePopup
|
||||||
|
height: 330
|
||||||
|
noFooter: true
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupInfoPopup {
|
||||||
|
id: groupInfoPopup
|
||||||
|
profileClick: {
|
||||||
|
profilePopup.openPopup.bind(profilePopup)
|
||||||
|
}
|
||||||
|
onClosed: {
|
||||||
|
mouseArea.menuOpened = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PopupMenu {
|
PopupMenu {
|
||||||
property int channelIndex
|
property int channelIndex
|
||||||
property bool channelMuted
|
property bool channelMuted
|
||||||
property int chatType
|
property int chatType
|
||||||
|
property string chatName
|
||||||
|
property string chatId
|
||||||
|
property string chatIdenticon
|
||||||
|
|
||||||
id: channelContextMenu
|
id: channelContextMenu
|
||||||
width: 175
|
width: 175
|
||||||
|
@ -71,20 +91,41 @@ ScrollView {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
function openMenu(channelIndex, muted, chatType) {
|
function openMenu(channelIndex, muted, chatType, chatName, chatId, chatIdenticon) {
|
||||||
channelContextMenu.channelIndex = channelIndex
|
channelContextMenu.channelIndex = channelIndex
|
||||||
channelContextMenu.channelMuted = muted
|
channelContextMenu.channelMuted = muted
|
||||||
channelContextMenu.chatType = chatType
|
channelContextMenu.chatType = chatType
|
||||||
|
channelContextMenu.chatName = chatName
|
||||||
|
channelContextMenu.chatId = chatId
|
||||||
|
channelContextMenu.chatIdenticon = chatIdenticon
|
||||||
channelContextMenu.popup()
|
channelContextMenu.popup()
|
||||||
}
|
}
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
//% "View Group"
|
enabled: channelContextMenu.chatType !== Constants.chatTypePublic
|
||||||
text: qsTrId("view-group")
|
text: {
|
||||||
|
if (channelContextMenu.chatType === Constants.chatTypeOneToOne) {
|
||||||
|
return qsTrId("view-profile")
|
||||||
|
}
|
||||||
|
if (channelContextMenu.chatType === Constants.chatTypePrivateGroupChat) {
|
||||||
|
return qsTrId("view-group")
|
||||||
|
}
|
||||||
|
return qsTrId("share-chat")
|
||||||
|
}
|
||||||
icon.source: "../../../img/group.svg"
|
icon.source: "../../../img/group.svg"
|
||||||
icon.width: 16
|
icon.width: 16
|
||||||
icon.height: 16
|
icon.height: 16
|
||||||
onTriggered: console.log('TODO View group')
|
onTriggered: {
|
||||||
|
chatsModel.setActiveChannelByIndex(channelContextMenu.channelIndex)
|
||||||
|
chatGroupsListView.currentIndex = channelContextMenu.channelIndex
|
||||||
|
if (channelContextMenu.chatType === Constants.chatTypeOneToOne) {
|
||||||
|
return profilePopup.openPopup(channelContextMenu.chatName, channelContextMenu.chatId, channelContextMenu.chatIdenticon)
|
||||||
|
}
|
||||||
|
if (channelContextMenu.chatType === Constants.chatTypePrivateGroupChat) {
|
||||||
|
return groupInfoPopup.open()
|
||||||
|
}
|
||||||
|
// return qsTrId("share-chat")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {}
|
Separator {}
|
||||||
|
@ -107,57 +148,6 @@ ScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PopupMenu { */
|
|
||||||
/* hasArrow: false */
|
|
||||||
/* title: qstr("Mute chat") */
|
|
||||||
|
|
||||||
/* // TODO implement mute chat in Model and call it here */
|
|
||||||
/* Action { */
|
|
||||||
//% "15 minutes"
|
|
||||||
/* text: qsTrId("15-minutes"); */
|
|
||||||
/* icon.width: 0; */
|
|
||||||
/* onTriggered: { */
|
|
||||||
/* chatsModel.muteChannel(channelContextMenu.channelIndex, Constants.muteChat15Minutes) */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
/* Action { */
|
|
||||||
//% "1 hour"
|
|
||||||
/* text: qsTrId("1-hour"); */
|
|
||||||
/* icon.width: 0; */
|
|
||||||
/* onTriggered: { */
|
|
||||||
/* chatsModel.muteChannel(channelContextMenu.channelIndex, Constants.muteChatOneHour) */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
/* Action { */
|
|
||||||
//% "8 hours"
|
|
||||||
/* text: qsTrId("8-hours"); */
|
|
||||||
/* icon.width: 0; */
|
|
||||||
/* onTriggered: { */
|
|
||||||
/* chatsModel.muteChannel(channelContextMenu.channelIndex, Constants.muteChatEightHours) */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
/* Action { */
|
|
||||||
//% "24 hours"
|
|
||||||
/* text: qsTrId("24-hours"); */
|
|
||||||
/* icon.width: 0; */
|
|
||||||
/* onTriggered: { */
|
|
||||||
/* chatsModel.muteChannel(channelContextMenu.channelIndex, Constants.muteChat24Hours) */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
/* Action { */
|
|
||||||
//% "Until I turn it back on"
|
|
||||||
/* text: qsTrId("until-i-turn-it-back-on"); */
|
|
||||||
/* icon.width: 0; */
|
|
||||||
/* onTriggered: { */
|
|
||||||
/* console.log(appSettings.mutedChannels) */
|
|
||||||
/* appSettings.mutedChannels.push({ */
|
|
||||||
/* name: "Foo" */
|
|
||||||
/* }) */
|
|
||||||
/* console.log(appSettings.mutedChannels) */
|
|
||||||
/* //chatsModel.muteChannel(channelContextMenu.channelIndex, Constants.muteChatUntilUnmuted) */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
Action {
|
Action {
|
||||||
//% "Mark as Read"
|
//% "Mark as Read"
|
||||||
text: qsTrId("mark-as-read")
|
text: qsTrId("mark-as-read")
|
||||||
|
|
Loading…
Reference in New Issue