From 50be00a3867a019e7a663d532aef71bd74a3a1e4 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 26 Aug 2022 16:53:03 +0200 Subject: [PATCH] Feature : add a slide menu on timeline by a right-click to display actions to do (Add a way to delete entirely the chat room from timeline). Fix leaving chat room when emptying history and still in the chat room. Delete chat room only if it is empty (no messages and no events), and if it has been left by the user. Remove timeline from list only if the chat room is on Deleted state (doesn't exist on server and local). --- CHANGELOG.md | 2 + linphone-app/assets/languages/da.ts | 15 +- linphone-app/assets/languages/de.ts | 15 +- linphone-app/assets/languages/en.ts | 19 +- linphone-app/assets/languages/es.ts | 15 +- linphone-app/assets/languages/fr_FR.ts | 15 +- linphone-app/assets/languages/hu.ts | 15 +- linphone-app/assets/languages/it.ts | 15 +- linphone-app/assets/languages/ja.ts | 15 +- linphone-app/assets/languages/lt.ts | 15 +- linphone-app/assets/languages/pt_BR.ts | 15 +- linphone-app/assets/languages/ru.ts | 15 +- linphone-app/assets/languages/sv.ts | 15 +- linphone-app/assets/languages/tr.ts | 15 +- linphone-app/assets/languages/uk.ts | 15 +- linphone-app/assets/languages/zh_CN.ts | 15 +- linphone-app/resources.qrc | 1 + .../components/chat-room/ChatRoomModel.cpp | 8 +- .../other/colors/ColorListModel.hpp | 4 +- .../components/timeline/TimelineListModel.cpp | 3 +- .../src/components/timeline/TimelineModel.cpp | 2 +- .../timeline/TimelineProxyModel.cpp | 2 +- .../Styles/Timeline/TimelineStyle.qml | 28 ++- .../ui/modules/Linphone/Timeline/Timeline.qml | 64 +------ .../Linphone/Timeline/TimelineItem.qml | 166 ++++++++++++++++++ linphone-app/ui/modules/Linphone/qmldir | 1 + .../ui/views/App/Main/Conversation.qml | 2 +- 27 files changed, 428 insertions(+), 84 deletions(-) create mode 100644 linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml diff --git a/CHANGELOG.md b/CHANGELOG.md index a820c4cae..833cd45bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Animated file in chats/notifications. - Round progress bar for transferring a file and allow to cancel it. - hide all accounts if their custom parameter 'hidden' is set to 1. +- Right-click on a timeline will show a slide menu to do actions on the timeline. ### Fixed - Crash on exit. - Crash when using no account. - Memory stability. +- Clean 3 chat behaviors : Leave chat room (in group info section of conversation menu), erase history (in conversation's menu), delete chat room (in slide menu, or if chat room is empty and left) ## 4.4.8 - 2022-07-04 diff --git a/linphone-app/assets/languages/da.ts b/linphone-app/assets/languages/da.ts index a55c0c549..e2a0d71d1 100644 --- a/linphone-app/assets/languages/da.ts +++ b/linphone-app/assets/languages/da.ts @@ -1012,7 +1012,7 @@ Server url ikke konfigureret. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Klik her: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/de.ts b/linphone-app/assets/languages/de.ts index 086d9ddb2..66722d3a3 100644 --- a/linphone-app/assets/languages/de.ts +++ b/linphone-app/assets/languages/de.ts @@ -1012,7 +1012,7 @@ Server URL ist nicht konfiguriert. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Klicken Sie hier: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts index 83b9147dd..f15b754f0 100644 --- a/linphone-app/assets/languages/en.ts +++ b/linphone-app/assets/languages/en.ts @@ -823,7 +823,7 @@ Server URL not configured. conferencesDeleted 'Conference has been deleted' : Message text in a banner to warn the user that the conference has been deleted. - + Conference has been deleted @@ -1012,8 +1012,8 @@ Server URL not configured. conversationMenuDelete - 'Delete' : Item menu to delete the chat - Delete + 'Delete history' : Item menu to delete the chat's history + Delete history conversationMenuViewContact @@ -3413,6 +3413,19 @@ Click here: <a href="%1">%1</a> Conferences + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + Are you sure you want to delete and leave this timeline? + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database. + + UseAppSipAccount diff --git a/linphone-app/assets/languages/es.ts b/linphone-app/assets/languages/es.ts index 46054561e..149ca8ef1 100644 --- a/linphone-app/assets/languages/es.ts +++ b/linphone-app/assets/languages/es.ts @@ -1012,7 +1012,7 @@ URL del servidor no configurada. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Haga clic aquí: <a href="%1">%1 </a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts index acd4b545c..c9637bb18 100644 --- a/linphone-app/assets/languages/fr_FR.ts +++ b/linphone-app/assets/languages/fr_FR.ts @@ -1012,7 +1012,7 @@ URL du serveur non configurée. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Cliquez ici : <a href="%1">%1</a> Conférences + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/hu.ts b/linphone-app/assets/languages/hu.ts index 03f161483..823bf3a92 100644 --- a/linphone-app/assets/languages/hu.ts +++ b/linphone-app/assets/languages/hu.ts @@ -1006,7 +1006,7 @@ A kiszolgáló URL-je nincs konfigurálva. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3377,6 +3377,19 @@ Kattintson ide: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/it.ts b/linphone-app/assets/languages/it.ts index 4a7ec1fc9..db8e3825c 100644 --- a/linphone-app/assets/languages/it.ts +++ b/linphone-app/assets/languages/it.ts @@ -1012,7 +1012,7 @@ URL del server non configurato. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history Elimina @@ -3390,6 +3390,19 @@ Clicca: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/ja.ts b/linphone-app/assets/languages/ja.ts index 55e98abc5..6ee61d20a 100644 --- a/linphone-app/assets/languages/ja.ts +++ b/linphone-app/assets/languages/ja.ts @@ -1006,7 +1006,7 @@ conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3377,6 +3377,19 @@ + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/lt.ts b/linphone-app/assets/languages/lt.ts index 27ea67e9a..c986cd660 100644 --- a/linphone-app/assets/languages/lt.ts +++ b/linphone-app/assets/languages/lt.ts @@ -1018,7 +1018,7 @@ Nesukonfigūruotas serverio url. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3403,6 +3403,19 @@ Spustelėkite čia: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/pt_BR.ts b/linphone-app/assets/languages/pt_BR.ts index 172f94417..0a2d54314 100644 --- a/linphone-app/assets/languages/pt_BR.ts +++ b/linphone-app/assets/languages/pt_BR.ts @@ -1012,7 +1012,7 @@ URL do servidor não configurado. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Clique aqui: <a href="%1">%1 </a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/ru.ts b/linphone-app/assets/languages/ru.ts index f6a9a0a6d..93df74484 100644 --- a/linphone-app/assets/languages/ru.ts +++ b/linphone-app/assets/languages/ru.ts @@ -1018,7 +1018,7 @@ conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3403,6 +3403,19 @@ Конференции + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/sv.ts b/linphone-app/assets/languages/sv.ts index 64a50a977..8bff184ca 100644 --- a/linphone-app/assets/languages/sv.ts +++ b/linphone-app/assets/languages/sv.ts @@ -1012,7 +1012,7 @@ Serverwebbadressen är inte konfigurerad. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3390,6 +3390,19 @@ Klicka här: <a href="%1">%1</a> + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/tr.ts b/linphone-app/assets/languages/tr.ts index 702efc2f6..218a91244 100644 --- a/linphone-app/assets/languages/tr.ts +++ b/linphone-app/assets/languages/tr.ts @@ -1006,7 +1006,7 @@ Sunucu url'si yapılandırılmadı. conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3377,6 +3377,19 @@ Buraya tıklayın: <a href="%1">%1</a> Toplantılar + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/uk.ts b/linphone-app/assets/languages/uk.ts index ba19b67fd..a085a5b1b 100644 --- a/linphone-app/assets/languages/uk.ts +++ b/linphone-app/assets/languages/uk.ts @@ -1018,7 +1018,7 @@ conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3403,6 +3403,19 @@ + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/assets/languages/zh_CN.ts b/linphone-app/assets/languages/zh_CN.ts index 5968edabc..f91605462 100644 --- a/linphone-app/assets/languages/zh_CN.ts +++ b/linphone-app/assets/languages/zh_CN.ts @@ -1006,7 +1006,7 @@ conversationMenuDelete - 'Delete' : Item menu to delete the chat + 'Delete history' : Item menu to delete the chat's history @@ -3377,6 +3377,19 @@ + + TimelineItem + + deleteTimeline + 'Are you sure you want to delete and leave this timeline?' + + + + deleteTimelineTooltip + 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + + + UseAppSipAccount diff --git a/linphone-app/resources.qrc b/linphone-app/resources.qrc index 9f8cb951d..b7109d0cc 100644 --- a/linphone-app/resources.qrc +++ b/linphone-app/resources.qrc @@ -416,6 +416,7 @@ ui/modules/Linphone/TelKeypad/TelKeypad.qml ui/modules/Linphone/Timeline/Timeline.js ui/modules/Linphone/Timeline/Timeline.qml + ui/modules/Linphone/Timeline/TimelineItem.qml ui/modules/Linphone/View/ParticipantsListView.qml ui/modules/Linphone/View/ParticipantsView.qml ui/modules/Linphone/View/SipAddressesView.qml diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index c4a01aa92..97d9cea25 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -258,7 +258,8 @@ void ChatRoomModel::removeAllEntries () { if(haveLogs) emit CoreManager::getInstance()->callLogsCountChanged(); } - deleteChatRoom(); + if( mChatRoom->isReadOnly())// = hasBeenLeft() + deleteChatRoom(); endResetModel(); emit allEntriesRemoved(mSelf.lock()); emit focused();// Removing all entries is like having focus. Don't wait asynchronous events. @@ -599,8 +600,11 @@ void ChatRoomModel::deleteChatRoom(){ } void ChatRoomModel::leaveChatRoom (){ - if(mChatRoom) + if(mChatRoom){ mChatRoom->leave(); + if( mChatRoom->getHistorySize() == 0 && mChatRoom->getHistoryEventsSize() == 0) + deleteChatRoom(); + } } diff --git a/linphone-app/src/components/other/colors/ColorListModel.hpp b/linphone-app/src/components/other/colors/ColorListModel.hpp index b9da325b4..7244ea433 100644 --- a/linphone-app/src/components/other/colors/ColorListModel.hpp +++ b/linphone-app/src/components/other/colors/ColorListModel.hpp @@ -138,7 +138,9 @@ class ColorListModel : public ProxyListModel { ADD_COLOR("progress_bg", "black", "Background of round progress bar") ADD_COLOR("progress_remaining_fg", "white", "Remaining progression color") - + + ADD_COLOR("timeline_bg_1", "#EFF0F2", "Timeline background color 1") + ADD_COLOR("timeline_bg_2", "#FFFFFF", "Timeline background color 2") // Keywords: 'mKeywordsMap' // s=standard, ma=main, l=list, sc=screen, me=menu diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index da335636b..20e6e12a7 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -309,7 +309,8 @@ void TimelineListModel::onChatRoomStateChanged(const std::shared_ptrgetChatRoomModel()) timeline->getChatRoomModel()->resetMessageCount(); - remove(timeline); + if(state == linphone::ChatRoom::State::Deleted) + remove(timeline); } } } diff --git a/linphone-app/src/components/timeline/TimelineModel.cpp b/linphone-app/src/components/timeline/TimelineModel.cpp index 533dad7f7..6433085e0 100644 --- a/linphone-app/src/components/timeline/TimelineModel.cpp +++ b/linphone-app/src/components/timeline/TimelineModel.cpp @@ -67,7 +67,7 @@ void TimelineModel::connectTo(ChatRoomListener * listener){ // ============================================================================= QSharedPointer TimelineModel::create(std::shared_ptr chatRoom, const std::list>& callLogs, QObject *parent){ - if((!chatRoom || chatRoom->getState() != linphone::ChatRoom::State::Terminated) && (!CoreManager::getInstance()->getTimelineListModel() || !CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, false)) ) { + if((!chatRoom || chatRoom->getState() != linphone::ChatRoom::State::Deleted) && (!CoreManager::getInstance()->getTimelineListModel() || !CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, false)) ) { QSharedPointer model = QSharedPointer::create(chatRoom, parent); if(model && model->getChatRoomModel()){ diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.cpp b/linphone-app/src/components/timeline/TimelineProxyModel.cpp index a516a9a2f..694dc9c55 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.cpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.cpp @@ -84,7 +84,7 @@ void TimelineProxyModel::setFilterText(const QString& text){ bool TimelineProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const { const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); auto timeline = sourceModel()->data(index).value(); - if(!timeline || !timeline->getChatRoomModel() || timeline->getChatRoomModel()->getState() == (int)linphone::ChatRoom::State::Terminated) + if(!timeline || !timeline->getChatRoomModel() || timeline->getChatRoomModel()->getState() == (int)linphone::ChatRoom::State::Deleted) return false; bool haveEncryption = timeline->getChatRoomModel()->haveEncryption(); if(!CoreManager::getInstance()->getSettingsModel()->getStandardChatEnabled() && !haveEncryption) diff --git a/linphone-app/ui/modules/Linphone/Styles/Timeline/TimelineStyle.qml b/linphone-app/ui/modules/Linphone/Styles/Timeline/TimelineStyle.qml index 1b7d35c47..b5e63dd63 100644 --- a/linphone-app/ui/modules/Linphone/Styles/Timeline/TimelineStyle.qml +++ b/linphone-app/ui/modules/Linphone/Styles/Timeline/TimelineStyle.qml @@ -21,8 +21,8 @@ QtObject { property int height: 60 property QtObject backgroundColor: QtObject { - property color a: ColorsList.add(sectionName+'_contact_bg_a', 'g10').color - property color b: ColorsList.add(sectionName+'_contact_bg_b', 'a').color + property color a: ColorsList.add(sectionName+'_contact_bg_a', 'timeline_bg_1').color + property color b: ColorsList.add(sectionName+'_contact_bg_b', 'timeline_bg_2').color property color selected: ColorsList.add(sectionName+'_contact_bg_c', 'i').color } @@ -64,4 +64,28 @@ QtObject { property color borderColor: ColorsList.add(sectionName+'_searchField_border', 'border').color property int pointSize: Units.dp * 9 } + + property QtObject selectedDeleteAction: QtObject { + property int iconSize: 40 + property string name : 'delete_on_selected' + property string icon : 'delete_custom' + property color backgroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_n', icon, 'me_h_b_inv_bg').color + property color backgroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_h', icon, 'me_n_b_inv_bg').color + property color backgroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_p', icon, 'me_p_b_inv_bg').color + property color foregroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_n', icon, 'me_n_b_inv_fg').color + property color foregroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_h', icon, 'me_h_b_inv_fg').color + property color foregroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_p', icon, 'me_p_b_inv_fg').color + } + + property QtObject deleteAction: QtObject { + property int iconSize: 40 + property string name : 'delete' + property string icon : 'delete_custom' + property color backgroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_n', icon, 'me_h_b_bg').color + property color backgroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_h', icon, 'me_n_b_bg').color + property color backgroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_bg_p', icon, 'me_p_b_bg').color + property color foregroundNormalColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_n', icon, 'me_h_b_fg').color + property color foregroundHoveredColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_h', icon, 'me_n_b_fg').color + property color foregroundPressedColor : ColorsList.addImageColor(sectionName+'_'+name+'_fg_p', icon, 'me_p_b_fg').color + } } diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index edc018b43..07a5553e8 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 import QtQuick.Controls 2.5 import Common 1.0 +import Common.Styles 1.0 import Linphone 1.0 import Linphone.Styles 1.0 import ColorsList 1.0 @@ -10,6 +11,7 @@ import ColorsList 1.0 import UtilsCpp 1.0 import 'Timeline.js' as Logic +import 'qrc:/ui/scripts/Utils/utils.js' as Utils // ============================================================================= @@ -361,66 +363,12 @@ Rectangle { Layout.fillWidth: true currentIndex: -1 - delegate: Item { - height: TimelineStyle.contact.height - width: parent ? parent.width : 0 - - Contact { - id: contactView - property bool isSelected: $modelData != undefined && $modelData.selected //view.currentIndex === index - - anchors.fill: parent - color: isSelected - ? TimelineStyle.contact.backgroundColor.selected - : ( - index % 2 == 0 - ? TimelineStyle.contact.backgroundColor.a - : TimelineStyle.contact.backgroundColor.b - ) - displayUnreadMessageCount: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled - entry: $modelData.chatRoomModel - sipAddressColor: isSelected - ? TimelineStyle.contact.sipAddress.color.selected - : TimelineStyle.contact.sipAddress.color.normal - usernameColor: isSelected - ? TimelineStyle.contact.username.color.selected - : TimelineStyle.contact.username.color.normal - TooltipArea { - id: contactTooltip - text: UtilsCpp.toDateTimeString($modelData.chatRoomModel.lastUpdateTime) - isClickable: true - } - Icon{ - icon: TimelineStyle.ephemeralTimer.icon - iconSize: TimelineStyle.ephemeralTimer.iconSize - overwriteColor: $modelData && $modelData.selected ? TimelineStyle.ephemeralTimer.selectedTimerColor : TimelineStyle.ephemeralTimer.timerColor - anchors.right:parent.right - anchors.bottom:parent.bottom - anchors.bottomMargin: 7 - anchors.rightMargin: 7 - visible: $modelData.chatRoomModel.ephemeralEnabled - } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - propagateComposedEvents: true - preventStealing: false - onClicked: { - if(mouse.button == Qt.LeftButton){ - timeline.entryClicked($modelData) - if(view.updateSelectionModels) - $modelData.selected = true - view.currentIndex = index; - }else{ - contactTooltip.show() - } - } - } + delegate: TimelineItem{ + timelineModel: $modelData + modelIndex: index Connections{ - target:$modelData + target: $modelData onSelectedChanged:{ gc() if(view.updateSelectionModels && selected) { diff --git a/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml b/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml new file mode 100644 index 000000000..d158924db --- /dev/null +++ b/linphone-app/ui/modules/Linphone/Timeline/TimelineItem.qml @@ -0,0 +1,166 @@ +import QtQuick 2.7 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.5 + +import Common 1.0 +import Common.Styles 1.0 +import Linphone 1.0 +import Linphone.Styles 1.0 +import ColorsList 1.0 + +import UtilsCpp 1.0 + +import 'Timeline.js' as Logic +import 'qrc:/ui/scripts/Utils/utils.js' as Utils + +// ============================================================================= +Item { + id: mainItem + property TimelineModel timelineModel + property bool optionsToggled: false + property int modelIndex: 0 + + height: TimelineStyle.contact.height + width: parent ? parent.width : 0 + + state: optionsToggled ? 'options' : 'normal' + states: [State { + name: "normal" + }, State { + name: "options" + } + ] + + transitions: [Transition { + from: 'normal' + to: 'options' + //NumberAnimation { target: contactView; property: 'x'; to:-contactView.width; duration: 200;} + NumberAnimation { target: optionsView; property: 'x'; to:0; duration: 200;} + }, + Transition { + from: 'options' + to: 'normal' + //NumberAnimation { target: contactView; property: 'x'; to:0; duration: 200;} + NumberAnimation { target: optionsView; property: 'x'; to:optionsView.width; duration: 200;} + } + ] + + + Contact { + id: contactView + property bool isSelected: mainItem.timelineModel != undefined && mainItem.timelineModel.selected //view.currentIndex === index + + height: mainItem.height + width: mainItem.width + color: isSelected + ? TimelineStyle.contact.backgroundColor.selected + : ( + mainItem.modelIndex % 2 == 0 + ? TimelineStyle.contact.backgroundColor.a + : TimelineStyle.contact.backgroundColor.b + ) + displayUnreadMessageCount: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled + entry: mainItem.timelineModel && mainItem.timelineModel.chatRoomModel + sipAddressColor: isSelected + ? TimelineStyle.contact.sipAddress.color.selected + : TimelineStyle.contact.sipAddress.color.normal + usernameColor: isSelected + ? TimelineStyle.contact.username.color.selected + : TimelineStyle.contact.username.color.normal + TooltipArea { + id: contactTooltip + text: mainItem.timelineModel && UtilsCpp.toDateTimeString(mainItem.timelineModel.chatRoomModel.lastUpdateTime) + isClickable: true + } + Icon{ + icon: TimelineStyle.ephemeralTimer.icon + iconSize: TimelineStyle.ephemeralTimer.iconSize + overwriteColor: mainItem.timelineModel && mainItem.timelineModel.selected ? TimelineStyle.ephemeralTimer.selectedTimerColor : TimelineStyle.ephemeralTimer.timerColor + anchors.right:parent.right + anchors.bottom:parent.bottom + anchors.bottomMargin: 7 + anchors.rightMargin: 7 + visible: mainItem.timelineModel && mainItem.timelineModel.chatRoomModel.ephemeralEnabled + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + propagateComposedEvents: true + preventStealing: false + onClicked: { + if(mouse.button == Qt.LeftButton){ + timeline.entryClicked(mainItem.timelineModel) + if(view.updateSelectionModels) + mainItem.timelineModel.selected = true + view.currentIndex = mainItem.modelIndex; + }else{ + mainItem.optionsToggled = !mainItem.optionsToggled + } + } + } + } + Item{ + id: optionsView + + height: mainItem.height + width: mainItem.width + + x:width + visible: x!=width + RowLayout{ + anchors.fill: parent + MouseArea { + Layout.fillHeight: true + Layout.fillWidth: true + onClicked: { + mainItem.optionsToggled = !mainItem.optionsToggled + } + } + Rectangle{ + Layout.fillHeight: true + Layout.preferredWidth: optionsLayout.width + + color: contactView.color + MouseArea {// Grabber + anchors.fill: parent + cursorShape: Qt.ArrowCursor + } + RowLayout{ + id: optionsLayout + anchors.centerIn: parent + /* TODO + CheckBoxText { + id: securedCheckBox + Layout.alignment: Qt.AlignCenter + text: '' + + onClicked: { + + } + }*/ + ActionButton{ + id: deleteButton + Layout.alignment: Qt.AlignCenter + Layout.rightMargin: 6 + + isCustom: true + colorSet: contactView.isSelected ? TimelineStyle.selectedDeleteAction : TimelineStyle.deleteAction + onClicked: window.attachVirtualWindow(Utils.buildCommonDialogUri('ConfirmDialog'), { + //: 'Are you sure you want to delete and leave this timeline?' + descriptionText: qsTr('deleteTimeline'), + }, function (status) { + if (status) { + mainItem.timelineModel.chatRoomModel.deleteChatRoom() + } + }) + TooltipArea { + //: 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.' + text: qsTr('deleteTimelineTooltip') + } + } + } + } + } + } + +} \ No newline at end of file diff --git a/linphone-app/ui/modules/Linphone/qmldir b/linphone-app/ui/modules/Linphone/qmldir index 70fb41e1d..768e7a5cd 100644 --- a/linphone-app/ui/modules/Linphone/qmldir +++ b/linphone-app/ui/modules/Linphone/qmldir @@ -58,6 +58,7 @@ Sticker 1.0 Sticker/Sticker.qml TelKeypad 1.0 TelKeypad/TelKeypad.qml Timeline 1.0 Timeline/Timeline.qml +TimelineItem 1.0 Timeline/TimelineItem.qml ParticipantsListView 1.0 View/ParticipantsListView.qml ParticipantsView 1.0 View/ParticipantsView.qml diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index 912fa9256..0ae8617ed 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -471,7 +471,7 @@ ColumnLayout { } MenuItem{ id: deleteMenuItem - //: 'Delete' : Item menu to delete the chat + //: 'Delete history' : Item menu to delete the chat's history text: qsTr('conversationMenuDelete') iconMenu: MenuItemStyle.deleteEntry.icon iconSizeMenu: 40