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

174 lines
6.2 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
Rectangle {
2020-08-14 12:08:09 +00:00
property int iconSize: 16
2020-05-27 21:59:34 +00:00
id: chatTopBarContent
color: Style.current.background
2020-05-27 21:59:34 +00:00
height: 56
Layout.fillWidth: true
border.color: Style.current.border
2020-05-27 21:59:34 +00:00
border.width: 1
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: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
identiconSize: 36
onClicked: {
switch (chatsModel.activeChannel.chatType) {
case Constants.chatTypePrivateGroupChat:
groupInfoPopup.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx())
break;
case Constants.chatTypeOneToOne:
const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id)
openProfilePopup(chatsModel.activeChannel.name, 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
chatName: chatsModel.activeChannel.name
chatType: chatsModel.activeChannel.chatType
identicon: chatsModel.activeChannel.identicon
muted: chatsModel.activeChannel.muted
}
2020-05-27 21:59:34 +00:00
}
2020-07-09 17:56:31 +00:00
Rectangle {
id: moreActionsBtnContainer
width: 40
height: 40
radius: Style.current.radius
color: Style.current.transparent
2020-05-27 21:59:34 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
2020-07-09 17:56:31 +00:00
anchors.rightMargin: Style.current.smallPadding
StyledText {
id: moreActionsBtn
text: "..."
font.letterSpacing: 0.5
font.bold: true
lineHeight: 1.4
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 25
}
2020-05-27 21:59:34 +00:00
MouseArea {
id: mouseArea
anchors.fill: parent
2020-07-09 17:56:31 +00:00
hoverEnabled: true
onEntered: {
parent.color = Style.current.border
2020-07-09 17:56:31 +00:00
}
onExited: {
parent.color = Style.current.transparent
}
2020-05-27 21:59:34 +00:00
onClicked: {
2020-06-10 19:41:03 +00:00
var menu = chatContextMenu;
var isPrivateGroupChat = chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat
if(isPrivateGroupChat){
2020-06-10 19:41:03 +00:00
menu = groupContextMenu
}
if (menu.opened) {
return menu.close()
}
if (isPrivateGroupChat) {
menu.popup(moreActionsBtn.x, moreActionsBtn.height)
} else {
menu.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx())
}
2020-05-27 21:59:34 +00:00
}
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
ChannelContextMenu {
2020-06-10 19:41:03 +00:00
id: chatContextMenu
groupInfoPopup: groupInfoPopup
2020-05-27 21:59:34 +00:00
}
2020-06-10 19:41:03 +00:00
PopupMenu {
id: groupContextMenu
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
2020-06-17 19:18:31 +00:00
Action {
2020-06-11 17:50:36 +00:00
icon.source: "../../../img/group_chat.svg"
icon.width: chatTopBarContent.iconSize
icon.height: chatTopBarContent.iconSize
//% "Group Information"
text: qsTrId("group-information")
onTriggered: groupInfoPopup.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx())
2020-06-11 17:50:36 +00:00
}
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)
}
2020-06-17 19:18:31 +00:00
Action {
2020-06-10 19:41:03 +00:00
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")
2020-08-26 15:52:26 +00:00
//% "Are you sure you want to leave this chat?"
deleteChatConfirmationDialog.confirmationText = qsTrId("are-you-sure-you-want-to-leave-this-chat-")
deleteChatConfirmationDialog.open()
}
2020-06-10 19:41:03 +00:00
}
}
2020-06-11 17:50:36 +00:00
GroupInfoPopup {
id: groupInfoPopup
}
2020-05-27 21:59:34 +00:00
}
}
ConfirmationDialog {
id: deleteChatConfirmationDialog
btnType: "warn"
onConfirmButtonClicked: {
chatsModel.leaveActiveChat()
deleteChatConfirmationDialog.close()
}
}
}