From 968d03683414b62b569a239ce38358e2851d17d9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 20 Jun 2024 12:58:19 +0400 Subject: [PATCH] Use Ui::NumberInput for the paid media price. --- Telegram/SourceFiles/boxes/send_files_box.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 754713062..d1f5cfeb6 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/premium_preview_box.h" #include "boxes/send_credits_box.h" #include "ui/effects/scroll_content_shadow.h" +#include "ui/widgets/fields/number_input.h" #include "ui/widgets/checkbox.h" #include "ui/widgets/scroll_area.h" #include "ui/widgets/popup_menu.h" @@ -124,13 +125,22 @@ void EditPriceBox( 0, st::defaultSubsectionTitlePadding.right(), 0))); - const auto field = box->addRow(object_ptr( + const auto wrap = box->addRow(object_ptr( box, + st::editTagField.heightMin)); + auto owned = object_ptr( + wrap, st::editTagField, tr::lng_paid_cost_placeholder(), - price ? QString::number(price) : QString())); + price ? QString::number(price) : QString(), + kMaxPrice); + const auto field = owned.data(); + wrap->widthValue() | rpl::start_with_next([=](int width) { + field->move(0, 0); + field->resize(width, field->height()); + wrap->resize(width, field->height()); + }, wrap->lifetime()); field->selectAll(); - field->setMaxLength(QString::number(kMaxPrice).size()); box->setFocusCallback([=] { field->setFocusFast(); }); @@ -168,8 +178,7 @@ void EditPriceBox( } }; - field->submits( - ) | rpl::start_with_next(save, field->lifetime()); + QObject::connect(field, &Ui::NumberInput::submitted, box, save); box->addButton(tr::lng_settings_save(), save); box->addButton(tr::lng_cancel(), [=] {