From d9fda168a7fab2f200ed860c68b6db17db39919f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 11 Aug 2019 22:02:48 +0200 Subject: [PATCH] GUI: track name recognition: optionally anchor at beginning of name --- src/mkvtoolnix-gui/merge/source_file.cpp | 2 +- src/mkvtoolnix-gui/util/settings.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mkvtoolnix-gui/merge/source_file.cpp b/src/mkvtoolnix-gui/merge/source_file.cpp index 6c50cbbcf..8b796e997 100644 --- a/src/mkvtoolnix-gui/merge/source_file.cpp +++ b/src/mkvtoolnix-gui/merge/source_file.cpp @@ -395,7 +395,7 @@ SourceFile::setupProgramMapFromProperties() { QString SourceFile::defaultRegexForDerivingLanguageFromFileName() { - return Q("[[({.+=#-](||)[])}.+=#-]"); + return Q("(?:^|[[({.+=#-])(||)[])}.+=#-]"); } QRegularExpression diff --git a/src/mkvtoolnix-gui/util/settings.cpp b/src/mkvtoolnix-gui/util/settings.cpp index e23b8dbf9..75b0f0d78 100644 --- a/src/mkvtoolnix-gui/util/settings.cpp +++ b/src/mkvtoolnix-gui/util/settings.cpp @@ -234,6 +234,20 @@ Settings::convertOldSettings() { reg->setValue(s_valMergeTrackPropertiesLayout, static_cast(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("[[({.+=#-](||)[])}.+=#-]"))) + reg->remove(s_valCustomRegex); + reg->endGroup(); + reg->endGroup(); } void