mirror of
https://gitlab.com/samplehive/sample-hive.git
synced 2026-10-23 21:25:00 +02:00
Add command line option to reset app data, new Paths header, more code refactoring.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
// Path to all the assets
|
||||
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
|
||||
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
|
||||
#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/icons/icon-hive_32x32.png"
|
||||
#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/icons/icon-hive_64x64.png"
|
||||
#define ICON_HIVE_128px SAMPLEHIVE_DATADIR "/icons/icon-hive_128x128.png"
|
||||
#define ICON_HIVE_256px SAMPLEHIVE_DATADIR "/icons/icon-hive_256x256.png"
|
||||
#define ICON_STAR_FILLED_16px SAMPLEHIVE_DATADIR "/icons/icon-star_filled_16x16.png"
|
||||
#define ICON_STAR_EMPTY_16px SAMPLEHIVE_DATADIR "/icons/icon-star_empty_16x16.png"
|
||||
#define ICON_PLAY_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-play-dark_16x16.png"
|
||||
#define ICON_STOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-dark_16x16.png"
|
||||
#define ICON_AB_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-dark_16x16.png"
|
||||
#define ICON_LOOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-dark_16x16.png"
|
||||
#define ICON_MUTE_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-dark_16x16.png"
|
||||
#define ICON_PLAY_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-play-light_16x16.png"
|
||||
#define ICON_STOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-light_16x16.png"
|
||||
#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png"
|
||||
#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png"
|
||||
#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png"
|
||||
#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png"
|
||||
|
||||
// Path to useful directories and files
|
||||
#define USER_HOME_DIR wxGetUserHome()
|
||||
#define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
|
||||
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
|
||||
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
|
||||
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
|
||||
@@ -74,18 +74,18 @@ namespace SampleHive
|
||||
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
|
||||
|
||||
// SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
|
||||
// : wxCommandEvent(eventType, winId)
|
||||
// {
|
||||
SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
|
||||
: wxCommandEvent(eventType, winId)
|
||||
{
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
|
||||
// {
|
||||
SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
|
||||
{
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||
|
||||
// SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
|
||||
// : wxCommandEvent(eventType, winId)
|
||||
|
||||
+18
-16
@@ -95,7 +95,8 @@ namespace SampleHive
|
||||
|
||||
public:
|
||||
std::pair<wxString, int> GetMessageAndSection() const { return { m_Msg, m_Section }; }
|
||||
void SetMessageAndSection(std::pair<const wxString&, int> status) { m_Msg = status.first; m_Section = status.second; }
|
||||
void SetMessageAndSection(std::pair<const wxString&, int> status)
|
||||
{ m_Msg = status.first; m_Section = status.second; }
|
||||
|
||||
private:
|
||||
wxString m_Msg;
|
||||
@@ -104,25 +105,26 @@ namespace SampleHive
|
||||
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
|
||||
|
||||
// class SH_InfoBarMessageEvent : public wxCommandEvent
|
||||
// {
|
||||
// public:
|
||||
// SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||
// ~SH_InfoBarMessageEvent();
|
||||
class SH_InfoBarMessageEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||
~SH_InfoBarMessageEvent();
|
||||
|
||||
// public:
|
||||
// virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
||||
public:
|
||||
virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
||||
|
||||
// public:
|
||||
// std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||
// void SetInfoBarMessage(std::pair<wxString, int> infoBarMessageEvent) { m_Msg = infoBarMessageEvent.first; m_Mode = infoBarMessageEvent.second; }
|
||||
public:
|
||||
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||
void SetInfoBarMessage(std::pair<const wxString&, int> info)
|
||||
{ m_Msg = info.first; m_Mode = info.second; }
|
||||
|
||||
// private:
|
||||
// wxString m_Msg;
|
||||
// int m_Mode;
|
||||
// };
|
||||
private:
|
||||
wxString m_Msg;
|
||||
int m_Mode;
|
||||
};
|
||||
|
||||
// wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
|
||||
|
||||
// class SH_TimerEvent : public wxCommandEvent
|
||||
// {
|
||||
|
||||
+27
-27
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Utility/Serialize.hpp"
|
||||
#include "Utility/Log.hpp"
|
||||
#include "Utility/Paths.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -30,10 +31,9 @@
|
||||
#include <yaml-cpp/emittermanip.h>
|
||||
#include <yaml-cpp/node/parse.h>
|
||||
|
||||
Serializer::Serializer(const std::string& filepath)
|
||||
: m_Filepath(filepath)
|
||||
Serializer::Serializer()
|
||||
{
|
||||
std::ifstream ifstrm(m_Filepath);
|
||||
std::ifstream ifstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
||||
std::string system_font_face = font.GetFaceName().ToStdString();
|
||||
@@ -94,10 +94,10 @@ Serializer::Serializer(const std::string& filepath)
|
||||
|
||||
m_Emitter << YAML::EndMap;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(CONFIG_FILEPATH);
|
||||
ofstrm << m_Emitter.c_str();
|
||||
|
||||
SH_LOG_INFO("Generated {} successfully!", m_Filepath);
|
||||
SH_LOG_INFO("Generated {} successfully!", CONFIG_FILEPATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ WindowSize Serializer::DeserializeWinSize() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (!config["Window"])
|
||||
{
|
||||
@@ -141,7 +141,7 @@ void Serializer::SerializeShowMenuAndStatusBar(std::string key, bool value)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto bar = config["Window"])
|
||||
{
|
||||
@@ -153,7 +153,7 @@ void Serializer::SerializeShowMenuAndStatusBar(std::string key, bool value)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -171,7 +171,7 @@ bool Serializer::DeserializeShowMenuAndStatusBar(std::string key) const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto bar = config["Window"])
|
||||
{
|
||||
@@ -200,7 +200,7 @@ void Serializer::SerializeBrowserControls(std::string key, bool value)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto media = config["Media"])
|
||||
{
|
||||
@@ -215,7 +215,7 @@ void Serializer::SerializeBrowserControls(std::string key, bool value)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -233,7 +233,7 @@ bool Serializer::DeserializeBrowserControls(std::string key) const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto media = config["Media"])
|
||||
{
|
||||
@@ -268,7 +268,7 @@ void Serializer::SerializeDisplaySettings(wxFont& font)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
auto display = config["Display"];
|
||||
|
||||
@@ -279,7 +279,7 @@ void Serializer::SerializeDisplaySettings(wxFont& font)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -302,7 +302,7 @@ wxFont Serializer::DeserializeDisplaySettings() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
auto display = config["Display"];
|
||||
|
||||
@@ -335,7 +335,7 @@ void Serializer::SerializeWaveformColour(wxColour& colour)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
auto display = config["Display"];
|
||||
|
||||
@@ -345,7 +345,7 @@ void Serializer::SerializeWaveformColour(wxColour& colour)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -365,7 +365,7 @@ wxColour Serializer::DeserializeWaveformColour() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
auto display = config["Display"];
|
||||
|
||||
@@ -392,7 +392,7 @@ void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string&
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto autoImportInfo = config["Collection"])
|
||||
{
|
||||
@@ -401,7 +401,7 @@ void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string&
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -422,7 +422,7 @@ ImportDirInfo Serializer::DeserializeAutoImportSettings() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto autoImportInfo = config["Collection"])
|
||||
{
|
||||
@@ -448,7 +448,7 @@ void Serializer::SerializeFollowSymLink(bool followSymLinks)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto followSymLinks = config["Collection"])
|
||||
{
|
||||
@@ -456,7 +456,7 @@ void Serializer::SerializeFollowSymLink(bool followSymLinks)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -476,7 +476,7 @@ bool Serializer::DeserializeFollowSymLink() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto followSymLinks = config["Collection"])
|
||||
{
|
||||
@@ -501,7 +501,7 @@ void Serializer::SerializeShowFileExtensionSetting(bool showExtension)
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto fileExtensionInfo = config["Collection"])
|
||||
{
|
||||
@@ -509,7 +509,7 @@ void Serializer::SerializeShowFileExtensionSetting(bool showExtension)
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(m_Filepath);
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
@@ -529,7 +529,7 @@ bool Serializer::DeserializeShowFileExtensionSetting() const
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(m_Filepath);
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto fileExtensionInfo = config["Collection"])
|
||||
{
|
||||
|
||||
@@ -45,13 +45,10 @@ typedef std::pair<bool, wxString> ImportDirInfo;
|
||||
class Serializer
|
||||
{
|
||||
public:
|
||||
Serializer(const std::string& filepath);
|
||||
Serializer();
|
||||
~Serializer();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------
|
||||
const std::string& m_Filepath;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
YAML::Emitter m_Emitter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user