diff --git a/Linphone/core/conference/ConferenceCore.cpp b/Linphone/core/conference/ConferenceCore.cpp index a2903fa0a..e27e34cf1 100644 --- a/Linphone/core/conference/ConferenceCore.cpp +++ b/Linphone/core/conference/ConferenceCore.cpp @@ -21,6 +21,7 @@ #include "ConferenceCore.hpp" #include "core/App.hpp" #include "model/conference/ConferenceModel.hpp" +#include "model/tool/ToolModel.hpp" #include "tool/Utils.hpp" #include "tool/thread/SafeConnection.hpp" @@ -39,6 +40,8 @@ ConferenceCore::ConferenceCore(const std::shared_ptr &conf mConferenceModel = ConferenceModel::create(conference); mSubject = Utils::coreStringToAppString(conference->getSubject()); mParticipantDeviceCount = conference->getParticipantDeviceList().size(); + auto activeSpeaker = conference->getActiveSpeakerParticipantDevice(); + if (activeSpeaker) mActiveSpeaker = ParticipantDeviceCore::create(activeSpeaker); mIsLocalScreenSharing = mConferenceModel->isLocalScreenSharing(); mIsScreenSharingEnabled = mConferenceModel->isScreenSharingEnabled(); mIsRecording = conference->isRecording(); @@ -67,9 +70,49 @@ void ConferenceCore::setSelf(QSharedPointer me) { mConferenceModelConnection->invokeToCore([this, count]() { setParticipantDeviceCount(count); }); }); - mConferenceModelConnection->makeConnectToModel(&ConferenceModel::participantDeviceCountChanged, [this](int count) { - mConferenceModelConnection->invokeToCore([this, count]() { setParticipantDeviceCount(count); }); - }); + mConferenceModelConnection->makeConnectToModel( + &ConferenceModel::conferenceStateChanged, + [this](const std::shared_ptr &conference, linphone::Conference::State newState) { + if (newState != linphone::Conference::State::Created) return; + if (!mActiveSpeaker) { + if (auto participantDevice = conference->getActiveSpeakerParticipantDevice()) { + auto device = ParticipantDeviceCore::create(participantDevice); + mConferenceModelConnection->invokeToCore([this, device]() { setActiveSpeaker(device); }); + } else if (conference->getParticipantDeviceList().size() > 1) { + for (auto &device : conference->getParticipantDeviceList()) { + if (!ToolModel::isMe(device->getAddress())) { + auto activeSpeaker = ParticipantDeviceCore::create(device); + mConferenceModelConnection->invokeToCore( + [this, activeSpeaker]() { setActiveSpeaker(activeSpeaker); }); + break; + } + } + } + } + int count = mConferenceModel->getParticipantDeviceCount(); + mConferenceModelConnection->invokeToCore([this, count]() { setParticipantDeviceCount(count); }); + }); + + mConferenceModelConnection->makeConnectToModel( + &ConferenceModel::participantDeviceCountChanged, + [this](const std::shared_ptr &conference, int count) { + if (!mActiveSpeaker) { + if (auto participantDevice = conference->getActiveSpeakerParticipantDevice()) { + auto device = ParticipantDeviceCore::create(participantDevice); + mConferenceModelConnection->invokeToCore([this, device]() { setActiveSpeaker(device); }); + } else if (conference->getParticipantDeviceList().size() > 1) { + for (auto &device : conference->getParticipantDeviceList()) { + if (!ToolModel::isMe(device->getAddress())) { + auto activeSpeaker = ParticipantDeviceCore::create(device); + mConferenceModelConnection->invokeToCore( + [this, activeSpeaker]() { setActiveSpeaker(activeSpeaker); }); + break; + } + } + } + } + mConferenceModelConnection->invokeToCore([this, count]() { setParticipantDeviceCount(count); }); + }); mConferenceModelConnection->makeConnectToModel(&ConferenceModel::isLocalScreenSharingChanged, [this]() { auto state = mConferenceModel->isLocalScreenSharing(); mConferenceModelConnection->invokeToCore([this, state]() { setIsLocalScreenSharing(state); }); diff --git a/Linphone/core/conference/ConferenceInfoList.cpp b/Linphone/core/conference/ConferenceInfoList.cpp index a2adcd7f0..fb26a2d22 100644 --- a/Linphone/core/conference/ConferenceInfoList.cpp +++ b/Linphone/core/conference/ConferenceInfoList.cpp @@ -42,6 +42,12 @@ QSharedPointer ConferenceInfoList::create() { ConferenceInfoList::ConferenceInfoList(QObject *parent) : ListProxy(parent) { mustBeInMainThread(getClassName()); App::getInstance()->mEngine->setObjectOwnership(this, QQmlEngine::CppOwnership); + connect(App::getInstance(), &App::currentDateChanged, this, [this] { + updateHaveCurrentDate(); + int dummyIndex = -1; + get(nullptr, &dummyIndex); + if (dummyIndex != -1) emit dataChanged(index(dummyIndex, 0), index(dummyIndex, 0)); + }); } ConferenceInfoList::~ConferenceInfoList() { @@ -161,9 +167,15 @@ void ConferenceInfoList::updateHaveCurrentDate() { } int ConferenceInfoList::getCurrentDateIndex() { - // Dummy item (nullptr) is QDate::currentDate() + auto today = QDate::currentDate(); auto confInfoList = getSharedList(); - auto it = std::find(confInfoList.begin(), confInfoList.end(), nullptr); + QList>::iterator it; + if (mHaveCurrentDate) { + it = std::find_if(confInfoList.begin(), confInfoList.end(), + [today](const QSharedPointer &item) { + return item && item->getDateTimeUtc().date() == today; + }); + } else it = std::find(confInfoList.begin(), confInfoList.end(), nullptr); return it == confInfoList.end() ? -1 : std::distance(confInfoList.begin(), it); } diff --git a/Linphone/core/conference/ConferenceInfoProxy.cpp b/Linphone/core/conference/ConferenceInfoProxy.cpp index 4aaa64e50..940023506 100644 --- a/Linphone/core/conference/ConferenceInfoProxy.cpp +++ b/Linphone/core/conference/ConferenceInfoProxy.cpp @@ -22,6 +22,7 @@ #include "ConferenceInfoCore.hpp" #include "ConferenceInfoGui.hpp" #include "ConferenceInfoList.hpp" +#include "core/App.hpp" DEFINE_ABSTRACT_OBJECT(ConferenceInfoProxy) @@ -31,10 +32,14 @@ ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : LimitProxy(parent) { connect( mList.get(), &ConferenceInfoList::haveCurrentDateChanged, this, [this] { + setCurrentDateIndex(getCurrentDateIndex()); auto sortModel = dynamic_cast(sourceModel()); sortModel->invalidate(); }, Qt::QueuedConnection); + connect( + App::getInstance(), &App::currentDateChanged, this, [this] { setCurrentDateIndex(getCurrentDateIndex()); }, + Qt::QueuedConnection); connect( mList.get(), &ConferenceInfoList::confInfoInserted, this, [this](int index, ConferenceInfoGui *data) { @@ -46,7 +51,8 @@ ConferenceInfoProxy::ConferenceInfoProxy(QObject *parent) : LimitProxy(parent) { } }, Qt::QueuedConnection); - connect(mList.get(), &ConferenceInfoList::initialized, this, &ConferenceInfoProxy::initialized); + connect(mList.get(), &ConferenceInfoList::initialized, this, + [this] { setCurrentDateIndex(getCurrentDateIndex()); }); } ConferenceInfoProxy::~ConferenceInfoProxy() { @@ -91,6 +97,14 @@ int ConferenceInfoProxy::getCurrentDateIndex() const { return proxyIndex; } +void ConferenceInfoProxy::setCurrentDateIndex(int index) { + if (mCurrentDateIndex != index) { + if (index >= mMaxDisplayItems) setMaxDisplayItems(index + 1); + mCurrentDateIndex = index; + emit currentDateIndexChanged(index); + } +} + bool ConferenceInfoProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { auto l = getItemAtSource(sourceLeft.row()); diff --git a/Linphone/core/conference/ConferenceInfoProxy.hpp b/Linphone/core/conference/ConferenceInfoProxy.hpp index fd2fee965..6424039e0 100644 --- a/Linphone/core/conference/ConferenceInfoProxy.hpp +++ b/Linphone/core/conference/ConferenceInfoProxy.hpp @@ -44,11 +44,12 @@ public: bool haveCurrentDate() const; Q_INVOKABLE int getCurrentDateIndex() const; + Q_INVOKABLE void setCurrentDateIndex(int index); signals: void haveCurrentDateChanged(); void conferenceInfoCreated(int index); - void initialized(); + void currentDateIndexChanged(int index); private: QSharedPointer mList; diff --git a/Linphone/core/participant/ParticipantDeviceList.cpp b/Linphone/core/participant/ParticipantDeviceList.cpp index 13869bbb4..767e08cbb 100644 --- a/Linphone/core/participant/ParticipantDeviceList.cpp +++ b/Linphone/core/participant/ParticipantDeviceList.cpp @@ -142,7 +142,8 @@ void ParticipantDeviceList::setSelf(QSharedPointer me) { }); }); mConferenceModelConnection->makeConnectToModel( - &ConferenceModel::conferenceStateChanged, [this](linphone::Conference::State state) { + &ConferenceModel::conferenceStateChanged, + [this](const std::shared_ptr &conference, linphone::Conference::State state) { lDebug() << "[ParticipantDeviceList] new state = " << (int)state; if (state == linphone::Conference::State::Created) { lDebug() << "[ParticipantDeviceList] : build devices"; diff --git a/Linphone/model/conference/ConferenceModel.cpp b/Linphone/model/conference/ConferenceModel.cpp index 7bd1b554a..12fa37cd8 100644 --- a/Linphone/model/conference/ConferenceModel.cpp +++ b/Linphone/model/conference/ConferenceModel.cpp @@ -175,13 +175,13 @@ void ConferenceModel::onParticipantAdded(const std::shared_ptr &participant) { lDebug() << "onParticipant Added" << participant->getAddress()->asStringUriOnly(); emit participantAdded(participant); - emit participantDeviceCountChanged(getParticipantDeviceCount()); + emit participantDeviceCountChanged(conference, getParticipantDeviceCount()); } void ConferenceModel::onParticipantRemoved(const std::shared_ptr &conference, const std::shared_ptr &participant) { lDebug() << "onParticipant Removed" << participant->getAddress()->asStringUriOnly(); emit participantRemoved(participant); - emit participantDeviceCountChanged(getParticipantDeviceCount()); + emit participantDeviceCountChanged(conference, getParticipantDeviceCount()); } void ConferenceModel::onParticipantDeviceAdded(const std::shared_ptr &conference, const std::shared_ptr &participantDevice) { @@ -191,7 +191,7 @@ void ConferenceModel::onParticipantDeviceAdded(const std::shared_ptrgetMe()->getDevices()) lDebug() << "\t--> " << d->getAddress()->asString().c_str(); emit participantDeviceAdded(participantDevice); - emit participantDeviceCountChanged(getParticipantDeviceCount()); + emit participantDeviceCountChanged(conference, getParticipantDeviceCount()); } void ConferenceModel::onParticipantDeviceRemoved( const std::shared_ptr &conference, @@ -201,7 +201,7 @@ void ConferenceModel::onParticipantDeviceRemoved( lDebug() << "Me devices : " << conference->getMe()->getDevices().size(); if (participantDevice->screenSharingEnabled()) emit isScreenSharingEnabledChanged(false); emit participantDeviceRemoved(participantDevice); - emit participantDeviceCountChanged(getParticipantDeviceCount()); + emit participantDeviceCountChanged(conference, getParticipantDeviceCount()); } void ConferenceModel::onParticipantDeviceStateChanged(const std::shared_ptr &conference, const std::shared_ptr &device, @@ -257,11 +257,11 @@ void ConferenceModel::onStateChanged(const std::shared_ptr linphone::Conference::State newState) { lDebug() << "onStateChanged:" << (int)newState; if (newState == linphone::Conference::State::Created) { - emit participantDeviceCountChanged(mMonitor->getParticipantDeviceList().size()); + emit participantDeviceCountChanged(conference, mMonitor->getParticipantDeviceList().size()); if (mMonitor->getScreenSharingParticipant()) emit isScreenSharingEnabledChanged(true); } // updateLocalParticipant(); - emit conferenceStateChanged(newState); + emit conferenceStateChanged(conference, newState); } void ConferenceModel::onSubjectChanged(const std::shared_ptr &conference, const std::string &subject) { diff --git a/Linphone/model/conference/ConferenceModel.hpp b/Linphone/model/conference/ConferenceModel.hpp index 710df533b..3d8c15a17 100644 --- a/Linphone/model/conference/ConferenceModel.hpp +++ b/Linphone/model/conference/ConferenceModel.hpp @@ -75,7 +75,7 @@ signals: void outputAudioDeviceChanged(const std::string &id); void isLocalScreenSharingChanged(bool enabled); void isScreenSharingEnabledChanged(bool enabled); - void participantDeviceCountChanged(int count); + void participantDeviceCountChanged(const std::shared_ptr &conference, int count); private: // LINPHONE LISTENERS @@ -137,7 +137,8 @@ signals: bool isSpeaking); void participantDeviceScreenSharingChanged(const std::shared_ptr &device, bool enabled); - void conferenceStateChanged(linphone::Conference::State newState); + void conferenceStateChanged(const std::shared_ptr &conference, + linphone::Conference::State newState); void subjectChanged(const std::string &subject); private: diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 610e7172f..5ae719094 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -237,6 +237,24 @@ std::shared_ptr ToolModel::findAccount(const QString &address return findAccount(linAddr); } +bool ToolModel::isLocal(const QString &address) { + auto linAddr = ToolModel::interpretUrl(address); + if (!CoreModel::getInstance()->getCore()->getDefaultAccount()) { + return false; + } else { + auto accountAddr = CoreModel::getInstance()->getCore()->getDefaultAccount()->getContactAddress(); + return linAddr && accountAddr ? accountAddr->weakEqual(linAddr) : false; + } +} + +bool ToolModel::isLocal(const std::shared_ptr &conference, + const std::shared_ptr &device) { + auto deviceAddress = device->getAddress(); + auto callAddress = conference->getMe()->getAddress(); + auto gruuAddress = findAccount(callAddress)->getContactAddress(); + return deviceAddress->equal(gruuAddress); +} + bool ToolModel::isMe(const QString &address) { bool isMe = false; auto linAddr = ToolModel::interpretUrl(address); @@ -252,16 +270,6 @@ bool ToolModel::isMe(const QString &address) { return isMe; } -bool ToolModel::isLocal(const QString &address) { - auto linAddr = ToolModel::interpretUrl(address); - if (!CoreModel::getInstance()->getCore()->getDefaultAccount()) { - return false; - } else { - auto accountAddr = CoreModel::getInstance()->getCore()->getDefaultAccount()->getContactAddress(); - return linAddr && accountAddr ? accountAddr->weakEqual(linAddr) : false; - } -} - bool ToolModel::isMe(const std::shared_ptr &address) { auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); if (!currentAccount) { // Default account is selected : Me is all local accounts. @@ -269,14 +277,6 @@ bool ToolModel::isMe(const std::shared_ptr &address) { } else return address ? currentAccount->getContactAddress()->weakEqual(address) : false; } -bool ToolModel::isLocal(const std::shared_ptr &conference, - const std::shared_ptr &device) { - auto deviceAddress = device->getAddress(); - auto callAddress = conference->getMe()->getAddress(); - auto gruuAddress = findAccount(callAddress)->getContactAddress(); - return deviceAddress->equal(gruuAddress); -} - std::shared_ptr ToolModel::getFriendList(const std::string &listName) { auto core = CoreModel::getInstance()->getCore(); auto friendList = core->getFriendListByName(listName); diff --git a/Linphone/view/Control/Display/Meeting/MeetingListView.qml b/Linphone/view/Control/Display/Meeting/MeetingListView.qml index bdac36929..9dc77391b 100644 --- a/Linphone/view/Control/Display/Meeting/MeetingListView.qml +++ b/Linphone/view/Control/Display/Meeting/MeetingListView.qml @@ -37,11 +37,7 @@ ListView { onConferenceInfoCreated: (index) => { mainItem.currentIndex = index } - onInitialized: { - var initIndex = confInfoProxy.getCurrentDateIndex() - if (initIndex >= maxDisplayItems) maxDisplayItems = initIndex + 1 - mainItem.currentIndex = initIndex - } + onCurrentDateIndexChanged: (index) => mainItem.currentIndex = index } section { diff --git a/Linphone/view/Control/Display/ProgressBar.qml b/Linphone/view/Control/Display/ProgressBar.qml index 7616b3014..5b18aa53f 100644 --- a/Linphone/view/Control/Display/ProgressBar.qml +++ b/Linphone/view/Control/Display/ProgressBar.qml @@ -11,19 +11,18 @@ ProgressBar { property color innerColor: DefaultStyle.info_500_main property color innerTextColor: centeredText ? DefaultStyle.info_500_main : DefaultStyle.grey_0 property bool innerTextVisible: true - property string innerText: Number.parseFloat(value*100).toFixed(0) + "%" - + property string innerText: Number.parseFloat(value*100).toFixed(0) + "%" property int barWidth: mainItem.visualPosition * mainItem.width property bool centeredText: textSize.width >= barWidth - - TextMetrics{ - id: textSize - text: mainItem.innerText - font { - pixelSize: 10 * DefaultStyle.dp - weight: 700 * DefaultStyle.dp - } - } + + TextMetrics{ + id: textSize + text: mainItem.innerText + font { + pixelSize: 10 * DefaultStyle.dp + weight: 700 * DefaultStyle.dp + } + } background: Rectangle { color: mainItem.backgroundColor @@ -33,6 +32,7 @@ ProgressBar { height: mainItem.height } contentItem: Item { + id: content Rectangle { id: bar color: mainItem.innerColor @@ -43,13 +43,16 @@ ProgressBar { Text { visible: mainItem.innerTextVisible text: mainItem.innerText - anchors.centerIn: mainItem.centeredText ? parent : bar + parent: mainItem.centeredText ? content : bar + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter color: mainItem.innerTextColor + maximumLineCount: 1 font { pixelSize: 10 * DefaultStyle.dp weight: 700 * DefaultStyle.dp - } - width: textSize.advanceWidth + } } } } diff --git a/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml b/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml index aa68be658..8dc9594b8 100644 --- a/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml +++ b/Linphone/view/Page/Form/Meeting/AddParticipantsForm.qml @@ -49,6 +49,8 @@ FocusScope{ _address: modelData } Text { + Layout.fillWidth: true + maximumLineCount: 1 property var nameObj: UtilsCpp.getDisplayName(modelData) text: nameObj ? nameObj.value : "" font.pixelSize: 14 * DefaultStyle.dp diff --git a/Linphone/view/Page/Main/Contact/ContactPage.qml b/Linphone/view/Page/Main/Contact/ContactPage.qml index 337be6a1f..4466f3562 100644 --- a/Linphone/view/Page/Main/Contact/ContactPage.qml +++ b/Linphone/view/Page/Main/Contact/ContactPage.qml @@ -625,7 +625,7 @@ AbstractMainPage { visible: deviceList.count > 0 Layout.fillWidth: true Layout.preferredHeight: 28 * DefaultStyle.dp - value: mainItem.selectedContact ? mainItem.selectedContact.core.verifiedDeviceCount / deviceList.count : 0 + value: mainItem.selectedContact ? mainItem.selectedContact.core.verifiedDeviceCount / deviceList.count : 0 } ListView { id: deviceList