Add new message action to pin and unpin messages in rooms
Self-explanatory, now you can manage pinned messages in NeoChat alone.
This commit is contained in:
@@ -1751,4 +1751,23 @@ ThreadModel *NeoChatRoom::modelForThread(const QString &threadRootId)
|
|||||||
return m_threadModels[threadRootId].get();
|
return m_threadModels[threadRootId].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NeoChatRoom::pinEvent(const QString &eventId)
|
||||||
|
{
|
||||||
|
auto eventIds = pinnedEventIds();
|
||||||
|
eventIds.push_back(eventId);
|
||||||
|
setPinnedEvents(eventIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeoChatRoom::unpinEvent(const QString &eventId)
|
||||||
|
{
|
||||||
|
auto eventIds = pinnedEventIds();
|
||||||
|
eventIds.removeAll(eventId);
|
||||||
|
setPinnedEvents(eventIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NeoChatRoom::isEventPinned(const QString &eventId) const
|
||||||
|
{
|
||||||
|
return pinnedEventIds().contains(eventId);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_neochatroom.cpp"
|
#include "moc_neochatroom.cpp"
|
||||||
|
|||||||
@@ -601,6 +601,23 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE ThreadModel *modelForThread(const QString &threadRootId);
|
Q_INVOKABLE ThreadModel *modelForThread(const QString &threadRootId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Pin a message in the room.
|
||||||
|
* @param eventId The id of the event to pin.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void pinEvent(const QString &eventId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unpin a message in the room.
|
||||||
|
* @param eventId The id of the event to unpin.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void unpinEvent(const QString &eventId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True if @p eventId is pinned in the room.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE bool isEventPinned(const QString &eventId) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_visible = false;
|
bool m_visible = false;
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,15 @@ KirigamiComponents.ConvergentContextMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component PinMessageAction: Kirigami.Action {
|
||||||
|
readonly property bool pinned: currentRoom.isEventPinned(root.eventId)
|
||||||
|
|
||||||
|
visible: currentRoom.canSendState("m.room.pinned_events")
|
||||||
|
text: pinned ? i18nc("@action:button 'Unpin' as in 'Unpin this message'", "Unpin") : i18nc("@action:button 'Pin' as in 'Pin the message in the room'", "Pin")
|
||||||
|
icon.name: pinned ? "window-unpin-symbolic" : "pin-symbolic"
|
||||||
|
onTriggered: pinned ? currentRoom.unpinEvent(root.eventId) : currentRoom.pinEvent(root.eventId)
|
||||||
|
}
|
||||||
|
|
||||||
headerContentItem: RowLayout {
|
headerContentItem: RowLayout {
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ DelegateContextMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DelegateContextMenu.PinMessageAction {}
|
||||||
|
|
||||||
DelegateContextMenu.ReportMessageAction {}
|
DelegateContextMenu.ReportMessageAction {}
|
||||||
|
|
||||||
DelegateContextMenu.ShowUserAction {}
|
DelegateContextMenu.ShowUserAction {}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ DelegateContextMenu {
|
|||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
separator: true
|
separator: true
|
||||||
}
|
}
|
||||||
|
DelegateContextMenu.PinMessageAction {}
|
||||||
DelegateContextMenu.ReportMessageAction {}
|
DelegateContextMenu.ReportMessageAction {}
|
||||||
DelegateContextMenu.ShowUserAction {}
|
DelegateContextMenu.ShowUserAction {}
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
|
|||||||
Reference in New Issue
Block a user