Update the look of the chatbar to be floating with the rich text controls on top and send buttons inline
This commit is contained in:
@@ -110,14 +110,10 @@ QQC2.Control {
|
||||
height: implicitHeight
|
||||
y: -height - 5
|
||||
z: 10
|
||||
<<<<<<< HEAD
|
||||
|
||||
chatDocumentHandler: documentHandler
|
||||
=======
|
||||
room: root.Message.room
|
||||
type: root.chatBarCache.isEditing ? ChatBarType.Edit : ChatBarType.Thread
|
||||
// textItem: textArea
|
||||
>>>>>>> c7858a151 (Move the remaining functionality of ChatDocumentHandler to ChatTextItemHelper or split into own objects)
|
||||
margins: 0
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
|
||||
@@ -60,21 +60,6 @@ RowLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
QQC2.Button {
|
||||
id: cancelButton
|
||||
|
||||
anchors.top: root.top
|
||||
anchors.right: root.right
|
||||
|
||||
visible: root.editable
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
text: i18nc("@action:button", "Cancel reply")
|
||||
icon.name: "dialog-close"
|
||||
onClicked: root.Message.room.mainCache.replyId = ""
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
}
|
||||
HoverHandler {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
@@ -86,5 +71,22 @@ RowLayout {
|
||||
id: _private
|
||||
// The space available for the component after taking away the border
|
||||
readonly property real availableContentWidth: root.Message.maxContentWidth - verticalBorder.implicitWidth - root.spacing
|
||||
|
||||
readonly property QQC2.Button cancelButton: QQC2.Button {
|
||||
id: cancelButton
|
||||
|
||||
parent: root
|
||||
anchors.top: root.top
|
||||
anchors.right: root.right
|
||||
|
||||
visible: root.editable
|
||||
display: QQC2.AbstractButton.IconOnly
|
||||
text: i18nc("@action:button", "Cancel reply")
|
||||
icon.name: "dialog-close"
|
||||
onClicked: root.Message.room.mainCache.replyId = ""
|
||||
QQC2.ToolTip.text: text
|
||||
QQC2.ToolTip.visible: hovered
|
||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +174,11 @@ void ChatBarMessageContentModel::connectKeyHelper()
|
||||
insertComponentAtCursor(MessageComponentType::Text);
|
||||
}
|
||||
});
|
||||
connect(m_keyHelper, &ChatKeyHelper::unhandledReturn, this, [this](bool isCompleting) {
|
||||
if (!isCompleting) {
|
||||
postMessage();
|
||||
}
|
||||
});
|
||||
connect(m_keyHelper, &ChatKeyHelper::imagePasted, this, [this](const QString &filePath) {
|
||||
m_room->cacheForType(m_type)->setAttachmentPath(filePath);
|
||||
});
|
||||
@@ -448,6 +453,21 @@ void ChatBarMessageContentModel::removeAttachment()
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatBarMessageContentModel::sendMessageWithEnter() const
|
||||
{
|
||||
return m_sendMessageWithEnter;
|
||||
}
|
||||
|
||||
void ChatBarMessageContentModel::setSendMessageWithEnter(bool sendMessageWithEnter)
|
||||
{
|
||||
if (sendMessageWithEnter == m_sendMessageWithEnter) {
|
||||
return;
|
||||
}
|
||||
m_sendMessageWithEnter = sendMessageWithEnter;
|
||||
m_keyHelper->sendMessageWithEnter = sendMessageWithEnter;
|
||||
Q_EMIT sendMessageWithEnterChanged();
|
||||
}
|
||||
|
||||
ChatBarMessageContentModel::ComponentIt ChatBarMessageContentModel::removeComponent(ComponentIt it)
|
||||
{
|
||||
if (it == m_components.end()) {
|
||||
|
||||
@@ -66,6 +66,11 @@ class ChatBarMessageContentModel : public MessageContentModel
|
||||
*/
|
||||
Q_PROPERTY(bool hasRichFormatting READ hasRichFormatting NOTIFY hasRichFormattingChanged)
|
||||
|
||||
/**
|
||||
* @brief The UserListModel to be used for room completions.
|
||||
*/
|
||||
Q_PROPERTY(bool sendMessageWithEnter READ sendMessageWithEnter WRITE setSendMessageWithEnter NOTIFY sendMessageWithEnterChanged)
|
||||
|
||||
public:
|
||||
explicit ChatBarMessageContentModel(QObject *parent = nullptr);
|
||||
|
||||
@@ -89,12 +94,16 @@ public:
|
||||
|
||||
Q_INVOKABLE void removeAttachment();
|
||||
|
||||
bool sendMessageWithEnter() const;
|
||||
void setSendMessageWithEnter(bool sendMessageWithEnter);
|
||||
|
||||
Q_INVOKABLE void postMessage();
|
||||
|
||||
Q_SIGNALS:
|
||||
void typeChanged();
|
||||
void focusRowChanged();
|
||||
void hasRichFormattingChanged();
|
||||
void sendMessageWithEnterChanged();
|
||||
|
||||
private:
|
||||
ChatBarType::Type m_type = ChatBarType::None;
|
||||
@@ -125,5 +134,7 @@ private:
|
||||
void updateCache() const;
|
||||
QString messageText() const;
|
||||
|
||||
bool m_sendMessageWithEnter = true;
|
||||
|
||||
void clearModel();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user