From 5d42559f836f3ba2b777ab508f0b56b21701483e Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 29 Jan 2025 10:28:49 +0100 Subject: [PATCH] fix ensure visible contact edition fix #LINQT-1569 dialer ui in call fix address artifact due to full default address addition in address list --- Linphone/core/friend/FriendCore.cpp | 25 ++++++++++------- Linphone/model/friend/FriendModel.cpp | 8 ++++++ Linphone/model/friend/FriendModel.hpp | 2 ++ Linphone/view/Control/Display/Sticker.qml | 2 ++ Linphone/view/Control/Input/NumericPad.qml | 3 ++- Linphone/view/Control/Input/SearchBar.qml | 2 +- .../view/Page/Form/Contact/ContactEdition.qml | 27 +++++++++++++++---- Linphone/view/Page/Main/Call/CallPage.qml | 8 +++--- .../view/Page/Main/Contact/ContactPage.qml | 2 +- .../view/Page/Window/Call/CallsWindow.qml | 25 +++++------------ 10 files changed, 65 insertions(+), 39 deletions(-) diff --git a/Linphone/core/friend/FriendCore.cpp b/Linphone/core/friend/FriendCore.cpp index 1bad6dc9..44fd39bb 100644 --- a/Linphone/core/friend/FriendCore.cpp +++ b/Linphone/core/friend/FriendCore.cpp @@ -409,12 +409,14 @@ void FriendCore::appendAddress(const QString &addr) { if (addr.isEmpty()) return; mCoreModelConnection->invokeToModel([this, addr]() { auto linphoneAddr = ToolModel::interpretUrl(addr); - QString interpretedAddress = linphoneAddr ? Utils::coreStringToAppString(linphoneAddr->asString()) : ""; - mCoreModelConnection->invokeToCore([this, interpretedAddress]() { + QString interpretedFullAddress = linphoneAddr ? Utils::coreStringToAppString(linphoneAddr->asString()) : ""; + QString interpretedAddress = linphoneAddr ? Utils::coreStringToAppString(linphoneAddr->asStringUriOnly()) : ""; + mCoreModelConnection->invokeToCore([this, interpretedAddress, interpretedFullAddress]() { if (interpretedAddress.isEmpty()) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false); else { mAddressList.append(Utils::createFriendAddressVariant(_addressLabel, interpretedAddress)); - if (mDefaultFullAddress.isEmpty()) mDefaultFullAddress = interpretedAddress; + if (mDefaultFullAddress.isEmpty()) mDefaultFullAddress = interpretedFullAddress; + if (mDefaultAddress.isEmpty()) mDefaultAddress = interpretedAddress; emit addressChanged(); setIsSaved(false); } @@ -467,9 +469,6 @@ QString FriendCore::getDefaultFullAddress() const { } void FriendCore::setDefaultFullAddress(const QString &address) { - auto it = std::find_if(mAddressList.begin(), mAddressList.end(), - [address](const QVariant &a) { return a.toMap()["address"].toString() == address; }); - if (it == mAddressList.end()) appendAddress(address); if (mDefaultFullAddress != address) { mDefaultFullAddress = address; emit defaultFullAddressChanged(); @@ -596,6 +595,8 @@ void FriendCore::writeFromModel(const std::shared_ptr &model) { Utils::createFriendAddressVariant(_addressLabel, Utils::coreStringToAppString(addr->asStringUriOnly()))); } mAddressList = addresses; + mDefaultAddress = model->getDefaultAddress(); + mDefaultFullAddress = model->getDefaultFullAddress(); QList phones; for (auto &number : model->getPhoneNumbers()) { @@ -637,8 +638,10 @@ void FriendCore::save() { // Save Values to model thisCopy->writeIntoModel(mFriendModel); thisCopy->deleteLater(); mVCardString = mFriendModel->getVCardAsString(); - mFriendModelConnection->invokeToCore([this]() { emit saved(); }); - setIsSaved(true); + mFriendModelConnection->invokeToCore([this]() { + setIsSaved(true); + emit saved(); + }); }); } else { mCoreModelConnection->invokeToModel([this, thisCopy]() { @@ -660,8 +663,11 @@ void FriendCore::save() { // Save Values to model thisCopy->writeIntoModel(mFriendModel); thisCopy->deleteLater(); mVCardString = mFriendModel->getVCardAsString(); + mCoreModelConnection->invokeToCore([this] { + setIsSaved(true); + emit saved(); + }); }); - emit saved(); }); } else { auto contact = core->createFriend(); @@ -688,6 +694,7 @@ void FriendCore::save() { // Save Values to model mCoreModelConnection->invokeToCore([this, created]() { if (created) setSelf(mCoreModelConnection->mCore); setIsSaved(created); + if (created) emit saved(); }); }); }); diff --git a/Linphone/model/friend/FriendModel.cpp b/Linphone/model/friend/FriendModel.cpp index a35bc1b5..61b04642 100644 --- a/Linphone/model/friend/FriendModel.cpp +++ b/Linphone/model/friend/FriendModel.cpp @@ -169,6 +169,14 @@ void FriendModel::clearAddresses() { emit addressesChanged(); } +QString FriendModel::getDefaultAddress() const { + return Utils::coreStringToAppString(mMonitor->getAddress()->asStringUriOnly()); +} + +QString FriendModel::getDefaultFullAddress() const { + return Utils::coreStringToAppString(mMonitor->getAddress()->asString()); +} + QString FriendModel::getFullName() const { if (mFullName.isEmpty()) return getGivenName() + " " + getFamilyName(); else return mFullName; diff --git a/Linphone/model/friend/FriendModel.hpp b/Linphone/model/friend/FriendModel.hpp index c667bf06..8e141090 100644 --- a/Linphone/model/friend/FriendModel.hpp +++ b/Linphone/model/friend/FriendModel.hpp @@ -51,6 +51,8 @@ public: QString getFamilyName() const; QString getOrganization() const; QString getJob() const; + QString getDefaultAddress() const; + QString getDefaultFullAddress() const; bool getStarred() const; std::shared_ptr getFriend() const; QString getPictureUri() const; diff --git a/Linphone/view/Control/Display/Sticker.qml b/Linphone/view/Control/Display/Sticker.qml index 30f4ac9d..604fb9b7 100644 --- a/Linphone/view/Control/Display/Sticker.qml +++ b/Linphone/view/Control/Display/Sticker.qml @@ -164,6 +164,8 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.top: centerItem.bottom anchors.topMargin: 21 * DefaultStyle.dp + anchors.left: parent.left + anchors.right: parent.right Text { Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter diff --git a/Linphone/view/Control/Input/NumericPad.qml b/Linphone/view/Control/Input/NumericPad.qml index 564c2133..aeea1ee4 100644 --- a/Linphone/view/Control/Input/NumericPad.qml +++ b/Linphone/view/Control/Input/NumericPad.qml @@ -8,6 +8,8 @@ import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle FocusScope{ id: mainItem + width: numPadGrid.width + height: numPadGrid.height property var currentCall property bool lastRowVisible: true @@ -87,7 +89,6 @@ FocusScope{ Layout.GridLayout { id: numPadGrid - anchors.fill: parent columns: 3 columnSpacing: 40 * DefaultStyle.dp rowSpacing: 10 * DefaultStyle.dp diff --git a/Linphone/view/Control/Input/SearchBar.qml b/Linphone/view/Control/Input/SearchBar.qml index 8c512729..938c3e2f 100644 --- a/Linphone/view/Control/Input/SearchBar.qml +++ b/Linphone/view/Control/Input/SearchBar.qml @@ -14,7 +14,7 @@ FocusScope { property string text: textField.searchText property bool magnifierVisible: true property var validator: RegularExpressionValidator{} - property Control.Popup numericPadPopup + property var numericPadPopup property alias numericPadButton: dialerButton readonly property bool hasActiveFocus: textField.activeFocus property alias color: backgroundItem.color diff --git a/Linphone/view/Page/Form/Contact/ContactEdition.qml b/Linphone/view/Page/Form/Contact/ContactEdition.qml index a356dc6e..8b598f58 100644 --- a/Linphone/view/Page/Form/Contact/ContactEdition.qml +++ b/Linphone/view/Page/Form/Contact/ContactEdition.qml @@ -159,11 +159,23 @@ MainRightPanel { contentWidth: 421 * DefaultStyle.dp contentY: 0 + signal ensureVisibleRequested(Item item) + function ensureVisible(r) { if (contentY >= r.y) contentY = r.y; else if (contentY+height <= r.y+r.height) - contentY = r.y+r.height-height; + contentY = r.y + r.height - height; + } + + // Hack to ensure the empty textfield is really visible, because + // its y changes too late after the editingFinished is emitted + function connectOnce(sig, slot) { + var f = function() { + slot.apply(this, arguments) + sig.disconnect(f) + } + sig.connect(f) } ScrollBar.vertical: Control.ScrollBar { @@ -295,9 +307,12 @@ MainRightPanel { } } FormItemLayout { + id: newAddressSipTextField label: qsTr("Adresse SIP") Layout.fillWidth: true - // onYChanged: editionLayout.ensureVisible(this) + onYChanged: { + editionLayout.ensureVisibleRequested(newAddressSipTextField) + } contentItem: TextField { id: newAddressTextField backgroundColor: DefaultStyle.grey_0 @@ -319,7 +334,7 @@ MainRightPanel { onEditingFinished: { if (text.length > 0) mainItem.contact.core.appendAddress(text) newAddressTextField.clear() - editionLayout.ensureVisible(this) + editionLayout.connectOnce(editionLayout.ensureVisibleRequested, editionLayout.ensureVisible) } } } @@ -381,7 +396,9 @@ MainRightPanel { id: phoneNumberInput Layout.fillWidth: true label: qsTr("Phone") - // onYChanged: editionLayout.ensureVisible(this) + onYChanged: { + editionLayout.ensureVisibleRequested(phoneNumberInput) + } contentItem: TextField { id: phoneNumberInputTextField backgroundColor: DefaultStyle.grey_0 @@ -403,7 +420,7 @@ MainRightPanel { onEditingFinished: { if (text.length != 0) mainItem.contact.core.appendPhoneNumber(phoneNumberInput.label, text) phoneNumberInputTextField.clear() - editionLayout.ensureVisible(this) + editionLayout.connectOnce(editionLayout.ensureVisibleRequested, editionLayout.ensureVisible) } } } diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml index e2a55b7d..27734be0 100644 --- a/Linphone/view/Page/Main/Call/CallPage.qml +++ b/Linphone/view/Page/Main/Call/CallPage.qml @@ -185,7 +185,7 @@ AbstractMainPage { placeholderText: qsTr("Rechercher un appel") visible: historyListView.count !== 0 || text.length !== 0 focus: true - KeyNavigation.up: titleLoader + KeyNavigation.up: newCallButton KeyNavigation.down: historyListView Binding { target: mainItem @@ -524,7 +524,7 @@ AbstractMainPage { KeyNavigation.left: groupCallButton onClicked: { listStackView.pop() - titleLoader.item.forceActiveFocus() + listStackView.currentItem?.forceActiveFocus() } } ColumnLayout { @@ -660,8 +660,8 @@ AbstractMainPage { anchors.fill: parent IconLabelButton { Layout.fillWidth: true - property bool isLdap: contactDetail.contact?.core?.isLdap - property bool isCardDAV: contactDetail.contact?.core?.isCardDAV + property bool isLdap: contactDetail.contact?.core?.isLdap || false + property bool isCardDAV: contactDetail.contact?.core?.isCardDAV || false text: contactDetail.contact ? qsTr("Voir le contact") : qsTr("Ajouter aux contacts") icon.source: AppIcons.plusCircle icon.width: 32 * DefaultStyle.dp diff --git a/Linphone/view/Page/Main/Contact/ContactPage.qml b/Linphone/view/Page/Main/Contact/ContactPage.qml index 27eeec8d..62a5936c 100644 --- a/Linphone/view/Page/Main/Contact/ContactPage.qml +++ b/Linphone/view/Page/Main/Contact/ContactPage.qml @@ -630,7 +630,7 @@ AbstractMainPage { Item{Layout.fillWidth: true} EffectImage { visible: listViewModelData.securityLevel === LinphoneEnums.SecurityLevel.EndToEndEncryptedAndVerified - source: AppIcons.trusted + imageSource: AppIcons.trusted Layout.preferredWidth: 22 * DefaultStyle.dp Layout.preferredHeight: 22 * DefaultStyle.dp } diff --git a/Linphone/view/Page/Window/Call/CallsWindow.qml b/Linphone/view/Page/Window/Call/CallsWindow.qml index f8344a8d..23d13d77 100644 --- a/Linphone/view/Page/Window/Call/CallsWindow.qml +++ b/Linphone/view/Page/Window/Call/CallsWindow.qml @@ -682,12 +682,8 @@ AbstractWindow { rightPanel.visible = false event.accepted = true } - Item { - Layout.fillWidth: true - Layout.fillHeight: true - } + Item{Layout.fillHeight: true} SearchBar { - id: dialerTextInput Layout.fillWidth: true Layout.leftMargin: 10 * DefaultStyle.dp Layout.rightMargin: 10 * DefaultStyle.dp @@ -695,24 +691,17 @@ AbstractWindow { color: DefaultStyle.grey_0 borderColor: DefaultStyle.grey_200 placeholderText: "" - numericPadPopup: numPadPopup + numericPadPopup: numPad numericPadButton.visible: false enabled: false } - - NumericPadPopup { - id: numPadPopup - width: parent.width - parent: numericPadContainer - closeButtonVisible: false - roundedBottom: true - visible: dialerPanelContent.visible + NumericPad { + id: numPad + Layout.alignment: Qt.AlignHCenter currentCall: callsModel.currentCall lastRowVisible: false - leftPadding: 40 * DefaultStyle.dp - rightPadding: 40 * DefaultStyle.dp - topPadding: 41 * DefaultStyle.dp - bottomPadding: 18 * DefaultStyle.dp + Layout.topMargin: 41 * DefaultStyle.dp + Layout.bottomMargin: 18 * DefaultStyle.dp onLaunchCall: { UtilsCpp.createCall(dialerTextInput.text) }