diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-01-15 23:10:26 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-16 08:28:11 +0100 |
commit | 07f0873531d7c8f1138d83d4e43106e2ab8d50a4 (patch) | |
tree | 93c01d9c604fcc5bc1e722de38437c09ed00ba62 /Userland/Applications | |
parent | 2372b3b8f9b6ff54e2be0593b4757a55ddee15af (diff) | |
download | serenity-07f0873531d7c8f1138d83d4e43106e2ab8d50a4.zip |
Presenter: Disable "Next" and "Previous" actions when non-applicable
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Presenter/PresenterWidget.cpp | 11 | ||||
-rw-r--r-- | Userland/Applications/Presenter/PresenterWidget.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Applications/Presenter/PresenterWidget.cpp b/Userland/Applications/Presenter/PresenterWidget.cpp index 83de69b6c6..b31c7852bc 100644 --- a/Userland/Applications/Presenter/PresenterWidget.cpp +++ b/Userland/Applications/Presenter/PresenterWidget.cpp @@ -71,12 +71,14 @@ ErrorOr<void> PresenterWidget::initialize_menubar() if (m_current_presentation) { m_current_presentation->next_frame(); update_web_view(); + update_slides_actions(); } }); auto previous_slide_action = GUI::Action::create("&Previous", { KeyCode::Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [this](auto&) { if (m_current_presentation) { m_current_presentation->previous_frame(); update_web_view(); + update_slides_actions(); } }); TRY(presentation_menu.try_add_action(next_slide_action)); @@ -103,6 +105,14 @@ void PresenterWidget::update_web_view() m_web_view->run_javascript(DeprecatedString::formatted("goto({}, {})", m_current_presentation->current_slide_number(), m_current_presentation->current_frame_in_slide_number())); } +void PresenterWidget::update_slides_actions() +{ + if (m_current_presentation) { + m_next_slide_action->set_enabled(m_current_presentation->has_a_next_frame()); + m_previous_slide_action->set_enabled(m_current_presentation->has_a_previous_frame()); + } +} + void PresenterWidget::set_file(StringView file_name) { auto presentation = Presentation::load_from_file(file_name); @@ -113,6 +123,7 @@ void PresenterWidget::set_file(StringView file_name) window()->set_title(DeprecatedString::formatted(title_template, m_current_presentation->title(), m_current_presentation->author())); set_min_size(m_current_presentation->normative_size()); m_web_view->load_html(MUST(m_current_presentation->render()), "presenter://slide.html"sv); + update_slides_actions(); } } diff --git a/Userland/Applications/Presenter/PresenterWidget.h b/Userland/Applications/Presenter/PresenterWidget.h index e2b731f27b..28d7c62437 100644 --- a/Userland/Applications/Presenter/PresenterWidget.h +++ b/Userland/Applications/Presenter/PresenterWidget.h @@ -39,6 +39,7 @@ protected: private: void update_web_view(); + void update_slides_actions(); RefPtr<WebView::OutOfProcessWebView> m_web_view; |