fix: fix TopBar Row layout

This commit is contained in:
Jonathan Rainville 2021-06-11 13:59:03 -04:00
parent 0b00a426ae
commit 80a3c932ce
1 changed files with 83 additions and 79 deletions

View File

@ -12,15 +12,15 @@ Item {
height: 56 height: 56
Loader { Loader {
property bool isGroupChatOrOneToOne: (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat || property bool isGroupChatOrOneToOne: (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat ||
chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne) chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne)
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: this.isGroupChatOrOneToOne ? Style.current.padding : Style.current.padding + 4 anchors.leftMargin: this.isGroupChatOrOneToOne ? Style.current.padding : Style.current.padding + 4
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 4 anchors.topMargin: 4
anchors.right: moreActionsBtn.left anchors.right: moreActionsBtn.left
anchors.rightMargin: Style.current.padding + moreActionsBtn.width anchors.rightMargin: Style.current.padding + moreActionsBtn.width
sourceComponent: this.isGroupChatOrOneToOne ? chatInfoButton : chatInfo sourceComponent: this.isGroupChatOrOneToOne ? chatInfoButton : chatInfo
} }
Component { Component {
@ -40,15 +40,15 @@ Item {
onClicked: { onClicked: {
switch (chatsModel.activeChannel.chatType) { switch (chatsModel.activeChannel.chatType) {
case Constants.chatTypePrivateGroupChat: case Constants.chatTypePrivateGroupChat:
openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel}) openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel})
break; break;
case Constants.chatTypeOneToOne: case Constants.chatTypeOneToOne:
const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id) const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id)
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.activeChannel.id), openProfilePopup(chatsModel.userNameOrAlias(chatsModel.activeChannel.id),
chatsModel.activeChannel.id, profileImage || chatsModel.activeChannel.identicon, chatsModel.activeChannel.id, profileImage || chatsModel.activeChannel.identicon,
"", chatsModel.activeChannel.nickname) "", chatsModel.activeChannel.nickname)
break; break;
} }
} }
} }
@ -66,81 +66,85 @@ Item {
} }
} }
StatusContextMenuButton { Row {
id: moreActionsBtn height: parent.height
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding anchors.rightMargin: Style.current.smallPadding
spacing: 12
onClicked: { StatusContextMenuButton {
var menu = chatContextMenu; id: moreActionsBtn
var isPrivateGroupChat = chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat anchors.verticalCenter: parent.verticalCenter
if(isPrivateGroupChat){
menu = groupContextMenu onClicked: {
var menu = chatContextMenu;
var isPrivateGroupChat = chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat
if(isPrivateGroupChat){
menu = groupContextMenu
}
if (menu.opened) {
return menu.close()
}
if (isPrivateGroupChat) {
menu.popup(moreActionsBtn.x, moreActionsBtn.height)
} else {
menu.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx(),
moreActionsBtn.x - chatContextMenu.width + moreActionsBtn.width + 4,
moreActionsBtn.height - 4)
}
} }
if (menu.opened) { ChannelContextMenu {
return menu.close() id: chatContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
} }
if (isPrivateGroupChat) { PopupMenu {
menu.popup(moreActionsBtn.x, moreActionsBtn.height) id: groupContextMenu
} else { closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
menu.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx(), Action {
moreActionsBtn.x - chatContextMenu.width + moreActionsBtn.width + 4, icon.source: "../../../img/group_chat.svg"
moreActionsBtn.height - 4) icon.width: chatTopBarContent.iconSize
} icon.height: chatTopBarContent.iconSize
} //% "Group Information"
text: qsTrId("group-information")
ChannelContextMenu {
id: chatContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
}
PopupMenu {
id: groupContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
Action {
icon.source: "../../../img/group_chat.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Group Information"
text: qsTrId("group-information")
onTriggered: openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel }) onTriggered: openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel })
} }
Action { Action {
icon.source: "../../../img/close.svg" icon.source: "../../../img/close.svg"
icon.width: chatTopBarContent.iconSize icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize icon.height: chatTopBarContent.iconSize
//% "Clear History" //% "Clear History"
text: qsTrId("clear-history") text: qsTrId("clear-history")
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id) onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
} }
Action { Action {
icon.source: "../../../img/leave_chat.svg" icon.source: "../../../img/leave_chat.svg"
icon.width: chatTopBarContent.iconSize icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize icon.height: chatTopBarContent.iconSize
//% "Leave group"
text: qsTrId("leave-group")
onTriggered: {
//% "Leave group" //% "Leave group"
deleteChatConfirmationDialog.title = qsTrId("leave-group") text: qsTrId("leave-group")
//% "Leave group" onTriggered: {
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group") //% "Leave group"
//% "Are you sure you want to leave this chat?" deleteChatConfirmationDialog.title = qsTrId("leave-group")
deleteChatConfirmationDialog.confirmationText = qsTrId("are-you-sure-you-want-to-leave-this-chat-") //% "Leave group"
deleteChatConfirmationDialog.open() deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group")
//% "Are you sure you want to leave this chat?"
deleteChatConfirmationDialog.confirmationText = qsTrId("are-you-sure-you-want-to-leave-this-chat-")
deleteChatConfirmationDialog.open()
}
} }
} }
} }
}
Rectangle { Rectangle {
id: separator id: separator
width: 1 width: 1
height: 24 height: 24
color: Style.current.separator color: Style.current.separator
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
StatusIconButton { StatusIconButton {