diff --git a/.dir-locals.el b/.dir-locals.el
old mode 100755
new mode 100644
diff --git a/src/App.cpp b/src/App.cpp
index 83d9394..90e448c 100644
--- a/src/App.cpp
+++ b/src/App.cpp
@@ -40,18 +40,6 @@ cApp::cApp()
cApp::~cApp()
{
- SampleHive::cSerializer serializer;
-
- if (serializer.DeserializeDemoMode())
- {
- if (wxFileExists("tempdb.db"))
- if (wxRemoveFile("tempdb.db"))
- SH_LOG_WARN("Deleted temporary database file..");
- else
- SH_LOG_ERROR("Could not delete file..");
- else
- SH_LOG_DEBUG("File doesn't exists");
- }
}
bool cApp::OnInit()
@@ -107,13 +95,32 @@ bool cApp::OnCmdLineParsed(wxCmdLineParser& parser)
if (parser.Found("version"))
{
std::cout << PROJECT_NAME << ' ' << PROJECT_VERSION << std::endl;
+ std::cout <<
+ "\nCopyright (C) 2021 Apoorv Singh"
+ "\nA simple, modern audio sample browser/manager for GNU/Linux."
+ "\n"
+ "\nThis file is a part of SampleHive"
+ "\n"
+ "\nSampleHive is free software: you can redistribute it and/or modify"
+ "\nit under the terms of the GNU General Public License as published by"
+ "\nthe Free Software Foundation, either version 3 of the License, or"
+ "\n(at your option) any later version."
+ "\n"
+ "\nSampleHive is distributed in the hope that it will be useful,"
+ "\nbut WITHOUT ANY WARRANTY; without even the implied warranty of"
+ "\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
+ "\nGNU General Public License for more details."
+ "\n"
+ "\nYou should have received a copy of the GNU General Public License"
+ "\nalong with this program. If not, see ."
+ << std::endl;
return false;
}
else if (parser.Found("reset"))
{
char ans;
- std::cout << "Are you sure you want reset app data? [y/N] ";
+ std::cout << "Are you sure you want clear all app data? [y/N] ";
std::cin >> ans;
if (ans == 'y' || ans == 'Y')
diff --git a/src/Database/Database.cpp b/src/Database/Database.cpp
index a08419f..e1a5032 100644
--- a/src/Database/Database.cpp
+++ b/src/Database/Database.cpp
@@ -1048,7 +1048,6 @@ void cDatabase::OpenDatabase()
void cDatabase::OpenTemporaryDatabase()
{
- SH_LOG_WARN("Creating temporary in memory database, all samples will be deleted on application exit.");
throw_on_sqlite3_error(sqlite3_open("tempdb.db", &m_pDatabase));
}
diff --git a/src/GUI/Dialogs/Settings.cpp b/src/GUI/Dialogs/Settings.cpp
index fbd9e3a..136e02e 100644
--- a/src/GUI/Dialogs/Settings.cpp
+++ b/src/GUI/Dialogs/Settings.cpp
@@ -31,7 +31,7 @@
cSettings::cSettings(wxWindow *window)
: wxDialog(window, wxID_ANY, "cSettings", wxDefaultPosition,
- wxSize(720, 270), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
+ wxSize(720, 300), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
m_pWindow(window)
{
m_pPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
@@ -76,6 +76,7 @@ cSettings::cSettings(wxWindow *window)
m_pCollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL);
m_pCollectionImportOptionsSizer = new wxBoxSizer(wxHORIZONTAL);
m_pCollectionShowExtensionSizer = new wxBoxSizer(wxVERTICAL);
+ m_pDoubleClickToPlaySizer = new wxBoxSizer(wxVERTICAL);
wxString defaultDir = wxGetHomeDir();
@@ -98,6 +99,8 @@ cSettings::cSettings(wxWindow *window)
m_pShowFileExtensionCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_ShowFileExtension,
"Show file extension", wxDefaultPosition, wxDefaultSize, 0);
m_pShowFileExtensionCheck->SetToolTip("Weather to show file extension");
+ m_pDoubleClickToPlayCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_DoubleClickToPlay,
+ "Enable double click to play sample", wxDefaultPosition, wxDefaultSize, 0);
m_pConfigurationSettingPanel = new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
@@ -133,6 +136,7 @@ cSettings::cSettings(wxWindow *window)
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckFollowSymLinks, this, SampleHive::ID::SD_FollowSymLinks);
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckRecursiveImport, this, SampleHive::ID::SD_RecursiveImport);
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckShowFileExtension, this, SampleHive::ID::SD_ShowFileExtension);
+ Bind(wxEVT_CHECKBOX, &cSettings::OnCheckEnableDoubleClickToPlay, this, SampleHive::ID::SD_DoubleClickToPlay);
Bind(wxEVT_SPINCTRL, &cSettings::OnChangeFontSize, this, SampleHive::ID::SD_FontSize);
Bind(wxEVT_BUTTON, &cSettings::OnSelectFont, this, SampleHive::ID::SD_FontBrowseButton);
Bind(wxEVT_BUTTON, &cSettings::OnClickBrowseAutoImportDir, this, SampleHive::ID::SD_BrowseAutoImportDir);
@@ -170,10 +174,12 @@ cSettings::cSettings(wxWindow *window)
m_pCollectionImportOptionsSizer->Add(m_pFollowSymLinksCheck, 0, wxALL, 2);
m_pCollectionImportOptionsSizer->Add(m_pRecursiveImportCheck, 0, wxALL, 2);
m_pCollectionShowExtensionSizer->Add(m_pShowFileExtensionCheck, 0, wxALL, 2);
+ m_pDoubleClickToPlaySizer->Add(m_pDoubleClickToPlayCheck, 0, wxALL, 2);
m_pCollectionMainSizer->Add(m_pCollectionImportDirSizer, 0, wxALL | wxEXPAND, 2);
m_pCollectionMainSizer->Add(m_pCollectionImportOptionsSizer, 0, wxALL | wxEXPAND, 2);
m_pCollectionMainSizer->Add(m_pCollectionShowExtensionSizer, 0, wxALL | wxEXPAND, 2);
+ m_pCollectionMainSizer->Add(m_pDoubleClickToPlaySizer, 0, wxALL | wxEXPAND, 2);
m_pButtonSizer->Add(m_pOkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
m_pButtonSizer->Add(m_pCancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
@@ -299,6 +305,13 @@ void cSettings::OnCheckShowFileExtension(wxCommandEvent& event)
serializer.SerializeShowFileExtension(m_pShowFileExtensionCheck->GetValue());
}
+void cSettings::OnCheckEnableDoubleClickToPlay(wxCommandEvent& event)
+{
+ SampleHive::cSerializer serializer;
+
+ serializer.SerializeDoubleClickToPlay(m_pDoubleClickToPlayCheck->GetValue());
+}
+
void cSettings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
{
SampleHive::cSerializer serializer;
@@ -418,6 +431,7 @@ void cSettings::LoadDefaultConfig()
m_pAutoImportCheck->SetValue(m_bAutoImport);
m_pImportDirLocation->SetValue(serializer.DeserializeAutoImport().second);
m_pShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtension());
+ m_pDoubleClickToPlayCheck->SetValue(serializer.DeserializeDoubleClickToPlay());
m_pFollowSymLinksCheck->SetValue(serializer.DeserializeFollowSymLink());
m_pRecursiveImportCheck->SetValue(serializer.DeserializeRecursiveImport());
diff --git a/src/GUI/Dialogs/Settings.hpp b/src/GUI/Dialogs/Settings.hpp
index 940d0ba..3155186 100644
--- a/src/GUI/Dialogs/Settings.hpp
+++ b/src/GUI/Dialogs/Settings.hpp
@@ -54,6 +54,7 @@ class cSettings : public wxDialog
void OnCheckFollowSymLinks(wxCommandEvent& event);
void OnCheckRecursiveImport(wxCommandEvent& event);
void OnCheckShowFileExtension(wxCommandEvent& event);
+ void OnCheckEnableDoubleClickToPlay(wxCommandEvent& event);
void OnClickBrowseAutoImportDir(wxCommandEvent& event);
void OnChangeFontSize(wxSpinEvent& event);
void OnSelectFont(wxCommandEvent& event);
@@ -126,10 +127,12 @@ class cSettings : public wxDialog
wxBoxSizer* m_pCollectionImportDirSizer = nullptr;
wxBoxSizer* m_pCollectionImportOptionsSizer = nullptr;
wxBoxSizer* m_pCollectionShowExtensionSizer = nullptr;
+ wxBoxSizer* m_pDoubleClickToPlaySizer = nullptr;
wxCheckBox* m_pAutoImportCheck = nullptr;
wxCheckBox* m_pFollowSymLinksCheck = nullptr;
wxCheckBox* m_pRecursiveImportCheck = nullptr;
wxCheckBox* m_pShowFileExtensionCheck = nullptr;
+ wxCheckBox* m_pDoubleClickToPlayCheck = nullptr;
wxTextCtrl* m_pImportDirLocation = nullptr;
wxButton* m_pBrowseAutoImportDirButton = nullptr;
diff --git a/src/GUI/ListCtrl.cpp b/src/GUI/ListCtrl.cpp
index 4d81627..95d9867 100644
--- a/src/GUI/ListCtrl.cpp
+++ b/src/GUI/ListCtrl.cpp
@@ -119,6 +119,7 @@ cListCtrl::cListCtrl(wxWindow* window)
this->EnableDragSource(wxDF_FILENAME);
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &cListCtrl::OnClickLibrary, this, SampleHive::ID::BC_Library);
+ Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &cListCtrl::OnDoubleClickLibrary, this, SampleHive::ID::BC_Library);
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &cListCtrl::OnDragFromLibrary, this);
this->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(cListCtrl::OnDragAndDropToLibrary), NULL, this);
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &cListCtrl::OnShowLibraryContextMenu, this, SampleHive::ID::BC_Library);
@@ -244,6 +245,54 @@ void cListCtrl::OnClickLibrary(wxDataViewEvent& event)
}
}
+void cListCtrl::OnDoubleClickLibrary(wxDataViewEvent& event)
+{
+ cDatabase db;
+ SampleHive::cSerializer serializer;
+
+ int selected_row = this->ItemToRow(event.GetItem());
+ int current_row = this->ItemToRow(this->GetCurrentItem());
+
+ if (selected_row < 0 || !event.GetItem().IsOk())
+ return;
+
+ if (selected_row != current_row)
+ {
+ this->SetCurrentItem(event.GetItem());
+ return;
+ }
+
+ // Update the waveform bitmap
+ SampleHive::cSignal::SendWaveformUpdateStatus(*this);
+
+ // Update LoopAB button value
+ SampleHive::cSignal::SendLoopABButtonValueChange(*this);
+
+ // Stop the timer
+ SampleHive::cSignal::SendTimerStopStatus(*this);
+
+ wxString selection = this->GetTextValue(selected_row, 1);
+
+ // Get curremt column
+ wxDataViewColumn* CurrentColumn = this->GetCurrentColumn();
+
+ // Get favorite column
+ wxDataViewColumn* FavoriteColumn = this->GetColumn(0);
+
+ if (!CurrentColumn)
+ return;
+
+ if (CurrentColumn != FavoriteColumn)
+ {
+ // ClearLoopPoints();
+ SampleHive::cSignal::SendClearLoopPointsStatus(*this);
+
+ // Play the sample
+ if (serializer.DeserializeDoubleClickToPlay())
+ SampleHive::cSignal::SendCallFunctionPlay(selection, false, *this);
+ }
+}
+
void cListCtrl::OnDragAndDropToLibrary(wxDropFilesEvent& event)
{
SH_LOG_DEBUG("Start Inserting Samples");
diff --git a/src/GUI/ListCtrl.hpp b/src/GUI/ListCtrl.hpp
index 1ef2ee8..4252054 100644
--- a/src/GUI/ListCtrl.hpp
+++ b/src/GUI/ListCtrl.hpp
@@ -39,6 +39,7 @@ class cListCtrl : public wxDataViewListCtrl
// -------------------------------------------------------------------
// Library event handlers
void OnClickLibrary(wxDataViewEvent& event);
+ void OnDoubleClickLibrary(wxDataViewEvent& event);
void OnDragAndDropToLibrary(wxDropFilesEvent& event);
void OnDragFromLibrary(wxDataViewEvent& event);
void OnShowLibraryContextMenu(wxDataViewEvent& event);
diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp
index b2f1e24..e178d84 100644
--- a/src/GUI/MainFrame.cpp
+++ b/src/GUI/MainFrame.cpp
@@ -132,6 +132,11 @@ cMainFrame::cMainFrame()
m_pLibrary = new cLibrary(m_pBottomSplitter);
+ if (m_bDemoMode)
+ {
+ m_pLibrary->GetInfoBarObject()->ShowMessage("WARNING: Demo mode is turned on, all samples will be deleted on application exit.", wxICON_WARNING);
+ }
+
SampleHive::cHiveData::Get().InitHiveData(*m_pLibrary->GetListCtrlObject(),
*m_pNotebook->GetHivesPanel()->GetHivesObject(),
m_pNotebook->GetHivesPanel()->GetFavoritesHive(),
@@ -957,4 +962,17 @@ cMainFrame::~cMainFrame()
// Delete wxFilesystemWatcher
delete m_pFsWatcher;
+
+ SampleHive::cSerializer serializer;
+
+ if (serializer.DeserializeDemoMode())
+ {
+ if (wxFileExists("tempdb.db"))
+ if (wxRemoveFile("tempdb.db"))
+ SH_LOG_WARN("Deleted temporary database file..");
+ else
+ SH_LOG_ERROR("Could not delete file..");
+ else
+ SH_LOG_DEBUG("File doesn't exists");
+ }
}
diff --git a/src/Utility/ControlIDs.hpp b/src/Utility/ControlIDs.hpp
index 2d42a0d..48907cf 100644
--- a/src/Utility/ControlIDs.hpp
+++ b/src/Utility/ControlIDs.hpp
@@ -60,6 +60,7 @@ namespace SampleHive { namespace ID {
SD_FollowSymLinks,
SD_RecursiveImport,
SD_ShowFileExtension,
+ SD_DoubleClickToPlay,
SD_BrowseAutoImportDir,
SD_FontType,
SD_FontSize,
diff --git a/src/Utility/Serialize.cpp b/src/Utility/Serialize.cpp
index 3135ef7..ab9d737 100644
--- a/src/Utility/Serialize.cpp
+++ b/src/Utility/Serialize.cpp
@@ -106,6 +106,7 @@ namespace SampleHive {
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 << "DoubleClickToPlay" << YAML::Value << false;
m_Emitter << YAML::EndMap << YAML::Newline;
m_Emitter << YAML::EndMap;
@@ -811,6 +812,59 @@ namespace SampleHive {
return show_extension;
}
+ void cSerializer::SerializeDoubleClickToPlay(bool enableDoubleClick)
+ {
+ YAML::Emitter out;
+
+ try
+ {
+ YAML::Node config = YAML::LoadFile(static_cast(CONFIG_FILEPATH));
+
+ if (auto doubleClickValue = config["Collection"])
+ {
+ doubleClickValue["DoubleClickToPlay"] = enableDoubleClick;
+
+ out << config;
+
+ std::ofstream ofstrm(static_cast(CONFIG_FILEPATH));
+ ofstrm << out.c_str();
+ }
+ else
+ {
+ SH_LOG_ERROR("Error! Cannot store show enable double click to play value.");
+ }
+ }
+ catch (const YAML::ParserException& ex)
+ {
+ SH_LOG_ERROR(ex.what());
+ }
+ }
+
+ bool cSerializer::DeserializeDoubleClickToPlay() const
+ {
+ bool double_click_to_play = false;
+
+ try
+ {
+ YAML::Node config = YAML::LoadFile(static_cast(CONFIG_FILEPATH));
+
+ if (auto doubleClickValue = config["Collection"])
+ {
+ double_click_to_play = doubleClickValue["DoubleClickToPlay"].as();
+ }
+ else
+ {
+ SH_LOG_ERROR("Error! Cannot fetch double click to play value.");
+ }
+ }
+ catch (const YAML::ParserException& ex)
+ {
+ SH_LOG_ERROR(ex.what());
+ }
+
+ return double_click_to_play;
+ }
+
void cSerializer::SerializeDemoMode(bool showDemoMode)
{
YAML::Emitter out;
diff --git a/src/Utility/Serialize.hpp b/src/Utility/Serialize.hpp
index 6ae7f77..9d594bf 100644
--- a/src/Utility/Serialize.hpp
+++ b/src/Utility/Serialize.hpp
@@ -109,6 +109,10 @@ namespace SampleHive {
void SerializeShowFileExtension(bool showExtension);
bool DeserializeShowFileExtension() const;
+ // Enable double click to play
+ void SerializeDoubleClickToPlay(bool showExtension);
+ bool DeserializeDoubleClickToPlay() const;
+
// Demo mode
void SerializeDemoMode(bool showDemoMode);
bool DeserializeDemoMode() const;