diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-17 15:05:24 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2017-04-17 15:05:24 +0200 |
commit | 2c0fc6f4087442079051c2df1fff7d8fa2ac7b19 (patch) | |
tree | 7cd42fd69fa76c263947e95bc2fc2da148269543 | |
parent | c59680b1d613187209358951589d022d65c6eaa6 (diff) |
Connect drumkit and midimap files as well as loading/status bare updates.
-rw-r--r-- | plugingui/drumkitframecontent.cc | 105 | ||||
-rw-r--r-- | plugingui/drumkitframecontent.h | 20 | ||||
-rw-r--r-- | plugingui/maintab.cc | 6 | ||||
-rw-r--r-- | plugingui/maintab.h | 15 | ||||
-rw-r--r-- | plugingui/mainwindow.cc | 6 | ||||
-rw-r--r-- | plugingui/mainwindow.h | 8 |
6 files changed, 122 insertions, 38 deletions
diff --git a/plugingui/drumkitframecontent.cc b/plugingui/drumkitframecontent.cc index c2e35b6..f767a00 100644 --- a/plugingui/drumkitframecontent.cc +++ b/plugingui/drumkitframecontent.cc @@ -26,6 +26,8 @@ */ #include "drumkitframecontent.h" +#include <settings.h> + #include "label.h" namespace GUI @@ -76,8 +78,12 @@ LineEdit& BrowseFile::getLineEdit() return lineedit; } -DrumkitframeContent::DrumkitframeContent(Widget* parent) +DrumkitframeContent::DrumkitframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier) : Widget(parent) + , settings{settings} + , settings_notifier{settings_notifier} { layout.setHAlignment(HAlignment::left); @@ -85,18 +91,36 @@ DrumkitframeContent::DrumkitframeContent(Widget* parent) midimapCaption.setText("Midimap file:"); layout.addItem(&drumkitCaption); - layout.addItem(&drumkitFile); - layout.addItem(&drumkitFileProgress); + layout.addItem(&drumkit_file); + layout.addItem(&drumkit_file_progress); layout.addItem(&midimapCaption); - layout.addItem(&midimapFile); - layout.addItem(&midimapFileProgress); + layout.addItem(&midimap_file); + layout.addItem(&midimap_file_progress); - CONNECT(&drumkitFile.getBrowseButton(), clickNotifier, + CONNECT(&drumkit_file.getBrowseButton(), clickNotifier, this, &DrumkitframeContent::kitBrowseClick); - CONNECT(&midimapFile.getBrowseButton(), clickNotifier, + + CONNECT(&midimap_file.getBrowseButton(), clickNotifier, this, &DrumkitframeContent::midimapBrowseClick); - midimapFileProgress.setTotal(2); + + CONNECT(this, settings_notifier.drumkit_file, + &drumkit_file.getLineEdit(), &LineEdit::setText); + CONNECT(this, settings_notifier.drumkit_load_status, + this, &DrumkitframeContent::setDrumKitLoadStatus); + + CONNECT(this, settings_notifier.midimap_file, + &midimap_file.getLineEdit(), &LineEdit::setText); + CONNECT(this, settings_notifier.midimap_load_status, + this, &DrumkitframeContent::setMidiMapLoadStatus); + + CONNECT(this, settings_notifier.number_of_files, + &drumkit_file_progress, &ProgressBar::setTotal); + + CONNECT(this, settings_notifier.number_of_files_loaded, + &drumkit_file_progress, &ProgressBar::setValue); + + midimap_file_progress.setTotal(2); file_browser.resize(450, 350); file_browser.setFixedSize(450, 350); @@ -107,12 +131,12 @@ void DrumkitframeContent::resize(std::size_t width, std::size_t height) Widget::resize(width, height); drumkitCaption.resize(width, 15); - drumkitFile.resize(width, 37); - drumkitFileProgress.resize(drumkitFile.getLineEditWidth(), 11); + drumkit_file.resize(width, 37); + drumkit_file_progress.resize(drumkit_file.getLineEditWidth(), 11); midimapCaption.resize(width, 15); - midimapFile.resize(width, 37); - midimapFileProgress.resize(drumkitFile.getLineEditWidth(), 11); + midimap_file.resize(width, 37); + midimap_file_progress.resize(drumkit_file.getLineEditWidth(), 11); layout.layout(); } @@ -133,28 +157,65 @@ void DrumkitframeContent::midimapBrowseClick() void DrumkitframeContent::selectKitFile(const std::string& filename) { - auto& line_edit = drumkitFile.getLineEdit(); - line_edit.setText(filename); - // TODO: //config.lastkit = drumkit; //config.save(); - // TODO: - //settings.drumkit_file.store(drumkit); + settings.drumkit_file.store(filename); } void DrumkitframeContent::selectMapFile(const std::string& filename) { - auto& line_edit = midimapFile.getLineEdit(); - line_edit.setText(filename); - // TODO: //config.lastmidimap = midimap; //config.save(); - // TODO: - //settings.midimap_file.store(midimap); + settings.midimap_file.store(filename); +} + +void DrumkitframeContent::setDrumKitLoadStatus(LoadStatus load_status) +{ + ProgressBarState state = ProgressBarState::Blue; + switch(load_status) + { + case LoadStatus::Idle: + case LoadStatus::Loading: + state = ProgressBarState::Blue; + break; + case LoadStatus::Done: + state = ProgressBarState::Green; + break; + case LoadStatus::Error: + state = ProgressBarState::Red; + break; + } + + drumkit_file_progress.setState(state); +} + +void DrumkitframeContent::setMidiMapLoadStatus(LoadStatus load_status) +{ + ProgressBarState state = ProgressBarState::Blue; + switch(load_status) + { + case LoadStatus::Idle: + midimap_file_progress.setValue(0); + break; + case LoadStatus::Loading: + midimap_file_progress.setValue(1); + state = ProgressBarState::Blue; + break; + case LoadStatus::Done: + midimap_file_progress.setValue(2); + state = ProgressBarState::Green; + break; + case LoadStatus::Error: + midimap_file_progress.setValue(2); + state = ProgressBarState::Red; + break; + } + + midimap_file_progress.setState(state); } } // GUI:: diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h index 7f442c5..143284c 100644 --- a/plugingui/drumkitframecontent.h +++ b/plugingui/drumkitframecontent.h @@ -26,6 +26,8 @@ */ #pragma once +#include <settings.h> + #include "button.h" #include "label.h" #include "lineedit.h" @@ -65,7 +67,9 @@ class DrumkitframeContent : public Widget { public: - DrumkitframeContent(Widget* parent); + DrumkitframeContent(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier); // From Widget virtual void resize(std::size_t width, std::size_t height) override; @@ -77,16 +81,22 @@ private: void selectKitFile(const std::string& filename); void selectMapFile(const std::string& filename); + void setDrumKitLoadStatus(LoadStatus load_status); + void setMidiMapLoadStatus(LoadStatus load_status); + VBoxLayout layout{this}; Label drumkitCaption{this}; Label midimapCaption{this}; - BrowseFile drumkitFile{this}; - BrowseFile midimapFile{this}; - ProgressBar drumkitFileProgress{this}; - ProgressBar midimapFileProgress{this}; + BrowseFile drumkit_file{this}; + BrowseFile midimap_file{this}; + ProgressBar drumkit_file_progress{this}; + ProgressBar midimap_file_progress{this}; FileBrowser file_browser{this}; + + Settings& settings; + SettingsNotifier& settings_notifier; }; } // GUI:: diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index f328076..bed26ba 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -29,7 +29,11 @@ namespace GUI { -MainTab::MainTab(Widget* parent) : Widget(parent) +MainTab::MainTab(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier) + : Widget(parent) + , drumkitframe_content{this, settings, settings_notifier} { layout.setSpacing(0); layout.setResizeChildren(true); diff --git a/plugingui/maintab.h b/plugingui/maintab.h index 9be489b..ba0648c 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -34,12 +34,19 @@ #include "humanizerframecontent.h" #include "diskstreamingframecontent.h" -namespace GUI { +class Settings; +class SettingsNotifier; -class MainTab : public Widget +namespace GUI +{ + +class MainTab + : public Widget { public: - MainTab(Widget* parent); + MainTab(Widget* parent, + Settings& settings, + SettingsNotifier& settings_notifier); private: GridLayout layout{this, 2, 40}; @@ -49,7 +56,7 @@ private: FrameWidget humanizer_frame{this, true}; FrameWidget diskstreaming_frame{this, true}; - DrumkitframeContent drumkitframe_content{this}; + DrumkitframeContent drumkitframe_content; StatusframeContent statusframe_content{this}; HumanizerframeContent humanizerframe_content{this}; DiskstreamingframeContent diskstreamingframe_content{this}; diff --git a/plugingui/mainwindow.cc b/plugingui/mainwindow.cc index 5c757be..82d98df 100644 --- a/plugingui/mainwindow.cc +++ b/plugingui/mainwindow.cc @@ -38,7 +38,9 @@ namespace GUI MainWindow::MainWindow(Settings& settings, void* native_window) : Window(native_window) - , settings(settings) + , settings{settings} + , settings_notifier{settings} + , main_tab{this, settings, settings_notifier} { CONNECT(this, sizeChangeNotifier, this, &MainWindow::sizeChanged); CONNECT(eventHandler(), closeNotifier, this, &MainWindow::closeEventHandler); @@ -94,7 +96,7 @@ void MainWindow::repaintEvent(RepaintEvent* repaintEvent) // DrumGizmo logo painter.drawImage(width() - logo.width() - 16, height() - logo.height() - 10, logo); - + // DrumGizmo version std::string version_string("v." + std::string(VERSION)); auto version_x = width() - font.textWidth(version_string) - sidebar.width() - 5; diff --git a/plugingui/mainwindow.h b/plugingui/mainwindow.h index 8a2f141..93ff416 100644 --- a/plugingui/mainwindow.h +++ b/plugingui/mainwindow.h @@ -62,7 +62,10 @@ private: TabWidget tabs{this}; - MainTab main_tab{this}; + Settings& settings; + SettingsNotifier settings_notifier{settings}; + + MainTab main_tab; // TODO use some nice textfield widget here TextEdit gpl_text_field{&tabs}; @@ -81,9 +84,6 @@ private: bool closing{false}; - Settings& settings; - SettingsNotifier settings_notifier{settings}; - Resource gpl{":../../COPYING"}; Font font; |