Inline Edit Fixes
- Make sure the connection to the room's chatBoxEditIdChanged signal is made so that the edit box gets filled. - Make sure the minimum height and preferred width are available to the loader so they can be set and dynamically updated. BUG: 465934
This commit is contained in:
@@ -26,9 +26,12 @@ TimelineContainer {
|
|||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.minimumHeight: item ? item.minimumHeight : -1
|
||||||
|
Layout.preferredWidth: item ? item.preferredWidth : -1
|
||||||
visible: currentRoom.chatBoxEditId === model.eventId
|
visible: currentRoom.chatBoxEditId === model.eventId
|
||||||
active: visible
|
active: visible
|
||||||
sourceComponent: MessageEditComponent {
|
sourceComponent: MessageEditComponent {
|
||||||
|
room: currentRoom
|
||||||
messageId: model.eventId
|
messageId: model.eventId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ import org.kde.neochat 1.0
|
|||||||
QQC2.TextArea {
|
QQC2.TextArea {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property var room
|
||||||
|
onRoomChanged: room.chatBoxEditIdChanged.connect(updateEditText)
|
||||||
|
|
||||||
property string messageId
|
property string messageId
|
||||||
|
|
||||||
Layout.fillWidth: true
|
property var minimumHeight: editButtons.height + topPadding + bottomPadding
|
||||||
Layout.minimumHeight: editButtons.height + topPadding + bottomPadding
|
property var preferredWidth: editTextMetrics.advanceWidth + rightPadding + Kirigami.Units.smallSpacing + Kirigami.Units.gridUnit
|
||||||
Layout.preferredWidth: editTextMetrics.advanceWidth + rightPadding + Kirigami.Units.smallSpacing + Kirigami.Units.gridUnit
|
|
||||||
rightPadding: editButtons.width + editButtons.anchors.rightMargin * 2
|
rightPadding: editButtons.width + editButtons.anchors.rightMargin * 2
|
||||||
|
|
||||||
color: Kirigami.Theme.textColor
|
color: Kirigami.Theme.textColor
|
||||||
@@ -29,7 +31,7 @@ QQC2.TextArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
currentRoom.editText = text
|
room.editText = text
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEnterPressed: {
|
Keys.onEnterPressed: {
|
||||||
@@ -91,7 +93,7 @@ QQC2.TextArea {
|
|||||||
text: i18nc("@action:button", "Cancel edit")
|
text: i18nc("@action:button", "Cancel edit")
|
||||||
icon.name: "dialog-close"
|
icon.name: "dialog-close"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
currentRoom.chatBoxEditId = "";
|
room.chatBoxEditId = "";
|
||||||
}
|
}
|
||||||
shortcut: "Escape"
|
shortcut: "Escape"
|
||||||
}
|
}
|
||||||
@@ -100,15 +102,6 @@ QQC2.TextArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: currentRoom
|
|
||||||
function onChatBoxEditIdChanged() {
|
|
||||||
if (currentRoom.chatBoxEditId == messageId && currentRoom.chatBoxEditMessage.length > 0) {
|
|
||||||
root.text = currentRoom.chatBoxEditMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CompletionMenu {
|
CompletionMenu {
|
||||||
id: completionMenu
|
id: completionMenu
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
@@ -131,7 +124,7 @@ QQC2.TextArea {
|
|||||||
cursorPosition: root.cursorPosition
|
cursorPosition: root.cursorPosition
|
||||||
selectionStart: root.selectionStart
|
selectionStart: root.selectionStart
|
||||||
selectionEnd: root.selectionEnd
|
selectionEnd: root.selectionEnd
|
||||||
room: currentRoom // We don't care about saving for edits so this is OK.
|
room: root.room // We don't care about saving for edits so this is OK.
|
||||||
}
|
}
|
||||||
|
|
||||||
TextMetrics {
|
TextMetrics {
|
||||||
@@ -142,7 +135,13 @@ QQC2.TextArea {
|
|||||||
function postEdit() {
|
function postEdit() {
|
||||||
actionsHandler.handleEdit();
|
actionsHandler.handleEdit();
|
||||||
root.clear();
|
root.clear();
|
||||||
currentRoom.chatBoxEditId = "";
|
room.chatBoxEditId = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEditText() {
|
||||||
|
if (room.chatBoxEditId == messageId && room.chatBoxEditMessage.length > 0) {
|
||||||
|
root.text = room.chatBoxEditMessage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user