Add serialization for window size, recursive search for files and media volume.
This commit is contained in:
parent
f40f514912
commit
c9b79a6935
|
|
@ -72,7 +72,8 @@ Settings::Settings(wxWindow *window)
|
||||||
|
|
||||||
m_CollectionMainSizer = new wxBoxSizer(wxVERTICAL);
|
m_CollectionMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_CollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_CollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_CollectionBottomSizer = new wxBoxSizer(wxVERTICAL);
|
m_CollectionImportOptionsSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
m_CollectionShowExtensionSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
wxString defaultDir = wxGetHomeDir();
|
wxString defaultDir = wxGetHomeDir();
|
||||||
|
|
||||||
|
|
@ -88,6 +89,10 @@ Settings::Settings(wxWindow *window)
|
||||||
"Follow symbolic links", wxDefaultPosition, wxDefaultSize, 0);
|
"Follow symbolic links", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_FollowSymLinksCheck->SetToolTip("Wheather to follow symbolic links");
|
m_FollowSymLinksCheck->SetToolTip("Wheather to follow symbolic links");
|
||||||
m_FollowSymLinksCheck->Disable();
|
m_FollowSymLinksCheck->Disable();
|
||||||
|
m_RecursiveImportCheck = new wxCheckBox(m_CollectionSettingPanel, SD_RecursiveImport,
|
||||||
|
"Recursive search", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_RecursiveImportCheck->SetToolTip("Recursively search for samples in the directory");
|
||||||
|
m_RecursiveImportCheck->Disable();
|
||||||
m_ShowFileExtensionCheck = new wxCheckBox(m_CollectionSettingPanel, SD_ShowFileExtension,
|
m_ShowFileExtensionCheck = new wxCheckBox(m_CollectionSettingPanel, SD_ShowFileExtension,
|
||||||
"Show file extension", wxDefaultPosition, wxDefaultSize, 0);
|
"Show file extension", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_ShowFileExtensionCheck->SetToolTip("Weather to show file extension");
|
m_ShowFileExtensionCheck->SetToolTip("Weather to show file extension");
|
||||||
|
|
@ -124,6 +129,7 @@ Settings::Settings(wxWindow *window)
|
||||||
// Bind events
|
// Bind events
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckAutoImport, this, SD_AutoImport);
|
Bind(wxEVT_CHECKBOX, &Settings::OnCheckAutoImport, this, SD_AutoImport);
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckFollowSymLinks, this, SD_FollowSymLinks);
|
Bind(wxEVT_CHECKBOX, &Settings::OnCheckFollowSymLinks, this, SD_FollowSymLinks);
|
||||||
|
Bind(wxEVT_CHECKBOX, &Settings::OnCheckRecursiveImport, this, SD_RecursiveImport);
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckShowFileExtension, this, SD_ShowFileExtension);
|
Bind(wxEVT_CHECKBOX, &Settings::OnCheckShowFileExtension, this, SD_ShowFileExtension);
|
||||||
Bind(wxEVT_SPINCTRL, &Settings::OnChangeFontSize, this, SD_FontSize);
|
Bind(wxEVT_SPINCTRL, &Settings::OnChangeFontSize, this, SD_FontSize);
|
||||||
Bind(wxEVT_BUTTON, &Settings::OnSelectFont, this, SD_FontBrowseButton);
|
Bind(wxEVT_BUTTON, &Settings::OnSelectFont, this, SD_FontBrowseButton);
|
||||||
|
|
@ -157,11 +163,13 @@ Settings::Settings(wxWindow *window)
|
||||||
m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_CollectionBottomSizer->Add(m_FollowSymLinksCheck, 0, wxALL, 2);
|
m_CollectionImportOptionsSizer->Add(m_FollowSymLinksCheck, 0, wxALL, 2);
|
||||||
m_CollectionBottomSizer->Add(m_ShowFileExtensionCheck, 0, wxALL, 2);
|
m_CollectionImportOptionsSizer->Add(m_RecursiveImportCheck, 0, wxALL, 2);
|
||||||
|
m_CollectionShowExtensionSizer->Add(m_ShowFileExtensionCheck, 0, wxALL, 2);
|
||||||
|
|
||||||
m_CollectionMainSizer->Add(m_CollectionImportDirSizer, 0, wxALL | wxEXPAND, 2);
|
m_CollectionMainSizer->Add(m_CollectionImportDirSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
m_CollectionMainSizer->Add(m_CollectionBottomSizer, 0, wxALL | wxEXPAND, 2);
|
m_CollectionMainSizer->Add(m_CollectionImportOptionsSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
|
m_CollectionMainSizer->Add(m_CollectionShowExtensionSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_ButtonSizer->Add(m_OkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_ButtonSizer->Add(m_OkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
m_ButtonSizer->Add(m_CancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_ButtonSizer->Add(m_CancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
|
|
@ -250,8 +258,9 @@ void Settings::OnCheckAutoImport(wxCommandEvent& event)
|
||||||
m_ImportDirLocation->Disable();
|
m_ImportDirLocation->Disable();
|
||||||
m_BrowseAutoImportDirButton->Disable();
|
m_BrowseAutoImportDirButton->Disable();
|
||||||
m_FollowSymLinksCheck->Disable();
|
m_FollowSymLinksCheck->Disable();
|
||||||
|
m_RecursiveImportCheck->Disable();
|
||||||
|
|
||||||
serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -259,8 +268,9 @@ void Settings::OnCheckAutoImport(wxCommandEvent& event)
|
||||||
m_ImportDirLocation->Enable();
|
m_ImportDirLocation->Enable();
|
||||||
m_BrowseAutoImportDirButton->Enable();
|
m_BrowseAutoImportDirButton->Enable();
|
||||||
m_FollowSymLinksCheck->Enable();
|
m_FollowSymLinksCheck->Enable();
|
||||||
|
m_RecursiveImportCheck->Enable();
|
||||||
|
|
||||||
serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,11 +281,18 @@ void Settings::OnCheckFollowSymLinks(wxCommandEvent& event)
|
||||||
serializer.SerializeFollowSymLink(m_FollowSymLinksCheck->GetValue());
|
serializer.SerializeFollowSymLink(m_FollowSymLinksCheck->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::OnCheckRecursiveImport(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
|
serializer.SerializeRecursiveImport(m_RecursiveImportCheck->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::OnCheckShowFileExtension(wxCommandEvent& event)
|
void Settings::OnCheckShowFileExtension(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
serializer.SerializeShowFileExtensionSetting(m_ShowFileExtensionCheck->GetValue());
|
serializer.SerializeShowFileExtension(m_ShowFileExtensionCheck->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
||||||
|
|
@ -297,7 +314,7 @@ void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
||||||
wxString path = dir_dialog.GetPath();
|
wxString path = dir_dialog.GetPath();
|
||||||
m_ImportDirLocation->SetValue(path);
|
m_ImportDirLocation->SetValue(path);
|
||||||
|
|
||||||
serializer.SerializeAutoImportSettings(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -348,7 +365,7 @@ void Settings::OnChangeFontSize(wxSpinEvent& event)
|
||||||
|
|
||||||
m_Font.SetPointSize(font_size);
|
m_Font.SetPointSize(font_size);
|
||||||
|
|
||||||
serializer.SerializeDisplaySettings(m_Font);
|
serializer.SerializeFontSettings(m_Font);
|
||||||
|
|
||||||
m_Window->SetFont(m_Font);
|
m_Window->SetFont(m_Font);
|
||||||
this->SetFont(m_Font);
|
this->SetFont(m_Font);
|
||||||
|
|
@ -365,8 +382,8 @@ void Settings::LoadDefaultConfig()
|
||||||
wxString system_font = sys_font.GetFaceName();
|
wxString system_font = sys_font.GetFaceName();
|
||||||
int system_font_size = sys_font.GetPointSize();
|
int system_font_size = sys_font.GetPointSize();
|
||||||
|
|
||||||
wxString font_face = serializer.DeserializeDisplaySettings().GetFaceName();
|
wxString font_face = serializer.DeserializeFontSettings().GetFaceName();
|
||||||
int font_size = serializer.DeserializeDisplaySettings().GetPointSize();
|
int font_size = serializer.DeserializeFontSettings().GetPointSize();
|
||||||
|
|
||||||
if (system_font != font_face)
|
if (system_font != font_face)
|
||||||
{
|
{
|
||||||
|
|
@ -392,18 +409,20 @@ void Settings::LoadDefaultConfig()
|
||||||
m_FontSize->SetValue(font_size);
|
m_FontSize->SetValue(font_size);
|
||||||
SetCustomFont();
|
SetCustomFont();
|
||||||
|
|
||||||
bAutoImport = serializer.DeserializeAutoImportSettings().first;
|
bAutoImport = serializer.DeserializeAutoImport().first;
|
||||||
wxString location = serializer.DeserializeAutoImportSettings().second;
|
|
||||||
|
|
||||||
m_AutoImportCheck->SetValue(bAutoImport);
|
m_AutoImportCheck->SetValue(bAutoImport);
|
||||||
m_ImportDirLocation->SetValue(location);
|
m_ImportDirLocation->SetValue(serializer.DeserializeAutoImport().second);
|
||||||
m_ShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtensionSetting());
|
m_ShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtension());
|
||||||
|
m_FollowSymLinksCheck->SetValue(serializer.DeserializeFollowSymLink());
|
||||||
|
m_RecursiveImportCheck->SetValue(serializer.DeserializeRecursiveImport());
|
||||||
|
|
||||||
if (bAutoImport)
|
if (bAutoImport)
|
||||||
{
|
{
|
||||||
m_ImportDirLocation->Enable();
|
m_ImportDirLocation->Enable();
|
||||||
m_BrowseAutoImportDirButton->Enable();
|
m_BrowseAutoImportDirButton->Enable();
|
||||||
m_FollowSymLinksCheck->Enable();
|
m_FollowSymLinksCheck->Enable();
|
||||||
|
m_RecursiveImportCheck->Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,7 +431,7 @@ void Settings::SetShowExtension(bool value)
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
m_ShowFileExtensionCheck->SetValue(value);
|
m_ShowFileExtensionCheck->SetValue(value);
|
||||||
serializer.SerializeShowFileExtensionSetting(value);
|
serializer.SerializeShowFileExtension(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::PrintFont()
|
void Settings::PrintFont()
|
||||||
|
|
@ -432,22 +451,22 @@ void Settings::SetCustomFont()
|
||||||
std::string system_font = sys_font.GetFaceName().ToStdString();
|
std::string system_font = sys_font.GetFaceName().ToStdString();
|
||||||
int system_font_size = sys_font.GetPointSize();
|
int system_font_size = sys_font.GetPointSize();
|
||||||
|
|
||||||
wxString font_face = serializer.DeserializeDisplaySettings().GetFaceName();
|
wxString font_face = serializer.DeserializeFontSettings().GetFaceName();
|
||||||
int font_size = serializer.DeserializeDisplaySettings().GetPointSize();
|
int font_size = serializer.DeserializeFontSettings().GetPointSize();
|
||||||
|
|
||||||
if (m_FontType->GetStringSelection() == "System default")
|
if (m_FontType->GetStringSelection() == "System default")
|
||||||
{
|
{
|
||||||
m_Window->SetFont(sys_font);
|
m_Window->SetFont(sys_font);
|
||||||
this->SetFont(sys_font);
|
this->SetFont(sys_font);
|
||||||
|
|
||||||
serializer.SerializeDisplaySettings(sys_font);
|
serializer.SerializeFontSettings(sys_font);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Window->SetFont(m_Font);
|
m_Window->SetFont(m_Font);
|
||||||
this->SetFont(m_Font);
|
this->SetFont(m_Font);
|
||||||
|
|
||||||
serializer.SerializeDisplaySettings(m_Font);
|
serializer.SerializeFontSettings(m_Font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,9 +89,11 @@ class Settings : public wxDialog
|
||||||
// Collection page
|
// Collection page
|
||||||
wxBoxSizer* m_CollectionMainSizer;
|
wxBoxSizer* m_CollectionMainSizer;
|
||||||
wxBoxSizer* m_CollectionImportDirSizer;
|
wxBoxSizer* m_CollectionImportDirSizer;
|
||||||
wxBoxSizer* m_CollectionBottomSizer;
|
wxBoxSizer* m_CollectionImportOptionsSizer;
|
||||||
|
wxBoxSizer* m_CollectionShowExtensionSizer;
|
||||||
wxCheckBox* m_AutoImportCheck;
|
wxCheckBox* m_AutoImportCheck;
|
||||||
wxCheckBox* m_FollowSymLinksCheck;
|
wxCheckBox* m_FollowSymLinksCheck;
|
||||||
|
wxCheckBox* m_RecursiveImportCheck;
|
||||||
wxCheckBox* m_ShowFileExtensionCheck;
|
wxCheckBox* m_ShowFileExtensionCheck;
|
||||||
wxTextCtrl* m_ImportDirLocation;
|
wxTextCtrl* m_ImportDirLocation;
|
||||||
wxButton* m_BrowseAutoImportDirButton;
|
wxButton* m_BrowseAutoImportDirButton;
|
||||||
|
|
@ -128,6 +130,7 @@ class Settings : public wxDialog
|
||||||
void OnClickDatabaseBrowse(wxCommandEvent& event);
|
void OnClickDatabaseBrowse(wxCommandEvent& event);
|
||||||
void OnCheckAutoImport(wxCommandEvent& event);
|
void OnCheckAutoImport(wxCommandEvent& event);
|
||||||
void OnCheckFollowSymLinks(wxCommandEvent& event);
|
void OnCheckFollowSymLinks(wxCommandEvent& event);
|
||||||
|
void OnCheckRecursiveImport(wxCommandEvent& event);
|
||||||
void OnCheckShowFileExtension(wxCommandEvent& event);
|
void OnCheckShowFileExtension(wxCommandEvent& event);
|
||||||
void OnClickBrowseAutoImportDir(wxCommandEvent& event);
|
void OnClickBrowseAutoImportDir(wxCommandEvent& event);
|
||||||
void OnChangeFontSize(wxSpinEvent& event);
|
void OnChangeFontSize(wxSpinEvent& event);
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,6 @@ MainFrame::MainFrame()
|
||||||
// Set the menu bar to use
|
// Set the menu bar to use
|
||||||
SetMenuBar(m_MenuBar);
|
SetMenuBar(m_MenuBar);
|
||||||
|
|
||||||
// Load default yaml config file.
|
|
||||||
LoadConfigFile();
|
|
||||||
|
|
||||||
// Initializing Sizers
|
// Initializing Sizers
|
||||||
m_MainSizer = new wxBoxSizer(wxVERTICAL);
|
m_MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
|
@ -419,6 +416,7 @@ MainFrame::MainFrame()
|
||||||
Bind(wxEVT_MENU, &MainFrame::OnSelectResetAppData, this, wxID_REFRESH);
|
Bind(wxEVT_MENU, &MainFrame::OnSelectResetAppData, this, wxID_REFRESH);
|
||||||
Bind(wxEVT_MENU, &MainFrame::OnSelectAbout, this, wxID_ABOUT);
|
Bind(wxEVT_MENU, &MainFrame::OnSelectAbout, this, wxID_ABOUT);
|
||||||
|
|
||||||
|
this->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnResizeFrame), NULL, this);
|
||||||
m_StatusBar->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnResizeStatusBar), NULL, this);
|
m_StatusBar->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnResizeStatusBar), NULL, this);
|
||||||
|
|
||||||
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &MainFrame::OnClickDirCtrl, this, BC_DirCtrl);
|
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &MainFrame::OnClickDirCtrl, this, BC_DirCtrl);
|
||||||
|
|
@ -556,6 +554,9 @@ MainFrame::MainFrame()
|
||||||
m_BottomRightPanelMainSizer->SetSizeHints(m_BottomRightPanel);
|
m_BottomRightPanelMainSizer->SetSizeHints(m_BottomRightPanel);
|
||||||
m_BottomRightPanelMainSizer->Layout();
|
m_BottomRightPanelMainSizer->Layout();
|
||||||
|
|
||||||
|
// Load default yaml config file.
|
||||||
|
LoadConfigFile();
|
||||||
|
|
||||||
// Restore the data previously added to Library
|
// Restore the data previously added to Library
|
||||||
LoadDatabase();
|
LoadDatabase();
|
||||||
|
|
||||||
|
|
@ -639,7 +640,7 @@ void MainFrame::AddSamples(wxArrayString& files)
|
||||||
filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
||||||
extension = files[i].AfterLast('.').ToStdString();
|
extension = files[i].AfterLast('.').ToStdString();
|
||||||
|
|
||||||
filename = serializer.DeserializeShowFileExtensionSetting() ?
|
filename = serializer.DeserializeShowFileExtension() ?
|
||||||
filename_with_extension : filename_without_extension;
|
filename_with_extension : filename_without_extension;
|
||||||
|
|
||||||
Sample sample;
|
Sample sample;
|
||||||
|
|
@ -790,7 +791,7 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event)
|
||||||
|
|
||||||
files = file_data.GetFilenames();
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
wxString file_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString file_name = serializer.DeserializeShowFileExtension() ?
|
||||||
files[i].BeforeLast('.') : files[i];
|
files[i].BeforeLast('.') : files[i];
|
||||||
|
|
||||||
SH_LOG_DEBUG("Dropping {} file(s) {} on {}", rows - i, files[i], m_Hives->GetItemText(drop_target));
|
SH_LOG_DEBUG("Dropping {} file(s) {} on {}", rows - i, files[i], m_Hives->GetItemText(drop_target));
|
||||||
|
|
@ -945,7 +946,11 @@ void MainFrame::OnClickPlay(wxCommandEvent& event)
|
||||||
|
|
||||||
void MainFrame::OnClickLoop(wxCommandEvent& event)
|
void MainFrame::OnClickLoop(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
bLoop = m_LoopButton->GetValue();
|
bLoop = m_LoopButton->GetValue();
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("loop", bLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnClickStop(wxCommandEvent& event)
|
void MainFrame::OnClickStop(wxCommandEvent& event)
|
||||||
|
|
@ -964,15 +969,21 @@ void MainFrame::OnClickStop(wxCommandEvent& event)
|
||||||
|
|
||||||
void MainFrame::OnClickMute(wxCommandEvent& event)
|
void MainFrame::OnClickMute(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
if (m_MuteButton->GetValue())
|
if (m_MuteButton->GetValue())
|
||||||
{
|
{
|
||||||
m_MediaCtrl->SetVolume(0.0);
|
m_MediaCtrl->SetVolume(0.0);
|
||||||
bMuted = true;
|
bMuted = true;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("muted", bMuted);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_MediaCtrl->SetVolume(1.0);
|
m_MediaCtrl->SetVolume(double(m_VolumeSlider->GetValue()) / 100);
|
||||||
bMuted = false;
|
bMuted = false;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("muted", bMuted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1032,25 +1043,35 @@ void MainFrame::UpdateElapsedTime(wxTimerEvent& event)
|
||||||
|
|
||||||
void MainFrame::OnCheckAutoplay(wxCommandEvent& event)
|
void MainFrame::OnCheckAutoplay(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
if (m_AutoPlayCheck->GetValue())
|
if (m_AutoPlayCheck->GetValue())
|
||||||
{
|
{
|
||||||
bAutoplay = true;
|
bAutoplay = true;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("autoplay", bAutoplay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bAutoplay = false;
|
bAutoplay = false;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("autoplay", bAutoplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnSlideVolume(wxScrollEvent& event)
|
void MainFrame::OnSlideVolume(wxScrollEvent& event)
|
||||||
{
|
{
|
||||||
m_MediaCtrl->SetVolume(float(m_VolumeSlider->GetValue()) / 100);
|
m_MediaCtrl->SetVolume(double(m_VolumeSlider->GetValue()) / 100);
|
||||||
|
|
||||||
PushStatusText(wxString::Format(_("Volume: %d"), m_VolumeSlider->GetValue()), 1);
|
PushStatusText(wxString::Format(_("Volume: %d"), m_VolumeSlider->GetValue()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnReleaseVolumeSlider(wxScrollEvent& event)
|
void MainFrame::OnReleaseVolumeSlider(wxScrollEvent& event)
|
||||||
{
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
|
serializer.SerializeMediaVolume(m_VolumeSlider->GetValue());
|
||||||
|
|
||||||
int selected_row = m_Library->GetSelectedRow();
|
int selected_row = m_Library->GetSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
|
|
@ -1298,7 +1319,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
wxDataViewItem sample_item = m_Hives->GetNthChild(selected_hive, i);
|
wxDataViewItem sample_item = m_Hives->GetNthChild(selected_hive, i);
|
||||||
|
|
||||||
wxString sample_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(sample_item).BeforeLast('.') :
|
m_Hives->GetItemText(sample_item).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(sample_item);
|
m_Hives->GetItemText(sample_item);
|
||||||
|
|
||||||
|
|
@ -1398,7 +1419,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
for (int i = 0; i < m_Library->GetItemCount(); i++)
|
for (int i = 0; i < m_Library->GetItemCount(); i++)
|
||||||
{
|
{
|
||||||
wxString matched_sample =
|
wxString matched_sample =
|
||||||
serializer.DeserializeShowFileExtensionSetting() ?
|
serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
||||||
m_Library->GetTextValue(i, 1);
|
m_Library->GetTextValue(i, 1);
|
||||||
|
|
||||||
|
|
@ -1407,7 +1428,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
child_item = m_Hives->GetNthChild(selected_hive, j);
|
child_item = m_Hives->GetNthChild(selected_hive, j);
|
||||||
|
|
||||||
wxString child_name =
|
wxString child_name =
|
||||||
serializer.DeserializeShowFileExtensionSetting() ?
|
serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child_item);
|
m_Hives->GetItemText(child_item);
|
||||||
|
|
||||||
|
|
@ -1457,7 +1478,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(),
|
const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(),
|
||||||
serializer.DeserializeShowFileExtensionSetting(),
|
serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px,
|
ICON_STAR_FILLED_16px,
|
||||||
ICON_STAR_EMPTY_16px);
|
ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
|
@ -1489,7 +1510,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_Database->FilterDatabaseBySampleName("", serializer.DeserializeShowFileExtensionSetting(),
|
const auto dataset = m_Database->FilterDatabaseBySampleName("", serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
|
|
@ -1528,11 +1549,11 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
case MN_RemoveSample:
|
case MN_RemoveSample:
|
||||||
for(int i = 0; i < m_Library->GetItemCount(); i++)
|
for(int i = 0; i < m_Library->GetItemCount(); i++)
|
||||||
{
|
{
|
||||||
wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
||||||
m_Library->GetTextValue(i, 1);
|
m_Library->GetTextValue(i, 1);
|
||||||
|
|
||||||
wxString selected_sample_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString selected_sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(event.GetItem()).BeforeLast('.') :
|
m_Hives->GetItemText(event.GetItem()).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(event.GetItem());
|
m_Hives->GetItemText(event.GetItem());
|
||||||
|
|
||||||
|
|
@ -1560,11 +1581,11 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
case MN_ShowInLibrary:
|
case MN_ShowInLibrary:
|
||||||
for(int i = 0; i < m_Library->GetItemCount(); i++)
|
for(int i = 0; i < m_Library->GetItemCount(); i++)
|
||||||
{
|
{
|
||||||
wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
||||||
m_Library->GetTextValue(i, 1);
|
m_Library->GetTextValue(i, 1);
|
||||||
|
|
||||||
wxString selected_sample_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString selected_sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(event.GetItem()).BeforeLast('.') :
|
m_Hives->GetItemText(event.GetItem()).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(event.GetItem());
|
m_Hives->GetItemText(event.GetItem());
|
||||||
|
|
||||||
|
|
@ -1669,7 +1690,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
wxString name = m_Library->GetTextValue(selected_row, 1);
|
wxString name = m_Library->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
filename = serializer.DeserializeShowFileExtensionSetting() ?
|
filename = serializer.DeserializeShowFileExtension() ?
|
||||||
name.BeforeLast('.').ToStdString() : name.ToStdString();
|
name.BeforeLast('.').ToStdString() : name.ToStdString();
|
||||||
|
|
||||||
db_status = m_Database->GetFavoriteColumnValueByFilename(filename);
|
db_status = m_Database->GetFavoriteColumnValueByFilename(filename);
|
||||||
|
|
@ -1779,7 +1800,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
child = m_Hives->GetNthChild(container, k);
|
child = m_Hives->GetNthChild(container, k);
|
||||||
|
|
||||||
wxString child_text = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child).BeforeLast('.') :
|
m_Hives->GetItemText(child).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child);
|
m_Hives->GetItemText(child);
|
||||||
|
|
||||||
|
|
@ -1815,7 +1836,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
wxString text_value = m_Library->GetTextValue(row, 1);
|
wxString text_value = m_Library->GetTextValue(row, 1);
|
||||||
|
|
||||||
std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ?
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ;
|
text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ;
|
||||||
|
|
||||||
m_Database->RemoveSampleFromDatabase(multi_selection);
|
m_Database->RemoveSampleFromDatabase(multi_selection);
|
||||||
|
|
@ -1829,7 +1850,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
child = m_Hives->GetNthChild(container, k);
|
child = m_Hives->GetNthChild(container, k);
|
||||||
|
|
||||||
wxString child_text = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child).BeforeLast('.') :
|
m_Hives->GetItemText(child).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child);
|
m_Hives->GetItemText(child);
|
||||||
|
|
||||||
|
|
@ -1877,7 +1898,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
|
|
||||||
wxString text_value = m_Library->GetTextValue(item_row, 1);
|
wxString text_value = m_Library->GetTextValue(item_row, 1);
|
||||||
|
|
||||||
std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ?
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
||||||
m_Library->GetTextValue(item_row, 1).ToStdString() ;
|
m_Library->GetTextValue(item_row, 1).ToStdString() ;
|
||||||
|
|
||||||
|
|
@ -1899,7 +1920,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
{
|
{
|
||||||
child = m_Hives->GetNthChild(container, k);
|
child = m_Hives->GetNthChild(container, k);
|
||||||
|
|
||||||
wxString child_text = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child).BeforeLast('.') :
|
m_Hives->GetItemText(child).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child);
|
m_Hives->GetItemText(child);
|
||||||
|
|
||||||
|
|
@ -2035,7 +2056,7 @@ void MainFrame::LoadDatabase()
|
||||||
{
|
{
|
||||||
const auto dataset = m_Database->LoadSamplesDatabase(*m_Hives, favorites_hive,
|
const auto dataset = m_Database->LoadSamplesDatabase(*m_Hives, favorites_hive,
|
||||||
*m_Trash, trash_root,
|
*m_Trash, trash_root,
|
||||||
serializer.DeserializeShowFileExtensionSetting(),
|
serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
if (dataset.empty())
|
if (dataset.empty())
|
||||||
|
|
@ -2071,7 +2092,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
{
|
{
|
||||||
case MN_DeleteTrash:
|
case MN_DeleteTrash:
|
||||||
{
|
{
|
||||||
wxString trashed_item_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString trashed_item_name = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') :
|
m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') :
|
||||||
m_Trash->GetItemText(selected_trashed_item);
|
m_Trash->GetItemText(selected_trashed_item);
|
||||||
|
|
||||||
|
|
@ -2111,7 +2132,7 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
|
|
||||||
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(),
|
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(),
|
||||||
dataset,
|
dataset,
|
||||||
serializer.DeserializeShowFileExtensionSetting(),
|
serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px,
|
ICON_STAR_FILLED_16px,
|
||||||
ICON_STAR_EMPTY_16px).empty())
|
ICON_STAR_EMPTY_16px).empty())
|
||||||
{
|
{
|
||||||
|
|
@ -2165,7 +2186,7 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event)
|
||||||
|
|
||||||
wxString text_value = m_Library->GetTextValue(item_row, 1);
|
wxString text_value = m_Library->GetTextValue(item_row, 1);
|
||||||
|
|
||||||
std::string multi_selection = serializer.DeserializeShowFileExtensionSetting() ?
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
m_Library->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
||||||
m_Library->GetTextValue(item_row, 1).ToStdString() ;
|
m_Library->GetTextValue(item_row, 1).ToStdString() ;
|
||||||
|
|
||||||
|
|
@ -2187,7 +2208,7 @@ void MainFrame::OnDragAndDropToTrash(wxDropFilesEvent& event)
|
||||||
{
|
{
|
||||||
child = m_Hives->GetNthChild(container, k);
|
child = m_Hives->GetNthChild(container, k);
|
||||||
|
|
||||||
wxString child_text = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child).BeforeLast('.') :
|
m_Hives->GetItemText(child).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child);
|
m_Hives->GetItemText(child);
|
||||||
|
|
||||||
|
|
@ -2363,7 +2384,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
|
|
||||||
for (int i = 0; i < m_Library->GetItemCount(); i++)
|
for (int i = 0; i < m_Library->GetItemCount(); i++)
|
||||||
{
|
{
|
||||||
wxString matched_sample = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
m_Library->GetTextValue(i, 1).BeforeLast('.') :
|
||||||
m_Library->GetTextValue(i, 1);
|
m_Library->GetTextValue(i, 1);
|
||||||
|
|
||||||
|
|
@ -2371,7 +2392,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
child_item = m_Hives->GetNthChild(selected_item, j);
|
child_item = m_Hives->GetNthChild(selected_item, j);
|
||||||
|
|
||||||
wxString child_name = serializer.DeserializeShowFileExtensionSetting() ?
|
wxString child_name = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
m_Hives->GetItemText(child_item).BeforeLast('.') :
|
||||||
m_Hives->GetItemText(child_item);
|
m_Hives->GetItemText(child_item);
|
||||||
|
|
||||||
|
|
@ -2456,7 +2477,7 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event)
|
||||||
wxVector<wxVector<wxVariant>> dataset;
|
wxVector<wxVector<wxVariant>> dataset;
|
||||||
|
|
||||||
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), dataset,
|
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), dataset,
|
||||||
serializer.DeserializeShowFileExtensionSetting(),
|
serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Error! Database is empty.");
|
SH_LOG_INFO("Error! Database is empty.");
|
||||||
|
|
@ -2487,7 +2508,7 @@ void MainFrame::OnDoSearch(wxCommandEvent& event)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto dataset = m_Database->FilterDatabaseBySampleName(search,
|
const auto dataset = m_Database->FilterDatabaseBySampleName(search,
|
||||||
serializer.DeserializeShowFileExtensionSetting(),
|
serializer.DeserializeShowFileExtension(),
|
||||||
ICON_STAR_FILLED_16px,
|
ICON_STAR_FILLED_16px,
|
||||||
ICON_STAR_EMPTY_16px);
|
ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
|
@ -2558,13 +2579,26 @@ void MainFrame::LoadConfigFile()
|
||||||
|
|
||||||
int height = 600, width = 800;
|
int height = 600, width = 800;
|
||||||
|
|
||||||
bAutoplay = serializer.DeserializeBrowserControls("autoplay");
|
bAutoplay = serializer.DeserializeMediaOptions("autoplay");
|
||||||
bLoop = serializer.DeserializeBrowserControls("loop");
|
bLoop = serializer.DeserializeMediaOptions("loop");
|
||||||
bMuted = serializer.DeserializeBrowserControls("muted");
|
bMuted = serializer.DeserializeMediaOptions("muted");
|
||||||
|
|
||||||
|
m_AutoPlayCheck->SetValue(bAutoplay);
|
||||||
|
m_LoopButton->SetValue(bLoop);
|
||||||
|
m_MuteButton->SetValue(bMuted);
|
||||||
|
|
||||||
|
m_VolumeSlider->SetValue(serializer.DeserializeMediaVolume());
|
||||||
|
|
||||||
|
if (!bMuted)
|
||||||
|
m_MediaCtrl->SetVolume(double(m_VolumeSlider->GetValue()) / 100);
|
||||||
|
else
|
||||||
|
m_MediaCtrl->SetVolume(0.0);
|
||||||
|
|
||||||
width = serializer.DeserializeWinSize().first;
|
width = serializer.DeserializeWinSize().first;
|
||||||
height = serializer.DeserializeWinSize().second;
|
height = serializer.DeserializeWinSize().second;
|
||||||
|
|
||||||
|
int min_width = 960, min_height = 540;
|
||||||
|
|
||||||
bShowMenuBar = serializer.DeserializeShowMenuAndStatusBar("menubar");
|
bShowMenuBar = serializer.DeserializeShowMenuAndStatusBar("menubar");
|
||||||
bShowStatusBar = serializer.DeserializeShowMenuAndStatusBar("statusbar");
|
bShowStatusBar = serializer.DeserializeShowMenuAndStatusBar("statusbar");
|
||||||
|
|
||||||
|
|
@ -2573,11 +2607,11 @@ void MainFrame::LoadConfigFile()
|
||||||
m_ToggleStatusBar->Check(bShowStatusBar);
|
m_ToggleStatusBar->Check(bShowStatusBar);
|
||||||
m_StatusBar->Show(bShowStatusBar);
|
m_StatusBar->Show(bShowStatusBar);
|
||||||
|
|
||||||
m_ToggleExtension->Check(serializer.DeserializeShowFileExtensionSetting());
|
m_ToggleExtension->Check(serializer.DeserializeShowFileExtension());
|
||||||
|
|
||||||
this->SetFont(serializer.DeserializeDisplaySettings());
|
this->SetFont(serializer.DeserializeFontSettings());
|
||||||
this->SetSize(width, height);
|
this->SetSize(width, height);
|
||||||
this->SetMinSize(wxSize(width, height));
|
this->SetMinSize(wxSize(min_width, min_height));
|
||||||
this->CenterOnScreen(wxBOTH);
|
this->CenterOnScreen(wxBOTH);
|
||||||
this->SetIcon(wxIcon(ICON_HIVE_256px, wxICON_DEFAULT_TYPE, -1, -1));
|
this->SetIcon(wxIcon(ICON_HIVE_256px, wxICON_DEFAULT_TYPE, -1, -1));
|
||||||
this->SetTitle(PROJECT_NAME);
|
this->SetTitle(PROJECT_NAME);
|
||||||
|
|
@ -2620,12 +2654,16 @@ void MainFrame::CreateWatcher()
|
||||||
m_FsWatcher = new wxFileSystemWatcher();
|
m_FsWatcher = new wxFileSystemWatcher();
|
||||||
m_FsWatcher->SetOwner(this);
|
m_FsWatcher->SetOwner(this);
|
||||||
|
|
||||||
wxString path = serializer.DeserializeAutoImportSettings().second;
|
wxString path = serializer.DeserializeAutoImport().second;
|
||||||
|
|
||||||
if (serializer.DeserializeAutoImportSettings().first)
|
if (serializer.DeserializeAutoImport().first)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Adding watch entry: {}", path);
|
SH_LOG_INFO("Adding watch entry: {}", path);
|
||||||
|
|
||||||
|
if (serializer.DeserializeRecursiveImport())
|
||||||
AddWatchEntry(wxFSWPath_Tree, path.ToStdString());
|
AddWatchEntry(wxFSWPath_Tree, path.ToStdString());
|
||||||
|
else
|
||||||
|
AddWatchEntry(wxFSWPath_Dir, path.ToStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2663,6 +2701,7 @@ void MainFrame::AddWatchEntry(wxFSWPathType type, std::string path)
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case wxFSWPath_Dir:
|
case wxFSWPath_Dir:
|
||||||
|
ok = m_FsWatcher->Add(filename);
|
||||||
break;
|
break;
|
||||||
case wxFSWPath_Tree:
|
case wxFSWPath_Tree:
|
||||||
ok = m_FsWatcher->AddTree(filename);
|
ok = m_FsWatcher->AddTree(filename);
|
||||||
|
|
@ -2735,7 +2774,7 @@ FileInfo MainFrame::GetFilenamePathAndExtension(const wxString& selected,
|
||||||
|
|
||||||
if (checkExtension)
|
if (checkExtension)
|
||||||
{
|
{
|
||||||
extension = serializer.DeserializeShowFileExtensionSetting() ?
|
extension = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Database->GetSampleFileExtension(selected.ToStdString()) :
|
m_Database->GetSampleFileExtension(selected.ToStdString()) :
|
||||||
m_Database->GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
m_Database->GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
||||||
}
|
}
|
||||||
|
|
@ -2803,13 +2842,13 @@ void MainFrame::OnSelectToggleExtension(wxCommandEvent& event)
|
||||||
|
|
||||||
if (m_ToggleExtension->IsChecked())
|
if (m_ToggleExtension->IsChecked())
|
||||||
{
|
{
|
||||||
serializer.SerializeShowFileExtensionSetting(true);
|
serializer.SerializeShowFileExtension(true);
|
||||||
m_InfoBar->ShowMessage(_("Extension showing, restart the application to view changes "
|
m_InfoBar->ShowMessage(_("Extension showing, restart the application to view changes "
|
||||||
"or press CTRL+E to toggle show/hide."), wxICON_INFORMATION);
|
"or press CTRL+E to toggle show/hide."), wxICON_INFORMATION);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serializer.SerializeShowFileExtensionSetting(false);
|
serializer.SerializeShowFileExtension(false);
|
||||||
m_InfoBar->ShowMessage(_("Extension hidden, restart the application to view changes "
|
m_InfoBar->ShowMessage(_("Extension hidden, restart the application to view changes "
|
||||||
"or press CTRL+E to toggle show/hide."), wxICON_INFORMATION);
|
"or press CTRL+E to toggle show/hide."), wxICON_INFORMATION);
|
||||||
}
|
}
|
||||||
|
|
@ -2997,6 +3036,17 @@ void MainFrame::OnResizeStatusBar(wxSizeEvent& event)
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainFrame::OnResizeFrame(wxSizeEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Frame resized to {}, {}", GetSize().GetWidth(), GetSize().GetHeight());
|
||||||
|
|
||||||
|
serializer.SerializeWinSize(GetSize().GetWidth(), GetSize().GetHeight());
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
void MainFrame::SetAfterFrameCreate()
|
void MainFrame::SetAfterFrameCreate()
|
||||||
{
|
{
|
||||||
m_TopSplitter->SetSashPosition(200);
|
m_TopSplitter->SetSashPosition(200);
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ class MainFrame : public wxFrame
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// FileSystemWatcher
|
// FileSystemWatcher
|
||||||
wxFileSystemWatcher* m_FsWatcher;
|
wxFileSystemWatcher* m_FsWatcher = nullptr;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxLongLong m_LoopA, m_LoopB;
|
wxLongLong m_LoopA, m_LoopB;
|
||||||
|
|
@ -258,6 +258,10 @@ class MainFrame : public wxFrame
|
||||||
// Statusbar event handler
|
// Statusbar event handler
|
||||||
void OnResizeStatusBar(wxSizeEvent& event);
|
void OnResizeStatusBar(wxSizeEvent& event);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Frame resize event handler
|
||||||
|
void OnResizeFrame(wxSizeEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Timer update event handler
|
// Timer update event handler
|
||||||
void UpdateElapsedTime(wxTimerEvent& event);
|
void UpdateElapsedTime(wxTimerEvent& event);
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
std::string extension = serializer.DeserializeShowFileExtensionSetting() ?
|
std::string extension = serializer.DeserializeShowFileExtension() ?
|
||||||
m_Database.GetSampleFileExtension(selection.ToStdString()) :
|
m_Database.GetSampleFileExtension(selection.ToStdString()) :
|
||||||
m_Database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
m_Database.GetSampleFileExtension(selection.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ enum ControlIDs
|
||||||
SD_BrowseDatabaseDir,
|
SD_BrowseDatabaseDir,
|
||||||
SD_AutoImport,
|
SD_AutoImport,
|
||||||
SD_FollowSymLinks,
|
SD_FollowSymLinks,
|
||||||
|
SD_RecursiveImport,
|
||||||
SD_ShowFileExtension,
|
SD_ShowFileExtension,
|
||||||
SD_BrowseAutoImportDir,
|
SD_BrowseAutoImportDir,
|
||||||
SD_FontType,
|
SD_FontType,
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ Serializer::Serializer()
|
||||||
m_Emitter << YAML::Key << "Autoplay" << YAML::Value << false;
|
m_Emitter << YAML::Key << "Autoplay" << YAML::Value << false;
|
||||||
m_Emitter << YAML::Key << "Loop" << YAML::Value << false;
|
m_Emitter << YAML::Key << "Loop" << YAML::Value << false;
|
||||||
m_Emitter << YAML::Key << "Muted" << YAML::Value << false;
|
m_Emitter << YAML::Key << "Muted" << YAML::Value << false;
|
||||||
|
m_Emitter << YAML::Key << "Volume" << YAML::Value << 100;
|
||||||
m_Emitter << YAML::EndMap << YAML::Newline;
|
m_Emitter << YAML::EndMap << YAML::Newline;
|
||||||
|
|
||||||
m_Emitter << YAML::Newline << YAML::Key << "Display";
|
m_Emitter << YAML::Newline << YAML::Key << "Display";
|
||||||
|
|
@ -89,6 +90,7 @@ Serializer::Serializer()
|
||||||
m_Emitter << YAML::Key << "AutoImport" << YAML::Value << false;
|
m_Emitter << YAML::Key << "AutoImport" << YAML::Value << false;
|
||||||
m_Emitter << YAML::Key << "Directory" << YAML::Value << dir;
|
m_Emitter << YAML::Key << "Directory" << YAML::Value << dir;
|
||||||
m_Emitter << YAML::Key << "FollowSymLink" << YAML::Value << false;
|
m_Emitter << YAML::Key << "FollowSymLink" << YAML::Value << false;
|
||||||
|
m_Emitter << YAML::Key << "RecursiveImport" << YAML::Value << false;
|
||||||
m_Emitter << YAML::Key << "ShowFileExtension" << YAML::Value << true;
|
m_Emitter << YAML::Key << "ShowFileExtension" << YAML::Value << true;
|
||||||
m_Emitter << YAML::EndMap << YAML::Newline;
|
m_Emitter << YAML::EndMap << YAML::Newline;
|
||||||
|
|
||||||
|
|
@ -106,6 +108,35 @@ Serializer::~Serializer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Serializer::SerializeWinSize(int w, int h)
|
||||||
|
{
|
||||||
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto win = config["Window"])
|
||||||
|
{
|
||||||
|
win["Width"] = w;
|
||||||
|
win["Height"] = h;
|
||||||
|
|
||||||
|
out << config;
|
||||||
|
|
||||||
|
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
ofstrm << out.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! Cannot store window size values.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WindowSize Serializer::DeserializeWinSize() const
|
WindowSize Serializer::DeserializeWinSize() const
|
||||||
{
|
{
|
||||||
int width = 800, height = 600;
|
int width = 800, height = 600;
|
||||||
|
|
@ -194,7 +225,7 @@ bool Serializer::DeserializeShowMenuAndStatusBar(std::string key) const
|
||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serializer::SerializeBrowserControls(std::string key, bool value)
|
void Serializer::SerializeMediaOptions(std::string key, bool value)
|
||||||
{
|
{
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
|
@ -227,7 +258,7 @@ void Serializer::SerializeBrowserControls(std::string key, bool value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::DeserializeBrowserControls(std::string key) const
|
bool Serializer::DeserializeMediaOptions(std::string key) const
|
||||||
{
|
{
|
||||||
bool control = false;
|
bool control = false;
|
||||||
|
|
||||||
|
|
@ -247,7 +278,7 @@ bool Serializer::DeserializeBrowserControls(std::string key) const
|
||||||
control = media["Muted"].as<bool>();
|
control = media["Muted"].as<bool>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SH_LOG_ERROR("Error! Cannot fetch values.");
|
SH_LOG_ERROR("Error! Cannot fetch media values.");
|
||||||
}
|
}
|
||||||
catch(const YAML::ParserException& ex)
|
catch(const YAML::ParserException& ex)
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +290,56 @@ bool Serializer::DeserializeBrowserControls(std::string key) const
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serializer::SerializeDisplaySettings(wxFont& font)
|
void Serializer::SerializeMediaVolume(int volume)
|
||||||
|
{
|
||||||
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto media = config["Media"])
|
||||||
|
{
|
||||||
|
media["Volume"] = volume;
|
||||||
|
|
||||||
|
out << config;
|
||||||
|
|
||||||
|
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
ofstrm << out.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SH_LOG_ERROR("Error! Cannot store volume values.");
|
||||||
|
}
|
||||||
|
catch(const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Serializer::DeserializeMediaVolume() const
|
||||||
|
{
|
||||||
|
int volume = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto media = config["Media"])
|
||||||
|
volume = media["Volume"].as<int>();
|
||||||
|
else
|
||||||
|
SH_LOG_ERROR("Error! Cannot fetch volume values.");
|
||||||
|
}
|
||||||
|
catch(const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
SH_LOG_INFO("Volume: {}", volume);
|
||||||
|
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serializer::SerializeFontSettings(wxFont& font)
|
||||||
{
|
{
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
|
@ -293,7 +373,7 @@ void Serializer::SerializeDisplaySettings(wxFont& font)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont Serializer::DeserializeDisplaySettings() const
|
wxFont Serializer::DeserializeFontSettings() const
|
||||||
{
|
{
|
||||||
wxFont font;
|
wxFont font;
|
||||||
|
|
||||||
|
|
@ -386,7 +466,7 @@ wxColour Serializer::DeserializeWaveformColour() const
|
||||||
return static_cast<wxString>(colour);
|
return static_cast<wxString>(colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string& importDir)
|
void Serializer::SerializeAutoImport(bool autoImport, const std::string& importDir)
|
||||||
{
|
{
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
|
@ -415,7 +495,7 @@ void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportDirInfo Serializer::DeserializeAutoImportSettings() const
|
ImportDirInfo Serializer::DeserializeAutoImport() const
|
||||||
{
|
{
|
||||||
wxString dir;
|
wxString dir;
|
||||||
bool auto_import = false;
|
bool auto_import = false;
|
||||||
|
|
@ -452,7 +532,7 @@ void Serializer::SerializeFollowSymLink(bool followSymLinks)
|
||||||
|
|
||||||
if (auto followSymLinks = config["Collection"])
|
if (auto followSymLinks = config["Collection"])
|
||||||
{
|
{
|
||||||
followSymLinks["FollowSymLinks"] = followSymLinks;
|
followSymLinks["FollowSymLink"] = followSymLinks;
|
||||||
|
|
||||||
out << config;
|
out << config;
|
||||||
|
|
||||||
|
|
@ -480,7 +560,7 @@ bool Serializer::DeserializeFollowSymLink() const
|
||||||
|
|
||||||
if (auto followSymLinks = config["Collection"])
|
if (auto followSymLinks = config["Collection"])
|
||||||
{
|
{
|
||||||
follow_sym_links = followSymLinks["FollowSymLinks"].as<bool>();
|
follow_sym_links = followSymLinks["FollowSymLink"].as<bool>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -495,7 +575,60 @@ bool Serializer::DeserializeFollowSymLink() const
|
||||||
return follow_sym_links;
|
return follow_sym_links;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serializer::SerializeShowFileExtensionSetting(bool showExtension)
|
void Serializer::SerializeRecursiveImport(bool recursiveImport)
|
||||||
|
{
|
||||||
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto recursive = config["Collection"])
|
||||||
|
{
|
||||||
|
recursive["RecursiveImport"] = recursiveImport;
|
||||||
|
|
||||||
|
out << config;
|
||||||
|
|
||||||
|
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
ofstrm << out.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! Cannot store recursive import value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Serializer::DeserializeRecursiveImport() const
|
||||||
|
{
|
||||||
|
bool recursive_import = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto recursive = config["Collection"])
|
||||||
|
{
|
||||||
|
recursive_import = recursive["RecursiveImport"].as<bool>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! Cannot fetch recursive import value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
return recursive_import;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Serializer::SerializeShowFileExtension(bool showExtension)
|
||||||
{
|
{
|
||||||
YAML::Emitter out;
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
|
@ -523,7 +656,7 @@ void Serializer::SerializeShowFileExtensionSetting(bool showExtension)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Serializer::DeserializeShowFileExtensionSetting() const
|
bool Serializer::DeserializeShowFileExtension() const
|
||||||
{
|
{
|
||||||
bool show_extension = false;
|
bool show_extension = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class Serializer
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Window size
|
// Window size
|
||||||
|
void SerializeWinSize(int w, int h);
|
||||||
WindowSize DeserializeWinSize() const;
|
WindowSize DeserializeWinSize() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -64,13 +65,16 @@ class Serializer
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Browser controls
|
// Browser controls
|
||||||
void SerializeBrowserControls(std::string key, bool value);
|
void SerializeMediaOptions(std::string key, bool value);
|
||||||
bool DeserializeBrowserControls(std::string key) const;
|
bool DeserializeMediaOptions(std::string key) const;
|
||||||
|
|
||||||
|
void SerializeMediaVolume(int volume);
|
||||||
|
int DeserializeMediaVolume() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Display settings
|
// Display settings
|
||||||
void SerializeDisplaySettings(wxFont& font);
|
void SerializeFontSettings(wxFont& font);
|
||||||
wxFont DeserializeDisplaySettings() const;
|
wxFont DeserializeFontSettings() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Waveform colour
|
// Waveform colour
|
||||||
|
|
@ -79,16 +83,21 @@ class Serializer
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Auto import settings
|
// Auto import settings
|
||||||
void SerializeAutoImportSettings(bool autoImport, const std::string& importDir);
|
void SerializeAutoImport(bool autoImport, const std::string& importDir);
|
||||||
ImportDirInfo DeserializeAutoImportSettings() const;
|
ImportDirInfo DeserializeAutoImport() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Follow symbolic links
|
// Follow symbolic links
|
||||||
void SerializeFollowSymLink(bool followSymLink);
|
void SerializeFollowSymLink(bool followSymLink);
|
||||||
bool DeserializeFollowSymLink() const;
|
bool DeserializeFollowSymLink() const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Recursive import
|
||||||
|
void SerializeRecursiveImport(bool recursiveImport);
|
||||||
|
bool DeserializeRecursiveImport() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Show file extension
|
// Show file extension
|
||||||
void SerializeShowFileExtensionSetting(bool showExtension);
|
void SerializeShowFileExtension(bool showExtension);
|
||||||
bool DeserializeShowFileExtensionSetting() const;
|
bool DeserializeShowFileExtension() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue