summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Mayer <till.mayer@web.de>2019-11-09 18:03:12 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-09 20:55:47 +0100
commitb4c18870de1f2d819c553c941e243372eeca5195 (patch)
tree337f4ad149178502216eeed98721014817e881a1
parent56cd8b4d179a9f7cebdc8d52a8a1c051aec06a17 (diff)
downloadserenity-b4c18870de1f2d819c553c941e243372eeca5195.zip
SoundPlayer: Add option to hide scope
Fixes #521. The scope can be hidden using the option in the app menu.
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.cpp11
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.h1
-rw-r--r--Applications/SoundPlayer/main.cpp14
3 files changed, 21 insertions, 5 deletions
diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp
index 28776ba274..2dfb4f44ac 100644
--- a/Applications/SoundPlayer/SoundPlayerWidget.cpp
+++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp
@@ -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")) {
diff --git a/Applications/SoundPlayer/SoundPlayerWidget.h b/Applications/SoundPlayer/SoundPlayerWidget.h
index 6f144a5af2..f4c3b8b78e 100644
--- a/Applications/SoundPlayer/SoundPlayerWidget.h
+++ b/Applications/SoundPlayer/SoundPlayerWidget.h
@@ -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:
diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp
index f2699b969c..410b31fd8a 100644
--- a/Applications/SoundPlayer/main.cpp
+++ b/Applications/SoundPlayer/main.cpp
@@ -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));