mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-22 06:08:07 +00:00
- Add a custom way to display addresses.
- Fix layouts when texts are the same in contact descriptions.
This commit is contained in:
parent
83ec9407d5
commit
cc9802311b
18 changed files with 75 additions and 25 deletions
|
|
@ -263,7 +263,7 @@ void VcardModel::setCountry (const QString &country) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QVariantList VcardModel::getSipAddresses () const {
|
||||
QVariantList VcardModel::getSipAddresses () const {
|
||||
QVariantList list;
|
||||
if(mVcard->getVcard()){
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
|
|
@ -282,6 +282,25 @@ QVariantList VcardModel::getSipAddresses () const {
|
|||
return list;
|
||||
}
|
||||
|
||||
QVariantList VcardModel::getSipUsernames () const {
|
||||
QVariantList list;
|
||||
if(mVcard->getVcard()){
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
for (const auto &address : mVcard->getVcard()->getImpp()) {
|
||||
string value = address->getValue();
|
||||
shared_ptr<linphone::Address> linphoneAddress = core->createAddress(value);
|
||||
|
||||
if (linphoneAddress)
|
||||
list << Utils::coreStringToAppString(linphoneAddress->getUsername());
|
||||
else
|
||||
qWarning() << QStringLiteral("Unable to parse sip address: `%1`")
|
||||
.arg(QString::fromStdString(value));
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<linphone::Address>> VcardModel::getLinphoneSipAddresses () const {
|
||||
QList<std::shared_ptr<linphone::Address>> list;
|
||||
if(mVcard->getVcard()){
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class VcardModel : public QObject {
|
|||
Q_PROPERTY(QVariantMap address READ getAddress NOTIFY vcardUpdated);
|
||||
//Q_PROPERTY(QString sipAddress
|
||||
Q_PROPERTY(QVariantList sipAddresses READ getSipAddresses NOTIFY vcardUpdated);
|
||||
Q_PROPERTY(QVariantList sipUsernames READ getSipUsernames NOTIFY vcardUpdated);
|
||||
Q_PROPERTY(QVariantList companies READ getCompanies NOTIFY vcardUpdated);
|
||||
Q_PROPERTY(QVariantList emails READ getEmails NOTIFY vcardUpdated);
|
||||
Q_PROPERTY(QVariantList urls READ getUrls NOTIFY vcardUpdated);
|
||||
|
|
@ -71,6 +72,7 @@ public:
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
QVariantList getSipAddresses () const;
|
||||
QVariantList getSipUsernames () const;
|
||||
QList<std::shared_ptr<linphone::Address>> getLinphoneSipAddresses () const;
|
||||
QVariantMap getAddress () const;
|
||||
QVariantList getEmails () const;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ QString ParticipantListModel::addressesToString()const{
|
|||
for(auto item : mList){
|
||||
auto participant = item.objectCast<ParticipantModel>();
|
||||
if( participant->getParticipant())// is Participant. We test it because this participant is not accepted by chat room yet.
|
||||
txt << Utils::coreStringToAppString(participant->getParticipant()->getAddress()->asStringUriOnly());
|
||||
txt << Utils::toDisplayString(Utils::coreStringToAppString(participant->getParticipant()->getAddress()->asStringUriOnly()));
|
||||
}
|
||||
txt.removeFirst();// Remove me
|
||||
return txt.join(", ");
|
||||
|
|
|
|||
|
|
@ -133,6 +133,20 @@ QString Utils::toDateString(QDateTime date, const QString& format){
|
|||
return QLocale().toString(getOffsettedUTC(date), (!format.isEmpty() ? format : QLocale().dateFormat()) );
|
||||
}
|
||||
|
||||
// Return custom address to be displayed on UI.
|
||||
// In order to return only the username and to remove all domains from the GUI, you may just change the default mode.
|
||||
QString Utils::toDisplayString(const QString& str, SipDisplayMode displayMode){
|
||||
if(displayMode == SIP_DISPLAY_ALL) return str;
|
||||
std::shared_ptr<linphone::Address> addr = linphone::Factory::get()->createAddress(str.toStdString());
|
||||
QString displayString;
|
||||
if( addr && ( (displayMode & SIP_DISPLAY_USERNAME) == SIP_DISPLAY_USERNAME))
|
||||
displayString = Utils::coreStringToAppString(addr->getUsername());
|
||||
if(displayString.isEmpty())
|
||||
return str;
|
||||
else
|
||||
return displayString;
|
||||
}
|
||||
|
||||
QString Utils::getDisplayName(const QString& address){
|
||||
return getDisplayName(interpretUrl(address));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,13 @@ class Utils : public QObject{
|
|||
Q_OBJECT
|
||||
public:
|
||||
Utils(QObject * parent = nullptr) : QObject(parent){}
|
||||
|
||||
typedef enum{
|
||||
SIP_DISPLAY_USERNAME = 0,
|
||||
SIP_DISPLAY_ALL = -1
|
||||
}SipDisplayMode;
|
||||
Q_ENUM(SipDisplayMode)
|
||||
|
||||
// Qt interfaces
|
||||
Q_INVOKABLE static bool hasCapability(const QString& address, const LinphoneEnums::FriendCapability& capability);
|
||||
Q_INVOKABLE static QDateTime addMinutes(QDateTime date, const int& min);
|
||||
|
|
@ -62,6 +69,7 @@ public:
|
|||
Q_INVOKABLE static QString toDateTimeString(QDateTime date);
|
||||
Q_INVOKABLE static QString toTimeString(QDateTime date, const QString& format = "hh:mm:ss");
|
||||
Q_INVOKABLE static QString toDateString(QDateTime date, const QString& format = "");
|
||||
Q_INVOKABLE static QString toDisplayString(const QString& str, SipDisplayMode displayMode = SIP_DISPLAY_ALL);
|
||||
static void cleanDisplayNameCache(const QString& address = "");// if "", clean all cache
|
||||
Q_INVOKABLE static QString getDisplayName(const QString& address);
|
||||
Q_INVOKABLE static QString getInitials(const QString& username); // Support UTF32
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import QtQuick.Layouts 1.3
|
|||
import Common 1.0
|
||||
import Common.Styles 1.0
|
||||
|
||||
import UtilsCpp 1.0
|
||||
// =============================================================================
|
||||
|
||||
Controls.ItemDelegate {
|
||||
|
|
@ -64,7 +65,7 @@ Controls.ItemDelegate {
|
|||
pointSize: CommonItemDelegateStyle.contentItem.text.pointSize
|
||||
}
|
||||
|
||||
text: item.flattenedModel[container.textRole] || modelData
|
||||
text: UtilsCpp.toDisplayString(item.flattenedModel[container.textRole] || modelData)
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Item {
|
|||
spacing: AccountStatusStyle.horizontalSpacing
|
||||
|
||||
Item {
|
||||
Layout.alignment: Qt.AlignBottom | Qt.AlignLeft
|
||||
Layout.alignment: !subtitle.visible ? Qt.AlignVCenter | Qt.AlignLeft: Qt.AlignBottom | Qt.AlignLeft
|
||||
Layout.bottomMargin: AccountStatusStyle.presenceLevel.bottomMargin
|
||||
Layout.preferredHeight: AccountStatusStyle.presenceLevel.size
|
||||
Layout.preferredWidth: AccountStatusStyle.presenceLevel.size
|
||||
|
|
@ -70,7 +70,7 @@ Item {
|
|||
Text {
|
||||
id:username
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: accountStatus.noAccountConfigured ? Qt.AlignVCenter | Qt.AlignLeft: Qt.AlignBottom | Qt.AlignLeft
|
||||
Layout.alignment: !subtitle.visible ? Qt.AlignVCenter | Qt.AlignLeft: Qt.AlignBottom | Qt.AlignLeft
|
||||
color: AccountStatusStyle.username.colorModel.color
|
||||
elide: Text.ElideRight
|
||||
font.bold: true
|
||||
|
|
@ -104,13 +104,14 @@ Item {
|
|||
}//RowLayout
|
||||
|
||||
Text {
|
||||
id: subtitle
|
||||
Layout.preferredHeight:parent.height / 2
|
||||
Layout.preferredWidth:parent.width
|
||||
visible: !accountStatus.noAccountConfigured
|
||||
visible: !accountStatus.noAccountConfigured && text != username.text
|
||||
color: AccountStatusStyle.sipAddress.colorModel.color
|
||||
elide: Text.ElideRight
|
||||
font.pointSize: AccountStatusStyle.sipAddress.pointSize
|
||||
text: AccountSettingsModel.sipAddress
|
||||
text: UtilsCpp.toDisplayString(AccountSettingsModel.sipAddress)
|
||||
verticalAlignment: Text.AlignTop
|
||||
}
|
||||
}//ColumnLayout
|
||||
|
|
|
|||
|
|
@ -45,13 +45,16 @@ RowLayout {
|
|||
// The avatar is only visible for the first message of a incoming messages sequence.
|
||||
visible: index <= 0 ? true // 1. First message, so visible.
|
||||
: $chatEntry && !$chatEntry.isOutgoing && !mainRow.isTopGrouped || false
|
||||
|
||||
TooltipArea{
|
||||
delay:0
|
||||
text:avatar.username+'\n'+$chatEntry.fromSipAddress
|
||||
maxWidth: mainRow.width
|
||||
isClickable: true
|
||||
onClicked: {
|
||||
window.mainSearchBar.text = $chatEntry.fromSipAddress
|
||||
window.mainSearchBar.text = UtilsCpp.toDisplayString($chatEntry.fromSipAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,8 @@ Rectangle {
|
|||
? item.subject
|
||||
: item.username
|
||||
subtitleText: entry && item.showSubtitle
|
||||
? item.subtitle
|
||||
? UtilsCpp.toDisplayString(
|
||||
item.subtitle
|
||||
? item.subtitle
|
||||
: (entry.isOneToOne == undefined || entry.isOneToOne) && (entry.haveEncryption == undefined || !entry.haveEncryption)
|
||||
? item.organizer
|
||||
|
|
@ -132,6 +133,7 @@ Rectangle {
|
|||
: entry.participants
|
||||
? entry.participants.addressesToString
|
||||
: ''
|
||||
)
|
||||
: ''
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ Column {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: (parent.height-parent.topPadding-parent.bottomPadding)/parent.visibleChildren.length
|
||||
visible: subtitle.fullText != ''
|
||||
visible: subtitle.fullText != '' && subtitle.fullText != title.fullText
|
||||
TextEdit {
|
||||
id:subtitle
|
||||
property string fullText
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ Notification {
|
|||
property ChatRoomModel chatRoomModel : notification.timelineModel.getChatRoomModel()
|
||||
property var sipObserver: SipAddressesModel.getSipAddressObserver(notification.fullPeerAddress, notification.fullLocalAddress)
|
||||
subtitle: chatRoomModel.isOneToOne
|
||||
? SipAddressesModel.cleanSipAddress(notification.fullPeerAddress)
|
||||
? UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(notification.fullPeerAddress))
|
||||
: UtilsCpp.getDisplayName(notification.fullPeerAddress)
|
||||
entry: chatRoomModel ? chatRoomModel : sipObserver
|
||||
Component.onDestruction: sipObserver=null// Need to set it to null because of not calling destructor if not.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ Rectangle {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
height: CallStyle.header.contactDescription.height
|
||||
horizontalTextAlignment: Text.AlignHCenter
|
||||
subtitleText: SipAddressesModel.cleanSipAddress(call.peerAddress)
|
||||
subtitleText: UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(call.peerAddress))
|
||||
titleText: _sipAddressObserver ? UtilsCpp.getDisplayName(_sipAddressObserver.peerAddress) : ''
|
||||
width: contentWidth
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ Rectangle {
|
|||
width: parent.width
|
||||
|
||||
horizontalTextAlignment: Text.AlignHCenter
|
||||
subtitleText: SipAddressesModel.cleanSipAddress(parent.sipAddress)
|
||||
subtitleText: UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(parent.sipAddress))
|
||||
titleText: parent._sipAddressObserver ? UtilsCpp.getDisplayName(parent._sipAddressObserver.peerAddress) : ''
|
||||
}
|
||||
IncallAvatar {
|
||||
|
|
|
|||
|
|
@ -231,9 +231,9 @@ Rectangle {
|
|||
id: address
|
||||
Layout.fillWidth: true
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
visible: !conferenceModel && callModel && !callModel.isConference
|
||||
visible: !conferenceModel && callModel && !callModel.isConference && text != title.text
|
||||
text: !conferenceModel && callModel
|
||||
? SipAddressesModel.cleanSipAddress(callModel.peerAddress)
|
||||
? UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(callModel.peerAddress))
|
||||
: ''
|
||||
color: IncallStyle.title.colorModel.color
|
||||
font.pointSize: IncallStyle.title.addressPointSize
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ Rectangle {
|
|||
visible: !mainItem.conferenceInfoModel
|
||||
spacing: 10
|
||||
Text{
|
||||
id: displayName
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
text: mainItem._sipAddressObserver ? UtilsCpp.getDisplayName(mainItem._sipAddressObserver.peerAddress) : ''
|
||||
color: WaitingRoomStyle.callee.colorModel.color
|
||||
|
|
@ -218,12 +219,12 @@ Rectangle {
|
|||
}
|
||||
Text{
|
||||
Layout.fillWidth: true
|
||||
text: mainItem.callModel && SipAddressesModel.cleanSipAddress(mainItem.callModel.peerAddress)
|
||||
text: mainItem.callModel && UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(mainItem.callModel.peerAddress))
|
||||
color: WaitingRoomStyle.callee.colorModel.color
|
||||
font.pointSize: WaitingRoomStyle.callee.addressPointSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
visible: mainItem.callModel && !mainItem.conferenceInfoModel
|
||||
visible: mainItem.callModel && !mainItem.conferenceInfoModel && text != displayName.text
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ ColumnLayout {
|
|||
}else if(chatRoomModel.isSecure())
|
||||
return chatRoomModel.participants.addressesToString;
|
||||
else
|
||||
return SipAddressesModel.cleanSipAddress(chatRoomModel.sipAddress)
|
||||
return UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(chatRoomModel.sipAddress))
|
||||
}else
|
||||
return ''
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ ColumnLayout {
|
|||
presenceLevel: historyView._sipAddressObserver?Presence.getPresenceLevel(
|
||||
historyView._sipAddressObserver.presenceStatus
|
||||
):null
|
||||
presenceTimestamp: historyView._sipAddressObserver?Presence.getPresenceTimestamp(
|
||||
historyView._sipAddressObserver.presenceStatus
|
||||
):null
|
||||
presenceTimestamp: historyView._sipAddressObserver && historyView._sipAddressObserver.contact ? historyView._sipAddressObserver.contact.presenceTimestamp :null
|
||||
|
||||
username: historyView.entry && historyView.entry.wasConference
|
||||
? historyView.entry.title
|
||||
|
|
@ -76,10 +74,10 @@ ColumnLayout {
|
|||
|
||||
subtitleText: historyView.entry && historyView.entry.wasConference
|
||||
? ''
|
||||
: SipAddressesModel.cleanSipAddress(historyView.peerAddress)
|
||||
subtitleColor: HistoryViewStyle.bar.description.subtitleColor
|
||||
: UtilsCpp.toDisplayString(SipAddressesModel.cleanSipAddress(historyView.peerAddress))
|
||||
subtitleColor: HistoryViewStyle.bar.description.subtitleColor.color
|
||||
titleText: avatar.username
|
||||
titleColor: HistoryViewStyle.bar.description.titleColor
|
||||
titleColor: HistoryViewStyle.bar.description.titleColor.color
|
||||
visible:peerAddress
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import Utils 1.0
|
|||
|
||||
import App.Styles 1.0
|
||||
import ColorsList 1.0
|
||||
import UtilsCpp 1.0
|
||||
|
||||
import 'MainWindow.js' as Logic
|
||||
import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
||||
|
|
@ -139,7 +140,7 @@ ApplicationWindow {
|
|||
Layout.fillWidth: false
|
||||
|
||||
TooltipArea {
|
||||
text: AccountSettingsModel.sipAddress
|
||||
text: UtilsCpp.toDisplayString(AccountSettingsModel.sipAddress)
|
||||
hoveringCursor: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue