Turn bookmarks/aliases/at_index into Sections
This commit is contained in:
parent
fbd3f6f4a2
commit
3564e7a571
|
@ -1,7 +1,11 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- login page password spinner
|
- Fix MatrixForbidden when switching rooms with Alt+numbers
|
||||||
- Encrypted rooms don't show invites in member list after Mirage restart
|
- Verify PCN include_builtin works under QRC
|
||||||
|
- PCN docstrings
|
||||||
|
- PCN error handling
|
||||||
|
- PCN documentation
|
||||||
|
|
||||||
- Room display name not updated when someone removes theirs
|
- Room display name not updated when someone removes theirs
|
||||||
- Fix right margin of own `<image url>\n<image url>` messages
|
- Fix right margin of own `<image url>\n<image url>` messages
|
||||||
|
|
||||||
|
|
|
@ -1147,7 +1147,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
room.bookmarked = not room.bookmarked
|
room.bookmarked = not room.bookmarked
|
||||||
|
|
||||||
settings = self.backend.settings
|
settings = self.backend.settings
|
||||||
bookmarks = settings.RoomList.bookmarks
|
bookmarks = settings.RoomList.Bookmarks
|
||||||
user_bookmarks = bookmarks.setdefault(self.user_id, [])
|
user_bookmarks = bookmarks.setdefault(self.user_id, [])
|
||||||
|
|
||||||
if room.bookmarked and room_id not in user_bookmarks:
|
if room.bookmarked and room_id not in user_bookmarks:
|
||||||
|
@ -1157,10 +1157,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
user_bookmarks.remove(room_id)
|
user_bookmarks.remove(room_id)
|
||||||
|
|
||||||
# Changes inside dicts/lists aren't monitored, need to reassign
|
# Changes inside dicts/lists aren't monitored, need to reassign
|
||||||
settings.RoomList.bookmarks = {
|
settings.RoomList.Bookmarks[self.user_id] = user_bookmarks
|
||||||
**bookmarks, self.user_id: user_bookmarks,
|
|
||||||
}
|
|
||||||
|
|
||||||
self.backend.settings.save()
|
self.backend.settings.save()
|
||||||
|
|
||||||
async def room_forget(self, room_id: str) -> None:
|
async def room_forget(self, room_id: str) -> None:
|
||||||
|
@ -1874,7 +1871,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
)
|
)
|
||||||
unverified_devices = registered.unverified_devices
|
unverified_devices = registered.unverified_devices
|
||||||
|
|
||||||
bookmarks = self.backend.settings.RoomList.bookmarks
|
bookmarks = self.backend.settings.RoomList.Bookmarks
|
||||||
room_item = Room(
|
room_item = Room(
|
||||||
id = room.room_id,
|
id = room.room_id,
|
||||||
for_account = self.user_id,
|
for_account = self.user_id,
|
||||||
|
@ -1921,7 +1918,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
local_highlights = local_highlights,
|
local_highlights = local_highlights,
|
||||||
|
|
||||||
lexical_sorting = self.backend.settings.RoomList.lexical_sort,
|
lexical_sorting = self.backend.settings.RoomList.lexical_sort,
|
||||||
bookmarked = room.room_id in bookmarks.get(self.user_id, {}),
|
bookmarked = room.room_id in bookmarks.get(self.user_id, []),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
||||||
|
|
|
@ -267,8 +267,7 @@ class PCNFile(MappingFile):
|
||||||
def deserialized(self, data: str) -> Tuple[Section, bool]:
|
def deserialized(self, data: str) -> Tuple[Section, bool]:
|
||||||
root = Section.from_source_code(data, self.path)
|
root = Section.from_source_code(data, self.path)
|
||||||
edits = self.write_path.read_text() if self.write_path.exists() else ""
|
edits = self.write_path.read_text() if self.write_path.exists() else ""
|
||||||
root.deep_merge_edits(json.loads(edits))
|
return (root, root.deep_merge_edits(json.loads(edits)))
|
||||||
return (root, False)
|
|
||||||
|
|
||||||
def serialized(self) -> str:
|
def serialized(self) -> str:
|
||||||
edits = self.data.edits_as_dict()
|
edits = self.data.edits_as_dict()
|
||||||
|
|
|
@ -74,11 +74,6 @@ class RoomList:
|
||||||
# The application must be restarted to apply changes to this setting.
|
# The application must be restarted to apply changes to this setting.
|
||||||
lexical_sort: bool = False
|
lexical_sort: bool = False
|
||||||
|
|
||||||
# Mapping of account user ID to list of room ID to always keep on top.
|
|
||||||
# You can copy a room's ID by right clicking on it in the room list.
|
|
||||||
# Example: {"@alice:example.org": ["!aBc@example.org", "!123:example.org"]}
|
|
||||||
bookmarks: Dict[str, List[str]] = {}
|
|
||||||
|
|
||||||
# When clicking on a room, recenter the room list on that room.
|
# When clicking on a room, recenter the room list on that room.
|
||||||
click_centers: bool = False
|
click_centers: bool = False
|
||||||
|
|
||||||
|
@ -90,6 +85,13 @@ class RoomList:
|
||||||
# in addition to focusing the current page or chat composer.
|
# in addition to focusing the current page or chat composer.
|
||||||
escape_clears_filter: bool = True
|
escape_clears_filter: bool = True
|
||||||
|
|
||||||
|
class Bookmarks:
|
||||||
|
# Each property in this section is an account user ID, and the
|
||||||
|
# value is a list of room ID to always keep on top.
|
||||||
|
# A room's ID can be copied by right clicking on it in the room list.
|
||||||
|
|
||||||
|
"@account:example.org": List[str] = ["!roomID:a.org", "!other:b.org"]
|
||||||
|
|
||||||
class Chat:
|
class Chat:
|
||||||
# Center the chat header (room avatar, name and topic) even when sidepanes
|
# Center the chat header (room avatar, name and topic) even when sidepanes
|
||||||
# aren't hidden (see comment for the hide_sidepanes_under setting).
|
# aren't hidden (see comment for the hide_sidepanes_under setting).
|
||||||
|
@ -120,13 +122,15 @@ class Chat:
|
||||||
mark_read_delay: float = 0.2
|
mark_read_delay: float = 0.2
|
||||||
|
|
||||||
class Composer:
|
class Composer:
|
||||||
# Mapping of account user ID to alias.
|
class Aliases:
|
||||||
|
# Each property is the user ID of an account, value is the alias.
|
||||||
# From any chat, start a message with an alias followed by a space
|
# From any chat, start a message with an alias followed by a space
|
||||||
# to type and send as this associated account.
|
# to type and send as the associated account.
|
||||||
# The account must have permission to talk in the room.
|
# The account must have permission to talk in the room.
|
||||||
# To ignore an alias when typing, prepend it with a space.
|
# To ignore an alias when typing, prepend it with a space.
|
||||||
# Example: {"@alice:example.org": "al", "@bob:example.org": "b"}
|
|
||||||
aliases: Dict[str, str] = {}
|
"!account:example.org": str = "u"
|
||||||
|
"!other_account:example.org": str = "oa"
|
||||||
|
|
||||||
class Files:
|
class Files:
|
||||||
# Minimum width of the file name/size box for files without previews.
|
# Minimum width of the file name/size box for files without previews.
|
||||||
|
@ -154,7 +158,6 @@ class Chat:
|
||||||
# reveals the hidden controls.
|
# reveals the hidden controls.
|
||||||
autohide_image_controls_after: float = 2.0
|
autohide_image_controls_after: float = 2.0
|
||||||
|
|
||||||
|
|
||||||
class Keys:
|
class Keys:
|
||||||
# All keybind settings, unless their comment says otherwise, are list of
|
# All keybind settings, unless their comment says otherwise, are list of
|
||||||
# the possible shortcuts for an action, e.g. ["Ctrl+A", "Alt+Shift+A"].
|
# the possible shortcuts for an action, e.g. ["Ctrl+A", "Alt+Shift+A"].
|
||||||
|
@ -242,21 +245,21 @@ class Keys:
|
||||||
previous = ["Alt+Shift+N"]
|
previous = ["Alt+Shift+N"]
|
||||||
next = ["Alt+N"]
|
next = ["Alt+N"]
|
||||||
|
|
||||||
|
class AtIndex:
|
||||||
# Switch to the first room of the account number X in the list.
|
# Switch to the first room of the account number X in the list.
|
||||||
# This is a mapping of account number to keybind, e.g.
|
# Each property is a list of keybinds for the account number X.
|
||||||
# {1: "Ctrl+1"} would bind Ctrl+1 to the switch to the first account.
|
# Numbers beyond the default ones can be added.
|
||||||
at_index: Dict[int, str] = {
|
|
||||||
"1": f"{parent.os_ctrl()}+1",
|
1 = [Keys.os_ctrl() + "+1"]
|
||||||
"2": f"{parent.os_ctrl()}+2",
|
2 = [Keys.os_ctrl() + "+2"]
|
||||||
"3": f"{parent.os_ctrl()}+3",
|
3 = [Keys.os_ctrl() + "+3"]
|
||||||
"4": f"{parent.os_ctrl()}+4",
|
4 = [Keys.os_ctrl() + "+4"]
|
||||||
"5": f"{parent.os_ctrl()}+5",
|
5 = [Keys.os_ctrl() + "+5"]
|
||||||
"6": f"{parent.os_ctrl()}+6",
|
6 = [Keys.os_ctrl() + "+6"]
|
||||||
"7": f"{parent.os_ctrl()}+7",
|
7 = [Keys.os_ctrl() + "+7"]
|
||||||
"8": f"{parent.os_ctrl()}+8",
|
8 = [Keys.os_ctrl() + "+8"]
|
||||||
"9": f"{parent.os_ctrl()}+9",
|
9 = [Keys.os_ctrl() + "+9"]
|
||||||
"10": f"{parent.os_ctrl()}+0",
|
10 = [Keys.os_ctrl() + "+0"]
|
||||||
}
|
|
||||||
|
|
||||||
class Rooms:
|
class Rooms:
|
||||||
# Add a new room (direct chat, join or create a group).
|
# Add a new room (direct chat, join or create a group).
|
||||||
|
@ -282,21 +285,21 @@ class Keys:
|
||||||
previous_urgent = ["Alt+Shift+M"]
|
previous_urgent = ["Alt+Shift+M"]
|
||||||
next_urgent = ["Alt+M"]
|
next_urgent = ["Alt+M"]
|
||||||
|
|
||||||
|
class AtIndex:
|
||||||
# Switch to room number X in the current account.
|
# Switch to room number X in the current account.
|
||||||
# This is a mapping of room number to keybind, e.g.
|
# Each property is a list of keybinds for the room number X:
|
||||||
# {1: "Alt+1"} would bind Alt+1 to switch to the first room.
|
# Numbers beyond the default ones can be added.
|
||||||
at_index: Dict[int, str] = {
|
|
||||||
"1": f"{parent.alt_or_cmd()}+1",
|
1 = [Keys.alt_or_cmd() + "+1"]
|
||||||
"2": f"{parent.alt_or_cmd()}+2",
|
2 = [Keys.alt_or_cmd() + "+2"]
|
||||||
"3": f"{parent.alt_or_cmd()}+3",
|
3 = [Keys.alt_or_cmd() + "+3"]
|
||||||
"4": f"{parent.alt_or_cmd()}+4",
|
4 = [Keys.alt_or_cmd() + "+4"]
|
||||||
"5": f"{parent.alt_or_cmd()}+5",
|
5 = [Keys.alt_or_cmd() + "+5"]
|
||||||
"6": f"{parent.alt_or_cmd()}+6",
|
6 = [Keys.alt_or_cmd() + "+6"]
|
||||||
"7": f"{parent.alt_or_cmd()}+7",
|
7 = [Keys.alt_or_cmd() + "+7"]
|
||||||
"8": f"{parent.alt_or_cmd()}+8",
|
8 = [Keys.alt_or_cmd() + "+8"]
|
||||||
"9": f"{parent.alt_or_cmd()}+9",
|
9 = [Keys.alt_or_cmd() + "+9"]
|
||||||
"10": f"{parent.alt_or_cmd()}+0",
|
10 = [Keys.alt_or_cmd() + "+0"]
|
||||||
}
|
|
||||||
|
|
||||||
class Chat:
|
class Chat:
|
||||||
# Keybinds specific to the current chat page.
|
# Keybinds specific to the current chat page.
|
||||||
|
|
|
@ -275,22 +275,22 @@ HListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Object.keys(window.settings.Keys.Accounts.at_index)
|
model: Object.keys(window.settings.Keys.Accounts.AtIndex)
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
HShortcut {
|
HShortcut {
|
||||||
sequence: window.settings.Keys.Accounts.at_index[modelData]
|
sequences: window.settings.Keys.Accounts.AtIndex[modelData]
|
||||||
onActivated: goToAccountNumber(parseInt(modelData, 10) - 1)
|
onActivated: goToAccountNumber(parseInt(modelData, 10) - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Object.keys(window.settings.Keys.Rooms.at_index)
|
model: Object.keys(window.settings.Keys.Rooms.AtIndex)
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
HShortcut {
|
HShortcut {
|
||||||
sequence: window.settings.Keys.Rooms.at_index[modelData]
|
sequences: window.settings.Keys.Rooms.AtIndex[modelData]
|
||||||
onActivated: showAccountRoomAtIndex(parseInt(modelData,10) - 1)
|
onActivated: showAccountRoomAtIndex(parseInt(modelData,10) - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ HFlickableColumnPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aliasFieldItem.changed) {
|
if (aliasFieldItem.changed) {
|
||||||
window.settings.Chat.Composer.aliases[userId] =
|
window.settings.Chat.Composer.Aliases[userId] =
|
||||||
aliasFieldItem.text
|
aliasFieldItem.text
|
||||||
|
|
||||||
window.saveSettings()
|
window.saveSettings()
|
||||||
|
@ -251,7 +251,7 @@ HFlickableColumnPage {
|
||||||
HLabeledItem {
|
HLabeledItem {
|
||||||
id: aliasField
|
id: aliasField
|
||||||
|
|
||||||
readonly property var aliases: window.settings.Chat.Composer.aliases
|
readonly property var aliases: window.settings.Chat.Composer.Aliases
|
||||||
readonly property string currentAlias: aliases[userId] || ""
|
readonly property string currentAlias: aliases[userId] || ""
|
||||||
|
|
||||||
readonly property bool hasWhiteSpace: /\s/.test(item.text)
|
readonly property bool hasWhiteSpace: /\s/.test(item.text)
|
||||||
|
|
|
@ -21,7 +21,7 @@ HTextArea {
|
||||||
|
|
||||||
readonly property var usableAliases: {
|
readonly property var usableAliases: {
|
||||||
const obj = {}
|
const obj = {}
|
||||||
const aliases = window.settings.Chat.Composer.aliases
|
const aliases = window.settings.Chat.Composer.Aliases
|
||||||
|
|
||||||
// Get accounts that are members of this room with permission to talk
|
// Get accounts that are members of this room with permission to talk
|
||||||
for (const [id, alias] of Object.entries(aliases)) {
|
for (const [id, alias] of Object.entries(aliases)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user