Change room bookmark terminology to pin/unpin
Pin/unpin is more representative of what the function actually does for rooms in the left pane. Also change the corresponding icons and renames the config file section: RoomList.Bookmarks → RoomList.Pinned
This commit is contained in:
parent
13558fd61c
commit
8a6f7c262f
src
backend
config
gui/MainPane
icons/thin
@ -1138,22 +1138,22 @@ class MatrixClient(nio.AsyncClient):
|
||||
response = await super().join(string)
|
||||
return response.room_id
|
||||
|
||||
async def toggle_bookmark(self, room_id: str) -> None:
|
||||
room = self.models[self.user_id, "rooms"][room_id]
|
||||
room.bookmarked = not room.bookmarked
|
||||
async def toggle_room_pin(self, room_id: str) -> None:
|
||||
room = self.models[self.user_id, "rooms"][room_id]
|
||||
room.pinned = not room.pinned
|
||||
|
||||
settings = self.backend.settings
|
||||
bookmarks = settings.RoomList.Bookmarks
|
||||
user_bookmarks = bookmarks.setdefault(self.user_id, [])
|
||||
settings = self.backend.settings
|
||||
pinned = settings.RoomList.Pinned
|
||||
user_pinned = pinned.setdefault(self.user_id, [])
|
||||
|
||||
if room.bookmarked and room_id not in user_bookmarks:
|
||||
user_bookmarks.append(room_id)
|
||||
if room.pinned and room_id not in user_pinned:
|
||||
user_pinned.append(room_id)
|
||||
|
||||
while not room.bookmarked and room_id in user_bookmarks:
|
||||
user_bookmarks.remove(room_id)
|
||||
while not room.pinned and room_id in user_pinned:
|
||||
user_pinned.remove(room_id)
|
||||
|
||||
# Changes inside dicts/lists aren't monitored, need to reassign
|
||||
settings.RoomList.Bookmarks[self.user_id] = user_bookmarks
|
||||
settings.RoomList.Pinned[self.user_id] = user_pinned
|
||||
self.backend.settings.save()
|
||||
|
||||
async def room_forget(self, room_id: str) -> None:
|
||||
@ -2003,7 +2003,7 @@ class MatrixClient(nio.AsyncClient):
|
||||
)
|
||||
unverified_devices = registered.unverified_devices
|
||||
|
||||
bookmarks = self.backend.settings.RoomList.Bookmarks
|
||||
pinned = self.backend.settings.RoomList.Pinned
|
||||
room_item = Room(
|
||||
id = room.room_id,
|
||||
for_account = self.user_id,
|
||||
@ -2049,7 +2049,7 @@ class MatrixClient(nio.AsyncClient):
|
||||
local_unreads = local_unreads,
|
||||
|
||||
lexical_sorting = self.backend.settings.RoomList.lexical_sort,
|
||||
bookmarked = room.room_id in bookmarks.get(self.user_id, []),
|
||||
pinned = room.room_id in pinned.get(self.user_id, []),
|
||||
)
|
||||
|
||||
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
||||
|
@ -171,7 +171,7 @@ class Room(ModelItem):
|
||||
local_unreads: bool = False
|
||||
|
||||
lexical_sorting: bool = False
|
||||
bookmarked: bool = False
|
||||
pinned: bool = False
|
||||
|
||||
def __lt__(self, other: "Room") -> bool:
|
||||
"""Sort by membership, highlights/unread events, last event date, name.
|
||||
@ -186,14 +186,14 @@ class Room(ModelItem):
|
||||
if self.lexical_sorting:
|
||||
return (
|
||||
self.for_account,
|
||||
other.bookmarked,
|
||||
other.pinned,
|
||||
self.left,
|
||||
bool(other.inviter_id),
|
||||
(self.display_name or self.id).lower(),
|
||||
self.id,
|
||||
) < (
|
||||
other.for_account,
|
||||
self.bookmarked,
|
||||
self.pinned,
|
||||
other.left,
|
||||
bool(self.inviter_id),
|
||||
(other.display_name or other.id).lower(),
|
||||
@ -203,7 +203,7 @@ class Room(ModelItem):
|
||||
# Left rooms may still have an inviter_id, so check left first.
|
||||
return (
|
||||
self.for_account,
|
||||
other.bookmarked,
|
||||
other.pinned,
|
||||
self.left,
|
||||
bool(other.inviter_id),
|
||||
bool(other.highlights),
|
||||
@ -215,7 +215,7 @@ class Room(ModelItem):
|
||||
|
||||
) < (
|
||||
other.for_account,
|
||||
self.bookmarked,
|
||||
self.pinned,
|
||||
other.left,
|
||||
bool(self.inviter_id),
|
||||
bool(self.highlights),
|
||||
@ -238,7 +238,7 @@ class AccountOrRoom(Account, Room):
|
||||
self.account_order,
|
||||
self.id if self.type is Account else self.for_account,
|
||||
other.type is Account,
|
||||
other.bookmarked,
|
||||
other.pinned,
|
||||
self.left,
|
||||
bool(other.inviter_id),
|
||||
(self.display_name or self.id).lower(),
|
||||
@ -247,7 +247,7 @@ class AccountOrRoom(Account, Room):
|
||||
other.account_order,
|
||||
other.id if other.type is Account else other.for_account,
|
||||
self.type is Account,
|
||||
self.bookmarked,
|
||||
self.pinned,
|
||||
other.left,
|
||||
bool(self.inviter_id),
|
||||
(other.display_name or other.id).lower(),
|
||||
@ -258,7 +258,7 @@ class AccountOrRoom(Account, Room):
|
||||
self.account_order,
|
||||
self.id if self.type is Account else self.for_account,
|
||||
other.type is Account,
|
||||
other.bookmarked,
|
||||
other.pinned,
|
||||
self.left,
|
||||
bool(other.inviter_id),
|
||||
bool(other.highlights),
|
||||
@ -272,7 +272,7 @@ class AccountOrRoom(Account, Room):
|
||||
other.account_order,
|
||||
other.id if other.type is Account else other.for_account,
|
||||
self.type is Account,
|
||||
self.bookmarked,
|
||||
self.pinned,
|
||||
other.left,
|
||||
bool(self.inviter_id),
|
||||
bool(self.highlights),
|
||||
|
@ -93,7 +93,7 @@ class RoomList:
|
||||
# in addition to focusing the current page or chat composer.
|
||||
escape_clears_filter: bool = True
|
||||
|
||||
class Bookmarks:
|
||||
class Pinned:
|
||||
# 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.
|
||||
|
@ -63,7 +63,8 @@ HTile {
|
||||
|
||||
TitleLabel {
|
||||
text:
|
||||
(model.bookmarked ? "\u2665 " : "") +
|
||||
// U+1f4cc pushpin + force black-and-white variant
|
||||
(model.pinned ? "📌\ufe0e " : "") +
|
||||
(model.display_name || qsTr("Empty room"))
|
||||
color:
|
||||
model.unreads || model.local_unreads ?
|
||||
@ -135,6 +136,14 @@ HTile {
|
||||
}
|
||||
|
||||
contextMenu: HMenu {
|
||||
HMenuItem {
|
||||
icon.name: model.pinned ? "room-unpin": "room-pin"
|
||||
text: model.pinned ? qsTr("Unpin"): qsTr("Pin to top")
|
||||
onTriggered: py.callClientCoro(
|
||||
model.for_account, "toggle_room_pin", [model.id]
|
||||
)
|
||||
}
|
||||
|
||||
HMenuItemPopupSpawner {
|
||||
visible: joined
|
||||
enabled: model.can_invite && accountModel.presence !== "offline"
|
||||
@ -150,14 +159,6 @@ HTile {
|
||||
})
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: model.bookmarked ? "bookmark-remove": "bookmark-add"
|
||||
text: model.bookmarked ? qsTr("Remove bookmark"): qsTr("Bookmark")
|
||||
onTriggered: py.callClientCoro(
|
||||
model.for_account, "toggle_bookmark", [model.id]
|
||||
)
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "copy-room-id"
|
||||
text: qsTr("Copy room ID")
|
||||
|
3
src/icons/thin/room-pin.svg
Normal file
3
src/icons/thin/room-pin.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m11 17h2v5l-2 2zm7-2h-12c0-3.128.091-4.744 1.874-7.276.551-.783.915-1.3.915-2.373 0-2.372-1.789-1.695-1.789-5.351h10c0 3.616-1.789 3.005-1.789 5.35 0 1.073.364 1.59.915 2.374 1.785 2.535 1.874 4.154 1.874 7.276zm-9.968-2h7.936c-.298-4.376-2.756-4.142-2.756-7.649-.001-1.605.521-2.351 1.271-3.351h-4.966c.75 1 1.272 1.745 1.272 3.35 0 3.487-2.46 3.29-2.757 7.65z"/>
|
||||
</svg>
|
After (image error) Size: 469 B |
3
src/icons/thin/room-unpin.svg
Normal file
3
src/icons/thin/room-unpin.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m11 17h2v5l-2 2zm7-2h-12c0-3.128.091-4.744 1.874-7.276.551-.783.915-1.3.915-2.373 0-2.372-1.789-1.695-1.789-5.351h10c0 3.616-1.789 3.005-1.789 5.35 0 1.073.364 1.59.915 2.374 1.785 2.535 1.874 4.154 1.874 7.276zm-9.968-2h7.936c-.298-4.376-2.756-4.142-2.756-7.649-.001-1.605.521-2.351 1.271-3.351h-4.966c.75 1 1.272 1.745 1.272 3.35 0 3.487-2.46 3.29-2.757 7.65z"/>
|
||||
</svg>
|
After (image error) Size: 469 B |
Loading…
Reference in New Issue
Block a user