diff --git a/linphone-desktop/ui/modules/Common/Form/ActionSwitch.qml b/linphone-desktop/ui/modules/Common/Form/ActionSwitch.qml index 4d59685ec..541953bef 100644 --- a/linphone-desktop/ui/modules/Common/Form/ActionSwitch.qml +++ b/linphone-desktop/ui/modules/Common/Form/ActionSwitch.qml @@ -3,9 +3,9 @@ import QtQuick 2.7 // ============================================================================= Item { + property alias updating: actionButton.updating property alias useStates: actionButton.useStates property bool enabled: true - property alias updating: actionButton.updating property int iconSize // Optionnal. property string icon diff --git a/linphone-desktop/ui/modules/Common/Form/Switch.qml b/linphone-desktop/ui/modules/Common/Form/Switch.qml index 340f71f64..1232f00c3 100644 --- a/linphone-desktop/ui/modules/Common/Form/Switch.qml +++ b/linphone-desktop/ui/modules/Common/Form/Switch.qml @@ -8,19 +8,31 @@ import Common.Styles 1.0 Switch { id: control + // --------------------------------------------------------------------------- + + property bool enabled: true + + // --------------------------------------------------------------------------- + checked: false indicator: Rectangle { implicitHeight: SwitchStyle.indicator.height implicitWidth: SwitchStyle.indicator.width - border.color: control.checked - ? SwitchStyle.indicator.border.color.checked - : SwitchStyle.indicator.border.color.normal + border.color: control.enabled + ? ( + control.checked + ? SwitchStyle.indicator.border.color.checked + : SwitchStyle.indicator.border.color.normal + ) : SwitchStyle.indicator.border.color.disabled - color: control.checked - ? SwitchStyle.indicator.color.checked - : SwitchStyle.indicator.color.normal + color: control.enabled + ? ( + control.checked + ? SwitchStyle.indicator.color.checked + : SwitchStyle.indicator.color.normal + ) : SwitchStyle.indicator.color.disabled radius: SwitchStyle.indicator.radius x: control.leftPadding @@ -33,18 +45,29 @@ Switch { width: SwitchStyle.sphere.size anchors.verticalCenter: parent.verticalCenter - border.color: control.checked - ? (control.down - ? SwitchStyle.sphere.border.color.pressed - : SwitchStyle.sphere.border.color.checked - ) : SwitchStyle.sphere.border.color.normal - color: control.down - ? SwitchStyle.sphere.color.pressed - : SwitchStyle.sphere.color.normal + border.color: control.enabled + ? + ( + control.checked + ? ( + control.down + ? SwitchStyle.sphere.border.color.pressed + : SwitchStyle.sphere.border.color.checked + ) : SwitchStyle.sphere.border.color.normal + ) : SwitchStyle.sphere.border.color.disabled + + color: control.enabled + ? + ( + control.down + ? SwitchStyle.sphere.color.pressed + : SwitchStyle.sphere.color.normal + ) : SwitchStyle.sphere.color.disabled radius: width / 2 - x: control.checked ? parent.width - width : 0 + + // ----------------------------------------------------------------------- states: State { when: control.checked @@ -65,4 +88,12 @@ Switch { } } } + + // --------------------------------------------------------------------------- + + MouseArea { + anchors.fill: parent + + onClicked: control.enabled && control.toggle() + } } diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/SwitchStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/SwitchStyle.qml index 9bbd6e390..08b78bd35 100644 --- a/linphone-desktop/ui/modules/Common/Styles/Form/SwitchStyle.qml +++ b/linphone-desktop/ui/modules/Common/Styles/Form/SwitchStyle.qml @@ -17,12 +17,14 @@ QtObject { property QtObject border: QtObject { property QtObject color: QtObject { property color checked: Colors.i + property color disabled: Colors.c property color normal: Colors.c } } property QtObject color: QtObject { property color checked: Colors.i + property color disabled: Colors.e property color normal: Colors.k } } @@ -33,12 +35,14 @@ QtObject { property QtObject border: QtObject { property QtObject color: QtObject { property color checked: Colors.i + property color disabled: Colors.c property color normal: Colors.w property color pressed: Colors.w } } property QtObject color: QtObject { + property color disabled: Colors.e property color pressed: Colors.c property color normal: Colors.k } diff --git a/linphone-desktop/ui/views/App/Settings/SettingsNetwork.qml b/linphone-desktop/ui/views/App/Settings/SettingsNetwork.qml index 24234b336..107aee8b6 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsNetwork.qml +++ b/linphone-desktop/ui/views/App/Settings/SettingsNetwork.qml @@ -63,7 +63,7 @@ TabContainer { label: qsTr('sipUdpPortLabel') NumericField { - readOnly: randomSipUdpPort.checked + readOnly: randomSipUdpPort.checked || !enableSipUdpPort.checked } } @@ -72,8 +72,14 @@ TabContainer { Switch { id: randomSipUdpPort + + enabled: enableSipUdpPort.checked } } + + Switch { + id: enableSipUdpPort + } } FormLine { @@ -81,7 +87,7 @@ TabContainer { label: qsTr('sipTcpPortLabel') NumericField { - readOnly: randomSipTcpPort.checked + readOnly: randomSipTcpPort.checked || !enableSipTcpPort.checked } } @@ -90,8 +96,14 @@ TabContainer { Switch { id: randomSipTcpPort + + enabled: enableSipTcpPort.checked } } + + Switch { + id: enableSipTcpPort + } } FormLine { @@ -99,7 +111,7 @@ TabContainer { label: qsTr('audioRtpUdpPortLabel') NumericField { - readOnly: randomAudioRtpUdpPort.checked + readOnly: randomAudioRtpUdpPort.checked || !enableAudioRtpUdpPort.checked } } @@ -108,8 +120,14 @@ TabContainer { Switch { id: randomAudioRtpUdpPort + + enabled: enableAudioRtpUdpPort.checked } } + + Switch { + id: enableAudioRtpUdpPort + } } FormLine { @@ -126,6 +144,8 @@ TabContainer { Switch { id: randomVideoRtpUdpPort + + enabled: enableVideoRtpUdpPort.checked } }