Skip to content

Commit a9dc96f

Browse files
committed
Make author of AI tone clickable.
1 parent 1aa7b72 commit a9dc96f

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

Telegram/SourceFiles/boxes/preview_ai_tone_box.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ For license and copyright information please follow this link:
88
#include "boxes/preview_ai_tone_box.h"
99

1010
#include "boxes/create_ai_tone_box.h"
11+
#include "core/click_handler_types.h"
1112
#include "core/ui_integration.h"
1213
#include "data/data_ai_compose_tones.h"
1314
#include "data/data_session.h"
@@ -412,7 +413,8 @@ void ShowToneRemovedToast(std::shared_ptr<Ui::Show> show, bool deleted) {
412413
void PreviewAiToneBox(
413414
not_null<Ui::GenericBox*> box,
414415
not_null<Main::Session*> session,
415-
Data::AiComposeTone tone) {
416+
Data::AiComposeTone tone,
417+
base::weak_ptr<Window::SessionController> controller) {
416418
box->setStyle(st::aiComposeBox);
417419
box->setNoContentMargin(true);
418420
box->setWidth(st::boxWideWidth);
@@ -533,6 +535,17 @@ void PreviewAiToneBox(
533535
attribution->setMarkedText(
534536
std::move(text),
535537
Core::TextContext({ .session = session }));
538+
attribution->setClickHandlerFilter([=](
539+
const ClickHandlerPtr &handler,
540+
Qt::MouseButton button) {
541+
ActivateClickHandler(attribution, handler, ClickContext{
542+
.button = button,
543+
.other = QVariant::fromValue(ClickHandlerContext{
544+
.sessionWindow = controller,
545+
}),
546+
});
547+
return false;
548+
});
536549
}
537550
Ui::AddSkip(body, st::aiTonePreviewBottomSkip);
538551

Telegram/SourceFiles/boxes/preview_ai_tone_box.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ For license and copyright information please follow this link:
77
*/
88
#pragma once
99

10+
#include "base/weak_ptr.h"
11+
1012
namespace Data {
1113
struct AiComposeTone;
1214
} // namespace Data
@@ -15,11 +17,16 @@ namespace Main {
1517
class Session;
1618
} // namespace Main
1719

20+
namespace Window {
21+
class SessionController;
22+
} // namespace Window
23+
1824
namespace Ui {
1925
class GenericBox;
2026
} // namespace Ui
2127

2228
void PreviewAiToneBox(
2329
not_null<Ui::GenericBox*> box,
2430
not_null<Main::Session*> session,
25-
Data::AiComposeTone tone);
31+
Data::AiComposeTone tone,
32+
base::weak_ptr<Window::SessionController> controller);

Telegram/SourceFiles/core/local_url_handlers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ bool ShowAiStyle(
315315
strong->window().show(Box(
316316
PreviewAiToneBox,
317317
&strong->session(),
318-
std::move(tone)));
318+
std::move(tone),
319+
weak));
319320
}, [=](const MTP::Error &error) {
320321
const auto strong = weak.get();
321322
if (!strong) {

0 commit comments

Comments
 (0)