Allow editing tag name from search tags.
This commit is contained in:
parent
f072173d7c
commit
8459c29073
9 changed files with 111 additions and 23 deletions
|
@ -2833,6 +2833,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_context_animated_emoji_many#one" = "This message contains emoji from **{count} pack**.";
|
"lng_context_animated_emoji_many#one" = "This message contains emoji from **{count} pack**.";
|
||||||
"lng_context_animated_emoji_many#other" = "This message contains emoji from **{count} packs**.";
|
"lng_context_animated_emoji_many#other" = "This message contains emoji from **{count} packs**.";
|
||||||
"lng_context_animated_reaction" = "This reaction is from **{name} pack**.";
|
"lng_context_animated_reaction" = "This reaction is from **{name} pack**.";
|
||||||
|
"lng_context_animated_tag" = "This tag is from **{name} pack**.";
|
||||||
"lng_context_animated_reactions" = "Reactions contain emoji from **{name} pack**.";
|
"lng_context_animated_reactions" = "Reactions contain emoji from **{name} pack**.";
|
||||||
"lng_context_animated_reactions_many#one" = "Reactions contain emoji from **{count} pack**.";
|
"lng_context_animated_reactions_many#one" = "Reactions contain emoji from **{count} pack**.";
|
||||||
"lng_context_animated_reactions_many#other" = "Reactions contain emoji from **{count} packs**.";
|
"lng_context_animated_reactions_many#other" = "Reactions contain emoji from **{count} packs**.";
|
||||||
|
|
|
@ -1320,7 +1320,7 @@ editTagAbout: FlatLabel(defaultFlatLabel) {
|
||||||
}
|
}
|
||||||
editTagField: InputField(defaultInputField) {
|
editTagField: InputField(defaultInputField) {
|
||||||
textBg: transparent;
|
textBg: transparent;
|
||||||
textMargins: margins(24px, 10px, 32px, 0px);
|
textMargins: margins(24px, 10px, 32px, 2px);
|
||||||
|
|
||||||
placeholderFg: placeholderFg;
|
placeholderFg: placeholderFg;
|
||||||
placeholderFgActive: placeholderFgActive;
|
placeholderFgActive: placeholderFgActive;
|
||||||
|
@ -1328,7 +1328,7 @@ editTagField: InputField(defaultInputField) {
|
||||||
placeholderMargins: margins(2px, 0px, 2px, 0px);
|
placeholderMargins: margins(2px, 0px, 2px, 0px);
|
||||||
placeholderScale: 0.;
|
placeholderScale: 0.;
|
||||||
|
|
||||||
heightMin: 32px;
|
heightMin: 36px;
|
||||||
}
|
}
|
||||||
editTagLimit: FlatLabel(defaultFlatLabel) {
|
editTagLimit: FlatLabel(defaultFlatLabel) {
|
||||||
textFg: windowSubTextFg;
|
textFg: windowSubTextFg;
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "dialogs/dialogs_widget.h"
|
#include "dialogs/dialogs_widget.h"
|
||||||
#include "dialogs/dialogs_search_from_controllers.h"
|
#include "dialogs/dialogs_search_from_controllers.h"
|
||||||
#include "dialogs/dialogs_search_tags.h"
|
#include "dialogs/dialogs_search_tags.h"
|
||||||
|
#include "history/view/history_view_context_menu.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -3010,6 +3011,16 @@ void InnerWidget::searchInChat(
|
||||||
update(0, searchInChatOffset(), width(), height);
|
update(0, searchInChatOffset(), width(), height);
|
||||||
}, _searchTags->lifetime());
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
|
_searchTags->menuRequests(
|
||||||
|
) | rpl::start_with_next([=](Data::ReactionId id) {
|
||||||
|
HistoryView::ShowTagInListMenu(
|
||||||
|
&_menu,
|
||||||
|
_lastMousePosition.value_or(QCursor::pos()),
|
||||||
|
this,
|
||||||
|
id,
|
||||||
|
_controller);
|
||||||
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
_searchTags->heightValue() | rpl::skip(
|
_searchTags->heightValue() | rpl::skip(
|
||||||
1
|
1
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -132,11 +132,14 @@ void SearchTags::fill(
|
||||||
_tags.clear();
|
_tags.clear();
|
||||||
_tags.reserve(list.size());
|
_tags.reserve(list.size());
|
||||||
const auto link = [&](Data::ReactionId id) {
|
const auto link = [&](Data::ReactionId id) {
|
||||||
return std::make_shared<LambdaClickHandler>(crl::guard(this, [=](
|
return std::make_shared<GenericClickHandler>(crl::guard(this, [=](
|
||||||
ClickContext context) {
|
ClickContext context) {
|
||||||
if (!premium) {
|
if (!premium) {
|
||||||
MakePromoLink()->onClick(context);
|
MakePromoLink()->onClick(context);
|
||||||
return;
|
return;
|
||||||
|
} else if (context.button == Qt::RightButton) {
|
||||||
|
_menuRequests.fire_copy(id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const auto i = ranges::find(_tags, id, &Tag::id);
|
const auto i = ranges::find(_tags, id, &Tag::id);
|
||||||
if (i != end(_tags)) {
|
if (i != end(_tags)) {
|
||||||
|
@ -315,6 +318,10 @@ void SearchTags::paintCustomFrame(
|
||||||
_customCache);
|
_customCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<Data::ReactionId> SearchTags::menuRequests() const {
|
||||||
|
return _menuRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
void SearchTags::paint(
|
void SearchTags::paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
QPoint position,
|
QPoint position,
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
[[nodiscard]] auto selectedChanges() const
|
[[nodiscard]] auto selectedChanges() const
|
||||||
-> rpl::producer<std::vector<Data::ReactionId>>;
|
-> rpl::producer<std::vector<Data::ReactionId>>;
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<Data::ReactionId> menuRequests() const;
|
||||||
|
|
||||||
void paint(
|
void paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
QPoint position,
|
QPoint position,
|
||||||
|
@ -73,6 +75,7 @@ private:
|
||||||
Ui::Text::String _additionalText;
|
Ui::Text::String _additionalText;
|
||||||
rpl::event_stream<> _selectedChanges;
|
rpl::event_stream<> _selectedChanges;
|
||||||
rpl::event_stream<> _repaintRequests;
|
rpl::event_stream<> _repaintRequests;
|
||||||
|
rpl::event_stream<Data::ReactionId> _menuRequests;
|
||||||
mutable QImage _normalBg;
|
mutable QImage _normalBg;
|
||||||
mutable QImage _selectedBg;
|
mutable QImage _selectedBg;
|
||||||
mutable QImage _promoBg;
|
mutable QImage _promoBg;
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "dialogs/dialogs_search_from_controllers.h" // SearchFromBox
|
#include "dialogs/dialogs_search_from_controllers.h" // SearchFromBox
|
||||||
#include "dialogs/dialogs_search_tags.h"
|
#include "dialogs/dialogs_search_tags.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
|
#include "history/view/history_view_context_menu.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -26,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/multi_select.h"
|
#include "ui/widgets/multi_select.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
@ -297,6 +299,8 @@ private:
|
||||||
std::vector<Data::ReactionId> _searchTagsSelected;
|
std::vector<Data::ReactionId> _searchTagsSelected;
|
||||||
base::unique_qptr<Ui::MultiSelect> _select;
|
base::unique_qptr<Ui::MultiSelect> _select;
|
||||||
std::unique_ptr<Dialogs::SearchTags> _searchTags;
|
std::unique_ptr<Dialogs::SearchTags> _searchTags;
|
||||||
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||||
|
std::optional<QPoint> _mouseGlobalPosition;
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _window;
|
const not_null<Window::SessionController*> _window;
|
||||||
const not_null<History*> _history;
|
const not_null<History*> _history;
|
||||||
|
@ -461,6 +465,16 @@ void TopBar::refreshTags() {
|
||||||
requestSearch(false);
|
requestSearch(false);
|
||||||
}, _searchTags->lifetime());
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
|
_searchTags->menuRequests(
|
||||||
|
) | rpl::start_with_next([=](Data::ReactionId id) {
|
||||||
|
ShowTagInListMenu(
|
||||||
|
&_menu,
|
||||||
|
_mouseGlobalPosition.value_or(QCursor::pos()),
|
||||||
|
this,
|
||||||
|
id,
|
||||||
|
_window);
|
||||||
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
if (!_searchTagsSelected.empty()) {
|
if (!_searchTagsSelected.empty()) {
|
||||||
crl::on_main(this, [=] {
|
crl::on_main(this, [=] {
|
||||||
requestSearch(false);
|
requestSearch(false);
|
||||||
|
@ -497,6 +511,7 @@ void TopBar::refreshTags() {
|
||||||
parent->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
parent->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||||
if (e->type() == QEvent::MouseMove) {
|
if (e->type() == QEvent::MouseMove) {
|
||||||
const auto mouse = static_cast<QMouseEvent*>(e.get());
|
const auto mouse = static_cast<QMouseEvent*>(e.get());
|
||||||
|
_mouseGlobalPosition = mouse->globalPos();
|
||||||
const auto point = mouse->pos() - position;
|
const auto point = mouse->pos() - position;
|
||||||
const auto handler = _searchTags->lookupHandler(point);
|
const auto handler = _searchTags->lookupHandler(point);
|
||||||
ClickHandler::setActive(handler);
|
ClickHandler::setActive(handler);
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ void EditTagBox(
|
||||||
}, warning->lifetime());
|
}, warning->lifetime());
|
||||||
warning->setAttribute(Qt::WA_TransparentForMouseEvents);
|
warning->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
box->addButton(tr::lng_settings_save(), [=] {
|
const auto save = [=] {
|
||||||
const auto text = field->getLastText();
|
const auto text = field->getLastText();
|
||||||
if (text.size() > kTagNameLimit) {
|
if (text.size() > kTagNameLimit) {
|
||||||
field->showError();
|
field->showError();
|
||||||
|
@ -1085,7 +1085,12 @@ void EditTagBox(
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->closeBox();
|
strong->closeBox();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
field->submits(
|
||||||
|
) | rpl::start_with_next(save, field->lifetime());
|
||||||
|
|
||||||
|
box->addButton(tr::lng_settings_save(), save);
|
||||||
box->addButton(tr::lng_cancel(), [=] {
|
box->addButton(tr::lng_cancel(), [=] {
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
|
@ -1454,6 +1459,37 @@ void AddWhoReactedAction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddEditTagAction(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
const Data::ReactionId &id,
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
|
const auto owner = &controller->session().data();
|
||||||
|
const auto editLabel = owner->reactions().myTagTitle(id).isEmpty()
|
||||||
|
? tr::lng_context_tag_add_name(tr::now)
|
||||||
|
: tr::lng_context_tag_edit_name(tr::now);
|
||||||
|
menu->addAction(editLabel, [=] {
|
||||||
|
controller->show(Box(EditTagBox, controller, id));
|
||||||
|
}, &st::menuIconTagRename);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTagPackAction(
|
||||||
|
not_null<Ui::PopupMenu*> menu,
|
||||||
|
const Data::ReactionId &id,
|
||||||
|
not_null<Window::SessionController*> controller) {
|
||||||
|
if (const auto custom = id.custom()) {
|
||||||
|
const auto owner = &controller->session().data();
|
||||||
|
if (const auto set = owner->document(custom)->sticker()) {
|
||||||
|
if (set->set.id) {
|
||||||
|
AddEmojiPacksAction(
|
||||||
|
menu,
|
||||||
|
{ set->set },
|
||||||
|
EmojiPacksSource::Tag,
|
||||||
|
controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ShowTagMenu(
|
void ShowTagMenu(
|
||||||
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||||
QPoint position,
|
QPoint position,
|
||||||
|
@ -1476,12 +1512,7 @@ void ShowTagMenu(
|
||||||
});
|
});
|
||||||
}, &st::menuIconTagFilter);
|
}, &st::menuIconTagFilter);
|
||||||
|
|
||||||
const auto editLabel = owner->reactions().myTagTitle(id).isEmpty()
|
AddEditTagAction(menu->get(), id, controller);
|
||||||
? tr::lng_context_tag_add_name(tr::now)
|
|
||||||
: tr::lng_context_tag_edit_name(tr::now);
|
|
||||||
(*menu)->addAction(editLabel, [=] {
|
|
||||||
controller->show(Box(EditTagBox, controller, id));
|
|
||||||
}, &st::menuIconTagRename);
|
|
||||||
|
|
||||||
const auto removeTag = [=] {
|
const auto removeTag = [=] {
|
||||||
if (const auto item = owner->message(itemId)) {
|
if (const auto item = owner->message(itemId)) {
|
||||||
|
@ -1503,17 +1534,24 @@ void ShowTagMenu(
|
||||||
&st::menuIconTagRemoveAttention,
|
&st::menuIconTagRemoveAttention,
|
||||||
&st::menuIconTagRemoveAttention));
|
&st::menuIconTagRemoveAttention));
|
||||||
|
|
||||||
if (const auto custom = id.custom()) {
|
AddTagPackAction(menu->get(), id, controller);
|
||||||
if (const auto set = owner->document(custom)->sticker()) {
|
|
||||||
if (set->set.id) {
|
(*menu)->popup(position);
|
||||||
AddEmojiPacksAction(
|
}
|
||||||
menu->get(),
|
|
||||||
{ set->set },
|
void ShowTagInListMenu(
|
||||||
EmojiPacksSource::Reaction,
|
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||||
controller);
|
QPoint position,
|
||||||
}
|
not_null<QWidget*> context,
|
||||||
}
|
const Data::ReactionId &id,
|
||||||
}
|
not_null<Window::SessionController*> controller) {
|
||||||
|
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
|
context,
|
||||||
|
st::popupMenuExpandedSeparator);
|
||||||
|
|
||||||
|
AddEditTagAction(menu->get(), id, controller);
|
||||||
|
AddTagPackAction(menu->get(), id, controller);
|
||||||
|
|
||||||
(*menu)->popup(position);
|
(*menu)->popup(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1676,6 +1714,12 @@ void AddEmojiPacksAction(
|
||||||
lt_name,
|
lt_name,
|
||||||
TextWithEntities{ name },
|
TextWithEntities{ name },
|
||||||
Ui::Text::RichLangValue);
|
Ui::Text::RichLangValue);
|
||||||
|
case EmojiPacksSource::Tag:
|
||||||
|
return tr::lng_context_animated_tag(
|
||||||
|
tr::now,
|
||||||
|
lt_name,
|
||||||
|
TextWithEntities{ name },
|
||||||
|
Ui::Text::RichLangValue);
|
||||||
case EmojiPacksSource::Reaction:
|
case EmojiPacksSource::Reaction:
|
||||||
if (!name.text.isEmpty()) {
|
if (!name.text.isEmpty()) {
|
||||||
return tr::lng_context_animated_reaction(
|
return tr::lng_context_animated_reaction(
|
||||||
|
|
|
@ -88,11 +88,18 @@ void ShowWhoReactedMenu(
|
||||||
const Data::ReactionId &id,
|
const Data::ReactionId &id,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
rpl::lifetime &lifetime);
|
rpl::lifetime &lifetime);
|
||||||
|
void ShowTagInListMenu(
|
||||||
|
not_null<base::unique_qptr<Ui::PopupMenu>*> menu,
|
||||||
|
QPoint position,
|
||||||
|
not_null<QWidget*> context,
|
||||||
|
const Data::ReactionId &id,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
enum class EmojiPacksSource {
|
enum class EmojiPacksSource {
|
||||||
Message,
|
Message,
|
||||||
Reaction,
|
Reaction,
|
||||||
Reactions,
|
Reactions,
|
||||||
|
Tag,
|
||||||
};
|
};
|
||||||
[[nodiscard]] std::vector<StickerSetIdentifier> CollectEmojiPacks(
|
[[nodiscard]] std::vector<StickerSetIdentifier> CollectEmojiPacks(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a2c2d92cda2cffdafeb671d1f292a2002fb54217
|
Subproject commit 7328e2786248c673e3599695a56989d9c1062303
|
Loading…
Reference in a new issue