ChatBar animated its implicit height, and there is no way for us to force it animating on integer values only. It is contained in a Layout type, and QtQuick.Layouts are known to round up size of their items and position them on an integer scale. All in all, is caused bottom of chat bar (action icons row and the whole bottom edge) to flicker during height animation.
87 lines
2.3 KiB
QML
87 lines
2.3 KiB
QML
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
|
|
// SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import QtQuick 2.15
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import org.kde.kirigami 2.15 as Kirigami
|
|
import org.kde.neochat 1.0
|
|
|
|
/**
|
|
* @brief A component for typing and sending chat messages.
|
|
*
|
|
* This is designed to go to the bottom of the timeline and provides all the functionality
|
|
* required for the user to send messages to the room.
|
|
*
|
|
* This includes support for the following message types:
|
|
* - text
|
|
* - media (video, image, file)
|
|
* - emojis/stickers
|
|
* - location
|
|
*
|
|
* In addition when replying this component supports showing the message that is being
|
|
* replied to.
|
|
*
|
|
* @note The main role of this component is to layout the elements. The main functionality
|
|
* is handled by ChatBar
|
|
*
|
|
* @sa ChatBar
|
|
*/
|
|
ColumnLayout {
|
|
id: root
|
|
|
|
/**
|
|
* @brief The current room that user is viewing.
|
|
*/
|
|
required property NeoChatRoom currentRoom
|
|
|
|
/**
|
|
* @brief A message has been sent from the chat bar.
|
|
*/
|
|
signal messageSent()
|
|
|
|
/**
|
|
* @brief Insert the given text into the ChatBar.
|
|
*
|
|
* The text is inserted at the current cursor location.
|
|
*/
|
|
function insertText(text) {
|
|
chatBar.insertText(text)
|
|
}
|
|
|
|
spacing: 0
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
|
Kirigami.Theme.inherit: false
|
|
|
|
Kirigami.Separator {
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
ChatBar {
|
|
id: chatBar
|
|
|
|
visible: root.currentRoom.canSendEvent("m.room.message")
|
|
|
|
Layout.fillWidth: true
|
|
Layout.minimumHeight: Math.max(Kirigami.Units.gridUnit * 2, Math.round(implicitHeight) + Kirigami.Units.largeSpacing)
|
|
// lineSpacing is height+leading, so subtract leading once since leading only exists between lines.
|
|
Layout.maximumHeight: chatBarFontMetrics.lineSpacing * 8 - chatBarFontMetrics.leading + textField.topPadding + textField.bottomPadding
|
|
Layout.preferredHeight: Math.round(implicitHeight)
|
|
|
|
currentRoom: root.currentRoom
|
|
|
|
FontMetrics {
|
|
id: chatBarFontMetrics
|
|
font: chatBar.textField.font
|
|
}
|
|
|
|
onMessageSent: {
|
|
root.messageSent();
|
|
}
|
|
}
|
|
|
|
onActiveFocusChanged: chatBar.forceActiveFocus()
|
|
}
|