Introduce explicit clear button for in-reply-to and edit message, fixes #69

This commit is contained in:
Sebastian J. Wolf 2020-10-18 21:54:15 +02:00
parent 6161bc2894
commit dba973b522
2 changed files with 74 additions and 42 deletions

View file

@ -31,6 +31,9 @@ Row {
property string myUserId; property string myUserId;
property variant inReplyToMessage; property variant inReplyToMessage;
property bool editable: false;
signal clearRequested()
onInReplyToMessageChanged: { onInReplyToMessageChanged: {
if (inReplyToMessage) { if (inReplyToMessage) {
@ -47,10 +50,14 @@ Row {
border.width: 0 border.width: 0
} }
Row {
width: parent.width - Theme.paddingSmall - inReplyToMessageRectangle.width
spacing: Theme.paddingSmall
Column { Column {
id: inReplyToMessageColumn id: inReplyToMessageColumn
spacing: Theme.paddingSmall spacing: Theme.paddingSmall
width: parent.width - Theme.paddingSmall - inReplyToMessageRectangle.width width: parent.width - ( inReplyToRow.editable ? ( Theme.paddingSmall + removeInReplyToIconButton.width ) : 0 )
Text { Text {
id: inReplyToUserText id: inReplyToUserText
@ -82,4 +89,14 @@ Row {
} }
} }
IconButton {
id: removeInReplyToIconButton
icon.source: "image://theme/icon-m-clear"
visible: inReplyToRow.editable
onClicked: {
inReplyToRow.clearRequested();
}
}
}
} }

View file

@ -175,6 +175,8 @@ Page {
} }
} }
controlSendButton(); controlSendButton();
newMessageInReplyToRow.inReplyToMessage = null;
newMessageColumn.editMessageId = "0";
} }
function getWordBoundaries(text, cursorPosition) { function getWordBoundaries(text, cursorPosition) {
@ -1088,6 +1090,12 @@ Page {
} }
} }
editable: true
onClearRequested: {
newMessageInReplyToRow.inReplyToMessage = null;
}
id: newMessageInReplyToRow id: newMessageInReplyToRow
myUserId: chatPage.myUserId myUserId: chatPage.myUserId
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@ -1265,15 +1273,31 @@ Page {
} }
} }
Text { Row {
width: parent.width width: parent.width
spacing: Theme.paddingSmall
visible: newMessageColumn.editMessageId !== "0"
Text {
width: parent.width - Theme.paddingSmall - removeEditMessageIconButton.width
anchors.verticalCenter: parent.verticalCenter
id: editMessageText id: editMessageText
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
font.bold: true font.bold: true
text: qsTr("Edit Message") text: qsTr("Edit Message")
color: Theme.secondaryColor color: Theme.secondaryColor
visible: newMessageColumn.editMessageId !== "0" }
IconButton {
id: removeEditMessageIconButton
icon.source: "image://theme/icon-m-clear"
onClicked: {
newMessageColumn.editMessageId = "0";
newMessageTextField.text = "";
}
}
} }
Row { Row {
@ -1291,15 +1315,6 @@ Page {
labelVisible: false labelVisible: false
textLeftMargin: 0 textLeftMargin: 0
textTopMargin: 0 textTopMargin: 0
onFocusChanged: {
if (!focus) {
newMessageInReplyToRow.inReplyToMessage = null;
if (newMessageColumn.editMessageId !== "0") {
newMessageColumn.editMessageId = "0";
newMessageTextField.text = "";
}
}
}
EnterKey.onClicked: { EnterKey.onClicked: {
if (appSettings.sendByEnter) { if (appSettings.sendByEnter) {
sendMessage(); sendMessage();