From c52d7708d801fe63c1eb3b12b7dfc1c27d3d3a68 Mon Sep 17 00:00:00 2001 From: apoorv569 Date: Thu, 4 Nov 2021 19:16:58 +0530 Subject: [PATCH] Refactoring, organizing files in directories. Add directory watcher, removed unnecessary calls to settings dialog. --- meson.build | 26 +- src/App.cpp | 10 + src/App.hpp | 3 +- src/{ => Database}/Database.cpp | 44 +- src/{ => Database}/Database.hpp | 2 +- .../Dialogs/Settings.cpp} | 196 +++--- .../Dialogs/Settings.hpp} | 23 +- .../Dialogs/TagEditor.cpp} | 6 +- .../Dialogs/TagEditor.hpp} | 2 +- src/{ => GUI}/MainFrame.cpp | 652 +++++++++++------- src/{ => GUI}/MainFrame.hpp | 11 +- src/{ => GUI}/WaveformViewer.cpp | 26 +- src/{ => GUI}/WaveformViewer.hpp | 5 +- src/{ => Utility}/ControlID_Enums.hpp | 1 + src/{ => Utility}/SH_Event.cpp | 22 +- src/{ => Utility}/SH_Event.hpp | 20 + src/{ => Utility}/Sample.cpp | 33 +- src/{ => Utility}/Sample.hpp | 37 +- src/{ => Utility}/Serialize.cpp | 296 +++++--- src/{ => Utility}/Serialize.hpp | 45 +- src/{ => Utility}/Tags.cpp | 2 +- src/{ => Utility}/Tags.hpp | 0 22 files changed, 861 insertions(+), 601 deletions(-) rename src/{ => Database}/Database.cpp (96%) rename src/{ => Database}/Database.hpp (99%) rename src/{SettingsDialog.cpp => GUI/Dialogs/Settings.cpp} (69%) rename src/{SettingsDialog.hpp => GUI/Dialogs/Settings.hpp} (87%) rename src/{TagEditorDialog.cpp => GUI/Dialogs/TagEditor.cpp} (99%) rename src/{TagEditorDialog.hpp => GUI/Dialogs/TagEditor.hpp} (99%) rename src/{ => GUI}/MainFrame.cpp (85%) rename src/{ => GUI}/MainFrame.hpp (97%) rename src/{ => GUI}/WaveformViewer.cpp (94%) rename src/{ => GUI}/WaveformViewer.hpp (95%) rename src/{ => Utility}/ControlID_Enums.hpp (99%) rename src/{ => Utility}/SH_Event.cpp (67%) rename src/{ => Utility}/SH_Event.hpp (83%) rename src/{ => Utility}/Sample.cpp (61%) rename src/{ => Utility}/Sample.hpp (80%) rename src/{ => Utility}/Serialize.cpp (63%) rename src/{ => Utility}/Serialize.hpp (69%) rename src/{ => Utility}/Tags.cpp (99%) rename src/{ => Utility}/Tags.hpp (100%) diff --git a/meson.build b/meson.build index 53763bf..c9707cb 100755 --- a/meson.build +++ b/meson.build @@ -113,18 +113,24 @@ snd_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON', src = [ 'src/App.cpp', - 'src/MainFrame.cpp', - 'src/SettingsDialog.cpp', - 'src/TagEditorDialog.cpp', - 'src/Database.cpp', - 'src/Sample.cpp', - 'src/Serialize.cpp', - 'src/Tags.cpp', - 'src/WaveformViewer.cpp', - 'src/SH_Event.cpp', + + 'src/GUI/MainFrame.cpp', + 'src/GUI/WaveformViewer.cpp', + + 'src/GUI/Dialogs/Settings.cpp', + 'src/GUI/Dialogs/TagEditor.cpp', + + 'src/Database/Database.cpp', + + 'src/Utility/Sample.cpp', + 'src/Utility/Serialize.cpp', + 'src/Utility/Tags.cpp', + 'src/Utility/SH_Event.cpp', ] +include_dirs = include_directories('src') + # Dependencies wx = dependency('wxwidgets', version: '>=3.1.5', required: false) @@ -197,12 +203,14 @@ if wx_found sources: src, cpp_args: [wx_cxx_flags], link_args: [wx_libs], + include_directories : include_dirs, dependencies: [wx, taglib, sqlite3, yaml, snd], install: true, install_rpath: prefix / 'lib') else executable('SampleHive', sources: src, + include_directories : include_dirs, dependencies: [wx, taglib, sqlite3, yaml, snd], install: true, install_rpath: prefix / 'lib') diff --git a/src/App.cpp b/src/App.cpp index de21a93..80868fc 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -45,6 +46,9 @@ bool App::OnInit() if (!wxApp::OnInit()) return false; + wxLog::AddTraceMask("EventSource"); + wxLog::AddTraceMask(wxTRACE_FSWATCHER); + m_Frame = new MainFrame(); wxBitmap bitmap; @@ -85,3 +89,9 @@ bool App::OnCmdLineParsed(wxCmdLineParser& parser) return true; } + +void App::OnEventLoopEnter(wxEventLoopBase* event) +{ + if (m_Frame->CreateWatcherIfNecessary()) + wxLogDebug("Filesystem watcher created sucessfully"); +} diff --git a/src/App.hpp b/src/App.hpp index a10ce3c..0b6ebf5 100644 --- a/src/App.hpp +++ b/src/App.hpp @@ -20,7 +20,7 @@ #pragma once -#include "MainFrame.hpp" +#include "GUI/MainFrame.hpp" #include #include @@ -36,6 +36,7 @@ class App : public wxApp private: virtual bool OnInit(); + virtual void OnEventLoopEnter(wxEventLoopBase* event); virtual void OnInitCmdLine(wxCmdLineParser& parser); virtual bool OnCmdLineParsed(wxCmdLineParser& parser); }; diff --git a/src/Database.cpp b/src/Database/Database.cpp similarity index 96% rename from src/Database.cpp rename to src/Database/Database.cpp index 025dbd5..aa1141d 100644 --- a/src/Database.cpp +++ b/src/Database/Database.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "Database.hpp" +#include "Database/Database.hpp" #include #include @@ -126,7 +126,7 @@ void Database::CreateTableHives() } catch (const std::exception &e) { - show_modal_dialog_and_log("Error! Cannot create table hives: ", "Error", e.what()); + show_modal_dialog_and_log("Error! Cannot create hives table", "Error", e.what()); } } @@ -548,9 +548,12 @@ std::string Database::GetSampleFileExtension(const std::string &filename) return extension; } -wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &favorite_tree, wxDataViewItem &favorite_item, - wxTreeCtrl &trash_tree, wxTreeItemId &trash_item, bool show_extension, - const std::string &icon_star_filled, const std::string &icon_star_empty) +wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &favorite_tree, + wxDataViewItem &favorite_item, + wxTreeCtrl &trash_tree, wxTreeItemId &trash_item, + bool show_extension, + const std::string &icon_star_filled, + const std::string &icon_star_empty) { wxVector> vecSet; @@ -560,17 +563,17 @@ wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl & try { - int numRows = 0; + int num_rows = 0; Sqlite3Statement statement1(m_Database, "SELECT Count(*) FROM SAMPLES;"); if (SQLITE_ROW == sqlite3_step(statement1.stmt)) { - numRows = sqlite3_column_int(statement1.stmt, 0); + num_rows = sqlite3_column_int(statement1.stmt, 0); - wxLogDebug("rows %d", numRows); + wxLogDebug("Loading %d samples..", num_rows); - vecSet.reserve(numRows); + vecSet.reserve(num_rows); } Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \ @@ -615,8 +618,6 @@ wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl & // vec.push_back(true); vec.push_back(icon_filled); - wxLogDebug("Loading hives.."); - std::deque nodes; nodes.push_back(favorite_tree.GetNthChild(wxDataViewItem(wxNullPtr), 0)); @@ -633,7 +634,6 @@ wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl & if (favorite_tree.GetItemText(current_item) == hive_name) { found_item = current_item; - wxLogDebug("Loading, hive name: %s", hive_name); break; } @@ -652,21 +652,14 @@ wxVector> Database::LoadSamplesDatabase(wxDataViewTreeCtrl & if (found_item.IsOk()) { - // wxLogDebug("Another hive by the name %s already exist. Please try with a different name.", - // hive_name); if (show_extension) favorite_tree.AppendItem(found_item, wxString::Format("%s.%s", filename, file_extension)); else favorite_tree.AppendItem(found_item, filename); } - // else - // { - // favorite_tree.AppendItem(wxDataViewItem(wxNullPtr), hive_name); - // } } else - // vec.push_back(false); vec.push_back(icon_empty); if (show_extension) @@ -744,13 +737,6 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex else vec.push_back(icon_empty); - // if (favorite == 1) - // vec.push_back(true); - // else - // vec.push_back(false); - - // vec.push_back(filename); - if (show_extension) { vec.push_back(path.AfterLast('/')); @@ -872,8 +858,10 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl) while (SQLITE_ROW == sqlite3_step(statement.stmt)) { - wxLogDebug("Record found, fetching.."); - const auto hive = wxString(std::string(reinterpret_cast(sqlite3_column_text(statement.stmt, 0)))); + wxLogDebug("Loading hives.."); + + const auto hive = wxString(std::string(reinterpret_cast + (sqlite3_column_text(statement.stmt, 0)))); treeCtrl.AppendContainer(wxDataViewItem(wxNullPtr), hive); } diff --git a/src/Database.hpp b/src/Database/Database.hpp similarity index 99% rename from src/Database.hpp rename to src/Database/Database.hpp index eb11038..6f6d210 100644 --- a/src/Database.hpp +++ b/src/Database/Database.hpp @@ -19,7 +19,7 @@ */ #pragma once -#include "Sample.hpp" +#include "Utility/Sample.hpp" #include #include diff --git a/src/SettingsDialog.cpp b/src/GUI/Dialogs/Settings.cpp similarity index 69% rename from src/SettingsDialog.cpp rename to src/GUI/Dialogs/Settings.cpp index a182e03..a33d8b1 100644 --- a/src/SettingsDialog.cpp +++ b/src/GUI/Dialogs/Settings.cpp @@ -18,9 +18,9 @@ * along with this program. If not, see . */ -#include "ControlID_Enums.hpp" -#include "SettingsDialog.hpp" -#include "Serialize.hpp" +#include "GUI/Dialogs/Settings.hpp" +#include "Utility/ControlID_Enums.hpp" +#include "Utility/Serialize.hpp" #include #include @@ -52,34 +52,50 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st m_DisplayFontSizer = new wxBoxSizer(wxHORIZONTAL); m_WaveformColourSizer = new wxBoxSizer(wxHORIZONTAL); - wxString fontChoices[] = {"System default"}; Serializer serializer(m_ConfigFilepath); - // m_RowHeightText = new wxStaticText(); - m_FontTypeText = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Font", wxDefaultPosition, wxDefaultSize, 0); - // m_RowHeight = new wxChoice(); - m_FontType = new wxChoice(m_DisplaySettingPanel, SD_FontType, wxDefaultPosition, wxDefaultSize, 1, fontChoices, 0); + + wxString fontChoices[] = { "System default" }; + + m_FontTypeText = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Font", + wxDefaultPosition, wxDefaultSize, 0); + m_FontType = new wxChoice(m_DisplaySettingPanel, SD_FontType, + wxDefaultPosition, wxDefaultSize, 1, fontChoices, 0); m_FontType->SetSelection(0); - m_FontSize = new wxSpinCtrl(m_DisplaySettingPanel, SD_FontSize, "Default", wxDefaultPosition, wxDefaultSize); + m_FontSize = new wxSpinCtrl(m_DisplaySettingPanel, SD_FontSize, "Default", + wxDefaultPosition, wxDefaultSize); m_FontSize->SetValue(window->GetFont().GetPointSize()); - m_FontBrowseButton = new wxButton(m_DisplaySettingPanel, SD_FontBrowseButton, "Select font", wxDefaultPosition, wxDefaultSize, 0); - m_WaveformColourLabel = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Waveform colour", wxDefaultPosition, wxDefaultSize, 0); - m_WaveformColourPickerCtrl = new wxColourPickerCtrl(m_DisplaySettingPanel, SD_WaveformColourPickerCtrl, serializer.DeserializeWaveformColour(), - wxDefaultPosition, wxDefaultSize, wxCLRP_DEFAULT_STYLE); + m_FontBrowseButton = new wxButton(m_DisplaySettingPanel, SD_FontBrowseButton, "Select font", + wxDefaultPosition, wxDefaultSize, 0); + m_WaveformColourLabel = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Waveform colour", + wxDefaultPosition, wxDefaultSize, 0); + m_WaveformColourPickerCtrl = new wxColourPickerCtrl(m_DisplaySettingPanel, SD_WaveformColourPickerCtrl, + serializer.DeserializeWaveformColour(), + wxDefaultPosition, wxDefaultSize, + wxCLRP_DEFAULT_STYLE); m_CollectionSettingPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize); - m_CollectionTopSizer = new wxBoxSizer(wxVERTICAL); + m_CollectionMainSizer = new wxBoxSizer(wxVERTICAL); m_CollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL); - m_ShowFileExtensionSizer = new wxBoxSizer(wxHORIZONTAL); + m_CollectionBottomSizer = new wxBoxSizer(wxVERTICAL); wxString defaultDir = wxGetHomeDir(); - m_AutoImportCheck = new wxCheckBox(m_CollectionSettingPanel, SD_AutoImport, "Auto import", wxDefaultPosition, wxDefaultSize, 0); - m_ImportDirLocation = new wxTextCtrl(m_CollectionSettingPanel, wxID_ANY, defaultDir, wxDefaultPosition, wxDefaultSize, 0); + m_AutoImportCheck = new wxCheckBox(m_CollectionSettingPanel, SD_AutoImport, "Auto import", + wxDefaultPosition, wxDefaultSize, 0); + m_ImportDirLocation = new wxTextCtrl(m_CollectionSettingPanel, wxID_ANY, defaultDir, + wxDefaultPosition, wxDefaultSize, 0); m_ImportDirLocation->Disable(); - m_BrowseAutoImportDirButton = new wxButton(m_CollectionSettingPanel, SD_BrowseAutoImportDir, "Browse", wxDefaultPosition, wxDefaultSize, 0); + m_BrowseAutoImportDirButton = new wxButton(m_CollectionSettingPanel, SD_BrowseAutoImportDir, "Browse", + wxDefaultPosition, wxDefaultSize, 0); m_BrowseAutoImportDirButton->Disable(); - m_ShowFileExtensionCheck = new wxCheckBox(m_CollectionSettingPanel, SD_ShowFileExtension, "Show file extension", wxDefaultPosition, wxDefaultSize, 0); + m_FollowSymLinksCheck = new wxCheckBox(m_CollectionSettingPanel, SD_FollowSymLinks, + "Follow symbolic links", wxDefaultPosition, wxDefaultSize, 0); + m_FollowSymLinksCheck->SetToolTip("Wheather to follow symbolic links"); + m_FollowSymLinksCheck->Disable(); + m_ShowFileExtensionCheck = new wxCheckBox(m_CollectionSettingPanel, SD_ShowFileExtension, + "Show file extension", wxDefaultPosition, wxDefaultSize, 0); + m_ShowFileExtensionCheck->SetToolTip("Weather to show file extension"); m_ConfigurationSettingPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -88,12 +104,18 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st m_GeneralMainSizer->SetFlexibleDirection(wxBOTH); m_GeneralMainSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); - m_ConfigLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY, "Default configuration file location", wxDefaultPosition, wxDefaultSize); - m_ConfigText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, configFilepath, wxDefaultPosition, wxDefaultSize); - m_ConfigBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseConfigDir, "Browse", wxDefaultPosition, wxDefaultSize, 0); - m_DatabaseLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY, "Default database location", wxDefaultPosition, wxDefaultSize); - m_DatabaseText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, databaseFilepath, wxDefaultPosition, wxDefaultSize); - m_DatabaseBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseDatabaseDir, "Browse", wxDefaultPosition, wxDefaultSize, 0); + m_ConfigLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY, + "Default configuration file location", wxDefaultPosition, wxDefaultSize); + m_ConfigText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, configFilepath, + wxDefaultPosition, wxDefaultSize); + m_ConfigBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseConfigDir, "Browse", + wxDefaultPosition, wxDefaultSize, 0); + m_DatabaseLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY, "Default database location", + wxDefaultPosition, wxDefaultSize); + m_DatabaseText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, databaseFilepath, + wxDefaultPosition, wxDefaultSize); + m_DatabaseBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseDatabaseDir, "Browse", + wxDefaultPosition, wxDefaultSize, 0); m_Notebook->AddPage(m_DisplaySettingPanel, "Display"); m_Notebook->AddPage(m_CollectionSettingPanel, "Collection"); @@ -106,6 +128,7 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st // Bind events Bind(wxEVT_CHECKBOX, &Settings::OnCheckAutoImport, this, SD_AutoImport); + Bind(wxEVT_CHECKBOX, &Settings::OnCheckFollowSymLinks, this, SD_FollowSymLinks); Bind(wxEVT_CHECKBOX, &Settings::OnCheckShowFileExtension, this, SD_ShowFileExtension); Bind(wxEVT_SPINCTRL, &Settings::OnChangeFontSize, this, SD_FontSize); Bind(wxEVT_BUTTON, &Settings::OnSelectFont, this, SD_FontBrowseButton); @@ -139,10 +162,11 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2); m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2); - m_ShowFileExtensionSizer->Add(m_ShowFileExtensionCheck, 0, wxALL, 2); + m_CollectionBottomSizer->Add(m_FollowSymLinksCheck, 0, wxALL, 2); + m_CollectionBottomSizer->Add(m_ShowFileExtensionCheck, 0, wxALL, 2); - m_CollectionTopSizer->Add(m_CollectionImportDirSizer, 0, wxALL | wxEXPAND, 2); - m_CollectionTopSizer->Add(m_ShowFileExtensionSizer, 0, wxALL | wxEXPAND, 2); + m_CollectionMainSizer->Add(m_CollectionImportDirSizer, 0, wxALL | wxEXPAND, 2); + m_CollectionMainSizer->Add(m_CollectionBottomSizer, 0, wxALL | wxEXPAND, 2); m_ButtonSizer->Add(m_OkButton, 0, wxALL | wxALIGN_BOTTOM, 2); m_ButtonSizer->Add(m_CancelButton, 0, wxALL | wxALIGN_BOTTOM, 2); @@ -163,10 +187,10 @@ Settings::Settings(wxWindow* window, const std::string& configFilepath, const st m_DisplayTopSizer->Layout(); // Collection panel layout - m_CollectionSettingPanel->SetSizer(m_CollectionTopSizer); - m_CollectionTopSizer->Fit(m_CollectionSettingPanel); - m_CollectionTopSizer->SetSizeHints(m_CollectionSettingPanel); - m_CollectionTopSizer->Layout(); + m_CollectionSettingPanel->SetSizer(m_CollectionMainSizer); + m_CollectionMainSizer->Fit(m_CollectionSettingPanel); + m_CollectionMainSizer->SetSizeHints(m_CollectionSettingPanel); + m_CollectionMainSizer->Layout(); // Configuration panel layout m_ConfigurationSettingPanel->SetSizer(m_GeneralMainSizer); @@ -179,17 +203,17 @@ void Settings::OnClickConfigBrowse(wxCommandEvent& event) { wxString initial_dir = wxGetHomeDir(); - m_DirDialog = new wxDirDialog(this, "Select a directory..", initial_dir, - wxDD_DEFAULT_STYLE | - wxDD_DIR_MUST_EXIST | - wxDD_NEW_DIR_BUTTON, - wxDefaultPosition, wxDefaultSize); + wxDirDialog dir_dialog(this, "Select a directory..", initial_dir, + wxDD_DEFAULT_STYLE | + wxDD_DIR_MUST_EXIST | + wxDD_NEW_DIR_BUTTON, + wxDefaultPosition, wxDefaultSize); - switch (m_DirDialog->ShowModal()) + switch (dir_dialog.ShowModal()) { case wxID_OK: { - wxString path = m_DirDialog->GetPath(); + wxString path = dir_dialog.GetPath(); m_ConfigText->SetValue(path + "/config.yaml"); break; } @@ -202,17 +226,17 @@ void Settings::OnClickDatabaseBrowse(wxCommandEvent& event) { wxString initial_dir = wxGetHomeDir(); - m_DirDialog = new wxDirDialog(this, "Select a directory..", initial_dir, - wxDD_DEFAULT_STYLE | - wxDD_DIR_MUST_EXIST | - wxDD_NEW_DIR_BUTTON, - wxDefaultPosition, wxDefaultSize); + wxDirDialog dir_dialog(this, "Select a directory..", initial_dir, + wxDD_DEFAULT_STYLE | + wxDD_DIR_MUST_EXIST | + wxDD_NEW_DIR_BUTTON, + wxDefaultPosition, wxDefaultSize); - switch (m_DirDialog->ShowModal()) + switch (dir_dialog.ShowModal()) { case wxID_OK: { - wxString path = m_DirDialog->GetPath(); + wxString path = dir_dialog.GetPath(); m_DatabaseText->SetValue(path + "/config.yaml"); break; } @@ -230,33 +254,33 @@ void Settings::OnCheckAutoImport(wxCommandEvent& event) bAutoImport = false; m_ImportDirLocation->Disable(); m_BrowseAutoImportDirButton->Disable(); + m_FollowSymLinksCheck->Disable(); - serializer.SerializeAutoImportSettings(*m_ImportDirLocation, *m_AutoImportCheck); + serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString()); } else { bAutoImport = true; m_ImportDirLocation->Enable(); m_BrowseAutoImportDirButton->Enable(); + m_FollowSymLinksCheck->Enable(); - serializer.SerializeAutoImportSettings(*m_ImportDirLocation, *m_AutoImportCheck); + serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString()); } } +void Settings::OnCheckFollowSymLinks(wxCommandEvent& event) +{ + Serializer serialize(m_ConfigFilepath); + + serialize.SerializeFollowSymLink(m_FollowSymLinksCheck->GetValue()); +} + void Settings::OnCheckShowFileExtension(wxCommandEvent& event) { Serializer serialize(m_ConfigFilepath); - if (!m_ShowFileExtensionCheck->GetValue()) - { - bShowExtension = false; - serialize.SerializeShowFileExtensionSetting(*m_ShowFileExtensionCheck); - } - else - { - bShowExtension = true; - serialize.SerializeShowFileExtensionSetting(*m_ShowFileExtensionCheck); - } + serialize.SerializeShowFileExtensionSetting(m_ShowFileExtensionCheck->GetValue()); } void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event) @@ -265,20 +289,20 @@ void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event) wxString initial_dir = wxGetHomeDir(); - m_DirDialog = new wxDirDialog(this, "Select a directory..", initial_dir, - wxDD_DEFAULT_STYLE | - wxDD_DIR_MUST_EXIST | - wxDD_NEW_DIR_BUTTON, - wxDefaultPosition, wxDefaultSize); + wxDirDialog dir_dialog(this, "Select a directory..", initial_dir, + wxDD_DEFAULT_STYLE | + wxDD_DIR_MUST_EXIST | + wxDD_NEW_DIR_BUTTON, + wxDefaultPosition, wxDefaultSize); - switch (m_DirDialog->ShowModal()) + switch (dir_dialog.ShowModal()) { case wxID_OK: { - wxString path = m_DirDialog->GetPath(); + wxString path = dir_dialog.GetPath(); m_ImportDirLocation->SetValue(path); - serializer.SerializeAutoImportSettings(*m_ImportDirLocation, *m_AutoImportCheck); + serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString()); break; } default: @@ -288,13 +312,13 @@ void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event) void Settings::OnSelectFont(wxCommandEvent& event) { - m_FontDialog = new wxFontDialog(this); + wxFontDialog font_dialog(this); - switch (m_FontDialog->ShowModal()) + switch (font_dialog.ShowModal()) { case wxID_OK: { - wxFontData fontData = m_FontDialog->GetFontData(); + wxFontData fontData = font_dialog.GetFontData(); m_Font = fontData.GetChosenFont(); if (m_FontType->GetCount() > 1) @@ -324,7 +348,7 @@ void Settings::OnChangeFontSize(wxSpinEvent& event) int font_size = m_FontSize->GetValue(); - if ( m_FontType->GetStringSelection() == "System default" ) + if (m_FontType->GetStringSelection() == "System default") m_Font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT); m_Font.SetPointSize(font_size); @@ -343,13 +367,13 @@ void Settings::LoadDefaultConfig() Serializer serializer(m_ConfigFilepath); wxFont sys_font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT); - std::string system_font = sys_font.GetFaceName().ToStdString(); + wxString system_font = sys_font.GetFaceName(); int system_font_size = sys_font.GetPointSize(); - wxString font_face = serializer.DeserializeDisplaySettings().font_face; - int font_size = serializer.DeserializeDisplaySettings().font_size; + wxString font_face = serializer.DeserializeDisplaySettings().GetFaceName(); + int font_size = serializer.DeserializeDisplaySettings().GetPointSize(); - if ( system_font != font_face ) + if (system_font != font_face) { if (m_FontType->GetCount() > 1) { @@ -373,21 +397,29 @@ void Settings::LoadDefaultConfig() m_FontSize->SetValue(font_size); SetCustomFont(); - bAutoImport = serializer.DeserializeAutoImportSettings().auto_import; - wxString location = serializer.DeserializeAutoImportSettings().import_dir; - bShowExtension = serializer.DeserializeShowFileExtensionSetting(); + bAutoImport = serializer.DeserializeAutoImportSettings().first; + wxString location = serializer.DeserializeAutoImportSettings().second; m_AutoImportCheck->SetValue(bAutoImport); m_ImportDirLocation->SetValue(location); - m_ShowFileExtensionCheck->SetValue(bShowExtension); + m_ShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtensionSetting()); if (bAutoImport) { m_ImportDirLocation->Enable(); m_BrowseAutoImportDirButton->Enable(); + m_FollowSymLinksCheck->Enable(); } } +void Settings::SetShowExtension(bool value) +{ + Serializer serializer(m_ConfigFilepath); + + m_ShowFileExtensionCheck->SetValue(value); + serializer.SerializeShowFileExtensionSetting(value); +} + void Settings::PrintFont() { wxLogDebug("Font face: %s", m_Font.GetFaceName()); @@ -405,10 +437,10 @@ void Settings::SetCustomFont() std::string system_font = sys_font.GetFaceName().ToStdString(); int system_font_size = sys_font.GetPointSize(); - wxString font_face = serializer.DeserializeDisplaySettings().font_face; - int font_size = serializer.DeserializeDisplaySettings().font_size; + wxString font_face = serializer.DeserializeDisplaySettings().GetFaceName(); + int font_size = serializer.DeserializeDisplaySettings().GetPointSize(); - if ( m_FontType->GetStringSelection() == "System default" ) + if (m_FontType->GetStringSelection() == "System default") { m_Window->SetFont(sys_font); this->SetFont(sys_font); @@ -452,6 +484,8 @@ void Settings::OnChangeWaveformColour(wxColourPickerEvent& event) { wxLogDebug("Waveform colour not changed."); bWaveformColourChanged = false; + + serializer.SerializeWaveformColour(colour); } } diff --git a/src/SettingsDialog.hpp b/src/GUI/Dialogs/Settings.hpp similarity index 87% rename from src/SettingsDialog.hpp rename to src/GUI/Dialogs/Settings.hpp index 27edfe2..2e34dc7 100644 --- a/src/SettingsDialog.hpp +++ b/src/GUI/Dialogs/Settings.hpp @@ -45,7 +45,6 @@ class Settings : public wxDialog public: Settings(const std::string& configFilepath, const std::string& databaseFilepath); Settings(wxWindow* window, const std::string& configFilepath, const std::string& databaseFilepath); - ~Settings(); private: @@ -84,7 +83,6 @@ class Settings : public wxDialog wxStaticText* m_FontTypeText; wxChoice* m_RowHeight; wxChoice* m_FontType; - wxFontDialog* m_FontDialog; wxButton* m_FontBrowseButton; wxSpinCtrl* m_FontSize; wxBoxSizer* m_WaveformColourSizer; @@ -93,14 +91,14 @@ class Settings : public wxDialog // ------------------------------------------------------------------- // Collection page - wxBoxSizer* m_CollectionTopSizer; + wxBoxSizer* m_CollectionMainSizer; wxBoxSizer* m_CollectionImportDirSizer; - wxBoxSizer* m_ShowFileExtensionSizer; + wxBoxSizer* m_CollectionBottomSizer; wxCheckBox* m_AutoImportCheck; + wxCheckBox* m_FollowSymLinksCheck; wxCheckBox* m_ShowFileExtensionCheck; wxTextCtrl* m_ImportDirLocation; wxButton* m_BrowseAutoImportDirButton; - wxDirDialog* m_DirDialog; // ------------------------------------------------------------------- // General configuration page @@ -124,7 +122,8 @@ class Settings : public wxDialog private: // ------------------------------------------------------------------- bool bAutoImport = false; - bool bShowExtension = true; + // bool bFollowSymLinks = false; + // bool bShowExtension = true; bool bWaveformColourChanged = false; private: @@ -132,6 +131,7 @@ class Settings : public wxDialog void OnClickConfigBrowse(wxCommandEvent& event); void OnClickDatabaseBrowse(wxCommandEvent& event); void OnCheckAutoImport(wxCommandEvent& event); + void OnCheckFollowSymLinks(wxCommandEvent& event); void OnCheckShowFileExtension(wxCommandEvent& event); void OnClickBrowseAutoImportDir(wxCommandEvent& event); void OnChangeFontSize(wxSpinEvent& event); @@ -150,9 +150,14 @@ class Settings : public wxDialog // Getters wxString GetImportDirPath(); - inline wxFont GetFontType() { return m_Font; }; + // inline wxFont GetFontType() { return m_Font; }; inline bool CanAutoImport() { return bAutoImport; }; - inline bool ShouldShowFileExtension() { return bShowExtension; }; + // inline bool ShouldFollowSymLinks() { return bFollowSymLinks; }; + // inline bool ShouldShowFileExtension() { return bShowExtension; }; inline bool IsWaveformColourChanged() { return bWaveformColourChanged; } - inline wxColour GetWaveformColour() { return m_WaveformColourPickerCtrl->GetColour(); } + // inline wxColour GetWaveformColour() { return m_WaveformColourPickerCtrl->GetColour(); } + + // ------------------------------------------------------------------- + // Setters + void SetShowExtension(bool value); }; diff --git a/src/TagEditorDialog.cpp b/src/GUI/Dialogs/TagEditor.cpp similarity index 99% rename from src/TagEditorDialog.cpp rename to src/GUI/Dialogs/TagEditor.cpp index c18bd10..a7eaac7 100644 --- a/src/TagEditorDialog.cpp +++ b/src/GUI/Dialogs/TagEditor.cpp @@ -18,9 +18,9 @@ * along with this program. If not, see . */ -#include "ControlID_Enums.hpp" -#include "Database.hpp" -#include "TagEditorDialog.hpp" +#include "Utility/ControlID_Enums.hpp" +#include "Database/Database.hpp" +#include "GUI/Dialogs/TagEditor.hpp" #include #include diff --git a/src/TagEditorDialog.hpp b/src/GUI/Dialogs/TagEditor.hpp similarity index 99% rename from src/TagEditorDialog.hpp rename to src/GUI/Dialogs/TagEditor.hpp index a20c139..28c8542 100644 --- a/src/TagEditorDialog.hpp +++ b/src/GUI/Dialogs/TagEditor.hpp @@ -20,7 +20,7 @@ #pragma once -#include "Tags.hpp" +#include "Utility/Tags.hpp" #include diff --git a/src/MainFrame.cpp b/src/GUI/MainFrame.cpp similarity index 85% rename from src/MainFrame.cpp rename to src/GUI/MainFrame.cpp index 2a5f014..edb0688 100644 --- a/src/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -18,14 +18,13 @@ * along with this program. If not, see . */ -#include "MainFrame.hpp" -#include "ControlID_Enums.hpp" -#include "Database.hpp" -#include "SettingsDialog.hpp" -#include "TagEditorDialog.hpp" -#include "Tags.hpp" -#include "Sample.hpp" -#include "Serialize.hpp" +#include "GUI/MainFrame.hpp" +#include "GUI/Dialogs/Settings.hpp" +#include "GUI/Dialogs/TagEditor.hpp" +#include "Database/Database.hpp" +#include "Utility/ControlID_Enums.hpp" +#include "Utility/Tags.hpp" +#include "Utility/Sample.hpp" #include "SampleHiveConfig.hpp" #include @@ -35,6 +34,8 @@ #include #include +#include + #include #include #include @@ -44,12 +45,13 @@ #include #include #include +#include #include #include #include #include #include -// #include +#include #include #include #include @@ -115,7 +117,8 @@ MainFrame::MainFrame() m_AddFile->SetBitmap(wxArtProvider::GetBitmap(wxART_NORMAL_FILE)); m_FileMenu->Append(m_AddFile); - m_AddDirectory = new wxMenuItem(m_FileMenu, MN_AddDirectory, _("Add a directory\tCtrl+D"), _("Add a directory")); + m_AddDirectory = new wxMenuItem(m_FileMenu, MN_AddDirectory, + _("Add a directory\tCtrl+D"), _("Add a directory")); m_AddDirectory->SetBitmap(wxArtProvider::GetBitmap(wxART_FOLDER)); m_FileMenu->Append(m_AddDirectory); @@ -139,7 +142,8 @@ MainFrame::MainFrame() m_ViewMenu->Append(m_ToggleStatusBar)->Check(m_StatusBar->IsShown()); // Help menu items - m_HelpMenu->Append(wxID_REFRESH, _("Reset app data"), _("Clear the application data revert to default configuration")); + m_HelpMenu->Append(wxID_REFRESH, _("Reset app data"), + _("Clear the application data revert to default configuration")); m_HelpMenu->Append(wxID_ABOUT, wxEmptyString, _("Show about the application")); // Append all menus to menubar @@ -193,7 +197,8 @@ MainFrame::MainFrame() m_BottomSplitter->SetSashGravity(0); // Left half of the BottomSplitter window - m_BottomLeftPanel = new wxPanel(m_BottomSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_BottomLeftPanel = new wxPanel(m_BottomSplitter, wxID_ANY, + wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); // Initializing wxNotebook m_Notebook = new wxNotebook(m_BottomLeftPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP); @@ -246,26 +251,34 @@ MainFrame::MainFrame() m_Notebook->AddPage(m_TrashPanel, _("Trash"), false); // Right half of BottomSlitter window - m_BottomRightPanel = new wxPanel(m_BottomSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + m_BottomRightPanel = new wxPanel(m_BottomSplitter, wxID_ANY, + wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); // Set split direction m_TopSplitter->SplitHorizontally(m_TopPanel, m_BottomSplitter); m_BottomSplitter->SplitVertically(m_BottomLeftPanel, m_BottomRightPanel); - m_TopControlsPanel = new wxPanel(m_TopPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER); + m_TopControlsPanel = new wxPanel(m_TopPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL | wxNO_BORDER); // Looping region controls if (m_Theme.IsDark()) - m_LoopABButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_LoopABButton, static_cast(ICON_AB_LIGHT_16px), wxDefaultPosition, wxDefaultSize, 0); + m_LoopABButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_LoopABButton, + static_cast(ICON_AB_LIGHT_16px), + wxDefaultPosition, wxDefaultSize, 0); else - m_LoopABButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_LoopABButton, static_cast(ICON_AB_DARK_16px), wxDefaultPosition, wxDefaultSize, 0); + m_LoopABButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_LoopABButton, + static_cast(ICON_AB_DARK_16px), + wxDefaultPosition, wxDefaultSize, 0); m_LoopABButton->SetToolTip(_("Loop selected region")); // Initializing browser controls on top panel. - m_AutoPlayCheck = new wxCheckBox(m_TopControlsPanel, BC_Autoplay, _("Autoplay"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + m_AutoPlayCheck = new wxCheckBox(m_TopControlsPanel, BC_Autoplay, _("Autoplay"), + wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); m_AutoPlayCheck->SetToolTip(_("Autoplay")); - m_VolumeSlider = new wxSlider(m_TopControlsPanel, BC_Volume, 100, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); + m_VolumeSlider = new wxSlider(m_TopControlsPanel, BC_Volume, 100, 0, 100, + wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL); m_VolumeSlider->SetToolTip(_("Volume")); m_VolumeSlider->SetMinSize(wxSize(120, -1)); m_VolumeSlider->SetMaxSize(wxSize(120, -1)); @@ -275,24 +288,32 @@ MainFrame::MainFrame() // Initialize browser control buttons if (m_Theme.IsDark()) { - m_PlayButton = new wxBitmapButton(m_TopControlsPanel, BC_Play, static_cast(ICON_PLAY_LIGHT_16px), + m_PlayButton = new wxBitmapButton(m_TopControlsPanel, BC_Play, + static_cast(ICON_PLAY_LIGHT_16px), wxDefaultPosition, wxDefaultSize, 0); - m_LoopButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Loop, static_cast(ICON_LOOP_LIGHT_16px), + m_LoopButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Loop, + static_cast(ICON_LOOP_LIGHT_16px), wxDefaultPosition, wxDefaultSize, 0); - m_StopButton = new wxBitmapButton(m_TopControlsPanel, BC_Stop, static_cast(ICON_STOP_LIGHT_16px), + m_StopButton = new wxBitmapButton(m_TopControlsPanel, BC_Stop, + static_cast(ICON_STOP_LIGHT_16px), wxDefaultPosition, wxDefaultSize, 0); - m_MuteButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Mute, static_cast(ICON_MUTE_LIGHT_16px), + m_MuteButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Mute, + static_cast(ICON_MUTE_LIGHT_16px), wxDefaultPosition, wxDefaultSize, 0); } else { - m_PlayButton = new wxBitmapButton(m_TopControlsPanel, BC_Play, static_cast(ICON_PLAY_DARK_16px), + m_PlayButton = new wxBitmapButton(m_TopControlsPanel, BC_Play, + static_cast(ICON_PLAY_DARK_16px), wxDefaultPosition, wxDefaultSize, 0); - m_LoopButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Loop, static_cast(ICON_LOOP_DARK_16px), + m_LoopButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Loop, + static_cast(ICON_LOOP_DARK_16px), wxDefaultPosition, wxDefaultSize, 0); - m_StopButton = new wxBitmapButton(m_TopControlsPanel, BC_Stop, static_cast(ICON_STOP_DARK_16px), + m_StopButton = new wxBitmapButton(m_TopControlsPanel, BC_Stop, + static_cast(ICON_STOP_DARK_16px), wxDefaultPosition, wxDefaultSize, 0); - m_MuteButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Mute, static_cast(ICON_MUTE_DARK_16px), + m_MuteButton = new wxBitmapToggleButton(m_TopControlsPanel, BC_Mute, + static_cast(ICON_MUTE_DARK_16px), wxDefaultPosition, wxDefaultSize, 0); } @@ -301,14 +322,16 @@ MainFrame::MainFrame() m_StopButton->SetToolTip(_("Stop")); m_MuteButton->SetToolTip(_("Mute")); - m_SettingsButton = new wxButton(m_TopControlsPanel, BC_Settings, _("Settings"), wxDefaultPosition, wxDefaultSize, 0); + m_SettingsButton = new wxButton(m_TopControlsPanel, BC_Settings, _("Settings"), + wxDefaultPosition, wxDefaultSize, 0); m_SettingsButton->SetToolTip(_("Settings")); // Initializing wxSearchCtrl on bottom panel. - m_SearchBox = new wxSearchCtrl(m_BottomRightPanel, BC_Search, _("Search for samples.."), wxDefaultPosition, - wxDefaultSize, wxTE_PROCESS_ENTER); + m_SearchBox = new wxSearchCtrl(m_BottomRightPanel, BC_Search, _("Search for samples.."), + wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); - // Set minimum and maximum size of m_SearchBox so it doesn't expand too wide when resizing the main frame. + // Set minimum and maximum size of m_SearchBox + // so it doesn't expand too wide when resizing the main frame. m_SearchBox->SetMinSize(wxSize(-1, 38)); m_SearchBox->SetMaxSize(wxSize(-1, 38)); @@ -393,7 +416,8 @@ MainFrame::MainFrame() m_InfoBar = new wxInfoBar(m_BottomRightPanel); // Initializing wxMediaCtrl. - m_MediaCtrl = new wxMediaCtrl(this, BC_MediaCtrl, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString); + m_MediaCtrl = new wxMediaCtrl(this, BC_MediaCtrl, wxEmptyString, wxDefaultPosition, + wxDefaultSize, 0, wxEmptyString); // Intializing wxTimer m_Timer = new wxTimer(this); @@ -404,7 +428,7 @@ MainFrame::MainFrame() m_Database->CreateTableSamples(); m_Database->CreateTableHives(); - m_TopWaveformPanel = new WaveformViewer(this, m_TopPanel, *m_Library, *m_MediaCtrl, *m_Database, + m_TopWaveformPanel = new WaveformViewer(m_TopPanel, *m_Library, *m_MediaCtrl, *m_Database, m_ConfigFilepath, m_DatabaseFilepath); // Binding events. @@ -441,9 +465,11 @@ MainFrame::MainFrame() Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &MainFrame::OnClickLibrary, this, BC_Library); Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &MainFrame::OnDragFromLibrary, this); - m_Library->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MainFrame::OnDragAndDropToLibrary), NULL, this); + m_Library->Connect(wxEVT_DROP_FILES, + wxDropFilesEventHandler(MainFrame::OnDragAndDropToLibrary), NULL, this); Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &MainFrame::OnShowLibraryContextMenu, this, BC_Library); - Bind(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, &MainFrame::OnShowLibraryColumnHeaderContextMenu, this, BC_Library); + Bind(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, + &MainFrame::OnShowLibraryColumnHeaderContextMenu, this, BC_Library); Bind(wxEVT_TEXT, &MainFrame::OnDoSearch, this, BC_Search); Bind(wxEVT_SEARCHCTRL_SEARCH_BTN, &MainFrame::OnDoSearch, this, BC_Search); @@ -582,12 +608,13 @@ void MainFrame::OnClickSettings(wxCommandEvent& event) void MainFrame::AddSamples(wxArrayString& files) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); + Serializer serializer(m_ConfigFilepath); wxBusyCursor busy_cursor; wxWindowDisabler window_disabler; - wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."), _("Adding files, please wait..."), + wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."), + _("Adding files, please wait..."), static_cast(files.size()), this, wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); @@ -631,7 +658,7 @@ void MainFrame::AddSamples(wxArrayString& files) filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString(); extension = files[i].AfterLast('.').ToStdString(); - filename = settings.ShouldShowFileExtension() ? + filename = serializer.DeserializeShowFileExtensionSetting() ? filename_with_extension : filename_without_extension; Sample sample; @@ -679,7 +706,8 @@ void MainFrame::AddSamples(wxArrayString& files) } else { - wxString msg = wxString::Format(_("Error! Cannot open %s, Invalid file type."), filename_with_extension); + wxString msg = wxString::Format(_("Error! Cannot open %s, Invalid file type."), + filename_with_extension); m_InfoBar->ShowMessage(msg, wxICON_ERROR); } } @@ -715,10 +743,11 @@ void MainFrame::OnDragAndDropToLibrary(wxDropFilesEvent& event) wxString filepath; wxArrayString filepath_array; - wxProgressDialog* progressDialog = new wxProgressDialog(_("Reading files.."), _("Reading files, please wait..."), + wxProgressDialog* progressDialog = new wxProgressDialog(_("Reading files.."), + _("Reading files, please wait..."), event.GetNumberOfFiles(), this, - wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT | - wxPD_AUTO_HIDE); + wxPD_APP_MODAL | wxPD_SMOOTH | + wxPD_CAN_ABORT | wxPD_AUTO_HIDE); progressDialog->CenterOnParent(wxBOTH); @@ -750,7 +779,7 @@ void MainFrame::OnDragAndDropToLibrary(wxDropFilesEvent& event) void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); + Serializer serializer(m_ConfigFilepath); if (event.GetNumberOfFiles() > 0) { @@ -780,7 +809,8 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event) files = file_data.GetFilenames(); - wxString file_name = settings.ShouldShowFileExtension() ? files[i].BeforeLast('.') : files[i]; + wxString file_name = serializer.DeserializeShowFileExtensionSetting() ? + files[i].BeforeLast('.') : files[i]; wxLogDebug(_("Dropping %d files %s on %s"), rows - i, files[i], m_Hives->GetItemText(drop_target)); @@ -808,8 +838,8 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event) else { if (m_Hives->GetItemText(drop_target) == "") - wxMessageBox(_("Cannot drop item outside of a hive, try dropping on a hive."), _("Error!"), - wxOK | wxICON_ERROR | wxCENTRE, this); + wxMessageBox(_("Cannot drop item outside of a hive, try dropping on a hive."), + _("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this); else wxMessageBox(wxString::Format(_("%s is not a hive, try dropping on a hive."), m_Hives->GetItemText(drop_target)), _("Error!"), @@ -833,16 +863,18 @@ void MainFrame::OnAutoImportDir(const wxString& pathToDirectory) wxString filepath; wxArrayString filepath_array; - size_t number_of_files = wxDir::GetAllFiles(pathToDirectory, &filepath_array, wxEmptyString, wxDIR_DEFAULT); + size_t number_of_files = wxDir::GetAllFiles(pathToDirectory, &filepath_array, + wxEmptyString, wxDIR_DEFAULT); - wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."), _("Adding files, please wait..."), + wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."), + _("Adding files, please wait..."), static_cast(number_of_files), this, - wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT | - wxPD_AUTO_HIDE); + wxPD_APP_MODAL | wxPD_SMOOTH | + wxPD_CAN_ABORT | wxPD_AUTO_HIDE); progressDialog->CenterOnParent(wxBOTH); - for ( size_t i = 0; i < number_of_files; i++) + for (size_t i = 0; i < number_of_files; i++) { filepath = filepath_array[i]; @@ -861,7 +893,7 @@ void MainFrame::OnAutoImportDir(const wxString& pathToDirectory) progressDialog->Destroy(); AddSamples(filepath_array); - + wxLogDebug(_("Done Importing Samples")); } @@ -895,24 +927,12 @@ void MainFrame::OnDragFromDirCtrl(wxTreeEvent& event) void MainFrame::OnDragFromLibrary(wxDataViewEvent& event) { - // Settings settings(m_ConfigFilepath, m_DatabaseFilepath); - // int selected_row = m_Library->ItemToRow(event.GetItem()); if (selected_row < 0) return; wxString selection = m_Library->GetTextValue(selected_row, 1); - // wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); - // wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString()); - - // std::string extension = settings.ShouldShowFileExtension() ? - // m_Database->GetSampleFileExtension(selection.ToStdString()) : - // m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString()); - - // wxString sample = selection.Contains(wxString::Format(".%s", extension)) ? - // sample_with_extension : sample_without_extension; - wxString sample_path = GetFilenamePathAndExtension(selection).Path; wxFileDataObject* fileData = new wxFileDataObject(); @@ -927,8 +947,6 @@ void MainFrame::OnClickPlay(wxCommandEvent& event) { bStopped = false; - // Settings settings(m_ConfigFilepath, m_DatabaseFilepath); - // int selected_row = m_Library->GetSelectedRow(); if (selected_row < 0) @@ -936,16 +954,6 @@ void MainFrame::OnClickPlay(wxCommandEvent& event) wxString selection = m_Library->GetTextValue(selected_row, 1); - // wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); - // wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString()); - - // std::string extension = settings.ShouldShowFileExtension() ? - // m_Database->GetSampleFileExtension(selection.ToStdString()) : - // m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString()); - - // wxString sample = selection.Contains(wxString::Format(".%s", extension)) ? - // sample_with_extension : sample_without_extension; - wxString sample_path = GetFilenamePathAndExtension(selection).Path; if (bLoopPointsSet && m_LoopABButton->GetValue()) @@ -1083,9 +1091,7 @@ void MainFrame::OnReleaseVolumeSlider(wxScrollEvent& event) void MainFrame::OnClickLibrary(wxDataViewEvent& event) { - Settings settings(m_ConfigFilepath, m_DatabaseFilepath); - int selected_row = m_Library->ItemToRow(event.GetItem()); - + int selected_row = m_Library->ItemToRow(event.GetItem()); int current_row = m_Library->ItemToRow(m_Library->GetCurrentItem()); if (selected_row < 0 || !event.GetItem().IsOk()) @@ -1120,26 +1126,6 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event) if (!CurrentColumn) return; - //Get Filename - // int selected_row = m_Library->ItemToRow(event.GetItem()); - // if (selected_row < 0) return; - - // wxString selection; - // if(settings.ShouldShowFileExtension()) - // selection = m_Library->GetTextValue(selected_row, 1).BeforeLast('.'); - // else - // selection = m_Library->GetTextValue(selected_row, 1); - - // wxString sample_with_extension = m_Database->GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); - // wxString sample_without_extension = m_Database->GetSamplePathByFilename(selection.ToStdString()); - - // std::string extension = settings.ShouldShowFileExtension() ? - // m_Database->GetSampleFileExtension(selection.ToStdString()) : - // m_Database->GetSampleFileExtension(selection.BeforeLast('.').ToStdString()); - - // wxString sample = selection.Contains(wxString::Format(".%s", extension)) ? - // sample_with_extension : sample_without_extension; - wxString sample_path = GetFilenamePathAndExtension(selection).Path; std::string filename = GetFilenamePathAndExtension(selection).Filename; std::string extension = GetFilenamePathAndExtension(selection).Extension; @@ -1151,7 +1137,8 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event) if (bAutoplay) { if (bLoopPointsSet && m_LoopABButton->GetValue()) - PlaySample(sample_path.ToStdString(), selection.ToStdString(), true, m_LoopA.ToDouble(), wxFromStart); + PlaySample(sample_path.ToStdString(), selection.ToStdString(), + true, m_LoopA.ToDouble(), wxFromStart); else PlaySample(sample_path.ToStdString(), selection.ToStdString()); } @@ -1231,8 +1218,9 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event) void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); - wxDataViewItem selected_hive = event.GetItem(); + Serializer serializer(m_ConfigFilepath); + + wxDataViewItem selected_hive = event.GetItem(); wxString hive_name = m_Hives->GetItemText(selected_hive); @@ -1245,7 +1233,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) menu.Append(MN_DeleteHive, _("Delete hive"), _("Delete selected hive")); if (!bFiltered) - menu.Append(MN_FilterLibrary, _("Filter library"), _("Show only samples from current hive in library")); + menu.Append(MN_FilterLibrary, _("Filter library"), + _("Show only samples from current hive in library")); else menu.Append(MN_FilterLibrary, _("Clear filter"), _("Clear the filter")); } @@ -1314,9 +1303,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) if (found_item.IsOk()) { - wxMessageBox(wxString::Format( - _("Another hive by the name %s already exist. Please try with a different name."), - hive_name), + wxMessageBox(wxString::Format(_("Another hive by the name %s already exist. " + "Please try with a different name."), + hive_name), _("Error!"), wxOK | wxCENTRE, this); } else @@ -1330,7 +1319,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) wxLogDebug("Sample count: %d", sample_count); m_Hives->SetItemText(selected_hive, hive_name); - m_Database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString()); + m_Database->UpdateHive(selected_hive_name.ToStdString(), + hive_name.ToStdString()); } else { @@ -1338,14 +1328,17 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { wxDataViewItem sample_item = m_Hives->GetNthChild(selected_hive, i); - wxString sample_name = settings.ShouldShowFileExtension() ? + wxString sample_name = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(sample_item).BeforeLast('.') : m_Hives->GetItemText(sample_item); - wxLogDebug("Sample count: %d :: Sample name: %s", sample_count, sample_name); + wxLogDebug("Sample count: %d :: Sample name: %s", + sample_count, sample_name); - m_Database->UpdateHiveName(sample_name.ToStdString(), hive_name.ToStdString()); - m_Database->UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString()); + m_Database->UpdateHiveName(sample_name.ToStdString(), + hive_name.ToStdString()); + m_Database->UpdateHive(selected_hive_name.ToStdString(), + hive_name.ToStdString()); m_Hives->SetItemText(selected_hive, hive_name); } @@ -1369,18 +1362,17 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { wxString msg; - wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format( - _("Are you sure you want to delete " - "%s from hives?"), - hive_name), + wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format(_("Are you sure you want to " + "delete %s from hives?"), + hive_name), wxMessageBoxCaptionStr, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP); - wxMessageDialog deleteFilledHiveDialog(this, wxString::Format( - _("Are you sure you want to delete " - "%s and all sample inside %s from hives?"), - hive_name, hive_name), + wxMessageDialog deleteFilledHiveDialog(this, wxString::Format(_("Are you sure you want to " + "delete %s and all samples " + "inside %s from hives?"), + hive_name, hive_name), wxMessageBoxCaptionStr, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP); @@ -1393,7 +1385,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) } else if (!selected_hive.IsOk()) { - wxMessageBox(_("No hive selected, try selecting a hive first"), _("Error!"), wxOK | wxCENTRE, this); + wxMessageBox(_("No hive selected, try selecting a hive first"), _("Error!"), + wxOK | wxCENTRE, this); return; } else if (selected_hive.IsOk() && !m_Hives->IsContainer(selected_hive)) @@ -1437,7 +1430,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) for (int i = 0; i < m_Library->GetItemCount(); i++) { - wxString matched_sample = settings.ShouldShowFileExtension() ? + wxString matched_sample = + serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(i, 1).BeforeLast('.') : m_Library->GetTextValue(i, 1); @@ -1445,7 +1439,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { child_item = m_Hives->GetNthChild(selected_hive, j); - wxString child_name = settings.ShouldShowFileExtension() ? + wxString child_name = + serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child_item).BeforeLast('.') : m_Hives->GetItemText(child_item); @@ -1453,10 +1448,12 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { wxLogDebug(_("Found match")); - m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0); + m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), + i, 0); m_Database->UpdateFavoriteColumn(matched_sample.ToStdString(), 0); - m_Database->UpdateHiveName(matched_sample.ToStdString(), m_Hives->GetItemText(favorites_hive).ToStdString()); + m_Database->UpdateHiveName(matched_sample.ToStdString(), + m_Hives->GetItemText(favorites_hive).ToStdString()); break; } @@ -1470,9 +1467,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) m_Database->RemoveHiveFromDatabase(hive_name.ToStdString()); - msg = wxString::Format( - _("%s and all samples inside %s have been deleted from hives successfully."), - hive_name, hive_name); + msg = wxString::Format(_("%s and all samples inside %s " + "have been deleted from hives successfully."), + hive_name, hive_name); } break; case wxID_NO: @@ -1493,7 +1490,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) try { const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(), - settings.ShouldShowFileExtension(), + serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); if (dataset.empty()) @@ -1526,7 +1523,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) { try { - const auto dataset = m_Database->FilterDatabaseBySampleName("", settings.ShouldShowFileExtension(), + const auto dataset = m_Database->FilterDatabaseBySampleName("", serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); if (dataset.empty()) @@ -1565,11 +1562,11 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) case MN_RemoveSample: for(int i = 0; i < m_Library->GetItemCount(); i++) { - wxString matched_sample = settings.ShouldShowFileExtension() ? + wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(i, 1).BeforeLast('.') : m_Library->GetTextValue(i, 1); - wxString selected_sample_name = settings.ShouldShowFileExtension() ? + wxString selected_sample_name = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(event.GetItem()).BeforeLast('.') : m_Hives->GetItemText(event.GetItem()); @@ -1597,11 +1594,11 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) case MN_ShowInLibrary: for(int i = 0; i < m_Library->GetItemCount(); i++) { - wxString matched_sample = settings.ShouldShowFileExtension() ? + wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(i, 1).BeforeLast('.') : m_Library->GetTextValue(i, 1); - wxString selected_sample_name = settings.ShouldShowFileExtension() ? + wxString selected_sample_name = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(event.GetItem()).BeforeLast('.') : m_Hives->GetItemText(event.GetItem()); @@ -1628,8 +1625,9 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event) void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) { TagEditor* tagEditor; - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); - wxString msg; + Serializer serializer(m_ConfigFilepath); + + wxString msg; wxDataViewItem item = event.GetItem(); int selected_row; @@ -1663,13 +1661,17 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) if (m_Library->GetSelectedItemsCount() <= 1) { - menu.Append(MN_EditTagSample, _("Edit tags"), _("Edit the tags for the selected sample"))->Enable(true); - menu.Append(MN_OpenFile, _("Open in file manager"), _("Open the selected sample in system's file manager"))->Enable(true); + menu.Append(MN_EditTagSample, _("Edit tags"), + _("Edit the tags for the selected sample"))->Enable(true); + menu.Append(MN_OpenFile, _("Open in file manager"), + _("Open the selected sample in system's file manager"))->Enable(true); } else { - menu.Append(MN_EditTagSample, _("Edit tags"), _("Edit the tags for the selected sample"))->Enable(false); - menu.Append(MN_OpenFile, _("Open in file manager"), _("Open the selected sample in system's file manager"))->Enable(false); + menu.Append(MN_EditTagSample, _("Edit tags"), + _("Edit the tags for the selected sample"))->Enable(false); + menu.Append(MN_OpenFile, _("Open in file manager"), + _("Open the selected sample in system's file manager"))->Enable(false); } switch (m_Library->GetPopupMenuSelectionFromUser(menu, event.GetPosition())) @@ -1701,7 +1703,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) wxString name = m_Library->GetTextValue(selected_row, 1); - filename = settings.ShouldShowFileExtension() ? + filename = serializer.DeserializeShowFileExtensionSetting() ? name.BeforeLast('.').ToStdString() : name.ToStdString(); db_status = m_Database->GetFavoriteColumnValueByFilename(filename); @@ -1815,7 +1817,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) { child = m_Hives->GetNthChild(container, k); - wxString child_text = settings.ShouldShowFileExtension() ? + wxString child_text = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child).BeforeLast('.') : m_Hives->GetItemText(child); @@ -1851,7 +1853,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) wxString text_value = m_Library->GetTextValue(row, 1); - std::string multi_selection = settings.ShouldShowFileExtension() ? + std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ? text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ; m_Database->RemoveSampleFromDatabase(multi_selection); @@ -1865,7 +1867,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) { child = m_Hives->GetNthChild(container, k); - wxString child_text = settings.ShouldShowFileExtension() ? + wxString child_text = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child).BeforeLast('.') : m_Hives->GetItemText(child); @@ -1913,7 +1915,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) wxString text_value = m_Library->GetTextValue(item_row, 1); - std::string multi_selection = settings.ShouldShowFileExtension() ? + std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() : m_Library->GetTextValue(item_row, 1).ToStdString() ; @@ -1935,7 +1937,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) { child = m_Hives->GetNthChild(container, k); - wxString child_text = settings.ShouldShowFileExtension() ? + wxString child_text = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child).BeforeLast('.') : m_Hives->GetItemText(child); @@ -1988,7 +1990,8 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event) case wxID_NONE: return; default: - wxMessageBox(_("Unexpected wxMenu return code!"), _("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this); + wxMessageBox(_("Unexpected wxMenu return code!"), _("Error!"), + wxOK | wxICON_ERROR | wxCENTRE, this); } if(!msg.IsEmpty()) @@ -2055,28 +2058,26 @@ void MainFrame::OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event) void MainFrame::LoadDatabase() { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); - try - { - m_Database->LoadHivesDatabase(*m_Hives); + Serializer serializer(m_ConfigFilepath); + try + { const auto dataset = m_Database->LoadSamplesDatabase(*m_Hives, favorites_hive, - *m_Trash, trash_root, settings.ShouldShowFileExtension(), + *m_Trash, trash_root, + serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); if (dataset.empty()) - { wxLogInfo(_("Error! Database is empty.")); - } else { for (auto data : dataset) - { m_Library->AppendItem(data); - } } + + m_Database->LoadHivesDatabase(*m_Hives); } - catch (...) + catch(...) { std::cerr << "Error loading data." << std::endl; } @@ -2084,8 +2085,9 @@ void MainFrame::LoadDatabase() void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); - wxTreeItemId selected_trashed_item = event.GetItem(); + Serializer serializer(m_ConfigFilepath); + + wxTreeItemId selected_trashed_item = event.GetItem(); wxMenu menu; @@ -2100,7 +2102,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event) { wxLogDebug(_("Delete permanently")); - wxString trashed_item_name = settings.ShouldShowFileExtension() ? + wxString trashed_item_name = serializer.DeserializeShowFileExtensionSetting() ? m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') : m_Trash->GetItemText(selected_trashed_item); @@ -2113,7 +2115,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event) { wxLogDebug(_("Restore sample")); - wxArrayTreeItemIds selected_item_ids; + wxArrayTreeItemIds selected_item_ids; m_Trash->GetSelections(selected_item_ids); wxFileDataObject file_data; @@ -2142,7 +2144,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event) wxVector> dataset; if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), - dataset, settings.ShouldShowFileExtension(), + dataset, serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty()) { wxLogDebug(_("Error! Database is empty.")); @@ -2172,7 +2174,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event) void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); + Serializer serializer(m_ConfigFilepath); if (event.GetNumberOfFiles() > 0) { @@ -2193,7 +2195,7 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event) wxString text_value = m_Library->GetTextValue(item_row, 1); - std::string multi_selection = settings.ShouldShowFileExtension() ? + std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() : m_Library->GetTextValue(item_row, 1).ToStdString() ; @@ -2215,7 +2217,7 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event) { child = m_Hives->GetNthChild(container, k); - wxString child_text = settings.ShouldShowFileExtension() ? + wxString child_text = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child).BeforeLast('.') : m_Hives->GetItemText(child); @@ -2325,8 +2327,9 @@ void MainFrame::OnClickAddHive(wxCommandEvent& event) void MainFrame::OnClickRemoveHive(wxCommandEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); - wxDataViewItem selected_item = m_Hives->GetSelection(); + Serializer serializer(m_ConfigFilepath); + + wxDataViewItem selected_item = m_Hives->GetSelection(); wxString hive_name = m_Hives->GetItemText(selected_item); wxString msg; @@ -2397,7 +2400,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event) for (int i = 0; i < m_Library->GetItemCount(); i++) { - wxString matched_sample = settings.ShouldShowFileExtension() ? + wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ? m_Library->GetTextValue(i, 1).BeforeLast('.') : m_Library->GetTextValue(i, 1); @@ -2405,7 +2408,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event) { child_item = m_Hives->GetNthChild(selected_item, j); - wxString child_name = settings.ShouldShowFileExtension() ? + wxString child_name = serializer.DeserializeShowFileExtensionSetting() ? m_Hives->GetItemText(child_item).BeforeLast('.') : m_Hives->GetItemText(child_item); @@ -2448,7 +2451,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event) void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); + Serializer serializer(m_ConfigFilepath); wxArrayTreeItemIds selected_item_ids; m_Trash->GetSelections(selected_item_ids); @@ -2467,7 +2470,8 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event) if (selected_item_ids.IsEmpty()) { - wxMessageBox(_("No item selected, try selected a item first."), wxMessageBoxCaptionStr, wxOK | wxCENTRE, this); + wxMessageBox(_("No item selected, try selected a item first."), wxMessageBoxCaptionStr, + wxOK | wxCENTRE, this); return; } @@ -2491,7 +2495,7 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event) wxVector> dataset; if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), dataset, - settings.ShouldShowFileExtension(), + serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty()) { wxLogDebug(_("Error! Database is empty.")); @@ -2515,13 +2519,13 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event) void MainFrame::OnDoSearch(wxCommandEvent& event) { - Settings settings(this, m_ConfigFilepath, m_DatabaseFilepath); + Serializer serializer(m_ConfigFilepath); const auto search = m_SearchBox->GetValue().ToStdString(); try { - const auto dataset = m_Database->FilterDatabaseBySampleName(search, settings.ShouldShowFileExtension(), + const auto dataset = m_Database->FilterDatabaseBySampleName(search, serializer.DeserializeShowFileExtensionSetting(), ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); if (dataset.empty()) @@ -2553,51 +2557,63 @@ void MainFrame::OnCancelSearch(wxCommandEvent& event) void MainFrame::LoadConfigFile() { - int height = 600, width = 800; - // Check if SampleHive configuration directory exist and create it if not - if (wxFileName::Mkdir(APP_CONFIG_DIR, wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | - wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | - wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) + if (!wxDirExists(APP_CONFIG_DIR)) { - wxLogDebug(wxString::Format(_("Successfully created configuratin directory at %s"), APP_CONFIG_DIR)); - } - else - { - wxMessageBox(wxString::Format(_("Error! Could not create configuration directory %s"), APP_CONFIG_DIR), _("Error!"), - wxOK | wxCENTRE, this); + if (wxFileName::Mkdir(APP_CONFIG_DIR, wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | + wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | + wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) + { + wxLogDebug(wxString::Format(_("Successfully created configuratin directory at %s"), + APP_CONFIG_DIR)); + } + else + { + wxMessageBox(wxString::Format(_("Error! Could not create configuration directory %s"), + APP_CONFIG_DIR), _("Error!"), wxOK | wxCENTRE, this); + } } // Check if SampleHive data directory exist and create it if not - if (wxFileName::Mkdir(APP_DATA_DIR, wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | - wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | - wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) + if (!wxDirExists(APP_DATA_DIR)) { - wxLogDebug(wxString::Format(_("Successfully created data directory at %s"), APP_DATA_DIR)); - } - else - { - wxMessageBox(wxString::Format(_("Error! Could not create data directory %s"), APP_DATA_DIR), _("Error!"), - wxOK | wxCENTRE, this); + if (wxFileName::Mkdir(APP_DATA_DIR, wxPOSIX_USER_READ | wxPOSIX_USER_WRITE | wxPOSIX_USER_EXECUTE | + wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | + wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) + { + wxLogDebug(wxString::Format(_("Successfully created data directory at %s"), APP_DATA_DIR)); + } + else + { + wxMessageBox(wxString::Format(_("Error! Could not create data directory %s"), APP_DATA_DIR), + _("Error!"), wxOK | wxCENTRE, this); + } } - Settings settings(m_ConfigFilepath, m_DatabaseFilepath); Serializer serialize(m_ConfigFilepath); - wxString font_face = serialize.DeserializeDisplaySettings().font_face; - int font_size = serialize.DeserializeDisplaySettings().font_size; + wxLogDebug(_("Reading from configuration file..")); - serialize.DeserializeBrowserControls("autoplay", bAutoplay); - serialize.DeserializeBrowserControls("loop", bLoop); - serialize.DeserializeBrowserControls("muted", bMuted); + int height = 600, width = 800; - height = serialize.DeserializeWinSize("Height", height); - width = serialize.DeserializeWinSize("Width", width); + bAutoplay = serialize.DeserializeBrowserControls("autoplay"); + bLoop = serialize.DeserializeBrowserControls("loop"); + bMuted = serialize.DeserializeBrowserControls("muted"); - settings.GetFontType().SetFaceName(font_face); - settings.GetFontType().SetPointSize(font_size); + width = serialize.DeserializeWinSize().first; + height = serialize.DeserializeWinSize().second; - this->SetFont(settings.GetFontType()); + bShowMenuBar = serialize.DeserializeShowMenuAndStatusBar("menubar"); + bShowStatusBar = serialize.DeserializeShowMenuAndStatusBar("statusbar"); + + m_ToggleMenuBar->Check(bShowMenuBar); + m_MenuBar->Show(bShowMenuBar); + m_ToggleStatusBar->Check(bShowStatusBar); + m_StatusBar->Show(bShowStatusBar); + + m_ToggleExtension->Check(serialize.DeserializeShowFileExtensionSetting()); + + this->SetFont(serialize.DeserializeDisplaySettings()); this->SetSize(width, height); this->SetMinSize(wxSize(width, height)); this->CenterOnScreen(wxBOTH); @@ -2624,30 +2640,129 @@ void MainFrame::RefreshDatabase() LoadDatabase(); } -// bool MainFrame::CreateWatcherIfNecessary() -// { -// if (m_FsWatcher) -// return false; - -// CreateWatcher(); -// Connect(wxEVT_FSWATCHER, -// wxFileSystemWatcherEventHandler(MainFrame::OnFileSystemEvent)); - -// return true; -// } - -// void MainFrame::CreateWatcher() -// { -// wxCHECK_RET(!m_FsWatcher, "Watcher already initialized"); - -// m_FsWatcher = new wxFileSystemWatcher(); -// m_FsWatcher->SetOwner(this); -// } - -FileInfo -MainFrame::GetFilenamePathAndExtension(const wxString& selected, bool checkExtension, bool doGetFilename) const +bool MainFrame::CreateWatcherIfNecessary() { - Settings settings(m_ConfigFilepath, m_DatabaseFilepath); + if (m_FsWatcher) + return false; + + CreateWatcher(); + Bind(wxEVT_FSWATCHER, &MainFrame::OnFileSystemEvent, this); + + return true; +} + +void MainFrame::CreateWatcher() +{ + Serializer serializer(m_ConfigFilepath); + + wxCHECK_RET(!m_FsWatcher, "Watcher already initialized"); + + m_FsWatcher = new wxFileSystemWatcher(); + m_FsWatcher->SetOwner(this); + + wxString path = serializer.DeserializeAutoImportSettings().second; + + if (serializer.DeserializeAutoImportSettings().first) + { + wxLogDebug("Adding watch entry.."); + AddWatchEntry(wxFSWPath_Tree, path.ToStdString()); + } +} + +void MainFrame::AddWatchEntry(wxFSWPathType type, std::string path) +{ + Serializer serializer(m_ConfigFilepath); + + if (path.empty()) + { + path = wxDirSelector("Choose a directory to watch", "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); + + if (path.empty()) + return; + } + + wxCHECK_RET(m_FsWatcher, "Watcher not initialized"); + + wxLogDebug("Adding %s: '%s'", path, type == wxFSWPath_Dir ? "directory" : "directory tree"); + + wxFileName filename = wxFileName::DirName(path); + + if (filename.IsDir() && filename.IsDirReadable() && filename.IsOk()) + wxLogDebug("Path is ok, adding to watch list."); + + if (!serializer.DeserializeFollowSymLink()) + { + filename.DontFollowLink(); + } + + bool ok = false; + + switch (type) + { + case wxFSWPath_Dir: + break; + case wxFSWPath_Tree: + ok = m_FsWatcher->AddTree(filename); + break; + case wxFSWPath_File: + break; + case wxFSWPath_None: + wxFAIL_MSG("Unexpected path type."); + } + + if (!ok) + { + wxLogError("Error! Cannot add '%s' to watched paths", filename.GetPath()); + return; + } +} + +void MainFrame::OnFileSystemEvent(wxFileSystemWatcherEvent& event) +{ + wxLogTrace(wxTRACE_FSWATCHER, "*** %s ***", event.ToString()); + + int type = event.GetChangeType(); + + wxString path = event.GetPath().GetFullPath(); + + wxArrayString files; + files.push_back(path); + + wxLogDebug("%s %s", path, event.ToString()); + + switch (type) + { + case wxFSW_EVENT_CREATE: + wxLogDebug("NEW FILES DETECTED, ADDING: %s", path); + AddSamples(files); + break; + case wxFSW_EVENT_ACCESS: + wxLogDebug("ACCESSING DIRECTORY: %s", path); + break; + case wxFSW_EVENT_DELETE: + wxLogDebug("FILES DELETED IN DIRECTORY: %s", path); + break; + case wxFSW_EVENT_MODIFY: + wxLogDebug("DIRECTORY MODIFIED: %s", path); + break; + case wxFSW_EVENT_RENAME: + wxLogDebug("FILES RENAMED IN DIRECTORY: %s", event.GetNewPath().GetFullPath()); + break; + case wxFSW_EVENT_WARNING: + wxLogDebug("Filesystem watcher warning: %d", event.GetWarningType()); + break; + case wxFSW_EVENT_ERROR: + wxLogDebug("Error! Filesystem watcher: %s", event.GetErrorDescription()); + break; + default: + break; + } +} + +FileInfo MainFrame::GetFilenamePathAndExtension(const wxString& selected, + bool checkExtension, bool doGetFilename) const +{ + Serializer serializer(m_ConfigFilepath); wxString path; std::string extension, filename; @@ -2657,7 +2772,7 @@ MainFrame::GetFilenamePathAndExtension(const wxString& selected, bool checkExten if (checkExtension) { - extension = settings.ShouldShowFileExtension() ? + extension = serializer.DeserializeShowFileExtensionSetting() ? m_Database->GetSampleFileExtension(selected.ToStdString()) : m_Database->GetSampleFileExtension(selected.BeforeLast('.').ToStdString()); } @@ -2721,56 +2836,67 @@ void MainFrame::OnSelectAddDirectory(wxCommandEvent& event) void MainFrame::OnSelectToggleExtension(wxCommandEvent& event) { - wxMessageBox("// TODO", "Toggle extension", wxOK | wxCENTRE, this); + Serializer serializer(m_ConfigFilepath); - m_Trash->DeleteAllItems(); - - // wxDataViewItem root = wxDataViewItem(wxNullPtr); - - // int item_count = m_Hives->GetChildCount(root); - - // for (int i = 0; i < item_count; i++) - // { - // wxDataViewItem item = m_Hives->GetNthChild(root, i); - - // wxLogDebug("Deleteing: %s", m_Hives->GetItemText(item)); - - // // m_Hives->DeleteItem(item); - // // break; - // } - - /* TODO: Toggle Show/Hide Extensions - * Perhaps need Refresh() - * that just updates all elements - * and sample info in all widgets. - */ + if (m_ToggleExtension->IsChecked()) + { + serializer.SerializeShowFileExtensionSetting(true); + m_InfoBar->ShowMessage(_("Extension showing, restart the application to view changes " + "or press CTRL+E to toggle show/hide."), wxICON_INFORMATION); + } + else + { + serializer.SerializeShowFileExtensionSetting(false); + m_InfoBar->ShowMessage(_("Extension hidden, restart the application to view changes " + "or press CTRL+E to toggle show/hide."), wxICON_INFORMATION); + } } void MainFrame::OnSelectToggleMenuBar(wxCommandEvent& event) { + Serializer serializer(m_ConfigFilepath); + if (m_ToggleMenuBar->IsChecked()) { m_MenuBar->Show(); m_InfoBar->ShowMessage(_("MenuBar showing, press CTRL+M to toggle show/hide."), wxICON_INFORMATION); + + bShowMenuBar = true; + + serializer.SerializeShowMenuAndStatusBar("menubar", bShowMenuBar); } else { m_MenuBar->Hide(); m_InfoBar->ShowMessage(_("MenuBar hidden, press CTRL+M to toggle show/hide."), wxICON_INFORMATION); + + bShowMenuBar = false; + + serializer.SerializeShowMenuAndStatusBar("menubar", bShowMenuBar); } } void MainFrame::OnSelectToggleStatusBar(wxCommandEvent& event) { + Serializer serializer(m_ConfigFilepath); + if (m_ToggleStatusBar->IsChecked()) { m_StatusBar->Show(); m_InfoBar->ShowMessage(_("StatusBar showing, press CTRL+B to toggle show/hide."), wxICON_INFORMATION); + + bShowStatusBar = true; + + serializer.SerializeShowMenuAndStatusBar("statusbar", bShowStatusBar); } else { m_StatusBar->Hide(); m_InfoBar->ShowMessage(_("StatusBar hidden, press CTRL+B to toggle show/hide."), wxICON_INFORMATION); + + bShowStatusBar = false; + + serializer.SerializeShowMenuAndStatusBar("statusbar", bShowStatusBar); } } @@ -2791,17 +2917,26 @@ void MainFrame::OnSelectPreferences(wxCommandEvent& event) OnAutoImportDir(settings->GetImportDirPath()); RefreshDatabase(); } + if (settings->IsWaveformColourChanged()) + { + m_TopWaveformPanel->ResetDC(); + } + break; + case wxID_CANCEL: break; default: - break; + return; } } void MainFrame::OnSelectResetAppData(wxCommandEvent& event) { - wxMessageDialog clearDataDialog(this, wxString::Format(_("Warning! This will delete configuration file \"%s\" and database file \"%s\" permanently, " - "are you sure you want to delete these files?"), m_ConfigFilepath, m_DatabaseFilepath), - _("Clear app data"), wxYES_NO | wxNO_DEFAULT | wxCENTRE, wxDefaultPosition); + wxMessageDialog clearDataDialog(this, wxString::Format(_("Warning! This will delete configuration file " + "\"%s\" and database file \"%s\" permanently, " + "are you sure you want to delete these files?"), + m_ConfigFilepath, m_DatabaseFilepath), + _("Clear app data"), + wxYES_NO | wxNO_DEFAULT | wxCENTRE, wxDefaultPosition); bool remove = false; @@ -2829,7 +2964,8 @@ void MainFrame::OnSelectResetAppData(wxCommandEvent& event) if (configIsDeleted && dbIsDeleted) m_InfoBar->ShowMessage(_("Successfully cleared app data"), wxICON_INFORMATION); else - wxMessageBox(_("Error! Could not clear app data"), _("Error!"), wxOK | wxCENTRE | wxICON_ERROR, this); + wxMessageBox(_("Error! Could not clear app data"), _("Error!"), + wxOK | wxCENTRE | wxICON_ERROR, this); } break; case wxID_NO: @@ -2930,7 +3066,8 @@ void MainFrame::ClearLoopPoints() bLoopPointsSet = false; } -void MainFrame::PlaySample(const std::string& filepath, const std::string& sample, bool seek, wxFileOffset where, wxSeekMode mode) +void MainFrame::PlaySample(const std::string& filepath, const std::string& sample, + bool seek, wxFileOffset where, wxSeekMode mode) { wxLogDebug("TIMER STARTING FROM %s", __FUNCTION__); @@ -2951,4 +3088,7 @@ void MainFrame::PlaySample(const std::string& filepath, const std::string& sampl wxLogDebug(_("Error! Cannot load sample.")); } -MainFrame::~MainFrame(){} +MainFrame::~MainFrame() +{ + delete m_FsWatcher; +} diff --git a/src/MainFrame.hpp b/src/GUI/MainFrame.hpp similarity index 97% rename from src/MainFrame.hpp rename to src/GUI/MainFrame.hpp index 94273d8..9797d13 100644 --- a/src/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -20,10 +20,11 @@ #pragma once -#include "Database.hpp" -#include "WaveformViewer.hpp" +#include "Database/Database.hpp" +#include "GUI/WaveformViewer.hpp" #include "SampleHiveConfig.hpp" -#include "SH_Event.hpp" +#include "Utility/Serialize.hpp" +#include "Utility/SH_Event.hpp" #include #include @@ -192,6 +193,8 @@ class MainFrame : public wxFrame bool bMuted = false; bool bStopped = false; bool bFiltered = false; + bool bShowMenuBar = false; + bool bShowStatusBar = false; bool bLoopPointsSet = false; // ------------------------------------------------------------------- @@ -290,6 +293,8 @@ class MainFrame : public wxFrame // Directory watchers bool CreateWatcherIfNecessary(); void CreateWatcher(); + void AddWatchEntry(wxFSWPathType type, std::string path); + void OnFileSystemEvent(wxFileSystemWatcherEvent& event); // wxString TagLibTowx(const TagLib::String& in); diff --git a/src/WaveformViewer.cpp b/src/GUI/WaveformViewer.cpp similarity index 94% rename from src/WaveformViewer.cpp rename to src/GUI/WaveformViewer.cpp index d1b02d5..b21bf0c 100644 --- a/src/WaveformViewer.cpp +++ b/src/GUI/WaveformViewer.cpp @@ -18,12 +18,10 @@ * along with this program. If not, see . */ -#include "WaveformViewer.hpp" -#include "Database.hpp" -#include "SettingsDialog.hpp" -#include "Serialize.hpp" -#include "Tags.hpp" -#include "SH_Event.hpp" +#include "GUI/WaveformViewer.hpp" +#include "Utility/Serialize.hpp" +#include "Utility/Tags.hpp" +#include "Utility/SH_Event.hpp" #include @@ -38,11 +36,12 @@ #include -WaveformViewer::WaveformViewer(wxWindow* parentFrame, wxWindow* window, wxDataViewListCtrl& library, +WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl, Database& database, const std::string& configFilepath, const std::string& databaseFilepath) - : wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE), - m_ParentFrame(parentFrame), m_Window(window), m_Database(database), m_Library(library), m_MediaCtrl(mediaCtrl), + : wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE), + m_Window(window), m_Database(database), m_Library(library), m_MediaCtrl(mediaCtrl), m_ConfigFilepath(configFilepath), m_DatabaseFilepath(databaseFilepath) { this->SetDoubleBuffered(true); @@ -99,7 +98,8 @@ void WaveformViewer::OnPaint(wxPaintEvent& event) { dc.SetPen(wxPen(wxColour(200, 200, 200, 255), 4, wxPENSTYLE_SOLID)); dc.SetBrush(wxBrush(wxColour(200, 200, 200, 80), wxBRUSHSTYLE_SOLID)); - dc.DrawRectangle(wxRect(m_AnchorPoint.x, -2, m_CurrentPoint.x - m_AnchorPoint.x, this->GetSize().GetHeight() + 5)); + dc.DrawRectangle(wxRect(m_AnchorPoint.x, -2, m_CurrentPoint.x - m_AnchorPoint.x, + this->GetSize().GetHeight() + 5)); bAreaSelected = true; SendLoopPoints(); @@ -148,7 +148,6 @@ void WaveformViewer::RenderPlayhead(wxDC& dc) void WaveformViewer::UpdateWaveformBitmap() { - Settings settings(m_ParentFrame, m_ConfigFilepath, m_DatabaseFilepath); Serializer serializer(m_ConfigFilepath); int selected_row = m_Library.GetSelectedRow(); @@ -158,10 +157,11 @@ void WaveformViewer::UpdateWaveformBitmap() wxString selection = m_Library.GetTextValue(selected_row, 1); - wxString filepath_with_extension = m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); + wxString filepath_with_extension = + m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString()); wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString()); - std::string extension = settings.ShouldShowFileExtension() ? + std::string extension = serializer.DeserializeShowFileExtensionSetting() ? m_Database.GetSampleFileExtension(selection.ToStdString()) : m_Database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString()); diff --git a/src/WaveformViewer.hpp b/src/GUI/WaveformViewer.hpp similarity index 95% rename from src/WaveformViewer.hpp rename to src/GUI/WaveformViewer.hpp index e073d65..382e9b5 100644 --- a/src/WaveformViewer.hpp +++ b/src/GUI/WaveformViewer.hpp @@ -20,7 +20,7 @@ #pragma once -#include "Database.hpp" +#include "Database/Database.hpp" #include #include @@ -38,14 +38,13 @@ class WaveformViewer : public wxPanel { public: - WaveformViewer(wxWindow* parentFrame, wxWindow* window, wxDataViewListCtrl& library, + WaveformViewer(wxWindow* window, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl, Database& database, const std::string& configFilepath, const std::string& databaseFilepath); ~WaveformViewer(); private: // ------------------------------------------------------------------- - wxWindow* m_ParentFrame; wxWindow* m_Window; Database& m_Database; diff --git a/src/ControlID_Enums.hpp b/src/Utility/ControlID_Enums.hpp similarity index 99% rename from src/ControlID_Enums.hpp rename to src/Utility/ControlID_Enums.hpp index 272af52..e928034 100644 --- a/src/ControlID_Enums.hpp +++ b/src/Utility/ControlID_Enums.hpp @@ -55,6 +55,7 @@ enum ControlIDs SD_BrowseConfigDir, SD_BrowseDatabaseDir, SD_AutoImport, + SD_FollowSymLinks, SD_ShowFileExtension, SD_BrowseAutoImportDir, SD_FontType, diff --git a/src/SH_Event.cpp b/src/Utility/SH_Event.cpp similarity index 67% rename from src/SH_Event.cpp rename to src/Utility/SH_Event.cpp index c1e6920..0513ab4 100644 --- a/src/SH_Event.cpp +++ b/src/Utility/SH_Event.cpp @@ -1,4 +1,24 @@ -#include "SH_Event.hpp" +/* SampleHive + * Copyright (C) 2021 Apoorv Singh + * A simple, modern audio sample browser/manager for GNU/Linux. + * + * This file is a part of SampleHive + * + * SampleHive is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SampleHive is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "Utility/SH_Event.hpp" namespace SampleHive { diff --git a/src/SH_Event.hpp b/src/Utility/SH_Event.hpp similarity index 83% rename from src/SH_Event.hpp rename to src/Utility/SH_Event.hpp index 4444be1..3061a63 100644 --- a/src/SH_Event.hpp +++ b/src/Utility/SH_Event.hpp @@ -1,3 +1,23 @@ +/* SampleHive + * Copyright (C) 2021 Apoorv Singh + * A simple, modern audio sample browser/manager for GNU/Linux. + * + * This file is a part of SampleHive + * + * SampleHive is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SampleHive is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #pragma once #include diff --git a/src/Sample.cpp b/src/Utility/Sample.cpp similarity index 61% rename from src/Sample.cpp rename to src/Utility/Sample.cpp index 9ca753b..80cd259 100644 --- a/src/Sample.cpp +++ b/src/Utility/Sample.cpp @@ -26,10 +26,13 @@ * @copyright GNU GPL v3 */ -#include "Sample.hpp" +#include "Utility/Sample.hpp" ///Default Constructor, Creates an empty sample profile -Sample::Sample(){} +Sample::Sample() +{ + +} ///Overloaded Constructor, Creates a sample profile with supplied data. @see Set() Sample::Sample(int favorite, const std::string& filename, const std::string& fileExtension, @@ -56,18 +59,6 @@ void Sample::Clear() m_Path = ""; } -// int Sample::GetFavorite() { return m_Favorite; } -// int Sample::GetChannels() { return m_Channels; } -// int Sample::GetLength() { return m_Length; } -// int Sample::GetSampleRate() { return m_SampleRate; } -// int Sample::GetBitrate() { return m_Bitrate; } -// int Sample::GetTrashed () { return m_Trashed; } -// std::string Sample::GetFilename() { return m_Filename; } -// std::string Sample::GetFileExtension() { return m_FileExtension; } -// std::string Sample::GetSamplePack() { return m_SamplePack; } -// std::string Sample::GetType() { return m_Type; } -// std::string Sample::GetPath() { return m_Path; } - void Sample::Set(int favorite, const std::string& filename, const std::string& fileExtension, const std::string& samplePack, const std::string& type, int channels, int length, int sampleRate, int bitrate, const std::string& path, int trashed) @@ -83,16 +74,4 @@ void Sample::Set(int favorite, const std::string& filename, const std::string& f m_Bitrate = bitrate; m_Path = path; m_Trashed = trashed; -} - -// void Sample::SetFavorite(int favorite) { m_Favorite = favorite; } -// void Sample::SetChannels(int channels) { m_Channels = channels; } -// void Sample::SetLength(int length) { m_Length = length; } -// void Sample::SetSampleRate(int sampleRate) { m_SampleRate = sampleRate; } -// void Sample::SetBitrate(int bitrate) { m_Bitrate = bitrate; } -// void Sample::SetTrashed (int trashed) { m_Trashed = trashed; } -// void Sample::SetFilename(std::string filename) { m_Filename = filename; } -// void Sample::SetFileExtension(std::string fileExtension) { m_FileExtension = fileExtension; } -// void Sample::SetSamplePack(std::string samplePack) { m_SamplePack = samplePack; } -// void Sample::SetType(std::string type) { m_Type = type; } -// void Sample::SetPath(std::string path) { m_Path = path; } +} diff --git a/src/Sample.hpp b/src/Utility/Sample.hpp similarity index 80% rename from src/Sample.hpp rename to src/Utility/Sample.hpp index 9e00834..ac3bd9f 100644 --- a/src/Sample.hpp +++ b/src/Utility/Sample.hpp @@ -26,8 +26,7 @@ * @copyright GNU GPL v3 */ -#ifndef _SAMPLE_HPP__ -#define _SAMPLE_HPP__ +#pragma once #include @@ -62,18 +61,6 @@ class Sample public: // ------------------------------------------------------------------- // Getters - // int GetFavorite(); - // int GetChannels(); - // int GetLength(); - // int GetSampleRate(); - // int GetBitrate(); - // int GetTrashed (); - // std::string GetFilename(); - // std::string GetFileExtension(); - // std::string GetSamplePack(); - // std::string GetType(); - // std::string GetPath(); - int GetFavorite() const { return m_Favorite; } int GetChannels() const { return m_Channels; } int GetLength() const { return m_Length; } @@ -86,28 +73,12 @@ class Sample std::string GetType() const { return m_Type; } std::string GetPath() const { return m_Path; } - // ------------------------------------------------------------------- - // Clear sample data - void Clear(); - // ------------------------------------------------------------------- // Setters void Set(int favorite, const std::string& filename, const std::string& fileExtension, const std::string& samplePack, const std::string& type, int channels, int length, int sampleRate, int bitrate, const std::string& path, int trashed); - // void SetFavorite(int favorite); - // void SetChannels(int channels); - // void SetLength(int length); - // void SetSampleRate(int sampleRate); - // void SetBitrate(int bitrate); - // void SetTrashed(int trashed); - // void SetFilename(std::string filename); - // void SetFileExtension(std::string fileExtension); - // void SetSamplePack(std::string samplePack); - // void SetType(std::string type); - // void SetPath(std::string path); - void SetFavorite(int favorite) { m_Favorite = favorite; } void SetChannels(int channels) { m_Channels = channels; } void SetLength(int length) { m_Length = length; } @@ -119,6 +90,8 @@ class Sample void SetSamplePack(const std::string& samplePack) { m_SamplePack = samplePack; } void SetType(const std::string& type) { m_Type = type; } void SetPath(const std::string& path) { m_Path = path; } -}; -#endif + // ------------------------------------------------------------------- + // Clear sample data + void Clear(); +}; diff --git a/src/Serialize.cpp b/src/Utility/Serialize.cpp similarity index 63% rename from src/Serialize.cpp rename to src/Utility/Serialize.cpp index 3752fbf..06b95c7 100644 --- a/src/Serialize.cpp +++ b/src/Utility/Serialize.cpp @@ -18,14 +18,13 @@ * along with this program. If not, see . */ -#include "Serialize.hpp" +#include "Utility/Serialize.hpp" #include #include #include #include -// #include #include #include @@ -58,6 +57,8 @@ Serializer::Serializer(const std::string& filepath) m_Emitter << YAML::BeginMap; m_Emitter << YAML::Key << "Width" << YAML::Value << 1280; m_Emitter << YAML::Key << "Height" << YAML::Value << 720; + m_Emitter << YAML::Key << "ShowMenuBar" << YAML::Value << true; + m_Emitter << YAML::Key << "ShowStatusBar" << YAML::Value << true; m_Emitter << YAML::EndMap << YAML::Newline; m_Emitter << YAML::Newline << YAML::Key << "Media"; @@ -74,17 +75,17 @@ Serializer::Serializer(const std::string& filepath) m_Emitter << YAML::Key << "Family" << YAML::Value << system_font_face; m_Emitter << YAML::Key << "Size" << YAML::Value << system_font_size; m_Emitter << YAML::EndMap; - m_Emitter << YAML::EndMap << YAML::Newline; - - m_Emitter << YAML::Newline << YAML::Key << "Waveform"; + m_Emitter << YAML::Key << "Waveform"; m_Emitter << YAML::BeginMap; m_Emitter << YAML::Key << "Colour" << YAML::Value << colour.GetAsString().ToStdString(); + m_Emitter << YAML::EndMap; m_Emitter << YAML::EndMap << YAML::Newline; m_Emitter << YAML::Newline << YAML::Key << "Collection"; m_Emitter << YAML::BeginMap; m_Emitter << YAML::Key << "AutoImport" << YAML::Value << false; m_Emitter << YAML::Key << "Directory" << YAML::Value << dir; + m_Emitter << YAML::Key << "FollowSymLink" << YAML::Value << false; m_Emitter << YAML::Key << "ShowFileExtension" << YAML::Value << true; m_Emitter << YAML::EndMap << YAML::Newline; @@ -95,10 +96,6 @@ Serializer::Serializer(const std::string& filepath) wxLogDebug("Generated %s successfully!", m_Filepath); } - else - { - wxLogDebug("Config file already exists! Skipping.."); - } } Serializer::~Serializer() @@ -106,32 +103,23 @@ Serializer::~Serializer() } -int Serializer::DeserializeWinSize(std::string key, int size) const +WindowSize Serializer::DeserializeWinSize() const { int width = 800, height = 600; try { - YAML::Node data = YAML::LoadFile(m_Filepath); + YAML::Node config = YAML::LoadFile(m_Filepath); - if (!data["Window"]) + if (!config["Window"]) { - return false; + return { width, height }; } - if (auto win = data["Window"]) + if (auto win = config["Window"]) { - if (key == "Height") - { - size = height; - size = win["Height"].as(); - } - - if (key == "Width") - { - size = width; - size = win["Width"].as(); - } + height = win["Height"].as(); + width = win["Width"].as(); } } catch(const YAML::ParserException& ex) @@ -139,14 +127,73 @@ int Serializer::DeserializeWinSize(std::string key, int size) const std::cout << ex.what() << std::endl; } - wxLogDebug("Window size: %d", size); + wxLogDebug("Window size: %d, %d", width, height); - return size; + return { width, height }; } -bool Serializer::DeserializeBrowserControls(std::string key, bool control) const +void Serializer::SerializeShowMenuAndStatusBar(std::string key, bool value) { - bool autoplay = false; bool loop = false; bool muted = false; + YAML::Emitter out; + + try + { + YAML::Node config = YAML::LoadFile(m_Filepath); + + if (auto bar = config["Window"]) + { + if (key == "menubar") + bar["ShowMenuBar"] = value; + + if (key == "statusbar") + bar["ShowStatusBar"] = value; + + out << config; + + std::ofstream ofstrm(m_Filepath); + ofstrm << out.c_str(); + } + else + wxLogDebug("Error! Cannot store show bar values."); + } + catch(const YAML::ParserException& ex) + { + std::cout << ex.what() << std::endl; + } +} + +bool Serializer::DeserializeShowMenuAndStatusBar(std::string key) const +{ + bool show = false; + + try + { + YAML::Node config = YAML::LoadFile(m_Filepath); + + if (auto bar = config["Window"]) + { + if (key == "menubar") + show = bar["ShowMenuBar"].as(); + + if (key == "statusbar") + show = bar["ShowStatusBar"].as(); + } + else + { + wxLogDebug("Error! Cannot fetch show bar values."); + } + } + catch(const YAML::ParserException& ex) + { + std::cout << ex.what() << std::endl; + } + + return show; +} + +void Serializer::SerializeBrowserControls(std::string key, bool value) +{ + YAML::Emitter out; try { @@ -155,37 +202,56 @@ bool Serializer::DeserializeBrowserControls(std::string key, bool control) const if (auto media = config["Media"]) { if (key == "autoplay") - { - control = autoplay; - autoplay = media["Autoplay"].as(); - } + media["Autoplay"] = value; if (key == "loop") - { - control = loop; - loop = media["Loop"].as(); - } + media["Loop"] = value; if (key == "muted") - { - control = muted; - muted = media["Muted"].as(); - } + media["Muted"] = value; + + out << config; + + std::ofstream ofstrm(m_Filepath); + ofstrm << out.c_str(); } else + wxLogDebug("Error! Cannot store media values."); + } + catch(const YAML::ParserException& ex) + { + std::cout << ex.what() << std::endl; + } +} + +bool Serializer::DeserializeBrowserControls(std::string key) const +{ + bool control = false; + + try + { + YAML::Node config = YAML::LoadFile(m_Filepath); + + if (auto media = config["Media"]) { - wxLogDebug("Error! Cannot fetch values."); + if (key == "autoplay") + control = media["Autoplay"].as(); + + if (key == "loop") + control = media["Loop"].as(); + + if (key == "muted") + control = media["Muted"].as(); } + else + wxLogDebug("Error! Cannot fetch values."); } catch(const YAML::ParserException& ex) { std::cout << ex.what() << std::endl; } - wxLogDebug("Autoplay: %s, Loop: %s, Muted: %s", - autoplay ? "enabled" : "disabled", - loop ? "enabled" : "disabled", - muted ? "muted" : "unmuted"); + wxLogDebug("%s: %s", key, control ? "enabled" : "disabled"); return control; } @@ -205,10 +271,6 @@ void Serializer::SerializeDisplaySettings(wxFont& font) if (auto fontSetting = display["Font"]) { - wxLogDebug("Changing font settings"); - wxLogDebug("Font face: %s", font_face); - wxLogDebug("Font size: %d", font_size); - fontSetting["Family"] = font_face; fontSetting["Size"] = font_size; @@ -228,8 +290,10 @@ void Serializer::SerializeDisplaySettings(wxFont& font) } } -FontType Serializer::DeserializeDisplaySettings() const +wxFont Serializer::DeserializeDisplaySettings() const { + wxFont font; + wxString face; int size = 0 ; @@ -243,6 +307,9 @@ FontType Serializer::DeserializeDisplaySettings() const { face = font_setting["Family"].as(); size = font_setting["Size"].as(); + + font.SetFaceName(face); + font.SetPointSize(size); } else { @@ -254,7 +321,7 @@ FontType Serializer::DeserializeDisplaySettings() const std::cout << ex.what() << std::endl; } - return { face, size }; + return font; } void Serializer::SerializeWaveformColour(wxColour& colour) @@ -267,11 +334,10 @@ void Serializer::SerializeWaveformColour(wxColour& colour) { YAML::Node config = YAML::LoadFile(m_Filepath); - if (auto waveform = config["Waveform"]) - { - wxLogDebug("Changing waveform colour"); - wxLogDebug("Waveform colour: %s", colour_string); + auto display = config["Display"]; + if (auto waveform = display["Waveform"]) + { waveform["Colour"] = colour_string; out << config; @@ -298,7 +364,9 @@ wxColour Serializer::DeserializeWaveformColour() const { YAML::Node config = YAML::LoadFile(m_Filepath); - if (auto waveform = config["Waveform"]) + auto display = config["Display"]; + + if (auto waveform = display["Waveform"]) { colour = waveform["Colour"].as(); } @@ -315,21 +383,18 @@ wxColour Serializer::DeserializeWaveformColour() const return static_cast(colour); } -void Serializer::SerializeAutoImportSettings(wxTextCtrl& textCtrl, wxCheckBox& checkBox) +void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string& importDir) { YAML::Emitter out; - std::string import_dir = textCtrl.GetValue().ToStdString(); - bool auto_import = checkBox.GetValue(); - try { YAML::Node config = YAML::LoadFile(m_Filepath); if (auto autoImportInfo = config["Collection"]) { - autoImportInfo["AutoImport"] = auto_import; - autoImportInfo["Directory"] = import_dir; + autoImportInfo["AutoImport"] = autoImport; + autoImportInfo["Directory"] = importDir; out << config; @@ -366,38 +431,87 @@ ImportDirInfo Serializer::DeserializeAutoImportSettings() const wxLogDebug("Error! Cannot fetch import dir values."); } } + catch (const YAML::ParserException& ex) + { + std::cout << ex.what() << std::endl; + } + + return { auto_import, dir }; +} + +void Serializer::SerializeFollowSymLink(bool followSymLinks) +{ + YAML::Emitter out; + + try + { + YAML::Node config = YAML::LoadFile(m_Filepath); + + if (auto followSymLinks = config["Collection"]) + { + followSymLinks["FollowSymLinks"] = followSymLinks; + + out << config; + + std::ofstream ofstrm(m_Filepath); + ofstrm << out.c_str(); + } + else + { + wxLogDebug("Error! Cannot store follow symbolic links value."); + } + } + catch(const YAML::ParserException& ex) + { + std::cout << ex.what() << std::endl; + } +} + +bool Serializer::DeserializeFollowSymLink() const +{ + bool follow_sym_links = false; + + try + { + YAML::Node config = YAML::LoadFile(m_Filepath); + + if (auto followSymLinks = config["Collection"]) + { + follow_sym_links = followSymLinks["FollowSymLinks"].as(); + } + else + { + wxLogDebug("Error! Cannot fetch follow symbolic links value."); + } + } catch(const YAML::ParserException& ex) { std::cout << ex.what() << std::endl; } - return { auto_import, dir}; + return follow_sym_links; } -void Serializer::SerializeShowFileExtensionSetting(wxCheckBox& checkBox) +void Serializer::SerializeShowFileExtensionSetting(bool showExtension) { YAML::Emitter out; - bool show_extension = checkBox.GetValue(); - try { YAML::Node config = YAML::LoadFile(m_Filepath); if (auto fileExtensionInfo = config["Collection"]) { - fileExtensionInfo["ShowFileExtension"] = show_extension; + fileExtensionInfo["ShowFileExtension"] = showExtension; out << config; - wxLogDebug("Changing show file extension value."); - std::ofstream ofstrm(m_Filepath); ofstrm << out.c_str(); } else { - wxLogDebug("Error! Cannot store import dir values."); + wxLogDebug("Error! Cannot store show file extension value."); } } catch(const YAML::ParserException& ex) @@ -421,7 +535,7 @@ bool Serializer::DeserializeShowFileExtensionSetting() const } else { - wxLogDebug("Error! Cannot fetch import dir values."); + wxLogDebug("Error! Cannot fetch show file extension value."); } } catch(const YAML::ParserException& ex) @@ -431,41 +545,3 @@ bool Serializer::DeserializeShowFileExtensionSetting() const return show_extension; } - -void Serializer::SerializeDataViewTreeCtrlItems(wxTreeCtrl& tree, wxTreeItemId& item) -{ - std::string path = "tree.yaml"; - - std::ifstream ifstrm(path); - - YAML::Emitter out; - - out << YAML::BeginMap; // Container - out << YAML::Key << "Container" << YAML::Value << ""; - - if (tree.HasChildren(item)) - { - out << YAML::Key << "Child"; - out << YAML::BeginMap; // Child - - for ( size_t i = 0; i < tree.GetChildrenCount(item); i++ ) - { - // wxTreeItemIdValue cookie; - wxString child = tree.GetItemText(tree.GetSelection()); - out << YAML::Key << "Item" << YAML::Value << child.ToStdString(); - } - - out << YAML::EndMap; // Child - } - - out << YAML::EndMap; // Container - - std::ofstream ofstrm(path); - ofstrm << out.c_str(); -} - -bool Serializer::DeserializeDataViewTreeCtrlItems(YAML::Emitter &out, wxDataViewItem item) const -{ - - return false; -} diff --git a/src/Serialize.hpp b/src/Utility/Serialize.hpp similarity index 69% rename from src/Serialize.hpp rename to src/Utility/Serialize.hpp index 2a98218..f0459fc 100644 --- a/src/Serialize.hpp +++ b/src/Utility/Serialize.hpp @@ -38,17 +38,9 @@ #include #include -struct FontType -{ - wxString font_face; - int font_size; -}; - -struct ImportDirInfo -{ - bool auto_import; - wxString import_dir; -}; +typedef std::pair WindowSize; +// typedef std::pair FontType; +typedef std::pair ImportDirInfo; class Serializer { @@ -60,37 +52,46 @@ class Serializer // ------------------------------------------------------------------- const std::string& m_Filepath; + // ------------------------------------------------------------------- YAML::Emitter m_Emitter; public: // ------------------------------------------------------------------- // Window size - int DeserializeWinSize(std::string key, int size) const; + WindowSize DeserializeWinSize() const; + + // ------------------------------------------------------------------- + // Menu and status bar + void SerializeShowMenuAndStatusBar(std::string key, bool value); + bool DeserializeShowMenuAndStatusBar(std::string key) const; // ------------------------------------------------------------------- // Browser controls - void SerializeBrowserControls(); - bool DeserializeBrowserControls(std::string key, bool control) const; + void SerializeBrowserControls(std::string key, bool value); + bool DeserializeBrowserControls(std::string key) const; // ------------------------------------------------------------------- // Display settings void SerializeDisplaySettings(wxFont& font); - FontType DeserializeDisplaySettings() const; + wxFont DeserializeDisplaySettings() const; + + // ------------------------------------------------------------------- + // Waveform colour void SerializeWaveformColour(wxColour& colour); wxColour DeserializeWaveformColour() const; // ------------------------------------------------------------------- // Auto import settings - void SerializeAutoImportSettings(wxTextCtrl& textCtrl, wxCheckBox& checkBox); + void SerializeAutoImportSettings(bool autoImport, const std::string& importDir); ImportDirInfo DeserializeAutoImportSettings() const; // ------------------------------------------------------------------- - // Show file extension - void SerializeShowFileExtensionSetting(wxCheckBox& checkBox); - bool DeserializeShowFileExtensionSetting() const; + // Follow symbolic links + void SerializeFollowSymLink(bool followSymLink); + bool DeserializeFollowSymLink() const; // ------------------------------------------------------------------- - // Favorite samples - void SerializeDataViewTreeCtrlItems(wxTreeCtrl& tree, wxTreeItemId& item); - bool DeserializeDataViewTreeCtrlItems(YAML::Emitter& out, wxDataViewItem item) const; + // Show file extension + void SerializeShowFileExtensionSetting(bool showExtension); + bool DeserializeShowFileExtensionSetting() const; }; diff --git a/src/Tags.cpp b/src/Utility/Tags.cpp similarity index 99% rename from src/Tags.cpp rename to src/Utility/Tags.cpp index 35d1ae5..bdf33ef 100644 --- a/src/Tags.cpp +++ b/src/Utility/Tags.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "Tags.hpp" +#include "Utility/Tags.hpp" #include "SampleHiveConfig.hpp" #include diff --git a/src/Tags.hpp b/src/Utility/Tags.hpp similarity index 100% rename from src/Tags.hpp rename to src/Utility/Tags.hpp