ActionsHandler poperties

Make sure that all low level components get ActionsHandler through actual properties rather than magically
This commit is contained in:
James Graham
2023-10-22 13:39:34 +00:00
parent c2d82750b1
commit ef1d62d45c
6 changed files with 47 additions and 7 deletions

View File

@@ -50,6 +50,14 @@ QQC2.Control {
property NeoChatConnection connection
/**
* @brief The ActionsHandler object to use.
*
* This is expected to have the correct room set otherwise messages will be sent
* to the wrong room.
*/
required property ActionsHandler actionsHandler
/**
* @brief The list of actions in the ChatBar.
*
@@ -478,7 +486,7 @@ QQC2.Control {
}
function postMessage() {
actionsHandler.handleMessageEvent(_private.chatBarCache);
root.actionsHandler.handleMessageEvent(_private.chatBarCache);
repeatTimer.stop()
root.currentRoom.markAllMessagesAsRead();
textField.clear();

View File

@@ -38,6 +38,14 @@ ColumnLayout {
required property NeoChatConnection connection
/**
* @brief The ActionsHandler object to use.
*
* This is expected to have the correct room set otherwise messages will be sent
* to the wrong room.
*/
required property ActionsHandler actionsHandler
/**
* @brief A message has been sent from the chat bar.
*/
@@ -75,6 +83,7 @@ ColumnLayout {
Layout.preferredHeight: Math.round(implicitHeight)
currentRoom: root.currentRoom
actionsHandler: root.actionsHandler
FontMetrics {
id: chatBarFontMetrics

View File

@@ -18,6 +18,14 @@ QQC2.TextArea {
_private.chatBarCache.relationIdChanged.connect(_private.updateEditText)
}
/**
* @brief The ActionsHandler object to use.
*
* This is expected to have the correct room set otherwise messages will be sent
* to the wrong room.
*/
required property ActionsHandler actionsHandler
property string messageId
property var minimumHeight: editButtons.height + topPadding + bottomPadding
@@ -137,7 +145,7 @@ QQC2.TextArea {
}
function postEdit() {
actionsHandler.handleMessageEvent(_private.chatBarCache);
root.actionsHandler.handleMessageEvent(_private.chatBarCache);
root.clear();
_private.chatBarCache.editId = "";
}

View File

@@ -60,6 +60,13 @@ Kirigami.Page {
*/
property MediaMessageFilterModel mediaMessageFilterModel: RoomManager.mediaMessageFilterModel
/**
* @brief The ActionsHandler object to use.
*/
property ActionsHandler actionsHandler: ActionsHandler {
room: root.currentRoom
}
property bool loading: !root.currentRoom || (root.currentRoom.timelineSize === 0 && !root.currentRoom.allHistoryLoaded)
/// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation.
@@ -114,6 +121,7 @@ Kirigami.Page {
currentRoom: root.currentRoom
messageEventModel: root.messageEventModel
messageFilterModel: root.messageFilterModel
actionsHandler: root.actionsHandler
onFocusChatBox: {
if (chatBoxLoader.item) {
chatBoxLoader.item.forceActiveFocus()
@@ -155,6 +163,7 @@ Kirigami.Page {
width: parent.width
currentRoom: root.currentRoom
connection: root.connection
actionsHandler: root.actionsHandler
onMessageSent: {
if (!timelineViewLoader.item.atYEnd) {
timelineViewLoader.item.goToLastMessage();
@@ -180,11 +189,6 @@ Kirigami.Page {
}
}
ActionsHandler {
id: actionsHandler
room: root.currentRoom
}
Shortcut {
sequence: StandardKey.Cancel
onActivated: {

View File

@@ -63,6 +63,7 @@ MessageDelegate {
active: visible
sourceComponent: MessageEditComponent {
room: currentRoom
actionsHandler: root.ListView.view.actionsHandler
messageId: root.eventId
}
}

View File

@@ -41,6 +41,14 @@ QQC2.ScrollView {
*/
required property MessageFilterModel messageFilterModel
/**
* @brief The ActionsHandler object to use.
*
* This is expected to have the correct room set otherwise messages will be sent
* to the wrong room.
*/
required property ActionsHandler actionsHandler
readonly property bool atYEnd: messageListView.atYEnd
/// Used to determine if scrolling to the bottom should mark the message as unread
@@ -52,6 +60,8 @@ QQC2.ScrollView {
id: messageListView
// So that delegates can access the current room properly.
readonly property NeoChatRoom currentRoom: root.currentRoom
// So that delegates can access the actionsHandler properly.
readonly property ActionsHandler actionsHandler: root.actionsHandler
readonly property int largestVisibleIndex: count > 0 ? indexAt(contentX + (width / 2), contentY + height - 1) : -1
readonly property var sectionBannerItem: contentHeight >= height ? itemAtIndex(sectionBannerIndex()) : undefined