From cddaa90dcb61d9b80155e1701a165441273afdfa Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Mon, 22 Jul 2024 12:06:50 +0200 Subject: [PATCH] fix ui contact edition fix new address contact edition fix history filter fix auto change end date meeting creation fix contact with phone number only fix windows warning --- .../core/call-history/CallHistoryProxy.cpp | 2 +- Linphone/core/friend/FriendCore.cpp | 14 +- Linphone/view/Item/Contact/ContactEdition.qml | 237 ++++++++++-------- Linphone/view/Item/Meeting/MeetingSetUp.qml | 5 +- Linphone/view/Item/ScrollBar.qml | 2 +- 5 files changed, 152 insertions(+), 108 deletions(-) diff --git a/Linphone/core/call-history/CallHistoryProxy.cpp b/Linphone/core/call-history/CallHistoryProxy.cpp index 838309c92..1e5c14d20 100644 --- a/Linphone/core/call-history/CallHistoryProxy.cpp +++ b/Linphone/core/call-history/CallHistoryProxy.cpp @@ -73,7 +73,7 @@ bool CallHistoryProxy::filterAcceptsRow(int sourceRow, const QModelIndex &source QRegularExpression::CaseInsensitiveOption | QRegularExpression::UseUnicodePropertiesOption); auto callLog = qobject_cast(sourceModel())->getAt(sourceRow); - show = callLog->mRemoteAddress.contains(search); + show = callLog->mRemoteAddress.contains(search) || callLog->mDisplayName.contains(search); } return show; diff --git a/Linphone/core/friend/FriendCore.cpp b/Linphone/core/friend/FriendCore.cpp index 79488843d..d29a6731c 100644 --- a/Linphone/core/friend/FriendCore.cpp +++ b/Linphone/core/friend/FriendCore.cpp @@ -373,9 +373,13 @@ void FriendCore::removeAddress(int index) { void FriendCore::appendAddress(const QString &addr) { if (addr.isEmpty()) return; - mAddressList.append(createFriendAddressVariant(addressLabel, addr)); - if (mDefaultAddress.isEmpty()) mDefaultAddress = addr; - emit addressChanged(); + auto linAddr = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(addr)); + if (!linAddr) Utils::showInformationPopup(tr("Erreur"), tr("Adresse invalide"), false); + else { + mAddressList.append(createFriendAddressVariant(addressLabel, addr)); + if (mDefaultAddress.isEmpty()) mDefaultAddress = addr; + emit addressChanged(); + } } void FriendCore::resetAddresses(QList newList) { @@ -482,9 +486,9 @@ void FriendCore::writeIntoModel(std::shared_ptr model) const { std::list> addresses; for (auto &addr : mAddressList) { auto friendAddress = addr.toMap(); - auto num = + auto address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(friendAddress["address"].toString())); - addresses.push_back(num); + addresses.push_back(address); } model->resetAddresses(addresses); diff --git a/Linphone/view/Item/Contact/ContactEdition.qml b/Linphone/view/Item/Contact/ContactEdition.qml index 846884a4f..6f278d3c5 100644 --- a/Linphone/view/Item/Contact/ContactEdition.qml +++ b/Linphone/view/Item/Contact/ContactEdition.qml @@ -65,9 +65,10 @@ RightPanelLayout { ] content: ColumnLayout { - anchors.centerIn: parent - // anchors.leftMargin: 103 * DefaultStyle.dp + anchors.fill: parent + spacing: 63 * DefaultStyle.dp ColumnLayout { + spacing: 8 * DefaultStyle.dp Layout.alignment: Qt.AlignHCenter Layout.topMargin: 69 * DefaultStyle.dp Avatar { @@ -118,58 +119,96 @@ RightPanelLayout { } } RowLayout { - Layout.alignment: Qt.AlignHCenter Layout.fillHeight: true Layout.fillWidth: true - spacing: 100 * DefaultStyle.dp + Layout.alignment: Qt.AlignHCenter Layout.topMargin: 50 * DefaultStyle.dp Layout.bottomMargin: 50 * DefaultStyle.dp - ColumnLayout { - spacing: 20 * DefaultStyle.dp - FormItemLayout { - id: givenName - enableErrorText: true - label: qsTr("Prénom") - contentItem: TextField { - id: givenNameEdit - initialText: contact.core.givenName - onTextEdited: contact.core.givenName = text - backgroundColor: DefaultStyle.grey_0 - backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200 - } - } - FormItemLayout { - label: qsTr("Nom") - contentItem: TextField { - initialText: contact.core.familyName - onTextEdited: contact.core.familyName = text - backgroundColor: DefaultStyle.grey_0 - } - } - FormItemLayout { - label: qsTr("Entreprise") - contentItem: TextField { - initialText: contact.core.organization - onTextEdited: contact.core.organization = text - backgroundColor: DefaultStyle.grey_0 - } - } - FormItemLayout { - label: qsTr("Fonction") - contentItem: TextField { - initialText: contact.core.job - onTextEdited: contact.core.job = text - backgroundColor: DefaultStyle.grey_0 - } - } - Item{Layout.fillHeight: true} - } - Control.ScrollView { + spacing: 100 * DefaultStyle.dp + Flickable { + Layout.preferredWidth: contentWidth Layout.fillHeight: true + Layout.leftMargin: 100 * DefaultStyle.dp + contentWidth: content.implicitWidth contentHeight: content.height + clip: true + + ColumnLayout { + spacing: 20 * DefaultStyle.dp + anchors.fill: parent + FormItemLayout { + id: givenName + enableErrorText: true + label: qsTr("Prénom") + contentItem: TextField { + id: givenNameEdit + initialText: contact.core.givenName + onTextEdited: contact.core.givenName = text + backgroundColor: DefaultStyle.grey_0 + backgroundBorderColor: givenName.errorTextItem.opacity != 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200 + } + } + FormItemLayout { + label: qsTr("Nom") + contentItem: TextField { + initialText: contact.core.familyName + onTextEdited: contact.core.familyName = text + backgroundColor: DefaultStyle.grey_0 + } + } + FormItemLayout { + label: qsTr("Entreprise") + contentItem: TextField { + initialText: contact.core.organization + onTextEdited: contact.core.organization = text + backgroundColor: DefaultStyle.grey_0 + } + } + FormItemLayout { + label: qsTr("Fonction") + contentItem: TextField { + initialText: contact.core.job + onTextEdited: contact.core.job = text + backgroundColor: DefaultStyle.grey_0 + } + } + Item{Layout.fillHeight: true} + } + } + Flickable { + id: addressesFlickable + Layout.preferredWidth: contentWidth + Layout.fillHeight: true + Layout.rightMargin: 76 * DefaultStyle.dp + contentWidth: content.implicitWidth + contentHeight: content.implicitHeight + clip: true + + flickableDirection: Flickable.VerticalFlick + function ensureVisible(r) + { + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height+content.spacing) + contentY = r.y+r.height-height; + } + + Control.ScrollBar.vertical: Control.ScrollBar{ + id: scrollbar + active: true + interactive: true + policy: Control.ScrollBar.AlwaysOff + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.leftMargin: 15 * DefaultStyle.dp + } + Control.ScrollBar.horizontal: Control.ScrollBar{ + visible: false + } ColumnLayout { id: content - anchors.rightMargin: 10 * DefaultStyle.dp + anchors.fill: parent spacing: 20 * DefaultStyle.dp Repeater { id: addressesList @@ -177,41 +216,45 @@ RightPanelLayout { model: mainItem.contact && mainItem.contact.core.addresses || [] } delegate: FormItemLayout { - label: modelData.label - contentItem: RowLayout { - TextField { - onTextEdited: { - if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text) - } - property string _initialText: modelData.address - initialText: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_initialText) : _initialText - backgroundColor: DefaultStyle.grey_0 - Layout.preferredWidth: width - Layout.preferredHeight: height - } - Button { - Layout.preferredWidth: 24 * DefaultStyle.dp - Layout.preferredHeight: 24 * DefaultStyle.dp - Layout.alignment: Qt.AlignVCenter - background: Item{} - icon.source: AppIcons.closeX - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - icon.width: 24 * DefaultStyle.dp - icon.height: 24 * DefaultStyle.dp - onClicked: mainItem.contact.core.removeAddress(index) + label: modelData.label + contentItem: RowLayout { + spacing: 10 * DefaultStyle.dp + TextField { + onTextEdited: { + if (text.length != 0) mainItem.contact.core.setAddressAt(index, qsTr("Adresse SIP"), text) } + property string _initialText: modelData.address + initialText: SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(_initialText) : _initialText + backgroundColor: DefaultStyle.grey_0 + Layout.preferredWidth: width + Layout.preferredHeight: height + } + Button { + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + Layout.alignment: Qt.AlignVCenter + background: Item{} + icon.source: AppIcons.closeX + width: 24 * DefaultStyle.dp + height: 24 * DefaultStyle.dp + icon.width: 24 * DefaultStyle.dp + icon.height: 24 * DefaultStyle.dp + onClicked: mainItem.contact.core.removeAddress(index) } } + } } RowLayout { + onYChanged: addressesFlickable.ensureVisible(this) + spacing: 10 * DefaultStyle.dp FormItemLayout { label: qsTr("Adresse SIP") contentItem: TextField { backgroundColor: DefaultStyle.grey_0 + Component.onCompleted: text = "sip:" onEditingFinished: { if (text.length != 0) mainItem.contact.core.appendAddress(text) - text = "" + text = "sip:" } } } @@ -222,34 +265,41 @@ RightPanelLayout { } Repeater { // phone numbers + id: phoneNumberList model: VariantList { model: mainItem.contact && mainItem.contact.core.phoneNumbers || [] } - delegate: RowLayout { - FormItemLayout { - label: modelData.label - contentItem: TextField { + delegate: FormItemLayout { + label: modelData.label + contentItem: RowLayout { + spacing: 10 * DefaultStyle.dp + TextField { initialText: modelData.address onTextEdited: { if (text.length != 0) mainItem.contact.core.setPhoneNumberAt(index, qsTr("Téléphone"), text) } backgroundColor: DefaultStyle.grey_0 + Layout.preferredWidth: width + Layout.preferredHeight: height + } + Button { + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + Layout.alignment: Qt.AlignVCenter + background: Item{} + icon.source: AppIcons.closeX + width: 24 * DefaultStyle.dp + height: 24 * DefaultStyle.dp + icon.width: 24 * DefaultStyle.dp + icon.height: 24 * DefaultStyle.dp + onClicked: mainItem.contact.core.removePhoneNumber(index) } - } - Button { - Layout.preferredWidth: 24 * DefaultStyle.dp - Layout.preferredHeight: 24 * DefaultStyle.dp - background: Item{} - icon.source: AppIcons.closeX - width: 24 * DefaultStyle.dp - height: 24 * DefaultStyle.dp - icon.width: 24 * DefaultStyle.dp - icon.height: 24 * DefaultStyle.dp - onClicked: mainItem.contact.core.removePhoneNumber(index) } } } RowLayout { + onYChanged: addressesFlickable.ensureVisible(this) + spacing: 10 * DefaultStyle.dp FormItemLayout { id: phoneNumberInput label: qsTr("Phone") @@ -274,19 +324,6 @@ RightPanelLayout { } Item{Layout.fillHeight: true} } - Control.ScrollBar.vertical: Control.ScrollBar{ - id: scrollbar - active: true - interactive: true - policy: Control.ScrollBar.AsNeeded - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.leftMargin: 15 * DefaultStyle.dp - } - Control.ScrollBar.horizontal: Control.ScrollBar{ - visible: false - } } } @@ -301,9 +338,9 @@ RightPanelLayout { topPadding: 11 * DefaultStyle.dp bottomPadding: 11 * DefaultStyle.dp onClicked: { - if (givenNameEdit.text.length === 0 || addressesList.count === 0) { + if (givenNameEdit.text.length === 0 || (addressesList.count === 0 && phoneNumberList.count === 0)) { if (givenNameEdit.text.length === 0) givenName.errorMessage = qsTr("Veuillez saisir un prénom") - if (addressesList.count === 0) addressesErrorText.text = qsTr("Veuillez saisir une adresse ou un numéro de téléphone") + if (addressesList.count === 0 && phoneNumberList.count === 0) addressesErrorText.text = qsTr("Veuillez saisir une adresse ou un numéro de téléphone") return } mainItem.contact.core.save() diff --git a/Linphone/view/Item/Meeting/MeetingSetUp.qml b/Linphone/view/Item/Meeting/MeetingSetUp.qml index aed8ead2c..040e096cf 100644 --- a/Linphone/view/Item/Meeting/MeetingSetUp.qml +++ b/Linphone/view/Item/Meeting/MeetingSetUp.qml @@ -147,7 +147,8 @@ ColumnLayout { if (!selectedDate || selectedDate == mainItem.conferenceInfoGui.core.dateTime) return mainItem.conferenceInfoGui.core.dateTime = UtilsCpp.createDateTime(selectedDate, allDaySwitch.isAllDay ? 0 : startHour.selectedHour, allDaySwitch.isAllDay ? 0 : startHour.selectedMin) if (isCreation) { - if (allDaySwitch.position === 0) endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDate, 3600) + startHour.selectedDateTime = UtilsCpp.createDateTime(selectedDate, startHour.selectedHour, startHour.selectedMin) + if (allDaySwitch.position === 0) endDate.calendar.selectedDate = UtilsCpp.addSecs(startHour.selectedDateTime, 3600) else endDate.calendar.selectedDate = UtilsCpp.createDateTime(selectedDate, 23, 59) } } @@ -164,10 +165,12 @@ ColumnLayout { contentText.font.weight: (isCreation ? 700 : 400) * DefaultStyle.dp onSelectedHourChanged: { mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin) + endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600) endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//Qt.formatDateTime(UtilsCpp.createDateTime(new Date(), selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin), "hh:mm") } onSelectedMinChanged: { mainItem.conferenceInfoGui.core.dateTime = selectedDateTime//UtilsCpp.createDateTime(startDate.selectedDate, selectedHour, selectedMin) + endDate.calendar.selectedDate = UtilsCpp.addSecs(selectedDateTime, 3600) endHour.selectedDateTime = UtilsCpp.addSecs(selectedDateTime, 3600)//UtilsCpp.createDateTime(selectedDateTime, selectedHour == 23 ? 23 : selectedHour + 1, selectedHour == 23 ? 59 : selectedMin) } } diff --git a/Linphone/view/Item/ScrollBar.qml b/Linphone/view/Item/ScrollBar.qml index 435b38fd2..a233b1b92 100644 --- a/Linphone/view/Item/ScrollBar.qml +++ b/Linphone/view/Item/ScrollBar.qml @@ -1,5 +1,5 @@ import QtQuick 2.7 -import QtQuick.Controls 2.2 as Control +import QtQuick.Controls.Basic 2.2 as Control import QtQuick.Effects import QtQuick.Layouts import Linphone