Slightly improved code style for decimal counts.

This commit is contained in:
23rd 2024-05-21 05:22:27 +03:00 committed by John Preston
parent 030d35ea7e
commit 6336df2bd6
2 changed files with 10 additions and 9 deletions

View file

@ -7,13 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "history/view/reactions/history_view_reactions_tabs.h" #include "history/view/reactions/history_view_reactions_tabs.h"
#include "ui/rp_widget.h"
#include "ui/abstract_button.h"
#include "ui/painter.h"
#include "ui/controls/who_reacted_context_action.h"
#include "data/data_message_reaction_id.h" #include "data/data_message_reaction_id.h"
#include "styles/style_widgets.h" #include "lang/lang_tag.h"
#include "ui/abstract_button.h"
#include "ui/controls/who_reacted_context_action.h"
#include "ui/painter.h"
#include "ui/rp_widget.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_widgets.h"
namespace HistoryView::Reactions { namespace HistoryView::Reactions {
namespace { namespace {
@ -35,7 +36,7 @@ not_null<Ui::AbstractButton*> CreateTab(
bool selected = false; bool selected = false;
}; };
const auto stm = &st.item; const auto stm = &st.item;
const auto text = QString("%L1").arg(count); const auto text = Lang::FormatCountDecimal(count);
const auto font = st::semiboldFont; const auto font = st::semiboldFont;
const auto textWidth = font->width(text); const auto textWidth = font->width(text);
const auto result = Ui::CreateChild<Ui::AbstractButton>(parent.get()); const auto result = Ui::CreateChild<Ui::AbstractButton>(parent.get());

View file

@ -81,7 +81,7 @@ void PaintDetails(
line.name); line.name);
auto value = Ui::Text::String( auto value = Ui::Text::String(
st::statisticsDetailsPopupStyle, st::statisticsDetailsPopupStyle,
QString("%L1").arg(absoluteValue)); Lang::FormatCountDecimal(absoluteValue));
const auto nameWidth = name.maxWidth(); const auto nameWidth = name.maxWidth();
const auto valueWidth = value.maxWidth(); const auto valueWidth = value.maxWidth();
@ -177,7 +177,7 @@ PointDetailsWidget::PointDetailsWidget(
const auto calculatedWidth = [&]{ const auto calculatedWidth = [&]{
const auto maxValueText = Ui::Text::String( const auto maxValueText = Ui::Text::String(
_textStyle, _textStyle,
QString("%L1").arg(maxAbsoluteValue)); Lang::FormatCountDecimal(maxAbsoluteValue));
const auto maxValueTextWidth = maxValueText.maxWidth(); const auto maxValueTextWidth = maxValueText.maxWidth();
auto maxNameTextWidth = 0; auto maxNameTextWidth = 0;
@ -284,7 +284,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
textLine.name.setText(_textStyle, dataLine.name); textLine.name.setText(_textStyle, dataLine.name);
textLine.value.setText( textLine.value.setText(
_textStyle, _textStyle,
QString("%L1").arg(dataLine.y[xIndex])); Lang::FormatCountDecimal(dataLine.y[xIndex]));
hasPositiveValues |= (dataLine.y[xIndex] > 0); hasPositiveValues |= (dataLine.y[xIndex] > 0);
textLine.valueColor = QColor(dataLine.color); textLine.valueColor = QColor(dataLine.color);
if (_chartData.currencyRate) { if (_chartData.currencyRate) {