Fix reply component
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
|
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
|
||||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtTest
|
import QtTest
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
|
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
|
||||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtTest
|
import QtTest
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
|
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
|
||||||
// SPDX-License-Identifier: LGPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtTest
|
import QtTest
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
|
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
|
||||||
// SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
|
// SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
|
||||||
|
// SPDX-FileCopyrightText: 2026 James Graham <james.h.graham@protonmail.com>
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
@@ -118,7 +119,9 @@ Item {
|
|||||||
sendMessageWithEnter: NeoChatConfig.sendMessageWith === 0
|
sendMessageWithEnter: NeoChatConfig.sendMessageWith === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: MessageComponentChooser {}
|
delegate: MessageComponentChooser {
|
||||||
|
rightAnchorMargin: chatScrollView.QQC2.ScrollBar.vertical.visible ? chatScrollView.QQC2.ScrollBar.vertical.width : 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ChatButtonHelper : public QObject
|
|||||||
Q_PROPERTY(ChatTextItemHelper *textItem READ textItem WRITE setTextItem NOTIFY textItemChanged)
|
Q_PROPERTY(ChatTextItemHelper *textItem READ textItem WRITE setTextItem NOTIFY textItemChanged)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whether the text format at the current cursor is bold.
|
* @brief Whether rich formating is enabled at the current cursor location.
|
||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool richFormatEnabled READ richFormatEnabled NOTIFY richFormatEnabledChanged)
|
Q_PROPERTY(bool richFormatEnabled READ richFormatEnabled NOTIFY richFormatEnabledChanged)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ import org.kde.neochat
|
|||||||
DelegateChooser {
|
DelegateChooser {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extra margin required when anchoring an item on the right.
|
||||||
|
*
|
||||||
|
* Normally used for scrollbars.
|
||||||
|
*/
|
||||||
|
property int rightAnchorMargin: 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -119,7 +126,9 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Reply
|
roleValue: MessageComponentType.Reply
|
||||||
delegate: ReplyComponent {}
|
delegate: ReplyComponent {
|
||||||
|
rightAnchorMargin: root.rightAnchorMargin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.kde.neochat
|
|||||||
* show in their original form and are instead visualised with a MIME type delegate
|
* show in their original form and are instead visualised with a MIME type delegate
|
||||||
* e.g. Videos.
|
* e.g. Videos.
|
||||||
*/
|
*/
|
||||||
RowLayout {
|
QQC2.Control {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,59 +34,69 @@ RowLayout {
|
|||||||
*/
|
*/
|
||||||
required property bool editable
|
required property bool editable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extra margin required when anchoring an item on the right.
|
||||||
|
*
|
||||||
|
* Normally used for scrollbars.
|
||||||
|
*/
|
||||||
|
property int rightAnchorMargin: 0
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
padding: 0
|
||||||
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
contentItem: RowLayout {
|
||||||
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: verticalBorder
|
id: verticalBorder
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
implicitWidth: Kirigami.Units.smallSpacing
|
implicitWidth: Kirigami.Units.smallSpacing
|
||||||
color: root.replyContentModel.author?.color ?? Kirigami.Theme.highlightColor
|
color: root.replyContentModel.author?.color ?? Kirigami.Theme.highlightColor
|
||||||
radius: Kirigami.Units.cornerRadius
|
radius: Kirigami.Units.cornerRadius
|
||||||
}
|
}
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
Message.maxContentWidth: _private.availableContentWidth
|
Message.maxContentWidth: _private.availableContentWidth
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: contentRepeater
|
id: contentRepeater
|
||||||
model: root.replyContentModel
|
model: root.replyContentModel
|
||||||
delegate: ReplyMessageComponentChooser {
|
delegate: ReplyMessageComponentChooser {
|
||||||
onReplyClicked: RoomManager.goToEvent(root.replyContentModel.eventId)
|
onReplyClicked: RoomManager.goToEvent(root.replyContentModel.eventId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
HoverHandler {
|
||||||
HoverHandler {
|
cursorShape: Qt.PointingHandCursor
|
||||||
cursorShape: Qt.PointingHandCursor
|
}
|
||||||
}
|
TapHandler {
|
||||||
TapHandler {
|
acceptedButtons: Qt.LeftButton
|
||||||
acceptedButtons: Qt.LeftButton
|
onTapped: RoomManager.goToEvent(root.replyContentModel.eventId)
|
||||||
onTapped: RoomManager.goToEvent(root.replyContentModel.eventId)
|
}
|
||||||
}
|
QtObject {
|
||||||
QtObject {
|
id: _private
|
||||||
id: _private
|
// The space available for the component after taking away the border
|
||||||
// The space available for the component after taking away the border
|
readonly property real availableContentWidth: root.Message.maxContentWidth - verticalBorder.implicitWidth - root.spacing
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQC2.Button {
|
||||||
|
id: cancelButton
|
||||||
|
anchors.top: root.top
|
||||||
|
anchors.topMargin: Kirigami.Units.smallSpacing
|
||||||
|
anchors.right: root.right
|
||||||
|
anchors.rightMargin: root.rightAnchorMargin + Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user