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

220 lines
7.1 KiB
QML
Raw Normal View History

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import "../../../../imports"
2020-07-06 17:54:41 +00:00
import "../../../../shared"
import "../components"
Item {
property int iconPadding: 6
property var addToChat: function () {}
property var onSend: function () {}
id: chatButtonsContainer
width: {
var w = chatSendBtn.width + emojiIconContainer.width + 2 * iconPadding
if(stickerIconContainer.visible) {
w += stickerIconContainer.width + 2 * iconPadding;
}
if(imageIconContainer.visible) {
w += imageIconContainer.width + 2 * iconPadding;
}
return w;
}
2020-07-09 19:10:28 +00:00
Button {
id: chatSendBtn
visible: txtData.length > 0 || chatColumn.isImage
width: 30
height: 30
text: ""
anchors.rightMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
onClicked: {
onSend();
}
background: Rectangle {
color: parent.enabled ? Style.current.blue : Style.current.grey
radius: 50
}
2020-07-06 17:54:41 +00:00
SVGImage {
source: "../../../img/arrowUp.svg"
2020-07-09 19:10:28 +00:00
width: 13
height: 17
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
property bool hovered: false
id: emojiIconContainer
width: emojiIcon.width + chatButtonsContainer.iconPadding * 2
height: emojiIcon.height + chatButtonsContainer.iconPadding * 2
anchors.right: {
if(stickerIconContainer.visible) return stickerIconContainer.left;
if(imageIconContainer.visible) return imageIconContainer.left;
return chatSendBtn.left;
}
anchors.rightMargin: Style.current.padding - chatButtonsContainer.iconPadding * 2
anchors.verticalCenter: parent.verticalCenter
radius: Style.current.radius
color: hovered ? Style.current.secondaryBackground : Style.current.transparent
2020-07-06 17:54:41 +00:00
SVGImage {
id: emojiIcon
visible: txtData.length == 0
width: 20
height: 20
2020-07-06 17:54:41 +00:00
// fillMode: Image.PreserveAspectFit
source: "../../../img/emojiBtn.svg"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
}
ColorOverlay {
anchors.fill: emojiIcon
source: emojiIcon
color: emojiIconContainer.hovered || emojiPopup.opened ? Style.current.blue : Style.current.darkGrey
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: {
emojiIconContainer.hovered = true
}
onExited: {
emojiIconContainer.hovered = false
}
onClicked: {
if (emojiPopup.opened) {
emojiPopup.close()
} else {
emojiPopup.open()
}
}
}
}
Rectangle {
property bool hovered: false
id: stickerIconContainer
visible: !chatColumn.isExtendedInput && txtData.length == 0
width: emojiIcon.width + chatButtonsContainer.iconPadding * 2
height: emojiIcon.height + chatButtonsContainer.iconPadding * 2
anchors.right: imageIconContainer.visible ? imageIconContainer.left : parent.right
anchors.rightMargin: Style.current.padding - chatButtonsContainer.iconPadding * (imageIconContainer.visible ? 2 : 1)
anchors.verticalCenter: parent.verticalCenter
radius: Style.current.radius
color: hovered ? Style.current.secondaryBackground : Style.current.transparent
Image {
id: stickersIcon
width: 20
height: 20
fillMode: Image.PreserveAspectFit
source: "../../../img/stickers_icon.svg"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
}
ColorOverlay {
anchors.fill: stickersIcon
source: stickersIcon
color: stickerIconContainer.hovered || stickersPopup.opened ? Style.current.blue : Style.current.darkGrey
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: {
stickerIconContainer.hovered = true
}
onExited: {
stickerIconContainer.hovered = false
}
onClicked: {
if (stickersPopup.opened) {
stickersPopup.close()
} else {
stickersPopup.open()
}
}
}
}
Rectangle {
property bool hovered: false
visible: !chatColumn.isExtendedInput && (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne)
id: imageIconContainer
width: emojiIcon.width + chatButtonsContainer.iconPadding * 2
height: emojiIcon.height + chatButtonsContainer.iconPadding * 2
anchors.right: chatSendBtn.visible ? chatSendBtn.left : parent.right
anchors.rightMargin: Style.current.padding - chatButtonsContainer.iconPadding
anchors.verticalCenter: parent.verticalCenter
radius: Style.current.radius
color: hovered ? Style.current.secondaryBackground : Style.current.transparent
Image {
id: imageIcon
width: 20
height: 20
fillMode: Image.PreserveAspectFit
source: "../../../img/images_icon.svg"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
}
ColorOverlay {
anchors.fill: imageIcon
source: imageIcon
color: imageIconContainer.hovered ? Style.current.blue : Style.current.darkGrey
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onEntered: {
imageIconContainer.hovered = true
}
onExited: {
imageIconContainer.hovered = false
}
onClicked: {
imageDialog.open();
}
}
}
StickersPopup {
id: stickersPopup
width: 360
height: 440
x: parent.width - width - 8
y: parent.height - sendBtns.height - height - 8
recentStickers: chatsModel.recentStickers
stickerPackList: chatsModel.stickerPacks
}
EmojiPopup {
id: emojiPopup
width: 360
height: 440
x: parent.width - width - 8
y: parent.height - sendBtns.height - height - 8
addToChat: chatButtonsContainer.addToChat
}
}
/*##^##
Designer {
2020-07-09 19:10:28 +00:00
D{i:0;formeditorColor:"#ffffff";formeditorZoom:1.75}
}
##^##*/