Add keybind to open links in messages

Ctrl+O by default.
Opens externally all links in selecteds, focused or the last
message that has links.
Can't open files (media events) yet.
This commit is contained in:
miruka 2020-05-22 00:10:45 -04:00
parent bbd845c040
commit 6c7335e5db
3 changed files with 29 additions and 0 deletions

View File

@ -1,5 +1,6 @@
# TODO
- `i <= 1000` resp
- highlight messages being responded to
- highlight messages with mention
- add room members loading indicator

View File

@ -324,6 +324,7 @@ class UISettings(JSONDataFile):
"removeFocusedOrSelectedMessages": ["Ctrl+R", "Alt+Del"],
"replyToFocusedOrLastMessage": ["Ctrl+Q"], # Q for Quote
"debugFocusedMessage": ["Ctrl+Shift+D"],
"openMessagesLinks": ["Ctrl+O"],
"clearRoomMessages": ["Ctrl+L"],
"sendFile": ["Alt+S"],

View File

@ -125,6 +125,33 @@ Rectangle {
}
}
HShortcut {
sequences: window.settings.keys.openMessagesLinks
onActivated: {
let events = []
if (eventList.selectedCount) {
events = eventList.getSortedChecked()
} else if (eventList.currentIndex !== -1) {
events = [eventList.model.get(eventList.currentIndex)]
} else {
// Find most recent event containing links
for (let i = 0; i < eventList.model.count && i <= 1000; i++) {
const ev = eventList.model.get(i)
if (JSON.parse(ev.links).length) {
events = [ev]
break
}
}
}
for (const event of events) {
for (const link of JSON.parse(event.links))
Qt.openUrlExternally(link)
}
}
}
HShortcut {
active: eventList.currentItem