mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 21:58:06 +00:00
feat(app): many changes, pass a sip address observer to contact entry when it's possible
This commit is contained in:
parent
0dbb1c36ee
commit
ce2a71cef3
8 changed files with 170 additions and 158 deletions
|
|
@ -265,6 +265,7 @@
|
|||
<file>ui/modules/Common/Window/Window.qml</file>
|
||||
<file>ui/modules/Linphone/Account/AccountStatus.qml</file>
|
||||
<file>ui/modules/Linphone/Calls/CallControls.qml</file>
|
||||
<file>ui/modules/Linphone/Calls/Calls.js</file>
|
||||
<file>ui/modules/Linphone/Calls/Calls.qml</file>
|
||||
<file>ui/modules/Linphone/CardBlock.qml</file>
|
||||
<file>ui/modules/Linphone/Chat/Chat.js</file>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ void AsyncObjectBuilder::createObject (QQmlEngine *engine, const char *path, Dec
|
|||
#ifdef QT_DEBUG
|
||||
Q_ASSERT(!m_block_creation);
|
||||
m_block_creation = true;
|
||||
|
||||
Q_ASSERT(engine != nullptr);
|
||||
Q_ASSERT(path != nullptr);
|
||||
#endif // ifdef QT_DEBUG
|
||||
|
||||
m_component = new QQmlComponent(engine, QUrl(path), QQmlComponent::Asynchronous, this);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ Rectangle {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(sipAddress)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
signal clicked
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -56,10 +52,7 @@ Rectangle {
|
|||
|
||||
displayUnreadMessagesCount: true
|
||||
|
||||
entry: ({
|
||||
contact: _sipAddressObserver.contact,
|
||||
sipAddress: callControls.sipAddress
|
||||
})
|
||||
entry: SipAddressesModel.getSipAddressObserver(sipAddress)
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
|||
148
linphone-desktop/ui/modules/Linphone/Calls/Calls.js
Normal file
148
linphone-desktop/ui/modules/Linphone/Calls/Calls.js
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
// =============================================================================
|
||||
// `Calls.qml` Logic.
|
||||
// =============================================================================
|
||||
|
||||
.import Linphone 1.0 as Linphone
|
||||
|
||||
// =============================================================================
|
||||
|
||||
var MAP_STATUS_TO_PARAMS = (function () {
|
||||
var CallModel = Linphone.CallModel
|
||||
var map = {}
|
||||
|
||||
map[CallModel.CallStatusConnected] = (function (call) {
|
||||
return {
|
||||
actions: [{
|
||||
handler: (function () { call.pausedByUser = true }),
|
||||
name: qsTr('pauseCall')
|
||||
}, {
|
||||
handler: (function () { call.transfer() }),
|
||||
name: qsTr('transferCall')
|
||||
}, {
|
||||
handler: (function () { call.terminate() }),
|
||||
name: qsTr('terminateCall')
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'connected'
|
||||
}
|
||||
})
|
||||
|
||||
map[CallModel.CallStatusEnded] = (function (call) {
|
||||
return {
|
||||
string: 'ended'
|
||||
}
|
||||
})
|
||||
|
||||
map[CallModel.CallStatusIncoming] = (function (call) {
|
||||
return {
|
||||
actions: [{
|
||||
name: qsTr('acceptAudioCall'),
|
||||
handler: (function () { call.accept() })
|
||||
}, {
|
||||
name: qsTr('acceptVideoCall'),
|
||||
handler: (function () { call.acceptWithVideo() })
|
||||
}, {
|
||||
name: qsTr('terminateCall'),
|
||||
handler: (function () { call.terminate() })
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'incoming'
|
||||
}
|
||||
})
|
||||
|
||||
map[CallModel.CallStatusOutgoing] = (function (call) {
|
||||
return {
|
||||
component: callAction,
|
||||
handler: (function () { call.terminate() }),
|
||||
icon: 'hangup',
|
||||
string: 'outgoing'
|
||||
}
|
||||
})
|
||||
|
||||
map[CallModel.CallStatusPaused] = (function (call) {
|
||||
return {
|
||||
actions: [(call.pausedByUser ? {
|
||||
handler: (function () { call.pausedByUser = false }),
|
||||
name: qsTr('resumeCall')
|
||||
} : {
|
||||
handler: (function () { call.pausedByUser = true }),
|
||||
name: qsTr('pauseCall')
|
||||
}), {
|
||||
handler: (function () { call.transfer() }),
|
||||
name: qsTr('transferCall')
|
||||
}, {
|
||||
handler: (function () { call.terminate() }),
|
||||
name: qsTr('terminateCall')
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'paused'
|
||||
}
|
||||
})
|
||||
|
||||
return map;
|
||||
})()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function getParams (call) {
|
||||
if (call) {
|
||||
return MAP_STATUS_TO_PARAMS[call.status](call)
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
function handleCallRunning (index, call) {
|
||||
calls.currentIndex = index
|
||||
calls._selectedCall = call
|
||||
}
|
||||
|
||||
function handleRowsAboutToBeRemoved (_, first, last) {
|
||||
var index = calls.currentIndex
|
||||
|
||||
if (index >= first && index <= last) { // Remove current call.
|
||||
var model = calls.model
|
||||
|
||||
if (model.rowCount() - (last - first + 1) <= 0) {
|
||||
calls._selectedCall = null
|
||||
} else {
|
||||
if (first === 0) {
|
||||
calls._selectedCall = model.data(model.index(last + 1, 0))
|
||||
} else {
|
||||
calls._selectedCall = model.data(model.index(0, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleRowsRemoved (_, first, last) {
|
||||
var index = calls.currentIndex
|
||||
|
||||
// The current call has been removed.
|
||||
if (index >= first && index <= last) {
|
||||
if (calls.model.rowCount() === 0) {
|
||||
calls.currentIndex = -1 // No calls.
|
||||
} else {
|
||||
calls.currentIndex = 0 // The first call becomes the selected call.
|
||||
}
|
||||
}
|
||||
|
||||
// Update the current index of the selected call if it was after the removed calls.
|
||||
else if (last < index) {
|
||||
calls.currentIndex = index - (last - first + 1)
|
||||
}
|
||||
}
|
||||
|
||||
function handleRowsInserted (_, first, last) {
|
||||
// The last inserted outgoing element become the selected call.
|
||||
var model = calls.model
|
||||
|
||||
for (var index = last; index >= first; index--) {
|
||||
var call = model.data(model.index(index, 0))
|
||||
|
||||
if (call.isOutgoing) {
|
||||
calls.currentIndex = first
|
||||
calls._selectedCall = model.data(model.index(first, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import Common 1.0
|
|||
import Linphone 1.0
|
||||
import Linphone.Styles 1.0
|
||||
|
||||
import 'Calls.js' as Logic
|
||||
|
||||
// =============================================================================
|
||||
|
||||
ListView {
|
||||
|
|
@ -13,153 +15,23 @@ ListView {
|
|||
|
||||
readonly property var selectedCall: _selectedCall
|
||||
|
||||
property var _mapStatusToParams
|
||||
property var _selectedCall
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function _getParams (call) {
|
||||
if (call) {
|
||||
return _mapStatusToParams[call.status](call)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
clip: true
|
||||
spacing: 0
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Component.onCompleted: {
|
||||
_mapStatusToParams = {}
|
||||
|
||||
_mapStatusToParams[CallModel.CallStatusConnected] = (function (call) {
|
||||
return {
|
||||
actions: [{
|
||||
handler: (function () { call.pausedByUser = true }),
|
||||
name: qsTr('pauseCall')
|
||||
}, {
|
||||
handler: (function () { call.transfer() }),
|
||||
name: qsTr('transferCall')
|
||||
}, {
|
||||
handler: (function () { call.terminate() }),
|
||||
name: qsTr('terminateCall')
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'connected'
|
||||
}
|
||||
})
|
||||
|
||||
_mapStatusToParams[CallModel.CallStatusEnded] = (function (call) {
|
||||
return {
|
||||
string: 'ended'
|
||||
}
|
||||
})
|
||||
|
||||
_mapStatusToParams[CallModel.CallStatusIncoming] = (function (call) {
|
||||
return {
|
||||
actions: [{
|
||||
name: qsTr('acceptAudioCall'),
|
||||
handler: (function () { call.accept() })
|
||||
}, {
|
||||
name: qsTr('acceptVideoCall'),
|
||||
handler: (function () { call.acceptWithVideo() })
|
||||
}, {
|
||||
name: qsTr('terminateCall'),
|
||||
handler: (function () { call.terminate() })
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'incoming'
|
||||
}
|
||||
})
|
||||
|
||||
_mapStatusToParams[CallModel.CallStatusOutgoing] = (function (call) {
|
||||
return {
|
||||
component: callAction,
|
||||
handler: (function () { call.terminate() }),
|
||||
icon: 'hangup',
|
||||
string: 'outgoing'
|
||||
}
|
||||
})
|
||||
|
||||
_mapStatusToParams[CallModel.CallStatusPaused] = (function (call) {
|
||||
return {
|
||||
actions: [(call.pausedByUser ? {
|
||||
handler: (function () { call.pausedByUser = false }),
|
||||
name: qsTr('resumeCall')
|
||||
} : {
|
||||
handler: (function () { call.pausedByUser = true }),
|
||||
name: qsTr('pauseCall')
|
||||
}), {
|
||||
handler: (function () { call.transfer() }),
|
||||
name: qsTr('transferCall')
|
||||
}, {
|
||||
handler: (function () { call.terminate() }),
|
||||
name: qsTr('terminateCall')
|
||||
}],
|
||||
component: callActions,
|
||||
string: 'paused'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Connections {
|
||||
target: model
|
||||
|
||||
onRowsAboutToBeRemoved: {
|
||||
var index = calls.currentIndex
|
||||
|
||||
if (index >= first && index <= last) { // Remove current call.
|
||||
if (model.rowCount() - (last - first + 1) <= 0) {
|
||||
_selectedCall = null
|
||||
} else {
|
||||
if (first === 0) {
|
||||
_selectedCall = model.data(model.index(last + 1, 0))
|
||||
} else {
|
||||
_selectedCall = model.data(model.index(0, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onRowsRemoved: {
|
||||
var index = calls.currentIndex
|
||||
|
||||
// The current call has been removed.
|
||||
if (index >= first && index <= last) {
|
||||
if (model.rowCount() === 0) {
|
||||
calls.currentIndex = -1 // No calls.
|
||||
} else {
|
||||
calls.currentIndex = 0 // The first call becomes the selected call.
|
||||
}
|
||||
}
|
||||
|
||||
// Update the current index of the selected call if it was after the removed calls.
|
||||
else if (last < index) {
|
||||
calls.currentIndex = index - (last - first + 1)
|
||||
}
|
||||
}
|
||||
|
||||
// The last inserted outgoing element become the selected call.
|
||||
onRowsInserted: {
|
||||
for (var index = last; index >= first; index--) {
|
||||
var call = model.data(model.index(index, 0))
|
||||
|
||||
if (call.isOutgoing) {
|
||||
calls.currentIndex = first
|
||||
_selectedCall = model.data(model.index(first, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCallRunning: {
|
||||
calls.currentIndex = index
|
||||
_selectedCall = call
|
||||
}
|
||||
onCallRunning: Logic.handleCallRunning(index, call)
|
||||
onRowsAboutToBeRemoved: Logic.handleRowsAboutToBeRemoved(parent, first, last)
|
||||
onRowsInserted: Logic.handleRowsInserted(parent, first, last)
|
||||
onRowsRemoved: Logic.handleRowsRemoved(parent, first, last)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -260,10 +132,11 @@ ListView {
|
|||
Loader {
|
||||
id: loader
|
||||
|
||||
property int callId: index
|
||||
property var call: $call
|
||||
property var callControls: _callControls
|
||||
property var params: _getParams($call)
|
||||
readonly property int callId: index
|
||||
|
||||
readonly property var call: $call
|
||||
readonly property var callControls: _callControls
|
||||
readonly property var params: Logic.getParams($call)
|
||||
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: params.component
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ Notification {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
property var _call: notificationData && notificationData.call
|
||||
property var _contact: _sipAddressObserver.contact
|
||||
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(_call ? _call.sipAddress : '')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -49,10 +47,10 @@ Notification {
|
|||
Contact {
|
||||
Layout.fillWidth: true
|
||||
|
||||
entry: ({
|
||||
contact: notification._contact,
|
||||
sipAddress: notification._sipAddressObserver.sipAddress
|
||||
})
|
||||
entry: {
|
||||
var call = notification._call
|
||||
return SipAddressesModel.getSipAddressObserver(call ? call.sipAddress : '')
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ Notification {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
property string _sipAddress: notificationData && notificationData.sipAddress || ''
|
||||
property var _contact: _sipAddressObserver.contact
|
||||
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(_sipAddress)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -49,10 +47,7 @@ Notification {
|
|||
Contact {
|
||||
Layout.fillWidth: true
|
||||
|
||||
entry: ({
|
||||
contact: notification._contact,
|
||||
sipAddress: notification._sipAddress
|
||||
})
|
||||
entry: SipAddressesModel.getSipAddressObserver(notification._sipAddress)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ SearchBox {
|
|||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
entry: ({
|
||||
sipAddress: interpretableSipAddress
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue