diff options
author | Thitat Auareesuksakul <thitat@fluxthitat.me> | 2021-09-02 19:23:28 +0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-04 03:33:35 +0200 |
commit | 8d36893ddfb795855507fa84f27e5364a0239226 (patch) | |
tree | 675fa1ed371ba8e244b86595b46785672b2f11b9 | |
parent | 8f2521ce52abe384b67ee2693aeb1f3816dc2148 (diff) | |
download | serenity-8d36893ddfb795855507fa84f27e5364a0239226.zip |
SoundPlayer: Add spacebar keyboard shortcut for play/pause
-rw-r--r-- | Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp | 9 | ||||
-rw-r--r-- | Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index e6eba8c455..47ec452630 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com> + * Copyright (c) 2021, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -236,6 +237,14 @@ void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event) } } +void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event) +{ + if (event.key() == Key_Space) + m_play_button->click(); + + GUI::Widget::keydown_event(event); +} + SoundPlayerWidgetAdvancedView::~SoundPlayerWidgetAdvancedView() { manager().on_load_sample_buffer = nullptr; diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h index feec4bbfdb..5f2b91d2d8 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com> + * Copyright (c) 2021, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -40,6 +41,9 @@ public: m_visualization = new_visualization; } +protected: + void keydown_event(GUI::KeyEvent&) override; + private: void drop_event(GUI::DropEvent& event) override; GUI::Window& m_window; |