Commit 176e3d1a authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): many things:

  - `qsTr` supports `js` sources
  - create a logic file for `ui/views/App/Calls/Incall.qml`
  - `openConfirmDialog` in `ui/scripts/Utils/utils.js` supports properties` and
    `openWindow` supports correctly properties if `window` is a qml string
parent 99156f80
...@@ -163,12 +163,12 @@ file(STRINGS ${QRC_RESOURCES} QRC_RESOURCES_CONTENT) ...@@ -163,12 +163,12 @@ file(STRINGS ${QRC_RESOURCES} QRC_RESOURCES_CONTENT)
foreach (line ${QRC_RESOURCES_CONTENT}) foreach (line ${QRC_RESOURCES_CONTENT})
set(result) set(result)
string(REGEX REPLACE string(REGEX REPLACE
"^[ \t]*<[ \t]*file[ \t]*>[ \t]*(.+\\.qml)[ \t]*<[ \t]*/[ \t]*file[ \t]*>[ \t]*$" "^[ \t]*<[ \t]*file[ \t]*>[ \t]*(.+\\.[a-z]+)[ \t]*<[ \t]*/[ \t]*file[ \t]*>[ \t]*$"
"\\1" "\\1"
result result
${line}) ${line})
string(REGEX MATCH "qml$" isQml ${result}) string(REGEX MATCH "\\.[a-z]+$" isUi ${result})
if (NOT ${isQml} STREQUAL "") if (NOT ${isUi} STREQUAL "")
list(APPEND QML_SOURCES "${CMAKE_SOURCE_DIR}/${result}") list(APPEND QML_SOURCES "${CMAKE_SOURCE_DIR}/${result}")
endif () endif ()
endforeach () endforeach ()
......
...@@ -472,11 +472,11 @@ Server url not configured.</translation> ...@@ -472,11 +472,11 @@ Server url not configured.</translation>
<name>Incall</name> <name>Incall</name>
<message> <message>
<source>acceptVideoDescription</source> <source>acceptVideoDescription</source>
<translation type="unfinished"></translation> <translation>Your contact would like to turn on video.</translation>
</message> </message>
<message> <message>
<source>acceptVideoTitle</source> <source>acceptVideoTitle</source>
<translation type="unfinished"></translation> <translation>Video requested</translation>
</message> </message>
</context> </context>
<context> <context>
......
...@@ -472,11 +472,11 @@ Url du serveur non configurée.</translation> ...@@ -472,11 +472,11 @@ Url du serveur non configurée.</translation>
<name>Incall</name> <name>Incall</name>
<message> <message>
<source>acceptVideoDescription</source> <source>acceptVideoDescription</source>
<translation type="unfinished"></translation> <translation>Votre correspondant souhaite ajouter la vidéo.</translation>
</message> </message>
<message> <message>
<source>acceptVideoTitle</source> <source>acceptVideoTitle</source>
<translation type="unfinished"></translation> <translation>Demande de vidéo</translation>
</message> </message>
</context> </context>
<context> <context>
......
...@@ -313,6 +313,7 @@ ...@@ -313,6 +313,7 @@
<file>ui/scripts/Utils/utils.js</file> <file>ui/scripts/Utils/utils.js</file>
<file>ui/views/App/Calls/AbstractStartingCall.qml</file> <file>ui/views/App/Calls/AbstractStartingCall.qml</file>
<file>ui/views/App/Calls/CallsWindow.qml</file> <file>ui/views/App/Calls/CallsWindow.qml</file>
<file>ui/views/App/Calls/Incall.js</file>
<file>ui/views/App/Calls/Incall.qml</file> <file>ui/views/App/Calls/Incall.qml</file>
<file>ui/views/App/Calls/IncomingCall.qml</file> <file>ui/views/App/Calls/IncomingCall.qml</file>
<file>ui/views/App/Calls/OutgoingCall.qml</file> <file>ui/views/App/Calls/OutgoingCall.qml</file>
......
...@@ -102,7 +102,11 @@ function openConfirmDialog (parent, options) { ...@@ -102,7 +102,11 @@ function openConfirmDialog (parent, options) {
'}', '}',
parent, { parent, {
isString: true, isString: true,
exitHandler: options.exitHandler exitHandler: (options && options.exitHandler) ||
function () {
return 0
},
properties: options && options.properties
} }
) )
} }
...@@ -113,7 +117,7 @@ function openConfirmDialog (parent, options) { ...@@ -113,7 +117,7 @@ function openConfirmDialog (parent, options) {
// If options.isString is equals to true, a marshalling component can // If options.isString is equals to true, a marshalling component can
// be used. // be used.
// //
// Supported options: isString, exitHandler. // Supported options: isString, exitHandler, properties.
// //
// If exitHandler is used, window must implement exitStatus signal. // If exitHandler is used, window must implement exitStatus signal.
function openWindow (window, parent, options) { function openWindow (window, parent, options) {
...@@ -121,6 +125,13 @@ function openWindow (window, parent, options) { ...@@ -121,6 +125,13 @@ function openWindow (window, parent, options) {
if (options && options.isString) { if (options && options.isString) {
object = Qt.createQmlObject(window, parent) object = Qt.createQmlObject(window, parent)
var properties = options && options.properties
if (properties) {
for (var key in properties) {
object[key] = properties[key]
}
}
} else { } else {
var component = Qt.createComponent( var component = Qt.createComponent(
'qrc:/ui/views/App/' + window + '.qml' 'qrc:/ui/views/App/' + window + '.qml'
......
// =============================================================================
// `Incall.qml` Logic.
// =============================================================================
.import Linphone 1.0 as Linphone
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
// =============================================================================
function handleVideoRequested () {
var call = incall.call
var dialog
// Close dialog after 10s.
var timeout = Utils.setTimeout(incall, 10000, function () {
call.statusChanged.disconnect(endedHandler)
dialog.close()
call.rejectVideoRequest()
})
// Close dialog if call is ended.
var endedHandler = function (status) {
if (status === Linphone.CallModel.CallStatusEnded) {
Utils.clearTimeout(timeout)
call.statusChanged.disconnect(endedHandler)
dialog.close()
}
}
call.statusChanged.connect(endedHandler)
dialog = Utils.openConfirmDialog(window, {
descriptionText: qsTr('acceptVideoDescription'),
exitHandler: function (status) {
Utils.clearTimeout(timeout)
call.statusChanged.disconnect(endedHandler)
if (status) {
call.acceptVideoRequest()
} else {
call.rejectVideoRequest()
}
},
properties: {
modality: Qt.NonModal
},
title: qsTr('acceptVideoTitle')
})
}
...@@ -9,6 +9,8 @@ import Utils 1.0 ...@@ -9,6 +9,8 @@ import Utils 1.0
import App.Styles 1.0 import App.Styles 1.0
import 'Incall.js' as Logic
// ============================================================================= // =============================================================================
Rectangle { Rectangle {
...@@ -44,53 +46,14 @@ Rectangle { ...@@ -44,53 +46,14 @@ Rectangle {
color: CallStyle.backgroundColor color: CallStyle.backgroundColor
// ---------------------------------------------------------------------------
// Handle video requests.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Connections { Connections {
target: call target: call
onVideoRequested: { onVideoRequested: Logic.handleVideoRequested()
var dialog
// Close dialog after 10s.
var timeout = Utils.setTimeout(incall, 10000, function () {
call.statusChanged.disconnect(endedHandler)
dialog.close()
call.rejectVideoRequest()
})
// Close dialog if call is ended.
var endedHandler = function (status) {
if (status === CallModel.CallStatusEnded) {
Utils.clearTimeout(timeout)
call.statusChanged.disconnect(endedHandler)
dialog.close()
}
}
call.statusChanged.connect(endedHandler)
dialog = Utils.openConfirmDialog(window, {
descriptionText: qsTr('acceptVideoDescription'),
exitHandler: function (status) {
Utils.clearTimeout(timeout)
call.statusChanged.disconnect(endedHandler)
if (status) {
call.acceptVideoRequest()
} else {
call.rejectVideoRequest()
}
},
title: qsTr('acceptVideoTitle')
})
}
} }
// ---------------------------------------------------------------------------
ColumnLayout { ColumnLayout {
anchors { anchors {
fill: parent fill: parent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment