From 18b9bba21c8830d5493a3ca18da6594760b8cfa4 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 16 Apr 2022 22:01:25 +0300 Subject: [PATCH] Fixed width of time picker for different scales. --- Telegram/SourceFiles/ui/boxes/time_picker_box.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/ui/boxes/time_picker_box.cpp b/Telegram/SourceFiles/ui/boxes/time_picker_box.cpp index 43a5e50a1..4bc79dddc 100644 --- a/Telegram/SourceFiles/ui/boxes/time_picker_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/time_picker_box.cpp @@ -35,11 +35,14 @@ Fn TimePickerBox( const auto font = st::boxTextFont; const auto maxPhraseWidth = [&] { + // We have to use QFontMetricsF instead of + // FontData::width for more precise calculation. + const auto mf = QFontMetricsF(font->f); const auto maxPhrase = ranges::max_element( phrases, std::less<>(), - [&](const QString &s) { return font->width(s); }); - return font->width(*maxPhrase) + font->spacew * 2; + [&](const QString &s) { return mf.horizontalAdvance(s); }); + return std::ceil(mf.horizontalAdvance(*maxPhrase)); }(); const auto itemHeight = st::historyMessagesTTLPickerItemHeight; auto paintCallback = [=](