Introduce the ActionsHandler
This commit is contained in:
@@ -326,7 +326,6 @@ ToolBar {
|
||||
room: currentRoom ?? null
|
||||
}
|
||||
|
||||
|
||||
property int lineHeight: contentHeight / lineCount
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
@@ -470,12 +469,8 @@ ToolBar {
|
||||
}
|
||||
|
||||
function postMessage() {
|
||||
// Qt wraps lines so we need to use a small hack
|
||||
// to remove the wrapped lines but not break the empty
|
||||
// lines.
|
||||
const updatedText = inputField.text.trim()
|
||||
.replace(/@([^: ]*):([^ ]*\.[^ ]*)/, "[@$1:$2](https://matrix.to/#/@$1:$2)");
|
||||
documentHandler.postMessage(updatedText, attachmentPath, replyEventID, editEventId);
|
||||
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
|
||||
replyEventID, editEventId);
|
||||
clearAttachment();
|
||||
currentRoom.markAllMessagesAsRead();
|
||||
clear();
|
||||
|
||||
@@ -36,11 +36,11 @@ Kirigami.OverlaySheet {
|
||||
|
||||
Button {
|
||||
id: okButton
|
||||
|
||||
text: i18nc("@action:button", "Ok")
|
||||
onClicked: {
|
||||
Controller.createRoom(Controller.activeConnection, roomNameField.text, roomTopicField.text)
|
||||
roomManager.actionsHandler.createRoom(roomNameField.text, roomTopicField.text);
|
||||
root.close();
|
||||
// TODO investigate how to join the new room automatically
|
||||
root.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ Kirigami.ScrollablePage {
|
||||
property alias keyword: identifierField.text
|
||||
property string server
|
||||
|
||||
signal joinRoom(string room)
|
||||
|
||||
title: i18n("Explore Rooms")
|
||||
|
||||
header: Control {
|
||||
@@ -51,9 +49,9 @@ Kirigami.ScrollablePage {
|
||||
|
||||
onClicked: {
|
||||
if (!identifierField.isJoined) {
|
||||
Controller.joinRoom(connection, identifierField.text);
|
||||
roomManager.actionsHandler.joinRoom(identifierField.text);
|
||||
// When joining the room, the room will be opened
|
||||
}
|
||||
roomManager.enterRoom(connection.room(identifierField.room));
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
}
|
||||
@@ -104,12 +102,12 @@ Kirigami.ScrollablePage {
|
||||
width: publicRoomsListView.width
|
||||
onClicked: {
|
||||
if (!isJoined) {
|
||||
Controller.joinRoom(connection, roomID)
|
||||
roomManager.actionsHandler.joinRoom(connection, roomID)
|
||||
justJoined = true;
|
||||
} else {
|
||||
roomManager.enterRoom(connection.room(roomID))
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
contentItem: RowLayout {
|
||||
Kirigami.Avatar {
|
||||
|
||||
@@ -22,9 +22,6 @@ Kirigami.ScrollablePage {
|
||||
property var enteredRoom
|
||||
required property var activeConnection
|
||||
|
||||
signal enterRoom(var room)
|
||||
signal leaveRoom(var room)
|
||||
|
||||
function goToNextRoom() {
|
||||
do {
|
||||
listView.incrementCurrentIndex();
|
||||
|
||||
@@ -28,7 +28,27 @@ Kirigami.ScrollablePage {
|
||||
signal switchRoomUp()
|
||||
signal switchRoomDown()
|
||||
|
||||
title: currentRoom.name
|
||||
Connections {
|
||||
target: roomManager.actionsHandler
|
||||
onShowMessage: {
|
||||
page.header.contentItem.text = message;
|
||||
page.header.contentItem.type = messageType === ActionsHandler.Error ? Kirigami.MessageType.Error : Kirigami.MessageType.Information;
|
||||
page.header.contentItem.visible = true;
|
||||
}
|
||||
|
||||
onHideMessage: page.header.contentItem.visible = false
|
||||
}
|
||||
|
||||
header: QQC2.Control {
|
||||
visible: contentItem.visible
|
||||
padding: Kirigami.Units.smallSpacing
|
||||
contentItem: Kirigami.InlineMessage {
|
||||
showCloseButton: true
|
||||
visible: false
|
||||
}
|
||||
}
|
||||
|
||||
title: currentRoom.displayName
|
||||
titleDelegate: Component {
|
||||
RowLayout {
|
||||
visible: !Kirigami.Settings.isMobile
|
||||
|
||||
@@ -42,7 +42,10 @@ Kirigami.ScrollablePage {
|
||||
text: i18n("Chat")
|
||||
highlighted: true
|
||||
|
||||
onClicked: Controller.createDirectChat(connection, identifierField.text)
|
||||
onClicked: {
|
||||
connection.requestDirectChat(identifierField.text);
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,23 +106,27 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
|
||||
Button {
|
||||
id: joinChatButton
|
||||
Layout.alignment: Qt.AlignRight
|
||||
visible: directChats != null
|
||||
visible: directChats && directChats.length > 0
|
||||
|
||||
icon.name: "document-send"
|
||||
onClicked: {
|
||||
roomListForm.joinRoom(connection.room(directChats[0]))
|
||||
root.close()
|
||||
connection.requestDirectChat(userID);
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
icon.name: "irc-join-channel"
|
||||
// We wants to make sure an user can't start more than one
|
||||
// chat with someone.
|
||||
visible: !joinChatButton.visible
|
||||
|
||||
onClicked: {
|
||||
Controller.createDirectChat(connection, userID)
|
||||
root.close()
|
||||
connection.requestDirectChat(userID);
|
||||
applicationWindow().pageStack.layers.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user