summaryrefslogtreecommitdiff
path: root/plugingui
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
parent7d58f10c8034b779d752028ec3b5dcbce848c661 (diff)
Open FileBrowser with Browse buttons and read back result to LieEdit.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/drumkitframecontent.cc98
-rw-r--r--plugingui/drumkitframecontent.h56
-rw-r--r--plugingui/filebrowser.cc2
3 files changed, 113 insertions, 43 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::
diff --git a/plugingui/drumkitframecontent.h b/plugingui/drumkitframecontent.h
index 41dc01b..c2e515d 100644
--- a/plugingui/drumkitframecontent.h
+++ b/plugingui/drumkitframecontent.h
@@ -31,47 +31,25 @@
#include "lineedit.h"
#include "progressbar.h"
#include "widget.h"
+#include "filebrowser.h"
namespace GUI
{
-// TODO: move to own class?
-class File : public Widget
+class File
+ : public Widget
{
public:
- File(Widget* parent) : Widget(parent)
- {
- layout.setResizeChildren(false);
- layout.setVAlignment(VAlignment::center);
-
- layout.addItem(&lineedit);
- layout.addItem(&browse_button);
-
- browse_button.setText("Browse...");
- }
+ File(Widget* parent);
// From Widget
- virtual void resize(std::size_t width, std::size_t height) override
- {
- 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);
+ virtual void resize(std::size_t width, std::size_t height) override;
- layout.layout();
- }
+ std::size_t getLineEditWidth();
+ std::size_t getButtonWidth();
- std::size_t getLineEditWidth()
- {
- return lineedit_width;
- }
- std::size_t getButtonWidth()
- {
- return button_width;
- }
+ Button& getBrowseButton();
+ LineEdit& getLineEdit();
private:
HBoxLayout layout{this};
@@ -81,14 +59,10 @@ private:
std::size_t lineedit_width;
std::size_t button_width;
-
- LineEdit& getLineEdit()
- {
- return lineedit;
- }
};
-class DrumkitframeContent : public Widget
+class DrumkitframeContent
+ : public Widget
{
public:
DrumkitframeContent(Widget* parent);
@@ -96,7 +70,13 @@ public:
// From Widget
virtual void resize(std::size_t width, std::size_t height) override;
+ void kitBrowseClick();
+ void midimapBrowseClick();
+
private:
+ void selectKitFile(const std::string& filename);
+ void selectMapFile(const std::string& filename);
+
VBoxLayout layout{this};
Label drumkitCaption{this};
@@ -105,6 +85,8 @@ private:
File midimapFile{this};
ProgressBar drumkitFileProgress{this};
ProgressBar midimapFileProgress{this};
+
+ FileBrowser file_browser{this};
};
} // GUI::
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 3d3df99..d77a6bf 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -71,6 +71,8 @@ FileBrowser::FileBrowser(Widget* parent)
this, &FileBrowser::listSelectionChanged);
CONNECT(this, fileSelectNotifier,
this, &FileBrowser::select);
+ CONNECT(eventHandler(), closeNotifier,
+ this, &FileBrowser::cancel);
btn_sel.setText("Select");
CONNECT(&btn_sel, clickNotifier, this, &FileBrowser::selectButtonClicked);