Merge pull request #236 from monich/reply
Don't show Reply menu item if the message can't be replied to
This commit is contained in:
commit
c327d57872
2 changed files with 22 additions and 11 deletions
|
@ -28,6 +28,7 @@ ListItem {
|
||||||
property var chatId
|
property var chatId
|
||||||
property var messageId
|
property var messageId
|
||||||
property var myMessage
|
property var myMessage
|
||||||
|
property bool canReplyToMessage
|
||||||
readonly property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id)
|
readonly property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id)
|
||||||
property QtObject precalculatedValues: ListView.view.precalculatedValues
|
property QtObject precalculatedValues: ListView.view.precalculatedValues
|
||||||
readonly property color textColor: isOwnMessage ? Theme.highlightColor : Theme.primaryColor
|
readonly property color textColor: isOwnMessage ? Theme.highlightColor : Theme.primaryColor
|
||||||
|
@ -42,6 +43,9 @@ ListItem {
|
||||||
highlighted: (down || isSelected) && !menuOpen
|
highlighted: (down || isSelected) && !menuOpen
|
||||||
openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting
|
openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting
|
||||||
|
|
||||||
|
signal replyToMessage()
|
||||||
|
signal editMessage()
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(messageListItem.precalculatedValues.pageIsSelecting) {
|
if(messageListItem.precalculatedValues.pageIsSelecting) {
|
||||||
page.toggleMessageSelection(myMessage);
|
page.toggleMessageSelection(myMessage);
|
||||||
|
@ -88,20 +92,14 @@ ListItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem {
|
MenuItem {
|
||||||
onClicked: {
|
visible: messageListItem.canReplyToMessage
|
||||||
newMessageInReplyToRow.inReplyToMessage = myMessage;
|
onClicked: messageListItem.replyToMessage()
|
||||||
newMessageTextField.focus = true;
|
|
||||||
}
|
|
||||||
text: qsTr("Reply to Message")
|
text: qsTr("Reply to Message")
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
onClicked: {
|
|
||||||
newMessageColumn.editMessageId = messageId;
|
|
||||||
newMessageTextField.text = Functions.getMessageText(myMessage, false, false, true);
|
|
||||||
newMessageTextField.focus = true;
|
|
||||||
}
|
|
||||||
text: qsTr("Edit Message")
|
|
||||||
visible: myMessage.can_be_edited
|
visible: myMessage.can_be_edited
|
||||||
|
onClicked: messageListItem.editMessage()
|
||||||
|
text: qsTr("Edit Message")
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
|
@ -58,6 +58,8 @@ Page {
|
||||||
)
|
)
|
||||||
property var selectedMessages: []
|
property var selectedMessages: []
|
||||||
readonly property bool isSelecting: selectedMessages.length > 0
|
readonly property bool isSelecting: selectedMessages.length > 0
|
||||||
|
readonly property bool canSendMessages: hasSendPrivilege("can_send_messages")
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "selectMessages"
|
name: "selectMessages"
|
||||||
|
@ -77,6 +79,7 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
function toggleMessageSelection(message) {
|
function toggleMessageSelection(message) {
|
||||||
var selectionArray = selectedMessages;
|
var selectionArray = selectedMessages;
|
||||||
var foundIndex = -1
|
var foundIndex = -1
|
||||||
|
@ -923,6 +926,16 @@ Page {
|
||||||
myMessage: model.display
|
myMessage: model.display
|
||||||
messageId: model.message_id
|
messageId: model.message_id
|
||||||
extraContentComponentName: chatView.contentComponentNames[model.content_type]
|
extraContentComponentName: chatView.contentComponentNames[model.content_type]
|
||||||
|
canReplyToMessage: chatPage.canSendMessages
|
||||||
|
onReplyToMessage: {
|
||||||
|
newMessageInReplyToRow.inReplyToMessage = myMessage
|
||||||
|
newMessageTextField.focus = true
|
||||||
|
}
|
||||||
|
onEditMessage: {
|
||||||
|
newMessageColumn.editMessageId = messageId
|
||||||
|
newMessageTextField.text = Functions.getMessageText(myMessage, false, false, true)
|
||||||
|
newMessageTextField.focus = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
|
@ -1048,7 +1061,7 @@ Page {
|
||||||
height: isNeeded ? implicitHeight : 0
|
height: isNeeded ? implicitHeight : 0
|
||||||
Behavior on height { SmoothedAnimation { duration: 200 } }
|
Behavior on height { SmoothedAnimation { duration: 200 } }
|
||||||
|
|
||||||
readonly property bool isNeeded: !chatPage.isSelecting && chatPage.hasSendPrivilege("can_send_messages")
|
readonly property bool isNeeded: !chatPage.isSelecting && chatPage.canSendMessages
|
||||||
property string replyToMessageId: "0";
|
property string replyToMessageId: "0";
|
||||||
property string editMessageId: "0";
|
property string editMessageId: "0";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue