mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:07:35 +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_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||||
m_elapsed->set_preferred_size(80, 0);
|
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 = GLabel::construct(status_widget);
|
||||||
m_remaining->set_frame_shape(FrameShape::Container);
|
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)
|
void SoundPlayerWidget::open_file(String path)
|
||||||
{
|
{
|
||||||
if (!path.ends_with(".wav")) {
|
if (!path.ends_with(".wav")) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ class SoundPlayerWidget final : public GWidget {
|
||||||
public:
|
public:
|
||||||
virtual ~SoundPlayerWidget() override;
|
virtual ~SoundPlayerWidget() override;
|
||||||
void open_file(String path);
|
void open_file(String path);
|
||||||
|
void hide_scope(bool);
|
||||||
PlaybackManager& manager() { return m_manager; }
|
PlaybackManager& manager() { return m_manager; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#include "SoundPlayerWidget.h"
|
#include "SoundPlayerWidget.h"
|
||||||
#include <LibAudio/AClientConnection.h>
|
#include <LibAudio/AClientConnection.h>
|
||||||
#include <LibDraw/CharacterBitmap.h>
|
#include <LibDraw/CharacterBitmap.h>
|
||||||
|
#include <LibGUI/GAboutDialog.h>
|
||||||
#include <LibGUI/GAction.h>
|
#include <LibGUI/GAction.h>
|
||||||
#include <LibGUI/GApplication.h>
|
#include <LibGUI/GApplication.h>
|
||||||
#include <LibGUI/GFilePicker.h>
|
#include <LibGUI/GFilePicker.h>
|
||||||
#include <LibGUI/GMenu.h>
|
#include <LibGUI/GMenu.h>
|
||||||
#include <LibGUI/GMenuBar.h>
|
#include <LibGUI/GMenuBar.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
#include <LibGUI/GAboutDialog.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -33,24 +33,30 @@ int main(int argc, char** argv)
|
||||||
player->manager().play();
|
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&) {
|
app_menu->add_action(GCommonActions::make_open_action([&](auto&) {
|
||||||
Optional<String> path = GFilePicker::get_open_filepath("Open wav file...");
|
Optional<String> path = GFilePicker::get_open_filepath("Open wav file...");
|
||||||
if (path.has_value()) {
|
if (path.has_value()) {
|
||||||
player->open_file(path.value());
|
player->open_file(path.value());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
app_menu->add_action(move(hide_scope));
|
||||||
app_menu->add_separator();
|
app_menu->add_separator();
|
||||||
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
|
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
|
||||||
app.quit();
|
app.quit();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
menubar->add_menu(move(app_menu));
|
|
||||||
|
|
||||||
auto help_menu = make<GMenu>("Help");
|
auto help_menu = make<GMenu>("Help");
|
||||||
help_menu->add_action(GAction::create("About", [](auto&) {
|
help_menu->add_action(GAction::create("About", [](auto&) {
|
||||||
GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png"));
|
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));
|
menubar->add_menu(move(help_menu));
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue