From a93200e00b07e5e598280539ddce73fc0570243c Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Tue, 27 Sep 2022 14:19:53 +0200 Subject: [PATCH] Display outgoing call when calling instead of blank page. Use c++ global cursor to get position when leaving windows for fixing fullscreen behavior on comboboxes (and any others items that can grab mouse events). Qt workaround for fixing layouts that are not refreshed when size/content change. --- .../src/components/calls/CallsListModel.cpp | 15 ++++++++------- linphone-app/src/utils/Utils.cpp | 5 +++++ linphone-app/src/utils/Utils.hpp | 1 + linphone-app/ui/modules/Linphone/Calls/Calls.js | 7 +++++-- .../ui/views/App/Calls/IncallActiveSpeaker.qml | 15 ++++++++++++++- .../ui/views/App/Calls/IncallFullscreen.qml | 12 +++++++----- 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/linphone-app/src/components/calls/CallsListModel.cpp b/linphone-app/src/components/calls/CallsListModel.cpp index e3bc8e035..9e894d70d 100644 --- a/linphone-app/src/components/calls/CallsListModel.cpp +++ b/linphone-app/src/components/calls/CallsListModel.cpp @@ -474,6 +474,14 @@ void CallsListModel::handleCallStateChanged (const shared_ptr &c // ----------------------------------------------------------------------------- void CallsListModel::addCall (const shared_ptr &call) { + + QSharedPointer callModel = QSharedPointer::create(call); + qInfo() << QStringLiteral("Add call:") << callModel->getFullLocalAddress() << callModel->getFullPeerAddress(); + App::getInstance()->getEngine()->setObjectOwnership(callModel.get(), QQmlEngine::CppOwnership); + + add(callModel); + emit layoutChanged(); + if (call->getDir() == linphone::Call::Dir::Outgoing) { QQuickWindow *callsWindow = App::getInstance()->getCallsWindow(); if (callsWindow) { @@ -484,13 +492,6 @@ void CallsListModel::addCall (const shared_ptr &call) { App::smartShowWindow(callsWindow); } } - - QSharedPointer callModel = QSharedPointer::create(call); - qInfo() << QStringLiteral("Add call:") << callModel->getFullLocalAddress() << callModel->getFullPeerAddress(); - App::getInstance()->getEngine()->setObjectOwnership(callModel.get(), QQmlEngine::CppOwnership); - - add(callModel); - emit layoutChanged(); } diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index b51f7d962..d227945bf 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -564,4 +565,8 @@ QSize Utils::getImageSize(const QString& url){ return s; else return QSize(0,0); +} + +QPoint Utils::getCursorPosition(){ + return QCursor::pos(); } \ No newline at end of file diff --git a/linphone-app/src/utils/Utils.hpp b/linphone-app/src/utils/Utils.hpp index 141d447b3..b26ffd5d5 100644 --- a/linphone-app/src/utils/Utils.hpp +++ b/linphone-app/src/utils/Utils.hpp @@ -63,6 +63,7 @@ public: Q_INVOKABLE static bool isAnimatedImage(const QString& path); Q_INVOKABLE static bool isPhoneNumber(const QString& txt); Q_INVOKABLE QSize getImageSize(const QString& url); + Q_INVOKABLE static QPoint getCursorPosition(); //---------------------------------------------------------------------------------- static inline QString coreStringToAppString (const std::string &str) { diff --git a/linphone-app/ui/modules/Linphone/Calls/Calls.js b/linphone-app/ui/modules/Linphone/Calls/Calls.js index 3a2cff9a1..f8a0464a4 100644 --- a/linphone-app/ui/modules/Linphone/Calls/Calls.js +++ b/linphone-app/ui/modules/Linphone/Calls/Calls.js @@ -201,8 +201,11 @@ function handleCountChanged (count) { var model = calls.model var index = count - 1 - if(model && model.status === CallModel.CallStatusConnected) - updateSelectedCall(model.data(model.index(index, 0)), index) + if(model){ + var callModel = model.data(model.index(index, 0)) + if( callModel.status === Linphone.CallModel.CallStatusConnected || callModel.isOutgoing ) + updateSelectedCall(callModel, index) + } } else { setIndexWithCall(call) } diff --git a/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml b/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml index f635457ed..b67daff92 100644 --- a/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml +++ b/linphone-app/ui/views/App/Calls/IncallActiveSpeaker.qml @@ -120,7 +120,20 @@ Item { spacing: 15 verticalLayoutDirection: ListView.BottomToTop fitCacheToContent: false - onCountChanged: if(contentItem.height < miniViews.height) positionViewAtBeginning() + onCountChanged: updateView() + onHeightChanged: updateView() + function updateView(){ + if(contentItem.height < miniViews.height){ + contentItem.y = miniViews.height // Qt workaround because it do not set correctly value with positionning to beginning + } + } + Component.onCompleted: updateView() + Timer{ + running: true + interval: 500 + repeat: true + onTriggered: miniViews.updateView() + } delegate:Item{ height: miniViews.cellHeight width: miniViews.width diff --git a/linphone-app/ui/views/App/Calls/IncallFullscreen.qml b/linphone-app/ui/views/App/Calls/IncallFullscreen.qml index 982dcdcc3..a1330a2cc 100644 --- a/linphone-app/ui/views/App/Calls/IncallFullscreen.qml +++ b/linphone-app/ui/views/App/Calls/IncallFullscreen.qml @@ -570,12 +570,14 @@ Window { propagateComposedEvents: true cursorShape: undefined //cursorShape: Qt.ArrowCursor - onEntered: hideButtonsTimer.startTimer() - onExited: hideButtonsTimer.stopTimer() - - onPositionChanged: { - hideButtonsTimer.startTimer() + onExited: { + var cursorPosition = UtilsCpp.getCursorPosition() + mapToItem(window.contentItem, cursorPosition.x, cursorPosition.y) + if (cursorPosition.x <= 0 || cursorPosition.y <= 0 + || cursorPosition.x >= width || cursorPosition.y >= height) + hideButtonsTimer.stopTimer() } + onPositionChanged: hideButtonsTimer.startTimer() } }