From 2da7214af166c89d3b4d3f1354385623a97f3731 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 13 May 2019 13:15:03 -0400 Subject: [PATCH] HListView component with animations --- harmonyqml/backend/signal_manager.py | 5 ++-- harmonyqml/components/Base/HListView.qml | 28 +++++++++++++++++++ harmonyqml/components/Base/HStyle.qml | 2 ++ .../Chat/RoomEventList/RoomEventList.qml | 2 +- .../Chat/RoomSidePane/MembersView.qml | 2 +- .../components/SidePane/AccountList.qml | 3 +- .../SidePane/RoomCategoriesList.qml | 2 +- harmonyqml/components/SidePane/RoomList.qml | 2 +- 8 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 harmonyqml/components/Base/HListView.qml diff --git a/harmonyqml/backend/signal_manager.py b/harmonyqml/backend/signal_manager.py index ad17c475..54aabe3d 100644 --- a/harmonyqml/backend/signal_manager.py +++ b/harmonyqml/backend/signal_manager.py @@ -318,8 +318,9 @@ class SignalManager(QObject): if not event.isLocalEcho: continue - sb = (event.dict["sender"], event.dict["body"]) - new_sb = (new_event.dict["sender"], new_event.dict["body"]) + sb = (event.dict.get("sender"), event.dict.get("body")) + new_sb = (new_event.dict.get("sender"), + new_event.dict.get("body")) if sb == new_sb: # The oldest matching local echo shall be replaced diff --git a/harmonyqml/components/Base/HListView.qml b/harmonyqml/components/Base/HListView.qml new file mode 100644 index 00000000..a467ba45 --- /dev/null +++ b/harmonyqml/components/Base/HListView.qml @@ -0,0 +1,28 @@ +import QtQuick 2.7 + +ListView { + property int duration: HStyle.animationDurations + + add: Transition { + NumberAnimation { properties: "x,y"; from: 100; duration: duration } + } + + populate: Transition { + NumberAnimation { properties: "x,y"; duration: duration } + } + + move: Transition { + NumberAnimation { properties: "x,y"; duration: duration } + } + + displaced: Transition { + NumberAnimation { properties: "x,y"; duration: duration } + } + + remove: Transition { + ParallelAnimation { + NumberAnimation { property: "opacity"; to: 0; duration: duration } + NumberAnimation { properties: "x,y"; to: 100; duration: duration } + } + } +} diff --git a/harmonyqml/components/Base/HStyle.qml b/harmonyqml/components/Base/HStyle.qml index 5439fa3c..48f98b20 100644 --- a/harmonyqml/components/Base/HStyle.qml +++ b/harmonyqml/components/Base/HStyle.qml @@ -4,6 +4,8 @@ import QtQuick 2.7 QtObject { id: style + property int animationDurations: 120 + readonly property QtObject fontSize: QtObject { property int smallest: 6 property int smaller: 8 diff --git a/harmonyqml/components/Chat/RoomEventList/RoomEventList.qml b/harmonyqml/components/Chat/RoomEventList/RoomEventList.qml index ec0e41ec..a467d0e8 100644 --- a/harmonyqml/components/Chat/RoomEventList/RoomEventList.qml +++ b/harmonyqml/components/Chat/RoomEventList/RoomEventList.qml @@ -6,7 +6,7 @@ HRectangle { color: HStyle.chat.roomEventList.background - ListView { + HListView { id: roomEventListView delegate: RoomEventDelegate {} model: Backend.roomEvents.get(chatPage.roomId) diff --git a/harmonyqml/components/Chat/RoomSidePane/MembersView.qml b/harmonyqml/components/Chat/RoomSidePane/MembersView.qml index 62820254..c3b8da4b 100644 --- a/harmonyqml/components/Chat/RoomSidePane/MembersView.qml +++ b/harmonyqml/components/Chat/RoomSidePane/MembersView.qml @@ -8,7 +8,7 @@ HColumnLayout { Layout.leftMargin: roomSidePane.collapsed ? 0 : normalSpacing Layout.rightMargin: Layout.leftMargin - ListView { + HListView { id: memberList spacing: parent.Layout.leftMargin diff --git a/harmonyqml/components/SidePane/AccountList.qml b/harmonyqml/components/SidePane/AccountList.qml index e4c3d0c9..71503557 100644 --- a/harmonyqml/components/SidePane/AccountList.qml +++ b/harmonyqml/components/SidePane/AccountList.qml @@ -1,7 +1,8 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 +import "../Base" -ListView { +HListView { id: accountList clip: true diff --git a/harmonyqml/components/SidePane/RoomCategoriesList.qml b/harmonyqml/components/SidePane/RoomCategoriesList.qml index a584045a..0efd465c 100644 --- a/harmonyqml/components/SidePane/RoomCategoriesList.qml +++ b/harmonyqml/components/SidePane/RoomCategoriesList.qml @@ -2,7 +2,7 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 import "../Base" -ListView { +HListView { property string userId: "" id: roomCategoriesList diff --git a/harmonyqml/components/SidePane/RoomList.qml b/harmonyqml/components/SidePane/RoomList.qml index b5e57ec1..2e663933 100644 --- a/harmonyqml/components/SidePane/RoomList.qml +++ b/harmonyqml/components/SidePane/RoomList.qml @@ -2,7 +2,7 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 import "../Base" -ListView { +HListView { property string userId: "" property string category: ""