GUI: track name recognition: optionally anchor at beginning of name

This commit is contained in:
Moritz Bunkus 2019-08-11 22:02:48 +02:00
parent 1af71c6286
commit d9fda168a7
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 15 additions and 1 deletions

View File

@ -395,7 +395,7 @@ SourceFile::setupProgramMapFromProperties() {
QString
SourceFile::defaultRegexForDerivingLanguageFromFileName() {
return Q("[[({.+=#-](<ISO_639_1_CODES>|<ISO_639_2_CODES>|<LANGUAGE_NAMES>)[])}.+=#-]");
return Q("(?:^|[[({.+=#-])(<ISO_639_1_CODES>|<ISO_639_2_CODES>|<LANGUAGE_NAMES>)[])}.+=#-]");
}
QRegularExpression

View File

@ -234,6 +234,20 @@ Settings::convertOldSettings() {
reg->setValue(s_valMergeTrackPropertiesLayout, static_cast<int>(mergeUseVerticalInputLayout.toBool() ? TrackPropertiesLayout::VerticalTabWidget : TrackPropertiesLayout::HorizontalScrollArea));
reg->endGroup();
// Replace default track name recognition regex valid up to 36.0.0
// with new default one. Empty value will be replaced with actual
// new default later.
reg->beginGroup(s_grpSettings);
reg->beginGroup(s_grpDerivingTrackLanguagesFromFileNames);
auto val = reg->value(s_valCustomRegex).toString();
// writtenByVersion ≤ 36.0.0 → !(writtenByVersion > 36.0.0)
if ( !(version_number_t{"36"} < writtenByVersion)
&& (val == Q("[[({.+=#-](<ISO_639_1_CODES>|<ISO_639_2_CODES>|<LANGUAGE_NAMES>)[])}.+=#-]")))
reg->remove(s_valCustomRegex);
reg->endGroup();
reg->endGroup();
}
void