From a84e2b832674737f182ef081d5b43a07673f7a6a Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Thu, 2 Dec 2021 22:52:34 +0100 Subject: [PATCH] Fix search addresses (log error, repeaters and unshown secure icons) --- .../SmartSearchBar/SmartSearchBar.qml | 6 - .../Linphone/View/ParticipantsView.qml | 4 +- .../Linphone/View/SipAddressesView.qml | 149 +++++++++--------- .../views/App/Main/Dialogs/InfoChatRoom.qml | 2 +- 4 files changed, 78 insertions(+), 83 deletions(-) diff --git a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml index 37c60222c..610d6ab95 100644 --- a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml +++ b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml @@ -88,12 +88,6 @@ SearchBox { colorSet: SettingsModel.getShowStartChatButton() ? SipAddressesViewStyle.chat : SipAddressesViewStyle.history, secure: 1, visible: SettingsModel.secureChatEnabled && AccountSettingsModel.conferenceURI != '', - secureIconVisibleHandler : function(entry) { - if(entry) - return UtilsCpp.hasCapability(entry.sipAddress ? entry.sipAddress : entry, LinphoneEnums.FriendCapabilityLimeX3Dh); - else - return false; - }, handler: function (entry) { searchBox.closeMenu() searchBox.launchSecureChat(entry.sipAddress) diff --git a/linphone-app/ui/modules/Linphone/View/ParticipantsView.qml b/linphone-app/ui/modules/Linphone/View/ParticipantsView.qml index cb05ba475..ffb4a9869 100644 --- a/linphone-app/ui/modules/Linphone/View/ParticipantsView.qml +++ b/linphone-app/ui/modules/Linphone/View/ParticipantsView.qml @@ -127,7 +127,7 @@ ScrollableListView { }) Icon{ visible: modelData.secure>0 && - (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler($sipAddress) : true) + (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler({sipAddres:$sipAddress}) : true) icon:modelData.secure === 2?'secure_level_2':'secure_level_1' iconSize:15 anchors.right:parent.right @@ -297,7 +297,7 @@ ScrollableListView { } Icon{ visible: modelData.secure>0 && - (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler($sipAddress) : true) + (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler({sipAddres:$sipAddress}) : true) icon:modelData.secure === 2?'secure_level_2':'secure_level_1' iconSize:15 anchors.right:parent.right diff --git a/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml b/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml index 5c1ce2081..35505f613 100644 --- a/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml +++ b/linphone-app/ui/modules/Linphone/View/SipAddressesView.qml @@ -14,17 +14,17 @@ import Common.Styles 1.0 ScrollableListView { id: sipAddressesView - + // --------------------------------------------------------------------------- - + // Contains a list of: { // icon: 'string', // handler: function () { ... } // } property var actions: [] - + property string genSipAddress - + // Optional parameters. property string headerButtonDescription property string headerButtonIcon @@ -35,23 +35,23 @@ ScrollableListView { property bool showSwitch : false property bool showSeparator : true property bool isSelectable : true - + property var switchHandler : function(checked, index){ } - - + + readonly property string interpretableSipAddress: SipAddressesModel.interpretSipAddress( genSipAddress, false ) - + // --------------------------------------------------------------------------- - + signal entryClicked (var entry, var index) - + // --------------------------------------------------------------------------- // Header. // --------------------------------------------------------------------------- - + header: MouseArea { height: { var height = headerButton.visible ? SipAddressesViewStyle.header.button.height : 0 @@ -61,46 +61,46 @@ ScrollableListView { return height } width: parent.width - + // Workaround to handle mouse. // Without it, the mouse can be given to items list when mouse is hover header. hoverEnabled: true cursorShape: Qt.ArrowCursor - + Column { anchors.fill: parent - + spacing: 0 - + // ----------------------------------------------------------------------- // Default contact. // ----------------------------------------------------------------------- - + Loader { id: defaultContact - + height: SipAddressesViewStyle.entry.height width: parent.width - + visible: sipAddressesView.interpretableSipAddress.length > 0 - + sourceComponent: Rectangle { anchors.fill: parent color: SipAddressesViewStyle.entry.color.normal - + RowLayout { anchors { fill: parent rightMargin: SipAddressesViewStyle.entry.rightMargin } spacing: 0 - + Contact { id: contact - + Layout.fillHeight: true Layout.fillWidth: true - + entry: ({ sipAddress: sipAddressesView.interpretableSipAddress, isOneToOne:true, @@ -108,28 +108,28 @@ ScrollableListView { securityLevel:1 }) } - + ActionBar { id: defaultContactActionBar - + iconSize: SipAddressesViewStyle.entry.iconSize - + Repeater { model: sipAddressesView.actions - + ActionButton { isCustom: true backgroundRadius: 90 colorSet: modelData.colorSet - visible: sipAddressesView.actions[index].visible - - onClicked: sipAddressesView.actions[index].handler({ - sipAddress: sipAddressesView.interpretableSipAddress - }) + visible: modelData.visible + + onClicked: modelData.handler({ + sipAddress: sipAddressesView.interpretableSipAddress + }) Icon{ visible: modelData.secure>0 && - (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler({ sipAddress : sipAddressesView.interpretableSipAddress}) : true) + (modelData.secureIconVisibleHandler ? modelData.secureIconVisibleHandler({ sipAddress : sipAddressesView.interpretableSipAddress}) : true) icon: 'secure_on' iconSize:15 anchors.right:parent.right @@ -142,155 +142,155 @@ ScrollableListView { } } } - + // ----------------------------------------------------------------------- // Header button. // ----------------------------------------------------------------------- - + MouseArea { id: headerButton - + height: SipAddressesViewStyle.header.button.height width: parent.width - + visible: sipAddressesView.showHeader && !!sipAddressesView.headerButtonAction - + onClicked: sipAddressesView.headerButtonAction(sipAddressesView.interpretableSipAddress) - + Rectangle { anchors.fill: parent color: parent.pressed ? SipAddressesViewStyle.header.color.pressed : SipAddressesViewStyle.header.color.normal - + Text { anchors { left: parent.left leftMargin: SipAddressesViewStyle.header.leftMargin verticalCenter: parent.verticalCenter } - + font { bold: true pointSize: SipAddressesViewStyle.header.text.pointSize } - + color: headerButton.pressed ? SipAddressesViewStyle.header.text.color.pressed : SipAddressesViewStyle.header.text.color.normal text: sipAddressesView.headerButtonDescription } - + Icon { anchors { right: parent.right rightMargin: SipAddressesViewStyle.header.rightMargin verticalCenter: parent.verticalCenter } - + icon: sipAddressesView.headerButtonIcon iconSize: SipAddressesViewStyle.header.iconSize overwriteColor: sipAddressesView.headerButtonOverwriteColor - + visible: icon.length > 0 } } } } } - + // --------------------------------------------------------------------------- // Entries. // --------------------------------------------------------------------------- - + delegate: Rectangle { id: sipAddressEntry property var entry: modelData - + color: SipAddressesViewStyle.entry.color.normal height: SipAddressesViewStyle.entry.height width: parent ? parent.width : 0 - + Rectangle { id: indicator - + anchors.left: parent.left color: 'transparent' height: parent.height width: SipAddressesViewStyle.entry.indicator.width } - + MouseArea { id: mouseArea - + anchors.fill: parent cursorShape: Qt.ArrowCursor - + RowLayout { anchors { fill: parent rightMargin: SipAddressesViewStyle.entry.rightMargin } spacing: 0 - + // --------------------------------------------------------------------- // Contact or address info. // --------------------------------------------------------------------- - + Contact { Layout.fillHeight: true Layout.fillWidth: true showContactAddress: sipAddressesView.showContactAddress - + entry: modelData - + MouseArea { anchors.fill: parent onClicked: sipAddressesView.entryClicked(modelData, index) } } - - + + // --------------------------------------------------------------------- // Actions // --------------------------------------------------------------------- - + ActionBar { iconSize: SipAddressesViewStyle.entry.iconSize - + Switch{ anchors.verticalCenter: parent.verticalCenter width:50 //Layout.preferredWidth: 50 indicatorStyle: SwitchStyle.aux - + visible: sipAddressesView.showSwitch - + enabled:true checked: false onClicked: { //checked = !checked switchHandler(!checked, index) } - + } - + Repeater { model: sipAddressesView.actions - + ActionButton { isCustom: true backgroundRadius: 90 colorSet: modelData.colorSet tooltipText:modelData.tooltipText?modelData.tooltipText:'' - visible: sipAddressesView.actions[index].visible + visible: modelData.visible onClicked: { - sipAddressesView.actions[index].handler(sipAddressEntry.entry) + modelData.handler(sipAddressEntry.entry) } Icon{ visible: modelData.secure>0 && - (sipAddressesView.actions[index].secureIconVisibleHandler ? sipAddressesView.actions[index].secureIconVisibleHandler(sipAddressEntry.entry) : true) + (modelData.secureIconVisibleHandler ? modelData.secureIconVisibleHandler(sipAddressEntry.entry) : true) icon: 'secure_on' iconSize:15 anchors.right:parent.right @@ -299,10 +299,11 @@ ScrollableListView { } } } + } } } - + // Separator. Rectangle { color: SipAddressesViewStyle.entry.separator.color @@ -310,17 +311,17 @@ ScrollableListView { width: parent.width visible: sipAddressesView.showSeparator } - + // ------------------------------------------------------------------------- - + states: State { when: mouseArea.containsMouse && sipAddressesView.isSelectable - + PropertyChanges { color: SipAddressesViewStyle.entry.color.hovered target: sipAddressEntry } - + PropertyChanges { color: SipAddressesViewStyle.entry.indicator.color target: indicator diff --git a/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml b/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml index d2c50c82e..72011e6d2 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/InfoChatRoom.qml @@ -90,7 +90,7 @@ DialogPlus { secure: chatRoomModel.haveEncryption, visible: true, secureIconVisibleHandler : function(entry) { - return chatRoomModel.haveEncryption && UtilsCpp.hasCapability(entry.sipAddress, LinphoneEnums.FriendCapabilityLimeX3Dh); + return entry.sipAddress && chatRoomModel && chatRoomModel.haveEncryption && UtilsCpp.hasCapability(entry.sipAddress, LinphoneEnums.FriendCapabilityLimeX3Dh); }, handler: function (entry) { selectedParticipants.addAddress(entry.sipAddress)