status-desktop/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml

198 lines
7.4 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
2020-05-27 21:59:34 +00:00
import "../../../../shared"
import "../../../../shared/status"
2020-05-27 21:59:34 +00:00
import "../../../../imports"
import "../components"
2020-05-27 21:59:34 +00:00
Item {
2020-08-14 12:08:09 +00:00
property int iconSize: 16
2020-05-27 21:59:34 +00:00
id: chatTopBarContent
height: 56
Loader {
property bool isGroupChatOrOneToOne: (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat ||
chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne)
anchors.left: parent.left
anchors.leftMargin: this.isGroupChatOrOneToOne ? Style.current.padding : Style.current.padding + 4
anchors.top: parent.top
anchors.topMargin: 4
sourceComponent: this.isGroupChatOrOneToOne ? chatInfoButton : chatInfo
2020-05-27 21:59:34 +00:00
}
Component {
id: chatInfoButton
StatusChatInfoButton {
chatId: chatsModel.activeChannel.id
chatName: {
if (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
return chatsModel.activeChannel.name
}
chatsModel.userNameOrAlias(chatsModel.activeChannel.id)
}
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
identiconSize: 36
onClicked: {
switch (chatsModel.activeChannel.chatType) {
case Constants.chatTypePrivateGroupChat:
openPopup(groupInfoPopupComponent, {channel: chatsModel.activeChannel})
break;
case Constants.chatTypeOneToOne:
const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id)
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.activeChannel.id),
chatsModel.activeChannel.id, profileImage || chatsModel.activeChannel.identicon,
"", chatsModel.activeChannel.nickname)
break;
}
}
}
2020-05-27 21:59:34 +00:00
}
Component {
id: chatInfo
StatusChatInfo {
identiconSize: 36
2021-03-02 20:43:32 +00:00
chatId: chatsModel.activeChannel.id
chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
}
2020-05-27 21:59:34 +00:00
}
Row {
height: parent.height
2020-05-27 21:59:34 +00:00
anchors.right: parent.right
2020-07-09 17:56:31 +00:00
anchors.rightMargin: Style.current.smallPadding
spacing: 12
2020-07-09 17:56:31 +00:00
StatusContextMenuButton {
id: moreActionsBtn
anchors.verticalCenter: parent.verticalCenter
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)
}
2020-07-09 17:56:31 +00:00
}
2020-06-10 19:41:03 +00:00
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, {channel: chatsModel.activeChannel})
}
Action {
icon.source: "../../../img/close.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Clear History"
text: qsTrId("clear-history")
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
}
Action {
icon.source: "../../../img/leave_chat.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Leave group"
text: qsTrId("leave-group")
onTriggered: {
//% "Leave group"
deleteChatConfirmationDialog.title = qsTrId("leave-group")
//% "Leave group"
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()
}
}
2020-05-27 21:59:34 +00:00
}
}
2020-05-27 21:59:34 +00:00
2021-06-02 15:52:30 +00:00
// Rectangle {
// id: separator
// width: 1
// height: 24
// color: Style.current.separator
// anchors.verticalCenter: parent.verticalCenter
// }
// StatusIconButton {
// id: activityCenterBtn
// icon.name: "bell"
// iconColor: Style.current.contextMenuButtonForegroundColor
// hoveredIconColor: Style.current.contextMenuButtonForegroundColor
// highlightedBackgroundColor: Style.current.contextMenuButtonBackgroundHoverColor
// anchors.verticalCenter: parent.verticalCenter
// onClicked: activityCenter.open()
// Rectangle {
// // TODO unhardcode this
// property int nbUnseenNotifs: 3
// id: badge
// visible: nbUnseenNotifs > 0
// anchors.top: parent.top
// anchors.topMargin: -2
// anchors.left: parent.right
// anchors.leftMargin: -17
// radius: height / 2
// color: Style.current.blue
// border.color: activityCenterBtn.hovered ? Style.current.secondaryBackground : Style.current.background
// border.width: 2
// width: badge.nbUnseenNotifs < 10 ? 18 : badge.width + 14
// height: 18
// Text {
// font.pixelSize: 12
// color: Style.current.white
// anchors.centerIn: parent
// text: badge.nbUnseenNotifs
// }
// }
// }
2020-05-27 21:59:34 +00:00
}
ActivityCenter {
id: activityCenter
}
ConfirmationDialog {
id: deleteChatConfirmationDialog
btnType: "warn"
onConfirmButtonClicked: {
chatsModel.leaveActiveChat()
deleteChatConfirmationDialog.close()
}
}
}