Change location of chat history #LINQT-2449

This commit is contained in:
Gaelle Braud 2026-03-09 14:58:09 +01:00
parent 396ed158f5
commit 7fbc0c80d1
13 changed files with 1019 additions and 1002 deletions

View file

@ -54,13 +54,14 @@ CallHistoryCore::CallHistoryCore(const std::shared_ptr<linphone::CallLog> &callL
mDuration = QString::number(callLog->getDuration());
mIsConference = callLog->wasConference();
mCallId = Utils::coreStringToAppString(callLog->getCallId());
mHasChat = false;
if (mIsConference) {
auto confinfo = callLog->getConferenceInfo();
mConferenceInfo = ConferenceInfoCore::create(confinfo);
mRemoteAddress = Utils::coreStringToAppString(confinfo->getUri()->asStringUriOnly());
mDisplayName = Utils::coreStringToAppString(confinfo->getSubject());
if (auto chatroom = callLog->getChatRoom()) {
mChatCore = ChatCore::create(chatroom);
mHasChat = true;
}
} else {
mRemoteAddress = Utils::coreStringToAppString(addr->asStringUriOnly());
@ -160,8 +161,8 @@ void CallHistoryCore::setDuration(const QString &duration) {
}
}
ChatGui *CallHistoryCore::getChatGui() const {
return mChatCore ? new ChatGui(mChatCore) : nullptr;
std::shared_ptr<CallHistoryModel> CallHistoryCore::getModel() const {
return mCallHistoryModel;
}
void CallHistoryCore::remove() {

View file

@ -30,8 +30,6 @@
#include <linphone++/linphone.hh>
class CallHistoryModel;
class ChatCore;
class ChatGui;
class FriendModel;
class CallHistoryCore : public QObject, public AbstractObject {
@ -41,8 +39,8 @@ class CallHistoryCore : public QObject, public AbstractObject {
Q_PROPERTY(QString remoteAddress MEMBER mRemoteAddress CONSTANT)
Q_PROPERTY(bool isOutgoing MEMBER mIsOutgoing CONSTANT)
Q_PROPERTY(bool isConference MEMBER mIsConference CONSTANT)
Q_PROPERTY(bool hasChat MEMBER mHasChat CONSTANT)
Q_PROPERTY(ConferenceInfoGui *conferenceInfo READ getConferenceInfoGui CONSTANT)
Q_PROPERTY(ChatGui *chatGui READ getChatGui CONSTANT)
Q_PROPERTY(QDateTime date MEMBER mDate CONSTANT)
Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus CONSTANT)
Q_PROPERTY(QString duration READ getDuration WRITE setDuration NOTIFY durationChanged)
@ -58,7 +56,7 @@ public:
QString getDuration() const;
void setDuration(const QString &duration);
ChatGui *getChatGui() const;
std::shared_ptr<CallHistoryModel> getModel() const;
void onRemoved(const std::shared_ptr<linphone::Friend> &updatedFriend);
@ -81,7 +79,7 @@ signals:
private:
QString mDuration;
QSharedPointer<ConferenceInfoCore> mConferenceInfo = nullptr;
QSharedPointer<ChatCore> mChatCore = nullptr;
bool mHasChat = false;
std::shared_ptr<CallHistoryModel> mCallHistoryModel;
std::shared_ptr<FriendModel> mFriendModel;
QSharedPointer<SafeConnection<CallHistoryCore, FriendModel>> mFriendModelConnection;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -40,4 +40,8 @@ void CallHistoryModel::removeCallHistory() {
mustBeInLinphoneThread(getClassName() + "::removeCallHistory");
qInfo() << "Removing call log: " << Utils::coreStringToAppString(callLog->getCallId());
CoreModel::getInstance()->getCore()->removeCallLog(callLog);
}
std::shared_ptr<linphone::ChatRoom> CallHistoryModel::getChatRoom() const {
return callLog ? callLog->getChatRoom() : nullptr;
}

View file

@ -35,6 +35,7 @@ public:
~CallHistoryModel();
void removeCallHistory();
std::shared_ptr<linphone::ChatRoom> getChatRoom() const;
private:
std::shared_ptr<linphone::CallLog> callLog;

View file

@ -22,6 +22,7 @@
#include "UriTools.hpp"
#include "core/App.hpp"
#include "core/call-history/CallHistoryGui.hpp"
#include "core/call/CallGui.hpp"
#include "core/chat/ChatCore.hpp"
#include "core/chat/ChatGui.hpp"
@ -34,6 +35,7 @@
#include "core/path/Paths.hpp"
#include "core/payload-type/DownloadablePayloadTypeCore.hpp"
#include "core/recorder/RecorderGui.hpp"
#include "model/call-history/CallHistoryModel.hpp"
#include "model/object/VariantObject.hpp"
#include "model/tool/ToolModel.hpp"
#include "tool/providers/AvatarProvider.hpp"
@ -1711,6 +1713,22 @@ void Utils::openChat(ChatGui *chat) {
}
}
VariantObject *Utils::getChatForCallLog(CallHistoryGui *callLog) {
if (!callLog || !callLog->mCore) return nullptr;
VariantObject *data = new VariantObject("lookupCurrentCallChat");
if (!data) return nullptr;
data->makeRequest([core = callLog->mCore, data]() {
auto model = core->getModel();
if (!model) return QVariant();
auto chatRoom = model->getChatRoom();
if (!chatRoom) return QVariant();
auto chatCore = ChatCore::create(chatRoom);
return chatCore ? QVariant::fromValue(new ChatGui(chatCore)) : QVariant();
});
data->requestValue();
return data;
}
bool Utils::isEmptyMessage(QString message) {
return message.trimmed().isEmpty();
}

View file

@ -44,9 +44,9 @@
#endif // ifndef UTILS_NO_BREAK
class CallGui;
class CallHistoryGui;
class QQuickWindow;
class VariantObject;
class CallGui;
class ConferenceInfoGui;
class ConferenceCore;
class ParticipantDeviceCore;
@ -155,6 +155,7 @@ public:
Q_INVOKABLE static VariantObject *getChatForAddress(QString address);
Q_INVOKABLE static VariantObject *createGroupChat(QString subject, QStringList participantAddresses);
Q_INVOKABLE static void openChat(ChatGui *chat);
Q_INVOKABLE static VariantObject *getChatForCallLog(CallHistoryGui *callLog);
Q_INVOKABLE static bool isEmptyMessage(QString message);
Q_INVOKABLE static VariantObject *encodeTextToQmlRichFormat(const QString &text,
const QString &textPartToBold = QString(),

View file

@ -35,7 +35,6 @@ ColumnLayout {
property alias detailContent: detailControl.data
signal conferenceChatDisplayRequested()
signal conferenceCallHistoryDisplayRequested()
ColumnLayout {
spacing: Utils.getSizeWithScreenRatio(13)
@ -149,20 +148,15 @@ ColumnLayout {
}
LabelButton {
visible: !SettingsCpp.disableChatFeature
button.checkable: true
width: Utils.getSizeWithScreenRatio(56)
height: Utils.getSizeWithScreenRatio(56)
button.icon.width: Utils.getSizeWithScreenRatio(24)
button.icon.height: Utils.getSizeWithScreenRatio(24)
button.icon.source: button.checked ? AppIcons.callList : AppIcons.chatTeardropText
label: button.checked
//: "Call history"
? qsTr("contact_call_history_action")
//: "Conversation"
: qsTr("contact_conversation_action")
button.onCheckedChanged: {
if (button.checked) mainItem.conferenceChatDisplayRequested()
else mainItem.conferenceCallHistoryDisplayRequested()
label: qsTr("contact_conversation_action")
button.onPressed: {
mainItem.conferenceChatDisplayRequested()
}
}
}

View file

@ -14,7 +14,6 @@ Quick.Text {
anchors.fill: parent
acceptedButtons: Qt.NoButton
hoverEnabled: true
onContainsMouseChanged: console.log("mouse area contains mouse", containsMouse)
}
ToolTip {
id: tooltip

View file

@ -22,6 +22,7 @@ FocusScope {
property alias callHeaderContent: splitPanel.header.contentItem
property bool replyingToMessage: false
property bool editingMessage: false
property bool backButtonVisible: false
property string lastChar
property AccountGui currentAccount: AppCpp.currentAccount
property bool showEncryptedInfo: currentAccount && currentAccount.core.limeServerUrl !== "" && currentAccount.core.conferenceFactoryAddress !== ""
@ -29,6 +30,7 @@ FocusScope {
signal oneOneCall(bool video)
signal groupCall()
signal backButtonPressed()
onActiveFocusChanged: if(activeFocus) {
if (chatMessagesListView.lastItemVisible) chat.core.lMarkAsRead()
@ -103,7 +105,12 @@ FocusScope {
RowLayout {
id: headerInfos
spacing: Utils.getSizeWithScreenRatio(12)
// property int childrenWidth:
RoundButton {
icon.source: AppIcons.leftArrow
style: ButtonStyle.noBackground
visible: mainItem.backButtonVisible
onPressed: mainItem.backButtonPressed()
}
Avatar {
property var contactObj: mainItem.chat ? UtilsCpp.findFriendByAddress(mainItem.chat?.core.peerAddress) : null
contact: contactObj?.value || null
@ -115,7 +122,6 @@ FocusScope {
ColumnLayout {
Text {
Layout.fillWidth: true
Component.onCompleted: console.log(text, "width", width, "implicitWidth", implicitWidth, "advance", advance, contentWidth)
text: UtilsCpp.encodeEmojiToQmlRichFormat(mainItem.chat?.core.title) || ""
color: DefaultStyle.main2_600
maximumLineCount: 1

View file

@ -591,46 +591,41 @@ AbstractMainPage {
}
}
}
onConferenceChatDisplayRequested: detailContentStack.currentIndex = 1
onConferenceCallHistoryDisplayRequested: detailContentStack.currentIndex = 0
onConferenceChatDisplayRequested: {
rightPanelStackView.push(historyChatComp, {"callHistory": mainItem.selectedRowHistoryGui})
}
detailContent: Item {
Layout.preferredWidth: Utils.getSizeWithScreenRatio(360)
Layout.fillHeight: true
RoundedPane {
id: detailControl
visible: detailContentStack.currentIndex !== 0 || detailListView.count > 0
visible: detailListView.count > 0
width: parent.width
height: detailContentStack.currentIndex === 0
? Math.min(parent.height, detailListView.contentHeight) + topPadding + bottomPadding
: parent.height
height: Math.min(parent.height, detailListView.contentHeight) + topPadding + bottomPadding
background: Rectangle {
id: detailListBackground
anchors.fill: parent
color: DefaultStyle.grey_0
radius: Utils.getSizeWithScreenRatio(15)
}
contentItem: StackLayout {
id: detailContentStack
currentIndex: 0
Control.ScrollView {
id: historyScrollView
Control.ScrollBar.vertical: ScrollBar {
id: historyScrollBar
visible: historyScrollView.contentHeight > historyScrollView.height
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
}
CallHistoryListView {
id: detailListView
Layout.fillWidth: true
Layout.fillHeight: true
Layout.rightMargin: historyScrollBar.width + Utils.getSizeWithScreenRatio(8)
spacing: Utils.getSizeWithScreenRatio(14)
clip: true
searchText: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.remoteAddress : ""
busyIndicatorSize: Utils.getSizeWithScreenRatio(40)
contentItem: Control.ScrollView {
id: historyScrollView
Control.ScrollBar.vertical: ScrollBar {
id: historyScrollBar
visible: historyScrollView.contentHeight > historyScrollView.height
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
}
CallHistoryListView {
id: detailListView
Layout.fillWidth: true
Layout.fillHeight: true
Layout.rightMargin: historyScrollBar.width + Utils.getSizeWithScreenRatio(8)
spacing: Utils.getSizeWithScreenRatio(14)
clip: true
searchText: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.remoteAddress : ""
busyIndicatorSize: Utils.getSizeWithScreenRatio(40)
delegate: Item {
width: detailListView.width
@ -660,51 +655,45 @@ AbstractMainPage {
}
}
}
Text {
//: "Appel manqué"
text: modelData.core.status === LinphoneEnums.CallStatus.Missed ? qsTr("notification_missed_call_title")
: modelData.core.isOutgoing
//: "Appel sortant"
? qsTr("call_outgoing")
//: "Appel entrant"
: qsTr("call_audio_incoming")
font {
pixelSize: Typography.p1.pixelSize
weight: Typography.p1.weight
}
}
}
Text {
text: UtilsCpp.formatDate(modelData.core.date)
color: modelData.core.status === LinphoneEnums.CallStatus.Missed ? DefaultStyle.danger_500_main : DefaultStyle.main2_500_main
//: "Appel manqué"
text: modelData.core.status === LinphoneEnums.CallStatus.Missed ? qsTr("notification_missed_call_title")
: modelData.core.isOutgoing
//: "Appel sortant"
? qsTr("call_outgoing")
//: "Appel entrant"
: qsTr("call_audio_incoming")
font {
pixelSize: Utils.getSizeWithScreenRatio(12)
weight: Utils.getSizeWithScreenRatio(300)
pixelSize: Typography.p1.pixelSize
weight: Typography.p1.weight
}
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
Text {
text: UtilsCpp.formatElapsedTime(
modelData.core.duration,
false)
text: UtilsCpp.formatDate(modelData.core.date)
color: modelData.core.status === LinphoneEnums.CallStatus.Missed ? DefaultStyle.danger_500_main : DefaultStyle.main2_500_main
font {
pixelSize: Utils.getSizeWithScreenRatio(12)
weight: Utils.getSizeWithScreenRatio(300)
}
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
Text {
text: UtilsCpp.formatElapsedTime(
modelData.core.duration,
false)
font {
pixelSize: Utils.getSizeWithScreenRatio(12)
weight: Utils.getSizeWithScreenRatio(300)
}
}
}
}
}
SelectedChatView {
Layout.fillWidth: true
Layout.fillHeight: true
chat: contactDetail.callHistoryGui.core.chatGui
}
}
}
}
@ -714,6 +703,18 @@ AbstractMainPage {
}
}
}
Component {
id: historyChatComp
SelectedChatView {
backButtonVisible: true
property var callHistory: null
property var chatObj: callHistory ? UtilsCpp.getChatForCallLog(callHistory) : null
chat: chatObj ? chatObj.value : null
onBackButtonPressed: {
rightPanelStackView.pop()
}
}
}
component IconLabel: RowLayout {
id: iconLabel