Check if a call has been started on duration instead of call states.

Fix button size on main page.
Fix contact defaut view if having contacts.
Fix missing object Item on call loader.
This commit is contained in:
Julien Wadel 2024-10-17 16:55:39 +02:00
parent 1ad2170336
commit 72e4d1c81e
7 changed files with 38 additions and 31 deletions

View file

@ -112,6 +112,7 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
mCallModel = Utils::makeQObject_ptr<CallModel>(call); mCallModel = Utils::makeQObject_ptr<CallModel>(call);
mCallModel->setSelf(mCallModel); mCallModel->setSelf(mCallModel);
mDuration = call->getDuration(); mDuration = call->getDuration();
mIsStarted = mDuration > 0;
mMicrophoneMuted = call->getMicrophoneMuted(); mMicrophoneMuted = call->getMicrophoneMuted();
mSpeakerMuted = call->getSpeakerMuted(); mSpeakerMuted = call->getSpeakerMuted();
auto videoDirection = call->getCurrentParams()->getVideoDirection(); auto videoDirection = call->getCurrentParams()->getVideoDirection();
@ -130,6 +131,7 @@ CallCore::CallCore(const std::shared_ptr<linphone::Call> &call) : QObject(nullpt
if (mRemoteName.isEmpty()) mRemoteName = ToolModel::getDisplayName(mRemoteAddress); if (mRemoteName.isEmpty()) mRemoteName = ToolModel::getDisplayName(mRemoteAddress);
mLocalAddress = Utils::coreStringToAppString(call->getCallLog()->getLocalAddress()->asStringUriOnly()); mLocalAddress = Utils::coreStringToAppString(call->getCallLog()->getLocalAddress()->asStringUriOnly());
mStatus = LinphoneEnums::fromLinphone(call->getCallLog()->getStatus()); mStatus = LinphoneEnums::fromLinphone(call->getCallLog()->getStatus());
mTransferState = LinphoneEnums::fromLinphone(call->getTransferState()); mTransferState = LinphoneEnums::fromLinphone(call->getTransferState());
mLocalToken = Utils::coreStringToAppString(mCallModel->getLocalAtuhenticationToken()); mLocalToken = Utils::coreStringToAppString(mCallModel->getLocalAtuhenticationToken());
mRemoteTokens = mCallModel->getRemoteAtuhenticationTokens(); mRemoteTokens = mCallModel->getRemoteAtuhenticationTokens();
@ -459,6 +461,8 @@ void CallCore::setSelf(QSharedPointer<CallCore> me) {
}); });
} }
DEFINE_GET_SET_API(CallCore, bool, isStarted, IsStarted)
QString CallCore::getRemoteName() const { QString CallCore::getRemoteName() const {
return mRemoteName; return mRemoteName;
} }
@ -524,6 +528,7 @@ int CallCore::getDuration() const {
void CallCore::setDuration(int duration) { void CallCore::setDuration(int duration) {
if (mDuration != duration) { if (mDuration != duration) {
mDuration = duration; mDuration = duration;
setIsStarted(mDuration > 0);
emit durationChanged(mDuration); emit durationChanged(mDuration);
} }
} }

View file

@ -137,6 +137,8 @@ class CallCore : public QObject, public AbstractObject {
Q_PROPERTY(AudioStats audioStats READ getAudioStats WRITE setAudioStats NOTIFY audioStatsChanged) Q_PROPERTY(AudioStats audioStats READ getAudioStats WRITE setAudioStats NOTIFY audioStatsChanged)
Q_PROPERTY(VideoStats videoStats READ getVideoStats WRITE setVideoStats NOTIFY videoStatsChanged) Q_PROPERTY(VideoStats videoStats READ getVideoStats WRITE setVideoStats NOTIFY videoStatsChanged)
DECLARE_GUI_GETSET(bool, isStarted, IsStarted)
public: public:
// Should be call from model Thread. Will be automatically in App thread after initialization // Should be call from model Thread. Will be automatically in App thread after initialization
static QSharedPointer<CallCore> create(const std::shared_ptr<linphone::Call> &call); static QSharedPointer<CallCore> create(const std::shared_ptr<linphone::Call> &call);

View file

@ -79,6 +79,13 @@ public:
Q_SIGNAL void x##Changed(); \ Q_SIGNAL void x##Changed(); \
type m##X; type m##X;
#define DECLARE_GUI_GETSET(type, x, X) \
Q_PROPERTY(type x READ get##X WRITE set##X NOTIFY x##Changed) \
void set##X(type data); \
type get##X() const; \
Q_SIGNAL void x##Changed(); \
type m##X;
#define DECLARE_CORE_GET(type, x, X) \ #define DECLARE_CORE_GET(type, x, X) \
Q_PROPERTY(type x MEMBER m##X NOTIFY x##Changed) \ Q_PROPERTY(type x MEMBER m##X NOTIFY x##Changed) \
Q_SIGNAL void x##Changed(); \ Q_SIGNAL void x##Changed(); \
@ -143,6 +150,17 @@ public:
void set##X(type data); \ void set##X(type data); \
Q_SIGNAL void x##Changed(type x); Q_SIGNAL void x##Changed(type x);
#define DEFINE_GET_SET_API(Class, type, x, X) \
type Class::get##X() const { \
return m##X; \
} \
void Class::set##X(type data) { \
if (get##X() != data) { \
m##X = data; \
emit x##Changed(); \
} \
}
#define DEFINE_GETSET(Class, type, x, X, ownerNotNull) \ #define DEFINE_GETSET(Class, type, x, X, ownerNotNull) \
type Class::get##X() const { \ type Class::get##X() const { \
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \

View file

@ -14,9 +14,8 @@ Item {
property CallGui call property CallGui call
property ConferenceGui conference: call && call.core.conference property ConferenceGui conference: call && call.core.conference
property bool callTerminatedByUser: false property bool callTerminatedByUser: false
property bool callStarted: false property bool callStarted: call?.core.isStarted
readonly property var callState: call && call.core.state || undefined readonly property var callState: call && call.core.state || undefined
onCallStateChanged: if (callState === LinphoneEnums.CallState.Connected) callStarted = true
property int conferenceLayout: call && call.core.conferenceVideoLayout || 0 property int conferenceLayout: call && call.core.conferenceVideoLayout || 0
// property int participantDeviceCount: conference ? conference.core.participantDeviceCount : -1 // property int participantDeviceCount: conference ? conference.core.participantDeviceCount : -1
// onParticipantDeviceCountChanged: { // onParticipantDeviceCountChanged: {

View file

@ -175,26 +175,14 @@ FocusScope {
bottomPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp
leftPadding: 20 * DefaultStyle.dp leftPadding: 20 * DefaultStyle.dp
rightPadding: 20 * DefaultStyle.dp rightPadding: 20 * DefaultStyle.dp
contentItem: RowLayout { icon.source: AppIcons.newItemIconSource
Layout.alignment: Qt.AlignVCenter icon.width: 24 * DefaultStyle.dp
EffectImage { icon.height: 24 * DefaultStyle.dp
colorizationColor: DefaultStyle.grey_0 contentImageColor: DefaultStyle.grey_0
imageSource: mainItem.newItemIconSource text: mainItem.noItemButtonText
width: 24 * DefaultStyle.dp textSize: 18 * DefaultStyle.dp
height: 24 * DefaultStyle.dp textWeight: 600 * DefaultStyle.dp
fillMode: Image.PreserveAspectFit
}
Text {
text: mainItem.noItemButtonText
wrapMode: Text.WordWrap
color: DefaultStyle.grey_0
font {
weight: 600 * DefaultStyle.dp
pixelSize: 18 * DefaultStyle.dp
family: DefaultStyle.defaultFont
}
}
}
onPressed: mainItem.noItemButtonPressed() onPressed: mainItem.noItemButtonPressed()
} }
Item { Item {

View file

@ -51,14 +51,9 @@ AbstractMainPage {
} }
// rightPanelStackView.initialItem: contactDetail // rightPanelStackView.initialItem: contactDetail
Binding {
mainItem.showDefaultItem: false showDefaultItem: rightPanelStackView.depth == 0 && contactList.count == 0
when: rightPanelStackView.currentItem
restoreMode: Binding.RestoreBinding
}
showDefaultItem: contactList.model.sourceModel.count === 0
MagicSearchProxy { MagicSearchProxy {
id: allFriends id: allFriends
} }

View file

@ -1358,9 +1358,9 @@ AbstractWindow {
Component { Component {
id: inCallItem id: inCallItem
Loader{ Loader{
property string objectName: "inCallItem"
asynchronous: true asynchronous: true
sourceComponent: Item { sourceComponent: Item {
property string objectName: "inCallItem"
CallLayout{ CallLayout{
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: 20 * DefaultStyle.dp anchors.leftMargin: 20 * DefaultStyle.dp