Add DemoMode for auditioning samples without storing them in database.
This commit is contained in:
parent
3db1e5858e
commit
023874a9be
12
meson.build
12
meson.build
|
|
@ -120,10 +120,6 @@ wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
||||||
'wxUSE_LIBSDL': 'OFF',
|
'wxUSE_LIBSDL': 'OFF',
|
||||||
'wxUSE_MEDIACTRL': 'ON'})
|
'wxUSE_MEDIACTRL': 'ON'})
|
||||||
|
|
||||||
if host_sys == 'windows'
|
|
||||||
wx_opts.set_override_option('b_lto', 'false')
|
|
||||||
endif
|
|
||||||
|
|
||||||
taglib_opts = cmake.subproject_options()
|
taglib_opts = cmake.subproject_options()
|
||||||
taglib_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
taglib_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
||||||
'CMAKE_INSTALL_PREFIX': prefix,
|
'CMAKE_INSTALL_PREFIX': prefix,
|
||||||
|
|
@ -158,6 +154,14 @@ snd_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
||||||
'ENABLE_EXTERNAL_LIBS': 'ON',
|
'ENABLE_EXTERNAL_LIBS': 'ON',
|
||||||
'ENABLE_MPEG': 'ON'})
|
'ENABLE_MPEG': 'ON'})
|
||||||
|
|
||||||
|
# Disable link time optimization if host is Windows
|
||||||
|
if host_sys == 'windows'
|
||||||
|
wx_opts.set_override_option('b_lto', 'false')
|
||||||
|
taglib_opts.set_override_option('b_lto', 'false')
|
||||||
|
yaml_opts.set_override_option('b_lto', 'false')
|
||||||
|
snd_opts.set_override_option('b_lto', 'false')
|
||||||
|
endif
|
||||||
|
|
||||||
# Source files to be compiled
|
# Source files to be compiled
|
||||||
src = [
|
src = [
|
||||||
|
|
||||||
|
|
|
||||||
11
src/App.cpp
11
src/App.cpp
|
|
@ -40,7 +40,18 @@ cApp::cApp()
|
||||||
|
|
||||||
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()
|
bool cApp::OnInit()
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "Database/Database.hpp"
|
#include "Database/Database.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
@ -81,7 +82,12 @@ class Sqlite3Statement
|
||||||
|
|
||||||
cDatabase::cDatabase()
|
cDatabase::cDatabase()
|
||||||
{
|
{
|
||||||
OpenDatabase();
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
if (!serializer.DeserializeDemoMode())
|
||||||
|
OpenDatabase();
|
||||||
|
else
|
||||||
|
OpenTemporaryDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
cDatabase::~cDatabase()
|
cDatabase::~cDatabase()
|
||||||
|
|
@ -111,10 +117,22 @@ void cDatabase::CreateTableSamples()
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, samples, NULL, 0, &m_pErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, samples, NULL, 0, &m_pErrMsg));
|
||||||
SH_LOG_INFO("SAMPLES table created successfully.");
|
SH_LOG_INFO("SAMPLES table created successfully.");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
show_modal_dialog_and_log("Error! Cannot create SAMPLES table", "Error", e.what());
|
show_modal_dialog_and_log("Error! Cannot create SAMPLES table", "Error", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto indices = "CREATE INDEX IF NOT EXISTS idx_filename_path ON SAMPLES(FILENAME, PATH);";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, indices, NULL, 0, &m_pErrMsg));
|
||||||
|
SH_LOG_INFO("FILENAME PATH index created successfully.");
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
show_modal_dialog_and_log("Error! Cannot create INDEX Filename Path", "Error", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDatabase::CreateTableHives()
|
void cDatabase::CreateTableHives()
|
||||||
|
|
@ -469,6 +487,24 @@ void cDatabase::RemoveHiveFromDatabase(const std::string &hiveName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cDatabase::DeleteAllSamples()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto sql = "DELETE FROM SAMPLES;";
|
||||||
|
|
||||||
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, sql, NULL, 0, &m_pErrMsg));
|
||||||
|
|
||||||
|
SH_LOG_INFO("All Samples deleted.");
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
show_modal_dialog_and_log("Error! Could not delete samples.", "Error!", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string cDatabase::GetSamplePathByFilename(const std::string &filename)
|
std::string cDatabase::GetSamplePathByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
@ -1003,6 +1039,12 @@ void cDatabase::OpenDatabase()
|
||||||
throw_on_sqlite3_error(sqlite3_open(static_cast<std::string>(DATABASE_FILEPATH).c_str(), &m_pDatabase));
|
throw_on_sqlite3_error(sqlite3_open(static_cast<std::string>(DATABASE_FILEPATH).c_str(), &m_pDatabase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
void cDatabase::CloseDatabase()
|
void cDatabase::CloseDatabase()
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_close(m_pDatabase));
|
throw_on_sqlite3_error(sqlite3_close(m_pDatabase));
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ class cDatabase
|
||||||
void OpenDatabase();
|
void OpenDatabase();
|
||||||
void CloseDatabase();
|
void CloseDatabase();
|
||||||
|
|
||||||
|
void OpenTemporaryDatabase();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Create the table
|
// Create the table
|
||||||
|
|
@ -89,6 +91,8 @@ class cDatabase
|
||||||
void RemoveSampleFromDatabase(const std::string& filename);
|
void RemoveSampleFromDatabase(const std::string& filename);
|
||||||
void RemoveHiveFromDatabase(const std::string& hiveName);
|
void RemoveHiveFromDatabase(const std::string& hiveName);
|
||||||
|
|
||||||
|
void DeleteAllSamples();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>
|
||||||
LoadSamplesDatabase(wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
LoadSamplesDatabase(wxDataViewTreeCtrl& favorite_tree, wxDataViewItem& favorite_item,
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,20 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "Database/Database.hpp"
|
||||||
#include "GUI/DirectoryBrowser.hpp"
|
#include "GUI/DirectoryBrowser.hpp"
|
||||||
#include "Utility/ControlIDs.hpp"
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Sample.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
#include "Utility/Utils.hpp"
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
#include <wx/dataobj.h>
|
#include <wx/dataobj.h>
|
||||||
|
#include <wx/dir.h>
|
||||||
#include <wx/dnd.h>
|
#include <wx/dnd.h>
|
||||||
|
#include <wx/treebase.h>
|
||||||
|
|
||||||
cDirectoryBrowser::cDirectoryBrowser(wxWindow* window)
|
cDirectoryBrowser::cDirectoryBrowser(wxWindow* window)
|
||||||
: wxGenericDirCtrl(window, SampleHive::ID::BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition,
|
: wxGenericDirCtrl(window, SampleHive::ID::BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition,
|
||||||
|
|
@ -38,6 +44,7 @@ cDirectoryBrowser::cDirectoryBrowser(wxWindow* window)
|
||||||
|
|
||||||
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &cDirectoryBrowser::OnClickDirCtrl, this, SampleHive::ID::BC_DirCtrl);
|
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &cDirectoryBrowser::OnClickDirCtrl, this, SampleHive::ID::BC_DirCtrl);
|
||||||
Bind(wxEVT_TREE_BEGIN_DRAG, &cDirectoryBrowser::OnDragFromDirCtrl, this, this->GetTreeCtrl()->GetId());
|
Bind(wxEVT_TREE_BEGIN_DRAG, &cDirectoryBrowser::OnDragFromDirCtrl, this, this->GetTreeCtrl()->GetId());
|
||||||
|
Bind(wxEVT_TREE_ITEM_ACTIVATED, &cDirectoryBrowser::OnDirCtrlExpanded, this, this->GetTreeCtrl()->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cDirectoryBrowser::OnClickDirCtrl(wxCommandEvent& event)
|
void cDirectoryBrowser::OnClickDirCtrl(wxCommandEvent& event)
|
||||||
|
|
@ -76,6 +83,51 @@ void cDirectoryBrowser::OnDragFromDirCtrl(wxTreeEvent& event)
|
||||||
LogDragResult(drop_source.DoDragDrop());
|
LogDragResult(drop_source.DoDragDrop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cDirectoryBrowser::OnDirCtrlExpanded(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
cDatabase db;
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
if (serializer.DeserializeDemoMode())
|
||||||
|
{
|
||||||
|
wxBusyCursor busy_cursor;
|
||||||
|
wxWindowDisabler window_disabler;
|
||||||
|
|
||||||
|
wxString filepath;
|
||||||
|
wxArrayString filepath_array;
|
||||||
|
|
||||||
|
const wxString pathToDirectory = this->GetPath(event.GetItem());
|
||||||
|
|
||||||
|
size_t number_of_files = wxDir::GetAllFiles(pathToDirectory, &filepath_array, wxEmptyString, wxDIR_FILES);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < number_of_files; i++)
|
||||||
|
{
|
||||||
|
filepath = filepath_array[i];
|
||||||
|
|
||||||
|
if (wxFileExists(filepath))
|
||||||
|
{
|
||||||
|
filepath_array.push_back(filepath);
|
||||||
|
}
|
||||||
|
else if (wxDirExists(filepath))
|
||||||
|
{
|
||||||
|
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete all Files
|
||||||
|
if (SampleHive::cHiveData::Get().GetListCtrlItemCount() >= 1)
|
||||||
|
{
|
||||||
|
db.DeleteAllSamples();
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlDeleteAllItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleHive::cUtils::Get().AddSamples(filepath_array, this);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
cDirectoryBrowser::~cDirectoryBrowser()
|
cDirectoryBrowser::~cDirectoryBrowser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class cDirectoryBrowser : public wxGenericDirCtrl
|
||||||
// DirCtrl event handlers
|
// DirCtrl event handlers
|
||||||
void OnClickDirCtrl(wxCommandEvent& event);
|
void OnClickDirCtrl(wxCommandEvent& event);
|
||||||
void OnDragFromDirCtrl(wxTreeEvent& event);
|
void OnDragFromDirCtrl(wxTreeEvent& event);
|
||||||
|
void OnDirCtrlExpanded(wxTreeEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow* m_pWindow = nullptr;
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ cMainFrame::cMainFrame()
|
||||||
m_pEditMenu->Append(wxID_PREFERENCES, _("Preferences\tCtrl+P"), _("Open preferences dialog"));
|
m_pEditMenu->Append(wxID_PREFERENCES, _("Preferences\tCtrl+P"), _("Open preferences dialog"));
|
||||||
|
|
||||||
// View menu items
|
// View menu items
|
||||||
|
m_pDemoMode = new wxMenuItem(m_pViewMenu, wxID_ANY, _("Demo mode"), _("Toggle demo mode On/Off"), wxITEM_CHECK);
|
||||||
m_pToggleExtension = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleExtension,
|
m_pToggleExtension = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleExtension,
|
||||||
_("Toggle Extension\tCtrl+E"), _("Show/Hide Extension"), wxITEM_CHECK);
|
_("Toggle Extension\tCtrl+E"), _("Show/Hide Extension"), wxITEM_CHECK);
|
||||||
m_pToggleMenuBar = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleMenuBar,
|
m_pToggleMenuBar = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleMenuBar,
|
||||||
|
|
@ -83,6 +84,7 @@ cMainFrame::cMainFrame()
|
||||||
m_pToggleStatusBar = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleStatusBar,
|
m_pToggleStatusBar = new wxMenuItem(m_pViewMenu, SampleHive::ID::MN_ToggleStatusBar,
|
||||||
_("Toggle Status Bar\tCtrl+B"), _("Show/Hide Status Bar"), wxITEM_CHECK);
|
_("Toggle Status Bar\tCtrl+B"), _("Show/Hide Status Bar"), wxITEM_CHECK);
|
||||||
|
|
||||||
|
m_pViewMenu->Append(m_pDemoMode)->Check(false);
|
||||||
m_pViewMenu->Append(m_pToggleExtension)->Check(true);
|
m_pViewMenu->Append(m_pToggleExtension)->Check(true);
|
||||||
m_pViewMenu->Append(m_pToggleMenuBar)->Check(m_pMenuBar->IsShown());
|
m_pViewMenu->Append(m_pToggleMenuBar)->Check(m_pMenuBar->IsShown());
|
||||||
m_pViewMenu->Append(m_pToggleStatusBar)->Check(m_pStatusBar->IsShown());
|
m_pViewMenu->Append(m_pToggleStatusBar)->Check(m_pStatusBar->IsShown());
|
||||||
|
|
@ -153,6 +155,7 @@ cMainFrame::cMainFrame()
|
||||||
// Binding events.
|
// Binding events.
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddFile, this, SampleHive::ID::MN_AddFile);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddFile, this, SampleHive::ID::MN_AddFile);
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddDirectory, this, SampleHive::ID::MN_AddDirectory);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectAddDirectory, this, SampleHive::ID::MN_AddDirectory);
|
||||||
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleDemoMode, this, m_pDemoMode->GetId());
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleExtension, this, SampleHive::ID::MN_ToggleExtension);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleExtension, this, SampleHive::ID::MN_ToggleExtension);
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleMenuBar, this, SampleHive::ID::MN_ToggleMenuBar);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleMenuBar, this, SampleHive::ID::MN_ToggleMenuBar);
|
||||||
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleStatusBar, this, SampleHive::ID::MN_ToggleStatusBar);
|
Bind(wxEVT_MENU, &cMainFrame::OnSelectToggleStatusBar, this, SampleHive::ID::MN_ToggleStatusBar);
|
||||||
|
|
@ -199,8 +202,9 @@ cMainFrame::cMainFrame()
|
||||||
m_pTopPanelMainSizer->SetSizeHints(m_pTopPanel);
|
m_pTopPanelMainSizer->SetSizeHints(m_pTopPanel);
|
||||||
m_pTopPanelMainSizer->Layout();
|
m_pTopPanelMainSizer->Layout();
|
||||||
|
|
||||||
// Restore the data previously added to Library
|
// Restore the data previously added to Library only if demo mode is disabled
|
||||||
LoadDatabase();
|
if (!m_bDemoMode)
|
||||||
|
LoadDatabase();
|
||||||
|
|
||||||
// Set some properites after the frame has been created
|
// Set some properites after the frame has been created
|
||||||
CallAfter(&cMainFrame::SetAfterFrameCreate);
|
CallAfter(&cMainFrame::SetAfterFrameCreate);
|
||||||
|
|
@ -343,12 +347,13 @@ void cMainFrame::LoadConfigFile()
|
||||||
|
|
||||||
m_bShowMenuBar = serializer.DeserializeShowMenuAndStatusBar("menubar");
|
m_bShowMenuBar = serializer.DeserializeShowMenuAndStatusBar("menubar");
|
||||||
m_bShowStatusBar = serializer.DeserializeShowMenuAndStatusBar("statusbar");
|
m_bShowStatusBar = serializer.DeserializeShowMenuAndStatusBar("statusbar");
|
||||||
|
m_bDemoMode = serializer.DeserializeDemoMode();
|
||||||
|
|
||||||
m_pToggleMenuBar->Check(m_bShowMenuBar);
|
m_pToggleMenuBar->Check(m_bShowMenuBar);
|
||||||
m_pMenuBar->Show(m_bShowMenuBar);
|
m_pMenuBar->Show(m_bShowMenuBar);
|
||||||
m_pToggleStatusBar->Check(m_bShowStatusBar);
|
m_pToggleStatusBar->Check(m_bShowStatusBar);
|
||||||
m_pStatusBar->Show(m_bShowStatusBar);
|
m_pStatusBar->Show(m_bShowStatusBar);
|
||||||
|
m_pDemoMode->Check(m_bDemoMode);
|
||||||
m_pToggleExtension->Check(serializer.DeserializeShowFileExtension());
|
m_pToggleExtension->Check(serializer.DeserializeShowFileExtension());
|
||||||
|
|
||||||
this->SetFont(serializer.DeserializeFontSettings());
|
this->SetFont(serializer.DeserializeFontSettings());
|
||||||
|
|
@ -546,6 +551,28 @@ void cMainFrame::OnSelectAddDirectory(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cMainFrame::OnSelectToggleDemoMode(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
if (m_pDemoMode->IsChecked())
|
||||||
|
{
|
||||||
|
serializer.SerializeDemoMode(true);
|
||||||
|
m_pLibrary->GetInfoBarObject()->ShowMessage(_("Demo mode toggled on, "
|
||||||
|
"please restart the app for changes take effect"), wxICON_INFORMATION);
|
||||||
|
|
||||||
|
m_bDemoMode = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serializer.SerializeDemoMode(false);
|
||||||
|
m_pLibrary->GetInfoBarObject()->ShowMessage(_("Demo mode toggled off, "
|
||||||
|
"please restart the app for changes take effect"), wxICON_INFORMATION);
|
||||||
|
|
||||||
|
m_bDemoMode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cMainFrame::OnSelectToggleExtension(wxCommandEvent& event)
|
void cMainFrame::OnSelectToggleExtension(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
SampleHive::cSerializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
@ -919,7 +946,9 @@ void cMainFrame::InitDatabase()
|
||||||
{
|
{
|
||||||
m_pDatabase = std::make_unique<cDatabase>();
|
m_pDatabase = std::make_unique<cDatabase>();
|
||||||
m_pDatabase->CreateTableSamples();
|
m_pDatabase->CreateTableSamples();
|
||||||
m_pDatabase->CreateTableHives();
|
|
||||||
|
if (!m_bDemoMode)
|
||||||
|
m_pDatabase->CreateTableHives();
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ class cMainFrame : public wxFrame
|
||||||
// App menu items event handlers
|
// App menu items event handlers
|
||||||
void OnSelectAddFile(wxCommandEvent& event);
|
void OnSelectAddFile(wxCommandEvent& event);
|
||||||
void OnSelectAddDirectory(wxCommandEvent& event);
|
void OnSelectAddDirectory(wxCommandEvent& event);
|
||||||
|
void OnSelectToggleDemoMode(wxCommandEvent& event);
|
||||||
void OnSelectToggleExtension(wxCommandEvent& event);
|
void OnSelectToggleExtension(wxCommandEvent& event);
|
||||||
void OnSelectToggleMenuBar(wxCommandEvent& event);
|
void OnSelectToggleMenuBar(wxCommandEvent& event);
|
||||||
void OnSelectToggleStatusBar(wxCommandEvent& event);
|
void OnSelectToggleStatusBar(wxCommandEvent& event);
|
||||||
|
|
@ -153,6 +154,7 @@ class cMainFrame : public wxFrame
|
||||||
wxMenuItem* m_pToggleExtension = nullptr;
|
wxMenuItem* m_pToggleExtension = nullptr;
|
||||||
wxMenuItem* m_pToggleMenuBar = nullptr;
|
wxMenuItem* m_pToggleMenuBar = nullptr;
|
||||||
wxMenuItem* m_pToggleStatusBar = nullptr;
|
wxMenuItem* m_pToggleStatusBar = nullptr;
|
||||||
|
wxMenuItem* m_pDemoMode = nullptr;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Splitter windows
|
// Splitter windows
|
||||||
|
|
@ -198,4 +200,5 @@ class cMainFrame : public wxFrame
|
||||||
bool m_bShowMenuBar = false;
|
bool m_bShowMenuBar = false;
|
||||||
bool m_bShowStatusBar = false;
|
bool m_bShowStatusBar = false;
|
||||||
bool m_bLoopPointsSet = false;
|
bool m_bLoopPointsSet = false;
|
||||||
|
bool m_bDemoMode = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,11 @@ namespace SampleHive {
|
||||||
m_Emitter << YAML::Key << "ShowStatusBar" << YAML::Value << true;
|
m_Emitter << YAML::Key << "ShowStatusBar" << YAML::Value << true;
|
||||||
m_Emitter << YAML::EndMap << YAML::Newline;
|
m_Emitter << YAML::EndMap << YAML::Newline;
|
||||||
|
|
||||||
|
m_Emitter << YAML::Newline << YAML::Key << "General";
|
||||||
|
m_Emitter << YAML::BeginMap;
|
||||||
|
m_Emitter << YAML::Key << "DemoMode" << YAML::Value << false;
|
||||||
|
m_Emitter << YAML::EndMap << YAML::Newline;
|
||||||
|
|
||||||
m_Emitter << YAML::Newline << YAML::Key << "Media";
|
m_Emitter << YAML::Newline << YAML::Key << "Media";
|
||||||
m_Emitter << YAML::BeginMap;
|
m_Emitter << YAML::BeginMap;
|
||||||
m_Emitter << YAML::Key << "Autoplay" << YAML::Value << false;
|
m_Emitter << YAML::Key << "Autoplay" << YAML::Value << false;
|
||||||
|
|
@ -806,4 +811,57 @@ namespace SampleHive {
|
||||||
return show_extension;
|
return show_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cSerializer::SerializeDemoMode(bool showDemoMode)
|
||||||
|
{
|
||||||
|
YAML::Emitter out;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto general = config["General"])
|
||||||
|
{
|
||||||
|
general["DemoMode"] = showDemoMode;
|
||||||
|
|
||||||
|
out << config;
|
||||||
|
|
||||||
|
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
ofstrm << out.c_str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! Cannot store show demo mode value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cSerializer::DeserializeDemoMode() const
|
||||||
|
{
|
||||||
|
bool show_demo_mode = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||||
|
|
||||||
|
if (auto general = config["General"])
|
||||||
|
{
|
||||||
|
show_demo_mode = general["DemoMode"].as<bool>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error! Cannot fetch show demo mode value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const YAML::ParserException& ex)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR(ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
return show_demo_mode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,10 @@ namespace SampleHive {
|
||||||
void SerializeShowFileExtension(bool showExtension);
|
void SerializeShowFileExtension(bool showExtension);
|
||||||
bool DeserializeShowFileExtension() const;
|
bool DeserializeShowFileExtension() const;
|
||||||
|
|
||||||
|
// Demo mode
|
||||||
|
void SerializeDemoMode(bool showDemoMode);
|
||||||
|
bool DeserializeDemoMode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
YAML::Emitter m_Emitter;
|
YAML::Emitter m_Emitter;
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,11 @@ namespace SampleHive {
|
||||||
//Check All Files At Once
|
//Check All Files At Once
|
||||||
wxArrayString sorted_files;
|
wxArrayString sorted_files;
|
||||||
|
|
||||||
sorted_files = db.CheckDuplicates(files);
|
if (!serializer.DeserializeDemoMode())
|
||||||
files = sorted_files;
|
{
|
||||||
|
sorted_files = db.CheckDuplicates(files);
|
||||||
|
files = sorted_files;
|
||||||
|
}
|
||||||
|
|
||||||
if (files.size() < 1)
|
if (files.size() < 1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,4 @@ patch_filename = spdlog-1.8.5-1-wrap.zip
|
||||||
patch_hash = 3c38f275d5792b1286391102594329e98b17737924b344f98312ab09929b74be
|
patch_hash = 3c38f275d5792b1286391102594329e98b17737924b344f98312ab09929b74be
|
||||||
|
|
||||||
[provide]
|
[provide]
|
||||||
spdlog = spdlog_dep
|
spdlog = spdlog_dep
|
||||||
|
|
||||||
Loading…
Reference in New Issue