From e7f6a8a476eef1771b0723cba8be6df75d780f1b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 26 Sep 2025 10:49:02 +0300 Subject: [PATCH] Added ability to edit contact note with context menu. --- Telegram/Resources/langs/lang.strings | 1 + .../boxes/peers/edit_contact_box.cpp | 25 +++++++++++++++++-- .../boxes/peers/edit_contact_box.h | 5 ++++ .../info/profile/info_profile_actions.cpp | 7 ++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 3ebafa2720..dc8c2e8f29 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1605,6 +1605,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_info_birthday_today" = "{emoji} {date}"; "lng_info_notes_label" = "Notes"; "lng_info_notes_private" = "only visible to you"; +"lng_edit_note" = "Edit Note"; "lng_delete_note" = "Delete Note"; "lng_info_bio_label" = "Bio"; "lng_info_link_label" = "Link"; diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index f80ca5db54..8c49e042b5 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -130,7 +130,8 @@ public: Controller( not_null box, not_null window, - not_null user); + not_null user, + bool focusOnNotes = false); void prepare(); @@ -162,6 +163,7 @@ private: not_null _box; not_null _window; not_null _user; + bool _focusOnNotes = false; Ui::Checkbox *_sharePhone = nullptr; Ui::InputField *_notesField = nullptr; Ui::InputField *_firstNameField = nullptr; @@ -181,10 +183,12 @@ private: Controller::Controller( not_null box, not_null window, - not_null user) + not_null user, + bool focusOnNotes) : _box(box) , _window(window) , _user(user) +, _focusOnNotes(focusOnNotes) , _phone(UserPhone(user)) { } @@ -261,6 +265,11 @@ void Controller::initNameFields( _box->setTabOrder(last, first); } _focus = [=] { + if (_focusOnNotes && _notesField) { + _notesField->setFocusFast(); + _notesField->setCursorPosition(_notesField->getLastText().size()); + return; + } const auto firstValue = getValue(first); const auto lastValue = getValue(last); const auto empty = firstValue.isEmpty() && lastValue.isEmpty(); @@ -876,3 +885,15 @@ void EditContactBox( box->setWidth(st::boxWideWidth); box->lifetime().make_state(box, window, user)->prepare(); } + +void EditContactNoteBox( + not_null box, + not_null window, + not_null user) { + box->setWidth(st::boxWideWidth); + box->lifetime().make_state( + box, + window, + user, + true)->prepare(); +} diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.h b/Telegram/SourceFiles/boxes/peers/edit_contact_box.h index 3dc7d81f89..8877134fd2 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.h @@ -19,3 +19,8 @@ void EditContactBox( not_null box, not_null window, not_null user); + +void EditContactNoteBox( + not_null box, + not_null window, + not_null user); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index bfdd9d40e7..ddde408c46 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -775,6 +775,13 @@ void DeleteContactNote( raw->fillContextMenu(request); const auto addAction = Ui::Menu::CreateAddActionCallback( request.menu); + addAction({ + .text = tr::lng_edit_note(tr::now), + .handler = [=] { + controller->window().show( + Box(EditContactNoteBox, controller, user)); + }, + }); addAction({ .text = tr::lng_delete_note(tr::now), .handler = [=] {