summaryrefslogtreecommitdiff
path: root/plugingui/drumkitframecontent.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-17 10:17:48 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-17 10:17:48 +0200
commit33fbeeb2ec7c308fc48fc7ef0df01cd4a3a43f0c (patch)
tree123f847e883764bd9aea711ca87e81b5951d7aef /plugingui/drumkitframecontent.cc
parent7d58f10c8034b779d752028ec3b5dcbce848c661 (diff)
Open FileBrowser with Browse buttons and read back result to LieEdit.
Diffstat (limited to 'plugingui/drumkitframecontent.cc')
-rw-r--r--plugingui/drumkitframecontent.cc98
1 files changed, 92 insertions, 6 deletions
diff --git a/plugingui/drumkitframecontent.cc b/plugingui/drumkitframecontent.cc
index 3a87fbe..a2d7765 100644
--- a/plugingui/drumkitframecontent.cc
+++ b/plugingui/drumkitframecontent.cc
@@ -31,6 +31,51 @@
namespace GUI
{
+File::File(Widget* parent)
+ : Widget(parent)
+{
+ layout.setResizeChildren(false);
+ layout.setVAlignment(VAlignment::center);
+
+ layout.addItem(&lineedit);
+ layout.addItem(&browse_button);
+
+ browse_button.setText("Browse...");
+}
+
+void File::resize(std::size_t width, std::size_t height)
+{
+ Widget::resize(width, height);
+
+ lineedit_width = 0.72 * width;
+ button_width = width - lineedit_width;
+
+ lineedit.resize(lineedit_width, 29);
+ browse_button.resize(button_width, 30);
+
+ layout.layout();
+}
+
+std::size_t File::getLineEditWidth()
+{
+ return lineedit_width;
+}
+
+std::size_t File::getButtonWidth()
+{
+ return button_width;
+}
+
+Button& File::getBrowseButton()
+{
+ return browse_button;
+}
+
+LineEdit& File::getLineEdit()
+{
+ return lineedit;
+}
+
DrumkitframeContent::DrumkitframeContent(Widget* parent) : Widget(parent)
{
layout.setHAlignment(HAlignment::left);
@@ -45,14 +90,15 @@ DrumkitframeContent::DrumkitframeContent(Widget* parent) : Widget(parent)
layout.addItem(&midimapFile);
layout.addItem(&midimapFileProgress);
- // TODO:
- // CONNECT(&drumkitFile.browseButton, clickNotifier,
- // this, &DGWindow::kitBrowseClick);
- // TODO:
- // CONNECT(&midimapFile.browseButton, clickNotifier,
- // this, &DGWindow::midimapBrowseClick);
+ CONNECT(&drumkitFile.getBrowseButton(), clickNotifier,
+ this, &DrumkitframeContent::kitBrowseClick);
+ CONNECT(&midimapFile.getBrowseButton(), clickNotifier,
+ this, &DrumkitframeContent::midimapBrowseClick);
midimapFileProgress.setTotal(2);
+
+ file_browser.resize(450, 350);
+ file_browser.setFixedSize(450, 350);
}
void DrumkitframeContent::resize(std::size_t width, std::size_t height)
@@ -70,4 +116,44 @@ void DrumkitframeContent::resize(std::size_t width, std::size_t height)
layout.layout();
}
+void DrumkitframeContent::kitBrowseClick()
+{
+ CONNECT(&file_browser, fileSelectNotifier,
+ this, &DrumkitframeContent::selectKitFile);
+ file_browser.show();
+}
+
+void DrumkitframeContent::midimapBrowseClick()
+{
+ CONNECT(&file_browser, fileSelectNotifier,
+ this, &DrumkitframeContent::selectMapFile);
+ file_browser.show();
+}
+
+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);
+}
+
+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);
+}
+
} // GUI::