Add/View contact from a message.

This commit is contained in:
Julien Wadel 2023-02-27 12:18:44 +01:00
parent d77c818005
commit fdf56bf24a
24 changed files with 201 additions and 7 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Accept/decline CLI commands.
- Colored Emojis with its own font family.
- OAuth2 connection to retrieve remote provisioning (Experimental and not usable without configuration).
- Add/View contact from a message.
## 5.0.11 - undefined

View file

@ -706,6 +706,16 @@ Server url ikke konfigureret.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Besvar</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ Server URL ist nicht konfiguriert.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Antworten</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ Server URL not configured.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Reply</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation>View contact</translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation>Add to contacts</translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ URL del servidor no configurada.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Responder</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ URL du serveur non configurée.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Répondre</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -704,6 +704,16 @@ A kiszolgáló URL-je nincs konfigurálva.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Válasz</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ URL del server non configurato.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Rispondi</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -704,6 +704,16 @@
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -708,6 +708,16 @@ Nesukonfigūruotas serverio url.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ URL do servidor não configurado.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -708,6 +708,16 @@
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Ответить</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -706,6 +706,16 @@ Serverwebbadressen är inte konfigurerad.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Svara</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -704,6 +704,16 @@ Sunucu url&apos;si yapılandırılmadı.</translation>
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation>Yanıtla</translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -708,6 +708,16 @@
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -704,6 +704,16 @@
<extracomment>&apos;Reply&apos; : Reply to a message from menu</extracomment>
<translation></translation>
</message>
<message>
<source>menuViewContact</source>
<extracomment>&apos;View contact&apos; : Menu item to view the contact.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<source>menuAddContact</source>
<extracomment>&apos;Add to contacts&apos; : Menu item to add the contact to address book.</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatNoticeModel</name>

View file

@ -158,7 +158,7 @@ QString ChatMessageModel::getToSipAddress() const{
}
ContactModel * ChatMessageModel::getContactModel() const{
return mChatMessage ? CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(Utils::coreStringToAppString(mChatMessage->getFromAddress()->asString())).get() : nullptr;
return mChatMessage ? CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(Utils::cleanSipAddress(Utils::coreStringToAppString(mChatMessage->getFromAddress()->asStringUriOnly()))).get() : nullptr;
}
bool ChatMessageModel::isEphemeral() const{

View file

@ -53,6 +53,10 @@ QtObject {
property string view : 'contact_view_custom'
}
property QtObject entry: QtObject{
property int iconSize: 30
}
property QtObject normal : QtObject{
property int leftMargin: 5

View file

@ -28,6 +28,9 @@ Rectangle {
// ---------------------------------------------------------------------------
signal messageToSend (string text)
signal addContactClicked(string contactAddress)
signal viewContactClicked(string contactAddress)
// ---------------------------------------------------------------------------
@ -314,6 +317,8 @@ Rectangle {
container.goToMessage(message) // sometimes, there is no access to chat id (maybe because of cleaning component while loading new items). Use a global intermediate.
}
onConferenceIcsCopied: container.noticeBannerText = qsTr('conferencesCopiedICS')
onAddContactClicked: container.addContactClicked(contactAddress)
onViewContactClicked: container.viewContactClicked(contactAddress)
}
}
}

View file

