Add option to disable splash on startup and some cleanup.

This commit is contained in:
apoorv569
2022-02-10 20:43:31 +05:30
parent dde610a78f
commit 1ccb616b93
9 changed files with 132 additions and 40 deletions
+1
View File
@@ -65,6 +65,7 @@ namespace SampleHive { namespace ID {
SD_FontSize,
SD_FontBrowseButton,
SD_WaveformColourPickerCtrl,
SD_ShowSplash,
// -------------------------------------------------------------------
// App Menu items
+63 -2
View File
@@ -87,6 +87,10 @@ namespace SampleHive {
m_Emitter << YAML::BeginMap;
m_Emitter << YAML::Key << "Colour" << YAML::Value << colour.GetAsString().ToStdString();
m_Emitter << YAML::EndMap;
m_Emitter << YAML::Key << "Splash";
m_Emitter << YAML::BeginMap;
m_Emitter << YAML::Key << "ShowSplashOnStartup" << YAML::Value << true;
m_Emitter << YAML::EndMap;
m_Emitter << YAML::EndMap << YAML::Newline;
m_Emitter << YAML::Newline << YAML::Key << "Collection";
@@ -100,10 +104,10 @@ namespace SampleHive {
m_Emitter << YAML::EndMap;
std::ofstream ofstrm(CONFIG_FILEPATH);
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
ofstrm << m_Emitter.c_str();
SH_LOG_INFO("Generated {} successfully!", CONFIG_FILEPATH);
SH_LOG_INFO("Generated {} successfully!", static_cast<std::string>(CONFIG_FILEPATH));
}
}
@@ -529,6 +533,63 @@ namespace SampleHive {
return static_cast<wxString>(colour);
}
void cSerializer::SerializeShowSplash(bool value)
{
YAML::Emitter out;
try
{
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
auto display = config["Display"];
if (auto splash = display["Splash"])
{
splash["ShowSplashOnStartup"] = value;
out << config;
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
ofstrm << out.c_str();
}
else
{
SH_LOG_ERROR("Error! Cannot store show splash value.");
}
}
catch (const YAML::ParserException& ex)
{
SH_LOG_ERROR(ex.what());
}
}
bool cSerializer::DeserializeShowSplash() const
{
bool show = false;
try
{
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
auto display = config["Display"];
if (auto splash = display["Splash"])
{
show = splash["ShowSplashOnStartup"].as<bool>();
}
else
{
SH_LOG_ERROR("Error! Cannot fetch show splash value.");
}
}
catch (const YAML::ParserException& ex)
{
SH_LOG_ERROR(ex.what());
}
return show;
}
void cSerializer::SerializeAutoImport(bool autoImport, const std::string& importDir)
{
YAML::Emitter out;
+5
View File
@@ -84,6 +84,11 @@ namespace SampleHive {
void SerializeWaveformColour(wxColour& colour);
wxColour DeserializeWaveformColour() const;
// -------------------------------------------------------------------
// Splash screen
void SerializeShowSplash(bool value);
bool DeserializeShowSplash() const;
// -------------------------------------------------------------------
// Auto import settings
void SerializeAutoImport(bool autoImport, const std::string& importDir);