Commit b69e5bda authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsNetwork):

  - audio/video rtp ports supported
  - use a bidirectional binding in `PortField`
parent 6a47380f
...@@ -42,6 +42,27 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { ...@@ -42,6 +42,27 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Network. // Network.
// ============================================================================= // =============================================================================
QList<int> SettingsModel::getAudioPortRange () const {
int a, b;
CoreManager::getInstance()->getCore()->getAudioPortRange(a, b);
return QList<int>() << a << b;
}
void SettingsModel::setAudioPortRange (const QList<int> &range) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
int a = range[0];
int b = range[1];
if (b == -1)
core->setAudioPort(a);
else
core->setAudioPortRange(a, b);
emit audioPortRangeChanged(a, b);
}
// -----------------------------------------------------------------------------
QList<int> SettingsModel::getVideoPortRange () const { QList<int> SettingsModel::getVideoPortRange () const {
int a, b; int a, b;
CoreManager::getInstance()->getCore()->getVideoPortRange(a, b); CoreManager::getInstance()->getCore()->getVideoPortRange(a, b);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
class SettingsModel : public QObject { class SettingsModel : public QObject {
Q_OBJECT; Q_OBJECT;
Q_PROPERTY(QList<int> audioPortRange READ getAudioPortRange WRITE setAudioPortRange NOTIFY audioPortRangeChanged);
Q_PROPERTY(QList<int> videoPortRange READ getVideoPortRange WRITE setVideoPortRange NOTIFY videoPortRangeChanged); Q_PROPERTY(QList<int> videoPortRange READ getVideoPortRange WRITE setVideoPortRange NOTIFY videoPortRangeChanged);
Q_PROPERTY(bool useSipInfoForDtmfs READ getUseSipInfoForDtmfs WRITE setUseSipInfoForDtmfs NOTIFY dtmfsProtocolChanged); Q_PROPERTY(bool useSipInfoForDtmfs READ getUseSipInfoForDtmfs WRITE setUseSipInfoForDtmfs NOTIFY dtmfsProtocolChanged);
...@@ -49,6 +50,9 @@ public: ...@@ -49,6 +50,9 @@ public:
// Network. ------------------------------------------------------------------ // Network. ------------------------------------------------------------------
QList<int> getAudioPortRange () const;
void setAudioPortRange (const QList<int> &range);
QList<int> getVideoPortRange () const; QList<int> getVideoPortRange () const;
void setVideoPortRange (const QList<int> &range); void setVideoPortRange (const QList<int> &range);
...@@ -80,6 +84,7 @@ public: ...@@ -80,6 +84,7 @@ public:
static const std::string UI_SECTION; static const std::string UI_SECTION;
signals: signals:
void audioPortRangeChanged (int a, int b);
void videoPortRangeChanged (int a, int b); void videoPortRangeChanged (int a, int b);
void dtmfsProtocolChanged (); void dtmfsProtocolChanged ();
......
...@@ -9,9 +9,11 @@ Item { ...@@ -9,9 +9,11 @@ Item {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
property string text property alias readOnly: textField.readOnly
property bool supportsRange: false property bool supportsRange: false
property string text
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
signal editingFinished (int portA, int portB) signal editingFinished (int portA, int portB)
...@@ -47,15 +49,17 @@ Item { ...@@ -47,15 +49,17 @@ Item {
implicitWidth: textField.width implicitWidth: textField.width
implicitHeight: textField.height implicitHeight: textField.height
onTextChanged: textField.text = _computeText(_extractPorts(text))
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
Binding {
property: 'text'
target: textField
value: _computeText(_extractPorts(wrapper.text))
}
TextField { TextField {
id: textField id: textField
property bool locked: false
validator: RegExpValidator { validator: RegExpValidator {
regExp: wrapper.supportsRange regExp: wrapper.supportsRange
? Utils.PORT_RANGE_REGEX ? Utils.PORT_RANGE_REGEX
...@@ -63,13 +67,12 @@ Item { ...@@ -63,13 +67,12 @@ Item {
} }
// Workaround to supports empty string. // Workaround to supports empty string.
Keys.onReturnPressed: editingFinished() Keys.onReturnPressed: textField.focus = false
onActiveFocusChanged: !activeFocus && !text.length && editingFinished() onActiveFocusChanged: !activeFocus && editingFinished()
onEditingFinished: { onEditingFinished: {
var range = _extractPorts(textField.text) var range = _extractPorts(text)
textField.text = _computeText(range)
wrapper.text = textField.text = _computeText(range)
wrapper.editingFinished(range[0], range[1]) wrapper.editingFinished(range[0], range[1])
} }
} }
......
...@@ -40,10 +40,10 @@ TabContainer { ...@@ -40,10 +40,10 @@ TabContainer {
PortField { PortField {
//readOnly: randomSipUdpPort.checked || !enableSipUdpPort.checked //readOnly: randomSipUdpPort.checked || !enableSipUdpPort.checked
supportsRange: true //supportsRange: true
text: SettingsModel.videoPortRange.join(':') //text: SettingsModel.videoPortRange.join(':')
onEditingFinished: SettingsModel.videoPortRange = [ portA, portB ] //onEditingFinished: SettingsModel.videoPortRange = [ portA, portB ]
} }
} }
...@@ -89,13 +89,19 @@ TabContainer { ...@@ -89,13 +89,19 @@ TabContainer {
} }
FormLine { FormLine {
id: audioRtpUdpPort
readonly property int defaultPort: 7078
FormGroup { FormGroup {
label: qsTr('audioRtpUdpPortLabel') label: qsTr('audioRtpUdpPortLabel')
NumericField { PortField {
minValue: 0 readOnly: randomAudioRtpUdpPort.checked
maxValue: 65535 supportsRange: true
readOnly: randomAudioRtpUdpPort.checked || !enableAudioRtpUdpPort.checked text: SettingsModel.audioPortRange.join(':')
onEditingFinished: SettingsModel.audioPortRange = [ portA, portB ]
} }
} }
...@@ -103,25 +109,29 @@ TabContainer { ...@@ -103,25 +109,29 @@ TabContainer {
Switch { Switch {
id: randomAudioRtpUdpPort id: randomAudioRtpUdpPort
enabled: enableAudioRtpUdpPort.checked checked: SettingsModel.audioPortRange[0] === -1
}
}
FormEntry { onClicked: SettingsModel.audioPortRange = checked
Switch { ? [ audioRtpUdpPort.defaultPort, -1 ]
id: enableAudioRtpUdpPort : [ -1, -1 ]
} }
} }
} }
FormLine { FormLine {
id: videoRtpUdpPort
readonly property int defaultPort: 9078
FormGroup { FormGroup {
label: qsTr('videoRtpUdpPortLabel') label: qsTr('videoRtpUdpPortLabel')
NumericField { PortField {
minValue: 0 readOnly: randomVideoRtpUdpPort.checked
maxValue: 65535 supportsRange: true
readOnly: randomVideoRtpUdpPort.checked || !enableVideoRtpUdpPort.checked text: SettingsModel.videoPortRange.join(':')
onEditingFinished: SettingsModel.videoPortRange = [ portA, portB ]
} }
} }
...@@ -129,13 +139,11 @@ TabContainer { ...@@ -129,13 +139,11 @@ TabContainer {
Switch { Switch {
id: randomVideoRtpUdpPort id: randomVideoRtpUdpPort
enabled: enableVideoRtpUdpPort.checked checked: SettingsModel.videoPortRange[0] === -1
}
}
FormEntry { onClicked: SettingsModel.videoPortRange = checked
Switch { ? [ videoRtpUdpPort.defaultPort, -1 ]
id: enableVideoRtpUdpPort : [ -1, -1 ]
} }
} }
} }
......
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