@ -31,12 +31,15 @@ Item {
signal copySelectionDone()
signal replyClicked()
signal forwardClicked()
signal addContactClicked(string contactAddress)
signal viewContactClicked(string contactAddress)
function open(){
messageMenu.popup()
}
property string chatTextContent: chatMessageModel && chatMessageModel.content
property bool isContact: (chatMessageModel && chatMessageModel.contactModel) || false
Menu {
@ -48,7 +51,7 @@ Item {
//: 'Copy' : Text menu to copy selected text in message into clipboard
: qsTr('menuCopy'))
iconMenu: MenuItemStyle.copy.icon
iconSizeMenu: MenuItemStyle.copy.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
onTriggered: {
@ -67,7 +70,7 @@ Item {
enabled: TextToSpeech.available
text: qsTr('menuPlayMe')
iconMenu: MenuItemStyle.speaker.icon
iconSizeMenu: MenuItemStyle.speaker.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
onTriggered: TextToSpeech.say(container.chatTextContent)
@ -77,7 +80,7 @@ Item {
//: 'Forward' : Forward a message from menu
text: qsTr('menuForward')
iconMenu: MenuItemStyle.forward.icon
iconSizeMenu: MenuItemStyle.forward.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
onTriggered: container.forwardClicked()
@ -87,7 +90,7 @@ Item {
//: 'Reply' : Reply to a message from menu
text: qsTr('menuReply')
iconMenu: MenuItemStyle.reply.icon
iconSizeMenu: MenuItemStyle.reply.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
onTriggered: container.replyClicked()
@ -101,17 +104,30 @@ Item {
: qsTr('menuDeliveryStatus')
)
iconMenu: MenuItemStyle.imdn.icon
iconSizeMenu: MenuItemStyle.imdn.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
visible: container.deliveryCount > 0
onTriggered: container.deliveryStatusClicked()
}
MenuItem {
text: container.isContact
//: 'View contact' : Menu item to view the contact.
? qsTr('menuViewContact')
//: 'Add to contacts' : Menu item to add the contact to address book.
: qsTr('menuAddContact')
iconMenu: container.isContact ? MenuItemStyle.contact.view : MenuItemStyle.contact.add
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.aux
visible: !chatMessageModel.isOutgoing
onTriggered: container.isContact ? container.viewContactClicked(container.chatMessageModel.fromSipAddress) : container.addContactClicked(container.chatMessageModel.fromSipAddress)
}
MenuItem {
//: 'Delete' : Item menu to delete a message
text: qsTr('menuDelete')
iconMenu: MenuItemStyle.deleteEntry.icon
iconSizeMenu: MenuItemStyle.deleteEntry.iconSize
iconSizeMenu: MenuItemStyle.entry.iconSize
iconLayoutDirection: Qt.RightToLeft
menuItemStyle : MenuItemStyle.auxError
onTriggered: container.removeEntryRequested()

View file

@ -18,6 +18,8 @@ RowLayout {
signal forwardClicked()
signal goToMessage(ChatMessageModel message)
signal conferenceIcsCopied()
signal addContactClicked(string contactAddress)
signal viewContactClicked(string contactAddress)
implicitHeight: message.height
spacing: 0
@ -70,6 +72,8 @@ RowLayout {
onForwardClicked: parent.forwardClicked()
onGoToMessage: parent.goToMessage(message)
onConferenceIcsCopied: parent.conferenceIcsCopied()
onAddContactClicked: parent.addContactClicked(contactAddress)
onViewContactClicked: parent.viewContactClicked(contactAddress)
Layout.fillWidth: true

View file

@ -36,6 +36,8 @@ Item {
signal forwardClicked()
signal goToMessage(ChatMessageModel message)
signal conferenceIcsCopied()
signal addContactClicked(string contactAddress)
signal viewContactClicked(string contactAddress)
// ---------------------------------------------------------------------------
property string lastTextSelected
@ -211,5 +213,7 @@ Item {
onCopySelectionDone: container.copySelectionDone()
onReplyClicked: container.replyClicked()
onForwardClicked: container.forwardClicked()
onAddContactClicked: container.addContactClicked(contactAddress)
onViewContactClicked: container.viewContactClicked(contactAddress)
}
}

View file

@ -21,6 +21,8 @@ Item {
signal forwardClicked()
signal goToMessage(ChatMessageModel message)
signal conferenceIcsCopied()
signal addContactClicked(string contactAddress)
signal viewContactClicked(string contactAddress)
Message {
id: message
@ -31,6 +33,8 @@ Item {
onForwardClicked: parent.forwardClicked()
onGoToMessage: parent.goToMessage(message)
onConferenceIcsCopied: parent.conferenceIcsCopied()
onAddContactClicked: parent.addContactClicked(contactAddress)
onViewContactClicked: parent.viewContactClicked(contactAddress)
anchors {
left: parent.left

View file

@ -665,6 +665,12 @@ ColumnLayout {
updateFilter()
}
}
onAddContactClicked: window.setView('ContactEdit', {
sipAddress: contactAddress
})
onViewContactClicked: window.setView('ContactEdit', {
sipAddress: contactAddress
})
}
Connections {