Skip to content

Commit

Permalink
Added full support of '/' as the directory sepearator in ODF unless "…
Browse files Browse the repository at this point in the history
…CheckODF for HW1-compatibility" is set #827 (#1361)
  • Loading branch information
oleg68 authored Feb 1, 2023
1 parent 88a2b24 commit 1099973
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Added full support of '/' as the file sepearator in ODF unless 'Check ODF for HW1-compatibility' is set https://github.com/GrandOrgue/grandorgue/issues/827
- Added support of ODF comments from ';' at any position to the end of line https://github.com/GrandOrgue/grandorgue/issues/828
# 3.9.5 (2022-01-23)
- Fixed saving position when some panel is outside the screen area https://github.com/GrandOrgue/grandorgue/issues/1271
Expand Down
22 changes: 18 additions & 4 deletions help/grandorgue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4163,6 +4163,13 @@ user experience.
<simpara>Likewise, GrandOrgue users are <emphasis role="strong">strongly</emphasis> encouraged to report new warnings to the sample set designer.</simpara>
</note>
</sect2>
<sect2>
<title>Check ODF for HW1-compatibility</title>
<para>
This checkbox enables warnings when some ODF keys are not compatible with the Hauptwerk 1.
For example, when file names contains the '/' separator.
</para>
</sect2>
<sect2>
<title>Metronome</title>
<para>
Expand Down Expand Up @@ -6271,11 +6278,18 @@ Each setting may only occur once. The content is case sensitive.
No other elements are allowed in the file.
</para>
<para>
File paths in this format are relative to the location of the organ
file. The directory separator in these paths must be <emphasis>\</emphasis>. The paths
should not contain <emphasis>/</emphasis>. The paths should be considered case sensitive,
even if this is not enforced on all platforms.
File paths in this format are relative to the location of the organ
file. The directory separator in these paths may be
<emphasis>\</emphasis> or <emphasis>/</emphasis>. The paths should be
considered case sensitive, even if this is not enforced on all platforms.
</para>
<caution>
<simpara>
Hauptwerk only supports <emphasis>\</emphasis> as a directory
separator. So use <emphasis>/</emphasis> only if you do not intend
the ODF to be HW1-compatible.
</simpara>
</caution>
<para>
Boolean values are represented as <emphasis>Y</emphasis> for "true" and
<emphasis>N</emphasis> for "false".
Expand Down
Binary file modified help/images/settings_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/core/config/GOConfigReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include "GOUtil.h"
#include "config/GOConfigReaderDB.h"

GOConfigReader::GOConfigReader(GOConfigReaderDB &cfg, bool strict)
: m_Strict(strict), m_Config(cfg) {}
GOConfigReader::GOConfigReader(
GOConfigReaderDB &cfg, bool strict, bool hw1Check)
: m_Config(cfg), m_Strict(strict), m_IsHw1Check(hw1Check) {}

