From cce58a93617507a4f2e6927de4445e30b7b46617 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 17 Apr 2017 17:44:05 +0200 Subject: Connected streaming controls. --- plugingui/diskstreamingframecontent.cc | 47 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'plugingui/diskstreamingframecontent.cc') diff --git a/plugingui/diskstreamingframecontent.cc b/plugingui/diskstreamingframecontent.cc index bb4cfc3..53e2c9d 100644 --- a/plugingui/diskstreamingframecontent.cc +++ b/plugingui/diskstreamingframecontent.cc @@ -26,19 +26,41 @@ */ #include "diskstreamingframecontent.h" +#include + namespace GUI { -DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent) - : Widget(parent), slider_width{250} +DiskstreamingframeContent::DiskstreamingframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier) + : Widget(parent) + , slider_width{250} + , settings(settings) + , settings_notifier(settings_notifier) { label_text.setText("Cache limit (max memory usage):"); label_text.setAlignment(TextAlignment::center); button.setText("Apply"); // TODO connect - label_size.setText("600 MB"); // TODO connect + label_size.setText("0 MB"); label_size.setAlignment(TextAlignment::center); + + CONNECT(this, settings_notifier.disk_cache_upper_limit, + this, &DiskstreamingframeContent::limitSettingsValueChanged); + + CONNECT(&slider, valueChangedNotifier, + this, &DiskstreamingframeContent::limitValueChanged); + + CONNECT(&button, clickNotifier, + this, &DiskstreamingframeContent::reloadClicked); + + // TODO: + // CONNECT(this, settings_notifier.disk_cache_chunk_size, + // this, &DGWindow::chunkSettingsValueChanged); + // CONNECT(this, settings_notifier.number_of_underruns, + // this, &DGWindow::underrunsChanged); } void DiskstreamingframeContent::resize(std::size_t width, std::size_t height) @@ -59,4 +81,23 @@ void DiskstreamingframeContent::resize(std::size_t width, std::size_t height) label_size.resize(slider_width, 15); } +void DiskstreamingframeContent::limitSettingsValueChanged(float value) +{ + char buf[32]; + snprintf(buf, sizeof(buf) - 1, "%.2f MB", value / (1024 * 1024)); + label_size.setText(buf); + slider.setValue(value); +} + +void DiskstreamingframeContent::limitValueChanged(float value) +{ + settings.disk_cache_upper_limit.store(value); +} + +void DiskstreamingframeContent::reloadClicked() +{ + settings.reload_counter++; +} + + } // GUI:: -- cgit v1.2.3