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