diff --git a/Linphone/core/call-history/CallHistoryList.cpp b/Linphone/core/call-history/CallHistoryList.cpp index 686e2c034..58dec0086 100644 --- a/Linphone/core/call-history/CallHistoryList.cpp +++ b/Linphone/core/call-history/CallHistoryList.cpp @@ -57,10 +57,12 @@ void CallHistoryList::setSelf(QSharedPointer me) { mModelConnection = SafeConnection::create(me, CoreModel::getInstance()); mModelConnection->makeConnectToCore(&CallHistoryList::lUpdate, [this]() { + clearData(); + emit listAboutToBeReset(); mModelConnection->invokeToModel([this]() { + mustBeInLinphoneThread(getClassName()); // Avoid copy to lambdas QList> *callLogs = new QList>(); - mustBeInLinphoneThread(getClassName()); std::list> linphoneCallLogs; if (auto account = CoreModel::getInstance()->getCore()->getDefaultAccount()) { linphoneCallLogs = account->getCallLogs(); diff --git a/Linphone/core/call-history/CallHistoryList.hpp b/Linphone/core/call-history/CallHistoryList.hpp index e650af761..e91e233f4 100644 --- a/Linphone/core/call-history/CallHistoryList.hpp +++ b/Linphone/core/call-history/CallHistoryList.hpp @@ -62,6 +62,7 @@ signals: void lUpdate(); void lRemoveEntriesForAddress(QString address); void lRemoveAllEntries(); + void listAboutToBeReset(); private: // Check the state from CallHistoryCore: sender() must be a CallHistoryCore. diff --git a/Linphone/core/call-history/CallHistoryProxy.cpp b/Linphone/core/call-history/CallHistoryProxy.cpp index 657d1eb4c..57552f85b 100644 --- a/Linphone/core/call-history/CallHistoryProxy.cpp +++ b/Linphone/core/call-history/CallHistoryProxy.cpp @@ -27,6 +27,7 @@ DEFINE_ABSTRACT_OBJECT(CallHistoryProxy) CallHistoryProxy::CallHistoryProxy(QObject *parent) : LimitProxy(parent) { mHistoryList = CallHistoryList::create(); + connect(mHistoryList.get(), &CallHistoryList::listAboutToBeReset, this, &CallHistoryProxy::listAboutToBeReset); setSourceModels(new SortFilterList(mHistoryList.get(), Qt::DescendingOrder)); connect(App::getInstance(), &App::currentDateChanged, this, [this] { emit mHistoryList->lUpdate(); }); } @@ -56,7 +57,7 @@ bool CallHistoryProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QMo QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); auto callLog = getItemAtSource(sourceRow); - show = callLog->mDisplayName.contains(search) || callLog->mRemoteAddress.contains(search); + show = callLog && (callLog->mDisplayName.contains(search) || callLog->mRemoteAddress.contains(search)); } return show; } diff --git a/Linphone/core/call-history/CallHistoryProxy.hpp b/Linphone/core/call-history/CallHistoryProxy.hpp index 309a6c455..1ee5bbad9 100644 --- a/Linphone/core/call-history/CallHistoryProxy.hpp +++ b/Linphone/core/call-history/CallHistoryProxy.hpp @@ -41,6 +41,9 @@ public: Q_INVOKABLE void removeEntriesWithFilter(QString filter); Q_INVOKABLE void reload(); +signals: + void listAboutToBeReset(); + protected: QSharedPointer mHistoryList; diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 6fd1d2c3c..344301c33 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -81,6 +81,8 @@ void ChatList::connectItem(QSharedPointer chat) { void ChatList::setSelf(QSharedPointer me) { mModelConnection = SafeConnection::create(me, CoreModel::getInstance()); mModelConnection->makeConnectToCore(&ChatList::lUpdate, [this]() { + clearData(); + emit listAboutToBeReset(); mModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(getClassName()); // Avoid copy to lambdas @@ -126,13 +128,13 @@ void ChatList::setSelf(QSharedPointer me) { qWarning() << log().arg("Receiver account has no address, return"); return; } - auto senderAddress = message->getFromAddress(); auto defaultAddress = core->getDefaultAccount()->getContactAddress(); - if (!defaultAddress->weakEqual(receiverAddress)) { + if (defaultAddress && !defaultAddress->weakEqual(receiverAddress)) { qDebug() << log().arg("Receiver account is not the default one, do not add chat to list"); return; } - if (defaultAddress->weakEqual(senderAddress)) { + auto senderAddress = message->getFromAddress(); + if (defaultAddress && defaultAddress->weakEqual(senderAddress)) { qDebug() << log().arg("Sender account is the default one, do not add chat to list"); return; } diff --git a/Linphone/core/chat/ChatList.hpp b/Linphone/core/chat/ChatList.hpp index 3623b02f9..31f9c1764 100644 --- a/Linphone/core/chat/ChatList.hpp +++ b/Linphone/core/chat/ChatList.hpp @@ -51,6 +51,7 @@ signals: void chatRemoved(ChatGui *chat); void chatAdded(); void chatUpdated(); + void listAboutToBeReset(); private: QString mFilter; diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index 47d683415..194bef870 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -44,6 +44,7 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { connect(this, &ChatProxy::filterTextChanged, newChatList, [this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); connect(newChatList, &ChatList::chatRemoved, this, &ChatProxy::chatRemoved); + connect(newChatList, &ChatList::listAboutToBeReset, this, &ChatProxy::listAboutToBeReset); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); } diff --git a/Linphone/core/chat/ChatProxy.hpp b/Linphone/core/chat/ChatProxy.hpp index 02a980ed6..8f4682c42 100644 --- a/Linphone/core/chat/ChatProxy.hpp +++ b/Linphone/core/chat/ChatProxy.hpp @@ -44,6 +44,7 @@ public: signals: void chatRemoved(ChatGui *chat); + void listAboutToBeReset(); protected: QSharedPointer mList; diff --git a/Linphone/core/chat/message/EventLogList.cpp b/Linphone/core/chat/message/EventLogList.cpp index aea39b0e1..ca5962d2e 100644 --- a/Linphone/core/chat/message/EventLogList.cpp +++ b/Linphone/core/chat/message/EventLogList.cpp @@ -150,6 +150,8 @@ void EventLogList::findChatMessageWithFilter(QString filter, void EventLogList::setSelf(QSharedPointer me) { connect(this, &EventLogList::lUpdate, this, [this]() { + resetData(); + emit listAboutToBeReset(); for (auto &event : getSharedList()) { auto message = event->getChatMessageCore(); if (message) disconnect(message.get(), &ChatMessageCore::deleted, this, nullptr); diff --git a/Linphone/core/chat/message/EventLogList.hpp b/Linphone/core/chat/message/EventLogList.hpp index d0e65b108..685de1f6d 100644 --- a/Linphone/core/chat/message/EventLogList.hpp +++ b/Linphone/core/chat/message/EventLogList.hpp @@ -64,6 +64,7 @@ signals: void eventChanged(); void eventInserted(int index, EventLogGui *message); void messageWithFilterFound(int index); + void listAboutToBeReset(); private: QString mFilter; diff --git a/Linphone/core/chat/message/EventLogProxy.cpp b/Linphone/core/chat/message/EventLogProxy.cpp index f3f30bf2c..1f0e26d57 100644 --- a/Linphone/core/chat/message/EventLogProxy.cpp +++ b/Linphone/core/chat/message/EventLogProxy.cpp @@ -42,6 +42,7 @@ void EventLogProxy::setSourceModel(QAbstractItemModel *model) { auto newEventLogList = dynamic_cast(model); if (newEventLogList) { connect(newEventLogList, &EventLogList::eventChanged, this, &EventLogProxy::eventChanged); + connect(newEventLogList, &EventLogList::listAboutToBeReset, this, &EventLogProxy::listAboutToBeReset); connect(newEventLogList, &EventLogList::eventInserted, this, [this, newEventLogList](int index, EventLogGui *event) { invalidate(); diff --git a/Linphone/core/chat/message/EventLogProxy.hpp b/Linphone/core/chat/message/EventLogProxy.hpp index fc117e4bf..164cbb615 100644 --- a/Linphone/core/chat/message/EventLogProxy.hpp +++ b/Linphone/core/chat/message/EventLogProxy.hpp @@ -55,6 +55,7 @@ signals: void eventChanged(); void eventInserted(int index, EventLogGui *message); void indexWithFilterFound(int index); + void listAboutToBeReset(); protected: QSharedPointer mList; diff --git a/Linphone/data/config/linphonerc-factory b/Linphone/data/config/linphonerc-factory index f0ef7796c..dd8b6ddec 100644 --- a/Linphone/data/config/linphonerc-factory +++ b/Linphone/data/config/linphonerc-factory @@ -26,6 +26,7 @@ aggregate_imdn=1 enable_basic_to_client_group_chat_room_migration=0 enable_simple_group_chat_message_state=0 notify_each_friend_individually_when_presence_received=0 +hide_empty_chat_rooms=1 [net] force_ice_disablement=0 diff --git a/Linphone/view/Control/Display/Call/CallHistoryListView.qml b/Linphone/view/Control/Display/Call/CallHistoryListView.qml index 088b81996..114b5e132 100644 --- a/Linphone/view/Control/Display/Call/CallHistoryListView.qml +++ b/Linphone/view/Control/Display/Call/CallHistoryListView.qml @@ -29,6 +29,7 @@ ListView { Component.onCompleted: { loading = true } + onListAboutToBeReset: loading = true filterText: mainItem.searchText onFilterTextChanged: maxDisplayItems = initialDisplayItems initialDisplayItems: Math.max( @@ -43,16 +44,14 @@ ListView { spacing: Math.round(10 * DefaultStyle.dp) Keys.onPressed: event => { - if (event.key == Qt.Key_Escape) { - console.log("Back") - searchBar.forceActiveFocus() - event.accepted = true - } - } + if (event.key == Qt.Key_Escape) { + console.log("Back") + searchBar.forceActiveFocus() + event.accepted = true + } + } - Component.onCompleted: cacheBuffer = Math.max( - contentHeight, - 0) //contentHeight>0 ? contentHeight : 0// cache all items + Component.onCompleted: cacheBuffer = Math.max(mainItem.height,0) //contentHeight>0 ? contentHeight : 0// cache all items // remove binding loop onContentHeightChanged: Qt.callLater(function () { if (mainItem) diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 925d1c00f..8d0639a9a 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -44,6 +44,9 @@ ListView { onModelReset: { mainItem.resultsReceived() } + onListAboutToBeReset: { + loading = true + } onChatRemoved: { var currentChat = model.getAt(currentIndex) mainItem.currentIndex = -1 @@ -58,7 +61,6 @@ ListView { function selectChat(chatGui) { var index = chatProxy.findChatIndex(chatGui) - console.log("current index", mainItem.currentIndex, "new", index) mainItem.currentIndex = index // if the chat exists, it may not be displayed // in list if hide_empty_chatrooms is set. Thus, we need diff --git a/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml b/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml index 115c49176..91029e7a5 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml @@ -14,6 +14,9 @@ ListView { property color backgroundColor property bool lastItemVisible: false property int lastIndexFoundWithFilter: -1 + property real busyIndicatorSize: Math.round(60 * DefaultStyle.dp) + property bool loading: false + verticalLayoutDirection: ListView.BottomToTop signal showReactionsForMessageRequested(ChatMessageGui chatMessage) signal showImdnStatusForMessageRequested(ChatMessageGui chatMessage) @@ -87,7 +90,10 @@ ListView { if (!mainItem.visible) return if(mainItem.lastItemVisible) mainItem.positionViewAtIndex(index, ListView.Beginning) } + Component.onCompleted: loading = true + onListAboutToBeReset: loading = true onModelReset: Qt.callLater(function() { + loading = false var index = eventLogProxy.findFirstUnreadIndex() positionViewAtIndex(index, ListView.Beginning) eventLogProxy.markIndexAsRead(index) @@ -204,6 +210,16 @@ ListView { } } } + + BusyIndicator { + anchors.horizontalCenter: mainItem.horizontalCenter + visible: mainItem.loading + height: visible ? mainItem.busyIndicatorSize : 0 + width: mainItem.busyIndicatorSize + indicatorHeight: mainItem.busyIndicatorSize + indicatorWidth: mainItem.busyIndicatorSize + indicatorColor: DefaultStyle.main1_500_main + } delegate: DelegateChooser { role: "eventType" diff --git a/Linphone/view/Page/Form/Chat/SelectedChatView.qml b/Linphone/view/Page/Form/Chat/SelectedChatView.qml index b365ff671..28c48bbc5 100644 --- a/Linphone/view/Page/Form/Chat/SelectedChatView.qml +++ b/Linphone/view/Page/Form/Chat/SelectedChatView.qml @@ -248,7 +248,6 @@ FocusScope { anchors.fill: parent anchors.leftMargin: Math.round(18 * DefaultStyle.dp) anchors.rightMargin: Math.round(18 * DefaultStyle.dp) - onActiveFocusChanged: console.log("chat messages focus", activeFocus) Control.ScrollBar.vertical: scrollbar onShowReactionsForMessageRequested: (chatMessage) => { mainItem.chatMessage = chatMessage diff --git a/Linphone/view/Page/Layout/Main/MainLayout.qml b/Linphone/view/Page/Layout/Main/MainLayout.qml index da3aa6d2a..af853858c 100644 --- a/Linphone/view/Page/Layout/Main/MainLayout.qml +++ b/Linphone/view/Page/Layout/Main/MainLayout.qml @@ -84,9 +84,8 @@ Item { AccountProxy { id: accountProxy sourceModel: AppCpp.accounts - onDefaultAccountChanged: if (tabbar.currentIndex === 0 - && defaultAccount) - defaultAccount.core?.lResetMissedCalls() + onDefaultAccountChanged: if (tabbar.currentIndex === 0 && defaultAccount) + defaultAccount.core?.lResetMissedCalls() } CallProxy { @@ -130,7 +129,6 @@ Item { Layout.fillHeight: true Layout.preferredWidth: Math.round(82 * DefaultStyle.dp) defaultAccount: accountProxy.defaultAccount - currentIndex: 0 Binding on currentIndex { when: mainItem.contextualMenuOpenedComponent != undefined value: -1 diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml index a25f1c9c4..abf94d01a 100644 --- a/Linphone/view/Page/Main/Call/CallPage.qml +++ b/Linphone/view/Page/Main/Call/CallPage.qml @@ -21,8 +21,8 @@ AbstractMainPage { signal goToCallForwardSettings onVisibleChanged: if (!visible) { - goToCallHistory() - } + goToCallHistory() + } //Group call properties property ConferenceInfoGui confInfoGui @@ -109,8 +109,8 @@ AbstractMainPage { initialItem: historyListItem focus: true onActiveFocusChanged: if (activeFocus) { - currentItem.forceActiveFocus() - } + currentItem.forceActiveFocus() + } } Item { @@ -264,7 +264,7 @@ AbstractMainPage { background: Item {} contentItem: ColumnLayout { Text { - visible: historyListView.count === 0 + visible: historyListView.count === 0 && !historyListView.loading Layout.alignment: Qt.AlignHCenter Layout.topMargin: Math.round(137 * DefaultStyle.dp) //: "Aucun résultat…" @@ -290,6 +290,12 @@ AbstractMainPage { historyListView.model.reload() } } + Binding { + target: mainItem + property: "showDefaultItem" + when: historyListView.loading + value: false + } onCurrentIndexChanged: { mainItem.selectedRowHistoryGui = model.getAt( currentIndex) diff --git a/Linphone/view/Page/Main/Chat/ChatPage.qml b/Linphone/view/Page/Main/Chat/ChatPage.qml index f4645fa35..47c2a3039 100644 --- a/Linphone/view/Page/Main/Chat/ChatPage.qml +++ b/Linphone/view/Page/Main/Chat/ChatPage.qml @@ -188,7 +188,6 @@ AbstractMainPage { Control.ScrollBar.vertical: scrollbar onChatClicked: (chat) => { - console.log("chat clicked") mainItem.selectedChatGui = chat }