diff --git a/cozy/ui/library_view.py b/cozy/ui/library_view.py index c593c7a2..71c01a91 100644 --- a/cozy/ui/library_view.py +++ b/cozy/ui/library_view.py @@ -105,6 +105,10 @@ def populate_reader(self): self._reader_box.populate(self._view_model.readers) def _on_library_view_mode_changed(self): + self.refresh_filters() + self._navigation_view.pop_to_tag("main") + + def refresh_filters(self): visible_child_name = None active_filter_box: Gtk.ListBox = None @@ -130,7 +134,6 @@ def _on_library_view_mode_changed(self): self._main_stack.props.visible_child_name = main_view_page self._filter_stack.set_visible_child_name(visible_child_name) self._book_stack.set_visible_child_name(books_view_page) - self._navigation_view.pop_to_tag("main") if active_filter_box: self._apply_selected_filter(active_filter_box.get_selected_row()) diff --git a/cozy/ui/main_view.py b/cozy/ui/main_view.py index 7807eaaf..c926b688 100644 --- a/cozy/ui/main_view.py +++ b/cozy/ui/main_view.py @@ -91,6 +91,7 @@ def __init_actions(self): Init all app actions. """ self.create_action("about", self.show_about_window, ["F1"]) + self.create_action("reset_book", self.reset_book) self.create_action("remove_book", self.remove_book) self.create_action("mark_book_as_read", self.mark_book_as_read) self.create_action("jump_to_book_folder", self.jump_to_book_folder) @@ -130,6 +131,14 @@ def create_action( return action + def refresh_library_filters(self): + self._library_view.refresh_filters() + + def reset_book(self, *_) -> None: + if self.app.selected_book is not None: + self.app.selected_book.reset() + self.refresh_library_filters() + def remove_book(self, *_) -> None: if self.app.selected_book is not None: self.app.selected_book.remove() diff --git a/cozy/ui/widgets/book_card.py b/cozy/ui/widgets/book_card.py index 9dd47bbd..cfcb75ca 100644 --- a/cozy/ui/widgets/book_card.py +++ b/cozy/ui/widgets/book_card.py @@ -118,6 +118,9 @@ def set_playing(self, is_playing): def update_progress(self): self.play_button.progress = self.book.progress / self.book.duration + def reset(self) -> None: + self.book.last_played = 0 + def remove(self) -> None: self.emit("remove-book", self.book) diff --git a/data/ui/book_card.blp b/data/ui/book_card.blp index 94d87249..49694d70 100644 --- a/data/ui/book_card.blp +++ b/data/ui/book_card.blp @@ -11,14 +11,14 @@ template $BookCard: FlowBoxChild { valign: end; halign: end; - $BookElementPlayButton play_button { + $BookCardPlayButton play_button { width-request: 54; height-request: 54; margin-end: 18; margin-bottom: 18; focusable: true; focus-on-click: false; - icon_name: "media-playback-start-symbolic"; + icon-name: "media-playback-start-symbolic"; tooltip-text: _("Start/Stop playback"); clicked => $_play_pause(); @@ -128,6 +128,11 @@ menu book_menu { label: _("Mark as Read"); } + item { + action: 'app.reset_book'; + label: _("Remove from Recents"); + } + item { action: 'app.jump_to_book_folder'; label: _("Open in Files");