From ad37fb022244349ac3f61e0a74f190d5a5f16472 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 15 Feb 2023 14:52:36 +0100 Subject: [PATCH] Deactivate action buttons and menus if chat room has been left. --- CHANGELOG.md | 1 + .../ui/modules/Common/Form/ActionButton.qml | 19 +++++---- .../ui/modules/Common/Menus/MenuItem.qml | 42 ++++++++----------- .../ui/views/App/Main/Conversation.qml | 11 ++++- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce64a83ef..312052a34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Crash on ending call in conference. - Crash after showing participant devices. +- Deactivate action buttons and menus if chat room has been left. - Display of non-Ascii avatar - Remove duplicated nat policies. - Save Stun/Turn proxy configuration. diff --git a/linphone-app/ui/modules/Common/Form/ActionButton.qml b/linphone-app/ui/modules/Common/Form/ActionButton.qml index ba9856154..ff453865f 100644 --- a/linphone-app/ui/modules/Common/Form/ActionButton.qml +++ b/linphone-app/ui/modules/Common/Form/ActionButton.qml @@ -117,7 +117,8 @@ Item { if(color) return color else{ - console.warn("No color defined for :"+debugVar+ " on "+_getIcon()) + if( debugVar ) + console.warn("No color defined for :"+debugVar+ " on "+_getIcon()) return defaultColor } } @@ -128,10 +129,11 @@ Item { //return getColor(wrappedButton.colorSet.backgroundNormalColor, defaultColor, 'backgroundNormalColor') if (wrappedButton.updating || wrappedButton.toggled) return getColor(wrappedButton.colorSet.backgroundUpdatingColor, defaultColor, 'backgroundUpdatingColor') + var normalColor = getColor(wrappedButton.colorSet.backgroundNormalColor, defaultColor, 'backgroundNormalColor') if (!useStates) - return getColor(wrappedButton.colorSet.backgroundNormalColor, defaultColor, 'backgroundNormalColor') + return normalColor if (!wrappedButton.enabled) - return getColor(wrappedButton.colorSet.backgroundDisabledColor, defaultColor, 'backgroundDisabledColor') + return getColor(wrappedButton.colorSet.backgroundDisabledColor, normalColor) return button.down ? getColor(wrappedButton.colorSet.backgroundPressedColor, defaultColor, 'backgroundPressedColor') : (button.hovered ? getColor(wrappedButton.colorSet.backgroundHoveredColor, defaultColor, 'backgroundHoveredColor') : getColor(wrappedButton.colorSet.backgroundNormalColor, defaultColor, 'backgroundNormalColor')) @@ -145,10 +147,11 @@ Item { //return getColor(wrappedButton.colorSet.foregroundNormalColor, defaultColor, 'foregroundNormalColor') if (wrappedButton.updating || wrappedButton.toggled) return getColor(wrappedButton.colorSet.foregroundUpdatingColor, defaultColor, 'foregroundUpdatingColor') + var normalColor = getColor(wrappedButton.colorSet.foregroundNormalColor, defaultColor, 'foregroundNormalColor') if (!useStates) - return getColor(wrappedButton.colorSet.foregroundNormalColor, defaultColor, 'foregroundNormalColor') + return normalColor if (!wrappedButton.enabled) - return getColor(wrappedButton.colorSet.foregroundDisabledColor, defaultColor, 'foregroundDisabledColor') + return getColor(wrappedButton.colorSet.foregroundDisabledColor, normalColor) return button.down ? getColor(wrappedButton.colorSet.foregroundPressedColor, defaultColor, 'foregroundPressedColor') : (button.hovered ? getColor(wrappedButton.colorSet.foregroundHoveredColor, defaultColor, 'foregroundHoveredColor') : getColor(wrappedButton.colorSet.foregroundNormalColor, defaultColor, 'foregroundNormalColor')) @@ -194,7 +197,7 @@ Item { property int fitWidth: iconWidth || iconSize || parent.iconSize || parent.width height: fitHeight width: fitWidth - + opacity: enabled ? 1.0 : 0.5 Button { id: button @@ -296,6 +299,7 @@ Item { hoverEnabled: true acceptedButtons: Qt.NoButton cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor + visible: wrappedButton.enabled } } @@ -318,6 +322,7 @@ Item { hoverEnabled: true acceptedButtons: Qt.NoButton cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor + visible: wrappedButton.enabled } } TooltipArea { @@ -330,7 +335,7 @@ Item { hoverEnabled: true acceptedButtons: Qt.NoButton cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor - visible: !iconIsCustom && !tooltip.visible + visible: wrappedButton.enabled && !iconIsCustom && !tooltip.visible } } diff --git a/linphone-app/ui/modules/Common/Menus/MenuItem.qml b/linphone-app/ui/modules/Common/Menus/MenuItem.qml index 49645f7f0..b4c3d44d9 100644 --- a/linphone-app/ui/modules/Common/Menus/MenuItem.qml +++ b/linphone-app/ui/modules/Common/Menus/MenuItem.qml @@ -24,18 +24,28 @@ Controls.MenuItem { property int offsetTopMargin : 0 property int offsetBottomMargin : 0 + property color _textColor: + (button.down + ? menuItemStyle.text.color.pressed + : ( + button.hovered + ? menuItemStyle.text.color.hovered + : menuItemStyle.text.color.normal + )) + height:visible?undefined:0 Component.onCompleted: menu.width = Math.max(menu.width, implicitWidth) + opacity: enabled ? 1.0 : 0.5 background: Rectangle { color: button.down - ? menuItemStyle.background.color.pressed - : ( - button.hovered - ? menuItemStyle.background.color.hovered - : menuItemStyle.background.color.normal - ) + ? menuItemStyle.background.color.pressed + : ( + button.hovered + ? menuItemStyle.background.color.hovered + : menuItemStyle.background.color.normal + ) implicitHeight: button.menuItemStyle.background.height } contentItem:RowLayout{ @@ -51,15 +61,7 @@ Controls.MenuItem { visible: icon anchors.centerIn: parent iconSize: rowText.lineCount > 0 ? rowText.contentHeight/rowText.lineCount + 2 : 0 - overwriteColor: button.enabled - ? (button.down - ? menuItemStyle.text.color.pressed - : ( - button.hovered - ? menuItemStyle.text.color.hovered - : menuItemStyle.text.color.normal - )) - : menuItemStyle.text.color.disabled + overwriteColor: button._textColor } } Text { @@ -68,15 +70,7 @@ Controls.MenuItem { Layout.fillHeight: true Layout.leftMargin:(iconLayoutDirection == Qt.LeftToRight ? 0 : menuItemStyle.leftMargin) Layout.rightMargin:(iconLayoutDirection == Qt.LeftToRight ? menuItemStyle.rightMargin : 0) - color: button.enabled - ? (button.down - ? menuItemStyle.text.color.pressed - : ( - button.hovered - ? menuItemStyle.text.color.hovered - : menuItemStyle.text.color.normal - )) - : menuItemStyle.text.color.disabled + color: button._textColor elide: Text.ElideRight diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 8203b8d46..dc553985e 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -266,6 +266,7 @@ ColumnLayout { colorSet: ConversationStyle.bar.actions.videoCall visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton && !conversation.haveMoreThanOneParticipants + enabled: !conversation.chatRoomModel.isReadOnly onClicked: CallsListModel.launchVideoCall(chatRoomModel.participants.addressesToString) } @@ -275,6 +276,7 @@ ColumnLayout { colorSet: ConversationStyle.bar.actions.call visible: SettingsModel.outgoingCallsEnabled && !conversation.haveMoreThanOneParticipants + enabled: !conversation.chatRoomModel.isReadOnly onClicked: CallsListModel.launchAudioCall(chatRoomModel.participants.addressesToString) } @@ -284,6 +286,7 @@ ColumnLayout { colorSet: ConversationStyle.bar.actions.chat visible: SettingsModel.standardChatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel != 1 + enabled: !conversation.chatRoomModel.isReadOnly onClicked: CallsListModel.launchChat(chatRoomModel.participants.addressesToString, 0) } @@ -292,6 +295,7 @@ ColumnLayout { backgroundRadius: 1000 colorSet: ConversationStyle.bar.actions.chat visible: SettingsModel.secureChatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel == 1 + enabled: !conversation.chatRoomModel.isReadOnly onClicked: CallsListModel.launchChat(chatRoomModel.participants.addressesToString, 1) Icon{ @@ -318,9 +322,9 @@ ColumnLayout { backgroundRadius: 1000 colorSet: ConversationStyle.bar.actions.groupChat - visible: conversation.chatRoomModel && !conversation.chatRoomModel.isReadOnly && conversation.haveMoreThanOneParticipants && SettingsModel.outgoingCallsEnabled && (SettingsModel.videoConferenceEnabled || conversation.haveLessThanMinParticipantsForCall) + visible: conversation.chatRoomModel && conversation.haveMoreThanOneParticipants && SettingsModel.outgoingCallsEnabled && (SettingsModel.videoConferenceEnabled || conversation.haveLessThanMinParticipantsForCall) + enabled: !conversation.chatRoomModel.isReadOnly - //onClicked: CallsListModel. Logic.openConferenceManager({chatRoomModel:conversation.chatRoomModel, autoCall:true}) onClicked:{ if( SettingsModel.videoConferenceEnabled ){ groupCallButton.toggled = true @@ -442,6 +446,7 @@ ColumnLayout { text: qsTr('conversationMenuDevices') iconMenu: MenuItemStyle.devices.icon visible: conversationMenu.showDevices + enabled: !conversation.chatRoomModel.isReadOnly iconSizeMenu: 40 menuItemStyle : MenuItemStyle.aux2 onTriggered: { @@ -464,6 +469,7 @@ ColumnLayout { iconSizeMenu: 40 menuItemStyle : MenuItemStyle.aux2 visible: conversationMenu.showEphemerals + enabled: !conversation.chatRoomModel.isReadOnly onTriggered: { window.detachVirtualWindow() window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/EphemeralChatRoom.qml') @@ -486,6 +492,7 @@ ColumnLayout { iconSizeMenu: 40 menuItemStyle : MenuItemStyle.aux2 visible: conversationMenu.showScheduleMeeting + enabled: !conversation.chatRoomModel.isReadOnly onClicked: { conferenceInfoModel.resetConferenceInfo() conferenceInfoModel.isScheduled = true