bool GOConfigReader::Read(
GOSettingType type,
Expand Down Expand Up @@ -127,7 +128,7 @@ wxString GOConfigReader::ReadFileName(
GOSettingType type, wxString group, wxString key, bool required) {
const wxString fileName = ReadStringTrim(type, group, key, required);

if (m_Strict && fileName.Find(wxT('/')) != wxNOT_FOUND) {
if (m_IsHw1Check && fileName.Find(wxT('/')) != wxNOT_FOUND) {
wxLogWarning(
_("Filename '%s' contains non-portable directory separator /"), fileName);
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/config/GOConfigReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ typedef enum { ODFSetting, CMBSetting } GOSettingType;

class GOConfigReader {
private:
bool m_Strict;
GOConfigReaderDB &m_Config;
bool m_Strict;
bool m_IsHw1Check;

bool Read(
GOSettingType type,
Expand All @@ -34,7 +35,8 @@ class GOConfigReader {
wxString &value);

public:
GOConfigReader(GOConfigReaderDB &cfg, bool strict = true);
GOConfigReader(
GOConfigReaderDB &cfg, bool strict = true, bool hw1Check = false);

/**
* Reads a triple-value boolean (-1 - not defined, 0 - false, 1 - true)
Expand Down
8 changes: 6 additions & 2 deletions src/core/settings/GOSettingBool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ GOSettingBool::GOSettingBool(
GOSettingStore *store, wxString group, wxString name, bool default_value)
: GOSetting(store, group, name),
m_Value(default_value),
m_DefaultValue(default_value) {}
m_DefaultValue(default_value),
m_IsPresent(false) {}

void GOSettingBool::Load(GOConfigReader &cfg) {
(*this)(cfg.ReadBoolean(CMBSetting, m_Group, m_Name, false, m_DefaultValue));
int tripleValue = cfg.ReadBooleanTriple(CMBSetting, m_Group, m_Name, false);

m_IsPresent = tripleValue >= 0;
(*this)(m_IsPresent ? bool(tripleValue) : m_DefaultValue);
}

void GOSettingBool::Save(GOConfigWriter &cfg) {
Expand Down
3 changes: 3 additions & 0 deletions src/core/settings/GOSettingBool.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class GOSettingBool : private GOSetting {
private:
bool m_Value;
bool m_DefaultValue;
// whether the value was read from the setting or was set by default
bool m_IsPresent;

void Load(GOConfigReader &cfg);
void Save(GOConfigWriter &cfg);
Expand All @@ -25,6 +27,7 @@ class GOSettingBool : private GOSetting {
GOSettingBool(
GOSettingStore *store, wxString group, wxString name, bool default_value);

bool IsPresent() const { return m_IsPresent; }
void setDefaultValue(bool default_value);

bool operator()() const;
Expand Down
2 changes: 1 addition & 1 deletion src/grandorgue/GOOrganController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ wxString GOOrganController::Load(
}

try {
GOConfigReader cfg(ini, m_config.ODFCheck());
GOConfigReader cfg(ini, m_config.ODFCheck(), m_config.ODFHw1Check());
/* skip informational items */
cfg.ReadString(CMBSetting, wxT("Organ"), wxT("ChurchName"), false);
cfg.ReadString(CMBSetting, wxT("Organ"), wxT("ChurchAddress"), false);
Expand Down
5 changes: 5 additions & 0 deletions src/grandorgue/config/GOConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ GOConfig::GOConfig(wxString instance)
sizeof(m_InitialLoadTypes) / sizeof(m_InitialLoadTypes[0]),
GOInitialLoadType::LOAD_LAST_USED),
ODFCheck(this, wxT("General"), wxT("StrictODFCheck"), false),
ODFHw1Check(this, wxT("General"), wxT("ODFHw1Check"), false),
LoadChannels(this, wxT("General"), wxT("Channels"), 0, 2, 2),
LosslessCompression(
this, wxT("General"), wxT("LosslessCompression"), false),
Expand Down Expand Up @@ -395,6 +396,10 @@ void GOConfig::Load() {

GOSettingStore::Load(cfg);

// Fill ODFHw1Check with ODFCheck by default
if (!ODFHw1Check.IsPresent())
ODFHw1Check(ODFCheck());

if (Concurrency() == 0)
Concurrency(1);

Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/config/GOConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class GOConfig : public GOSettingStore, public GOOrganList {
GOSettingBool CompressCache;
GOSettingEnum<GOInitialLoadType> LoadLastFile;
GOSettingBool ODFCheck;
GOSettingBool ODFHw1Check;

GOSettingUnsigned LoadChannels;
GOSettingBool LosslessCompression;
Expand Down
9 changes: 9 additions & 0 deletions src/grandorgue/dialogs/settings/GOSettingsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ GOSettingsOptions::GOSettingsOptions(GOConfig &settings, wxWindow *parent)
5);
m_ODFCheck->SetValue(m_config.ODFCheck());

item9->Add(
m_ODFHw1Check
= new wxCheckBox(this, ID_ODF_CHECK, _("Check ODF for HW1-compatibility")),
0,
wxEXPAND | wxALL,
5);
m_ODFHw1Check->SetValue(m_config.ODFHw1Check());

item6 = new wxStaticBoxSizer(wxVERTICAL, this, _("&Metronome"));
grid = new wxFlexGridSizer(2, 5, 5);
grid->Add(
Expand Down Expand Up @@ -419,6 +427,7 @@ bool GOSettingsOptions::TransferDataFromWindow() {
m_config.ManageCache(m_ManageCache->IsChecked());
m_config.LoadLastFile(m_LoadLastFile->GetCurrentSelection());
m_config.ODFCheck(m_ODFCheck->IsChecked());
m_config.ODFHw1Check(m_ODFHw1Check->IsChecked());
m_config.RecordDownmix(m_RecordDownmix->IsChecked());
m_config.Volume(m_Volume->GetValue());
m_config.ScaleRelease(m_Scale->IsChecked());
Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/dialogs/settings/GOSettingsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class GOSettingsOptions : public wxPanel {
wxCheckBox *m_Scale;
wxCheckBox *m_Random;
wxCheckBox *m_ODFCheck;
wxCheckBox *m_ODFHw1Check;
wxCheckBox *m_RecordDownmix;
wxSpinCtrl *m_Volume;
wxChoice *m_BitsPerSample;
Expand Down

0 comments on commit 1099973

Please sign in to comment.