From 90d14582247288d46f9b18d5698540d3283c4bf8 Mon Sep 17 00:00:00 2001 From: Lukasz Mastalerz Date: Wed, 21 Jun 2023 18:12:44 +0200 Subject: [PATCH] [CP-2040] Character sequence causes file being displayed as empty line in relaxation app Fixed problem with displaying some filenames in Relaxation --- harmony_changelog.md | 1 + .../windows/RelaxationMainWindow.cpp | 15 ++++++++++++--- .../windows/RelaxationRunningLoopWindow.cpp | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/harmony_changelog.md b/harmony_changelog.md index 8addd3599b3d82e18903cfc6c84df08b9b15c674..1d0d89db7b0942eb0d64d6b365d0563e8fe2e3c5 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -25,6 +25,7 @@ * Fixed the problem with the not appearing system closing window in some cases * Fixed the buttons sometimes don't respond on press or release * Fixed no clock update +* Fixed problem with displaying some filenames in Relaxation ### Added diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp index 3a92b91c8315e4819e7dc8372b07be45be3cd93d..d15c0d3ac9fa58b6bb1e44078fe00385563327cf 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationMainWindow.cpp @@ -11,8 +11,9 @@ namespace { - constexpr auto maxDisplayedTitleLength = 30U; -} + constexpr auto maxDisplayedTitleLength = 30U; + constexpr auto incompleteSequenceCharCode = '\342'; +} // namespace namespace gui { @@ -28,10 +29,18 @@ namespace gui void RelaxationMainWindow::setSoundsList(std::vector sounds) { + auto trimTittle = [](const std::string &title) { + std::string shortTittle = title.substr(0, maxDisplayedTitleLength); + if (shortTittle.back() == incompleteSequenceCharCode) { + shortTittle.pop_back(); + } + return shortTittle; + }; + std::list menuOptionList; auto addRecord = [&](const db::multimedia_files::MultimediaFilesRecord &sound) { menuOptionList.emplace_back(std::make_unique( - sound.tags.title.substr(0, maxDisplayedTitleLength), + trimTittle(sound.tags.title), [=](gui::Item &item) { onActivated(sound); return true; diff --git a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp index 02265f2e78c6fcee8813048db409a75821e44fd4..e7cada7f0d7d4a469de719f6ed5aa8455e7d3d80 100644 --- a/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp +++ b/products/BellHybrid/apps/application-bell-relaxation/windows/RelaxationRunningLoopWindow.cpp @@ -18,6 +18,7 @@ namespace inline constexpr units::SOC dischargingLevelShowTop = 20; inline constexpr units::SOC dischargingLowBattery = 10; inline constexpr auto maxPossibleCharsToDisplay = 25U; + inline constexpr auto incompleteSequenceCharCode = '\342'; bool isBatteryCharging(const Store::Battery::State state) { @@ -77,6 +78,9 @@ namespace return title; } std::string newTittle = title.substr(0, maxPossibleCharsToDisplay - 2); + if (newTittle.back() == incompleteSequenceCharCode) { + newTittle.pop_back(); + } newTittle.append("..."); return newTittle;