Compare commits
2 Commits
v24.02.0
...
work/nvrwh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
210585129e | ||
|
|
3473b75863 |
@@ -35,7 +35,6 @@ void ActionsHandler::setRoom(NeoChatRoom *room)
|
||||
}
|
||||
|
||||
m_room = room;
|
||||
Q_EMIT roomChanged();
|
||||
}
|
||||
|
||||
void ActionsHandler::handleMessageEvent(ChatBarCache *chatBarCache)
|
||||
|
||||
@@ -35,20 +35,18 @@ class ActionsHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
/**
|
||||
* @brief The room that messages will be sent to.
|
||||
*/
|
||||
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
||||
QML_UNCREATABLE("")
|
||||
|
||||
public:
|
||||
explicit ActionsHandler(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief The room that messages will be sent to.
|
||||
*/
|
||||
[[nodiscard]] NeoChatRoom *room() const;
|
||||
void setRoom(NeoChatRoom *room);
|
||||
|
||||
Q_SIGNALS:
|
||||
void roomChanged();
|
||||
void showEffect(const QString &effect);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
@@ -478,7 +478,7 @@ QQC2.Control {
|
||||
}
|
||||
|
||||
function postMessage() {
|
||||
actionsHandler.handleMessageEvent(_private.chatBarCache);
|
||||
RoomManager.actionsHandler.handleMessageEvent(_private.chatBarCache);
|
||||
repeatTimer.stop()
|
||||
root.currentRoom.markAllMessagesAsRead();
|
||||
textField.clear();
|
||||
|
||||
@@ -137,7 +137,7 @@ QQC2.TextArea {
|
||||
}
|
||||
|
||||
function postEdit() {
|
||||
actionsHandler.handleMessageEvent(_private.chatBarCache);
|
||||
RoomManager.actionsHandler.handleMessageEvent(_private.chatBarCache);
|
||||
root.clear();
|
||||
_private.chatBarCache.editId = "";
|
||||
}
|
||||
|
||||
@@ -139,11 +139,6 @@ Kirigami.Page {
|
||||
}
|
||||
}
|
||||
|
||||
ActionsHandler {
|
||||
id: actionsHandler
|
||||
room: root.currentRoom
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: StandardKey.Cancel
|
||||
onActivated: {
|
||||
|
||||
@@ -292,7 +292,7 @@ QQC2.ScrollView {
|
||||
|
||||
Connections {
|
||||
enabled: Config.showFancyEffects
|
||||
target: actionsHandler
|
||||
target: RoomManager.actionsHandler
|
||||
|
||||
function onShowEffect(fancyEffect) {
|
||||
fancyEffectsContainer.processFancyEffectsReason(fancyEffect)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "roommanager.h"
|
||||
|
||||
#include "actionshandler.h"
|
||||
#include "chatbarcache.h"
|
||||
#include "controller.h"
|
||||
#include "enums/delegatetype.h"
|
||||
@@ -29,6 +30,7 @@ RoomManager::RoomManager(QObject *parent)
|
||||
, m_currentRoom(nullptr)
|
||||
, m_lastCurrentRoom(nullptr)
|
||||
, m_config(KSharedConfig::openStateConfig())
|
||||
, m_actionsHandler(new ActionsHandler(this))
|
||||
, m_messageEventModel(new MessageEventModel(this))
|
||||
, m_messageFilterModel(new MessageFilterModel(this, m_messageEventModel))
|
||||
, m_mediaMessageFilterModel(new MediaMessageFilterModel(this, m_messageFilterModel))
|
||||
@@ -36,6 +38,7 @@ RoomManager::RoomManager(QObject *parent)
|
||||
m_lastRoomConfig = m_config->group(QStringLiteral("LastOpenRoom"));
|
||||
|
||||
connect(this, &RoomManager::currentRoomChanged, this, [this]() {
|
||||
m_actionsHandler->setRoom(m_currentRoom);
|
||||
m_messageEventModel->setRoom(m_currentRoom);
|
||||
});
|
||||
}
|
||||
@@ -55,6 +58,11 @@ NeoChatRoom *RoomManager::currentRoom() const
|
||||
return m_currentRoom;
|
||||
}
|
||||
|
||||
ActionsHandler *RoomManager::actionsHandler() const
|
||||
{
|
||||
return m_actionsHandler;
|
||||
}
|
||||
|
||||
MessageEventModel *RoomManager::messageEventModel() const
|
||||
{
|
||||
return m_messageEventModel;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Quotient/room.h>
|
||||
#include <Quotient/uriresolver.h>
|
||||
|
||||
#include "actionshandler.h"
|
||||
#include "chatdocumenthandler.h"
|
||||
#include "enums/delegatetype.h"
|
||||
#include "models/mediamessagefiltermodel.h"
|
||||
@@ -44,6 +45,17 @@ class RoomManager : public QObject, public UriResolverBase
|
||||
*/
|
||||
Q_PROPERTY(NeoChatRoom *currentRoom READ currentRoom NOTIFY currentRoomChanged)
|
||||
|
||||
/**
|
||||
* @brief The ActionsHandler that should be used when sending messages.
|
||||
*
|
||||
* The room object the object uses will be updated by this class so there is no
|
||||
* need to do this manually or replace the object when a room changes.
|
||||
*
|
||||
* @note Available here so that the room page and drawer both have access to the
|
||||
* same model.
|
||||
*/
|
||||
Q_PROPERTY(ActionsHandler *actionsHandler READ actionsHandler CONSTANT)
|
||||
|
||||
/**
|
||||
* @brief The MessageEventModel that should be used for room message visualisation.
|
||||
*
|
||||
@@ -98,6 +110,8 @@ public:
|
||||
|
||||
NeoChatRoom *currentRoom() const;
|
||||
|
||||
ActionsHandler *actionsHandler() const;
|
||||
|
||||
MessageEventModel *messageEventModel() const;
|
||||
MessageFilterModel *messageFilterModel() const;
|
||||
MediaMessageFilterModel *mediaMessageFilterModel() const;
|
||||
@@ -375,6 +389,8 @@ private:
|
||||
KConfigGroup m_lastRoomConfig;
|
||||
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
||||
|
||||
ActionsHandler *m_actionsHandler;
|
||||
|
||||
MessageEventModel *m_messageEventModel;
|
||||
MessageFilterModel *m_messageFilterModel;
|
||||
MediaMessageFilterModel *m_mediaMessageFilterModel;
|
||||
|
||||
Reference in New Issue
Block a user