mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 20:27:46 +00:00
SoundPlayer: Add option to hide scope
Fixes #521. The scope can be hidden using the option in the app menu.
This commit is contained in:
parent
56cd8b4d17
commit
b4c18870de
3 changed files with 21 additions and 5 deletions
|
@ -26,7 +26,11 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConne
|
|||
m_elapsed->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
m_elapsed->set_preferred_size(80, 0);
|
||||
|
||||
m_sample_widget = SampleWidget::construct(status_widget);
|
||||
auto sample_widget_container = GWidget::construct(status_widget.ptr());
|
||||
sample_widget_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
sample_widget_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
|
||||
m_sample_widget = SampleWidget::construct(sample_widget_container);
|
||||
|
||||
m_remaining = GLabel::construct(status_widget);
|
||||
m_remaining->set_frame_shape(FrameShape::Container);
|
||||
|
@ -82,6 +86,11 @@ SoundPlayerWidget::Slider::~Slider()
|
|||
{
|
||||
}
|
||||
|
||||
void SoundPlayerWidget::hide_scope(bool hide)
|
||||
{
|
||||
m_sample_widget->set_visible(!hide);
|
||||
}
|
||||
|
||||
void SoundPlayerWidget::open_file(String path)
|
||||
{
|
||||
if (!path.ends_with(".wav")) {
|
||||
|
|
|
@ -13,6 +13,7 @@ class SoundPlayerWidget final : public GWidget {
|
|||
public:
|
||||
virtual ~SoundPlayerWidget() override;
|
||||
void open_file(String path);
|
||||
void hide_scope(bool);
|
||||
PlaybackManager& manager() { return m_manager; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "SoundPlayerWidget.h"
|
||||
#include <LibAudio/AClientConnection.h>
|
||||
#include <LibDraw/CharacterBitmap.h>
|
||||
#include <LibGUI/GAboutDialog.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GFilePicker.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GAboutDialog.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -33,24 +33,30 @@ int main(int argc, char** argv)
|
|||
player->manager().play();
|
||||
}
|
||||
|
||||
auto hide_scope = GAction::create("Hide scope", [&](GAction& action) {
|
||||
action.set_checked(!action.is_checked());
|
||||
player->hide_scope(action.is_checked());
|
||||
});
|
||||
hide_scope->set_checkable(true);
|
||||
|
||||
app_menu->add_action(GCommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> path = GFilePicker::get_open_filepath("Open wav file...");
|
||||
if (path.has_value()) {
|
||||
player->open_file(path.value());
|
||||
}
|
||||
}));
|
||||
|
||||
app_menu->add_action(move(hide_scope));
|
||||
app_menu->add_separator();
|
||||
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
|
||||
app.quit();
|
||||
}));
|
||||
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto help_menu = make<GMenu>("Help");
|
||||
help_menu->add_action(GAction::create("About", [](auto&) {
|
||||
GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png"));
|
||||
}));
|
||||
|
||||
menubar->add_menu(move(app_menu));
|
||||
menubar->add_menu(move(help_menu));
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue