Add clear messages shortcut

This commit is contained in:
miruka 2019-09-08 11:49:47 -04:00
parent db0de237e6
commit e93c251624
5 changed files with 22 additions and 4 deletions

View File

@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11 6.999c2.395.731 4.27 2.607 4.999 5.001.733-2.395 2.608-4.269 5.001-5-2.393-.731-4.268-2.605-5.001-5-.729 2.394-2.604 4.268-4.999 4.999zm7 7c1.437.438 2.562 1.564 2.999 3.001.44-1.437 1.565-2.562 3.001-3-1.436-.439-2.561-1.563-3.001-3-.437 1.436-1.562 2.561-2.999 2.999zm-6 5.501c1.198.365 2.135 1.303 2.499 2.5.366-1.198 1.304-2.135 2.501-2.5-1.197-.366-2.134-1.302-2.501-2.5-.364 1.197-1.301 2.134-2.499 2.5zm-6.001-12.5c-.875 2.873-3.128 5.125-5.999 6.001 2.876.88 5.124 3.128 6.004 6.004.875-2.874 3.128-5.124 5.996-6.004-2.868-.874-5.121-3.127-6.001-6.001z"/></svg>
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="m11 6.999c2.395.731 4.27 2.607 4.999 5.001.733-2.395 2.608-4.269 5.001-5-2.393-.731-4.268-2.605-5.001-5-.729 2.394-2.604 4.268-4.999 4.999zm7 7c1.437.438 2.562 1.564 2.999 3.001.44-1.437 1.565-2.562 3.001-3-1.436-.439-2.561-1.563-3.001-3-.437 1.436-1.562 2.561-2.999 2.999zm-6 5.501c1.198.365 2.135 1.303 2.499 2.5.366-1.198 1.304-2.135 2.501-2.5-1.197-.366-2.134-1.302-2.501-2.5-.364 1.197-1.301 2.134-2.499 2.5zm-6.001-12.5c-.875 2.873-3.128 5.125-5.999 6.001 2.876.88 5.124 3.128 6.004 6.004.875-2.874 3.128-5.124 5.996-6.004-2.868-.874-5.121-3.127-6.001-6.001z"/>
</svg>

Before

Width:  |  Height:  |  Size: 665 B

After

Width:  |  Height:  |  Size: 672 B

View File

@ -133,6 +133,8 @@ class UISettings(JSONConfigFile):
"Alt+Shift+Left", "Alt+Shift+Right",
"Alt+Shift+H", "Alt+Shift+L",
],
"clearRoomMessages": ["Ctrl+L"],
},
}

View File

@ -385,6 +385,7 @@ class MatrixClient(nio.AsyncClient):
async def clear_events(self, room_id: str) -> None:
self.cleared_events_rooms.add(room_id)
model = self.models[Event, self.user_id, room_id]
if model:
model.clear()
model.sync_now()

View File

@ -177,7 +177,7 @@ Rectangle {
}
HNoticePage {
text: qsTr("No messages to show yet")
text: qsTr("No messages to show yet.")
visible: eventList.model.count < 1
anchors.fill: parent

View File

@ -109,4 +109,17 @@ HShortcutHandler {
sequences: settings.keys.toggleCollapseAccount
onPressed: mainUI.sidePane.sidePaneList.toggleCollapseAccount()
}
// Chat
HShortcut {
enabled: window.uiState.page == "Chat/Chat.qml"
sequences: settings.keys.clearRoomMessages
onPressed: py.callClientCoro(
window.uiState.pageProperties.userId,
"clear_events",
[window.uiState.pageProperties.roomId],
)
}
}