Compare commits
407 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f75429cbaa | ||
|
|
dc8c4a8332 | ||
|
|
096530c96a | ||
|
|
ed0850d823 | ||
|
|
4a2173deaf | ||
|
|
f40a584905 | ||
|
|
e54204b136 | ||
|
|
715dff0a3e | ||
|
|
558daa3382 | ||
|
|
7265297b19 | ||
|
|
1fac6db8bd | ||
|
|
c9bd776d1e | ||
|
|
179e81478e | ||
|
|
9ef74c510c | ||
|
|
36f6917bd3 | ||
|
|
707951accb | ||
|
|
7eb98b50ec | ||
|
|
65f7bdb914 | ||
|
|
876c47c436 | ||
|
|
e8f16840de | ||
|
|
dd57ad567f | ||
|
|
54934fb835 | ||
|
|
bd49887607 | ||
|
|
aaa72b7c30 | ||
|
|
4cafacc8db | ||
|
|
374b3c68ac | ||
|
|
69d21f73ef | ||
|
|
6dc3bd65e8 | ||
|
|
deb9aa435b | ||
|
|
68cb568898 | ||
|
|
1ed81b1c9c | ||
|
|
a95fb5b28d | ||
|
|
4f7b5ca7da | ||
|
|
29b7673b88 | ||
|
|
66f375d2c6 | ||
|
|
77d214d2a5 | ||
|
|
09e6077e97 | ||
|
|
631d6abb06 | ||
|
|
c833b8a1b0 | ||
|
|
b58c03f0de | ||
|
|
1988435cdf | ||
|
|
7e704d9529 | ||
|
|
a39a8dbd2c | ||
|
|
90dfae52f5 | ||
|
|
dfc422b505 | ||
|
|
54cc12cf22 | ||
|
|
d81e832ae6 | ||
|
|
1399d2501d | ||
|
|
57254ca259 | ||
|
|
043e3ae97e | ||
|
|
68b9a8bc6a | ||
|
|
157d5c743b | ||
|
|
54d0290ba2 | ||
|
|
0fc2df8eec | ||
|
|
d9caf15d1d | ||
|
|
b674826392 | ||
|
|
37181f9d0a | ||
|
|
93aebc747d | ||
|
|
a84ac933dd | ||
|
|
b79c306bfe | ||
|
|
57d62423b3 | ||
|
|
f4674389d5 | ||
|
|
63c4c5064f | ||
|
|
ae1f364730 | ||
|
|
c6e322de86 | ||
|
|
68bf6f991c | ||
|
|
b15f5f8596 | ||
|
|
27a71a8dcd | ||
|
|
2044f8f9ad | ||
|
|
ffa4b1db87 | ||
|
|
cad25ae644 | ||
|
|
21094fe11b | ||
|
|
101dbdf243 | ||
|
|
0dc92762bc | ||
|
|
5fdaa6b91f | ||
|
|
968d036834 | ||
|
|
d47c5df73d | ||
|
|
6c1e7357c6 | ||
|
|
479b63c33a | ||
|
|
950a946a16 | ||
|
|
5f8da27c86 | ||
|
|
a9bd7803e6 | ||
|
|
3ece9b1566 | ||
|
|
e71a067f4b | ||
|
|
ebf456abe4 | ||
|
|
3552da5ce7 | ||
|
|
b5bd0f53ad | ||
|
|
7d115b3fab | ||
|
|
d0a030ab58 | ||
|
|
712c06756e | ||
|
|
301ffc15ef | ||
|
|
3c4a711b5d | ||
|
|
989145726d | ||
|
|
9eebd3b514 | ||
|
|
eb997ae9e3 | ||
|
|
db4c9b83f3 | ||
|
|
1196b6a3fb | ||
|
|
bef216bc93 | ||
|
|
811d75e383 | ||
|
|
049cde48ee | ||
|
|
cb65c50c19 | ||
|
|
f23c9a61bc | ||
|
|
b5d5ff3cbb | ||
|
|
c5ba0fa705 | ||
|
|
71893f4ef7 | ||
|
|
4a60c57661 | ||
|
|
fbbcc21198 | ||
|
|
d993386756 | ||
|
|
30819509d3 | ||
|
|
10c3fe0f63 | ||
|
|
3498a7f0ee | ||
|
|
648b23b548 | ||
|
|
ba89912834 | ||
|
|
c1bc7e6ab1 | ||
|
|
eea50ed6b0 | ||
|
|
006d6fe2c0 | ||
|
|
5180e0ec57 | ||
|
|
490ec7949f | ||
|
|
671a15d763 | ||
|
|
d2d5226dc7 | ||
|
|
b58ece3a38 | ||
|
|
2b4a2b5b97 | ||
|
|
382b175db2 | ||
|
|
2db81211c8 | ||
|
|
46157c99c4 | ||
|
|
c3ed5224c2 | ||
|
|
acee7c7cfc | ||
|
|
002fe9a72a | ||
|
|
93b7c47cda | ||
|
|
053f8ad1c0 | ||
|
|
60ca6895db | ||
|
|
fc5e9414b7 | ||
|
|
f768e405fa | ||
|
|
a22cf8e303 | ||
|
|
8a5797e1bd | ||
|
|
750ad600be | ||
|
|
eaf4575eb8 | ||
|
|
b9677fe1db | ||
|
|
4047f1733d | ||
|
|
3d114131e0 | ||
|
|
5810149a77 | ||
|
|
032fe3e0fc | ||
|
|
81d7fcba7e | ||
|
|
4e9b5b0d33 | ||
|
|
90068f6261 | ||
|
|
f37d056c14 | ||
|
|
f748988ae3 | ||
|
|
9a25d2c413 | ||
|
|
ec40292cbf | ||
|
|
5e8c3fb146 | ||
|
|
fa8ed186d8 | ||
|
|
c1f36d43d0 | ||
|
|
501cae2200 | ||
|
|
8ad5117495 | ||
|
|
d79da3d884 | ||
|
|
e4d88f829c | ||
|
|
2673e1df53 | ||
|
|
99e88d74bc | ||
|
|
43ffc9d67c | ||
|
|
053c462dc0 | ||
|
|
174b627a78 | ||
|
|
bb33d0b997 | ||
|
|
6f6fb3d1b6 | ||
|
|
3f216ad946 | ||
|
|
c49eb7041f | ||
|
|
a1d8202644 | ||
|
|
82428aef28 | ||
|
|
10f7b985c7 | ||
|
|
06075411a5 | ||
|
|
7e01b12825 | ||
|
|
273119fc55 | ||
|
|
e47e4ba338 | ||
|
|
cbcdeae200 | ||
|
|
c585112e37 | ||
|
|
392df8b56f | ||
|
|
0e6470a087 | ||
|
|
6c0ea0eb9f | ||
|
|
9229de2658 | ||
|
|
2935721cd0 | ||
|
|
a48cd5f15a | ||
|
|
9e77e80f92 | ||
|
|
deb50ee528 | ||
|
|
14909ae913 | ||
|
|
d5d9da7d0a | ||
|
|
86a048a021 | ||
|
|
aafa8631e0 | ||
|
|
9176bf2e47 | ||
|
|
72c667b153 | ||
|
|
fe6f65b3ab | ||
|
|
5db2821f8c | ||
|
|
9e3e7265d2 | ||
|
|
749b2e0e95 | ||
|
|
5b45397383 | ||
|
|
61c17c0a93 | ||
|
|
93e592472c | ||
|
|
379a94db42 | ||
|
|
4f4d216987 | ||
|
|
6400875d55 | ||
|
|
06d0e78b00 | ||
|
|
9043c18725 | ||
|
|
88e742927f | ||
|
|
a6fcc6d51d | ||
|
|
23a13ab54e | ||
|
|
e8a929bdbd | ||
|
|
eafc01e02b | ||
|
|
f817504d67 | ||
|
|
f91eb65239 | ||
|
|
e978770fbd | ||
|
|
9c83b8bac5 | ||
|
|
47ce34e987 | ||
|
|
1656a9c3e2 | ||
|
|
47e06cf385 | ||
|
|
f61f649a7e | ||
|
|
a7bffe7abd | ||
|
|
51b866293f | ||
|
|
bd20a3cfe4 | ||
|
|
86778aa4d9 | ||
|
|
12eecec501 | ||
|
|
26345208a9 | ||
|
|
ee680ac1f1 | ||
|
|
bb79a07262 | ||
|
|
70fe649743 | ||
|
|
400f0f8785 | ||
|
|
eac7bf1c48 | ||
|
|
f4abe37dff | ||
|
|
b7f165a259 | ||
|
|
c1b95afd88 | ||
|
|
36766e7546 | ||
|
|
59c016e4ce | ||
|
|
e9e347fa6c | ||
|
|
7aef0b0a83 | ||
|
|
d9572949f6 | ||
|
|
233e80d22d | ||
|
|
5c83858a50 | ||
|
|
c681569349 | ||
|
|
bb43afdd93 | ||
|
|
3ba1941808 | ||
|
|
72d1b43453 | ||
|
|
0c1b487956 | ||
|
|
ba611d0f2d | ||
|
|
50ce847b31 | ||
|
|
dd0d88ccd3 | ||
|
|
a1049ec7ce | ||
|
|
0fffeac8da | ||
|
|
1f0acae151 | ||
|
|
521c17b76c | ||
|
|
f9f51b4e41 | ||
|
|
4e8895ddd9 | ||
|
|
ad342a5324 | ||
|
|
5cfd86b829 | ||
|
|
27eb3e45be | ||
|
|
4953246c5d | ||
|
|
4df5372dab | ||
|
|
40fbd415ef | ||
|
|
974bf99921 | ||
|
|
8c0351be4e | ||
|
|
67f7816088 | ||
|
|
924d80ecba | ||
|
|
d219bccf2b | ||
|
|
02bd2bca64 | ||
|
|
57ecc2be1d | ||
|
|
d3a01b6235 | ||
|
|
58c060c59d | ||
|
|
cd7507fb23 | ||
|
|
9a5923676a | ||
|
|
c0f3d263a3 | ||
|
|
056ba644ed | ||
|
|
ebaffc333e | ||
|
|
be099880d8 | ||
|
|
885dcf0b28 | ||
|
|
a0d97f03cb | ||
|
|
c942034ca4 | ||
|
|
0bd780b20f | ||
|
|
7d75c25214 | ||
|
|
5defb9fb17 | ||
|
|
0549c8f037 | ||
|
|
3c246e1e92 | ||
|
|
58da617e3f | ||
|
|
1edf0ed70b | ||
|
|
c27c567225 | ||
|
|
93eff78cd6 | ||
|
|
a2a27e115c | ||
|
|
e9fb580ba4 | ||
|
|
d73313479b | ||
|
|
e4e343b871 | ||
|
|
dda6b92bec | ||
|
|
3dd894ad30 | ||
|
|
f08ff92470 | ||
|
|
923aaec085 | ||
|
|
1d3110228d | ||
|
|
7194781bb8 | ||
|
|
97a5e0c6ea | ||
|
|
a3ef36f9f7 | ||
|
|
d13bf19b79 | ||
|
|
493f0450b4 | ||
|
|
74861a334d | ||
|
|
a87a221f26 | ||
|
|
923a9ec6a8 | ||
|
|
b299881bf8 | ||
|
|
5ee2bca616 | ||
|
|
d1e914fb30 | ||
|
|
43cb315f47 | ||
|
|
dcc52a7333 | ||
|
|
84cde1354d | ||
|
|
3d81414c71 | ||
|
|
69c48e2b5b | ||
|
|
5ca9b74142 | ||
|
|
e11755af46 | ||
|
|
174fb62c32 | ||
|
|
0e30e306ff | ||
|
|
5e29f382cd | ||
|
|
8eb24f620d | ||
|
|
5adde6c93a | ||
|
|
42d6d0d58a | ||
|
|
6336df2bd6 | ||
|
|
030d35ea7e | ||
|
|
d81c3554cc | ||
|
|
ca37ffa086 | ||
|
|
154fe63b43 | ||
|
|
65384d54f1 | ||
|
|
2bf8cb84d0 | ||
|
|
f0a82de784 | ||
|
|
1a393ddebb | ||
|
|
9b11b95c5b | ||
|
|
d0bfee6963 | ||
|
|
f1636de572 | ||
|
|
b5eb195f43 | ||
|
|
4a0bffe618 | ||
|
|
53d97b4146 | ||
|
|
2a224c839e | ||
|
|
bc7aa91fbb | ||
|
|
ac2f35f12b | ||
|
|
39e03c3ca7 | ||
|
|
1ce49df123 | ||
|
|
1865fd382c | ||
|
|
e00c6ecfb8 | ||
|
|
279db771cf | ||
|
|
7b7438cd7b | ||
|
|
42d53e5543 | ||
|
|
fce520c9c0 | ||
|
|
b21bcb86cc | ||
|
|
7d61ab9412 | ||
|
|
701bf0d553 | ||
|
|
583bcca6a9 | ||
|
|
6a8edefc87 | ||
|
|
dd5643ac67 | ||
|
|
787cf7853e | ||
|
|
5bfbae3afc | ||
|
|
363b700f1f | ||
|
|
cde70b9807 | ||
|
|
f7ab8a2174 | ||
|
|
a011a7c316 | ||
|
|
487fa9728a | ||
|
|
8a58ded582 | ||
|
|
ec5d8b7373 | ||
|
|
732b67ca04 | ||
|
|
d102d256a9 | ||
|
|
bbb3a51b74 | ||
|
|
d0d1ef9e66 | ||
|
|
b01244fc42 | ||
|
|
b92a05011f | ||
|
|
5fb7992b04 | ||
|
|
f371cd1af2 | ||
|
|
144109db05 | ||
|
|
e120ae6ae6 | ||
|
|
d1106e5ae6 | ||
|
|
396ba9a984 | ||
|
|
92133e7f50 | ||
|
|
a19e71324b | ||
|
|
f762634036 | ||
|
|
ee4f83ffde | ||
|
|
f8188f360a | ||
|
|
2bbc7406da | ||
|
|
a9dd9aeb90 | ||
|
|
aa4156d1e7 | ||
|
|
4f5594c8cc | ||
|
|
0527e9a0f7 | ||
|
|
28cbb02b20 | ||
|
|
7d636820ac | ||
|
|
e2b78b673b | ||
|
|
a9a0fe7cf5 | ||
|
|
2b9e7a6b25 | ||
|
|
d6e827e982 | ||
|
|
d2e6003521 | ||
|
|
465fc42718 | ||
|
|
0dd6ff9d9b | ||
|
|
8a6b1677f4 | ||
|
|
470b3a2cbd | ||
|
|
a60783eae3 | ||
|
|
de73d8766c | ||
|
|
cd7cfcdf2f | ||
|
|
aee62c7591 | ||
|
|
0f524ac67d | ||
|
|
f223ae7eee | ||
|
|
68df8448a2 | ||
|
|
da31fef1ae | ||
|
|
4427ae4306 | ||
|
|
ef2aa05197 | ||
|
|
e5132e3fe8 | ||
|
|
3b6870396c | ||
|
|
f6b849e4f7 | ||
|
|
48e3802565 | ||
|
|
26ba7e57ce | ||
|
|
2605e754ff | ||
|
|
9e85b1aa23 | ||
|
|
88cd886ec8 | ||
|
|
adc536b81d |
@@ -57,14 +57,6 @@ include(cmake/validate_d3d_compiler.cmake)
|
||||
include(cmake/target_prepare_qrc.cmake)
|
||||
|
||||
include(cmake/options.cmake)
|
||||
|
||||
if (NOT DESKTOP_APP_USE_PACKAGED)
|
||||
if (WIN32)
|
||||
set(qt_version 5.15.13)
|
||||
elseif (APPLE)
|
||||
set(qt_version 6.2.8)
|
||||
endif()
|
||||
endif()
|
||||
include(cmake/external/qt/package.cmake)
|
||||
|
||||
set(desktop_app_skip_libs
|
||||
|
||||
@@ -120,10 +120,13 @@ PRIVATE
|
||||
api/api_common.h
|
||||
api/api_confirm_phone.cpp
|
||||
api/api_confirm_phone.h
|
||||
api/api_credits.cpp
|
||||
api/api_credits.h
|
||||
api/api_earn.cpp
|
||||
api/api_earn.h
|
||||
api/api_editing.cpp
|
||||
api/api_editing.h
|
||||
api/api_filter_updates.h
|
||||
api/api_global_privacy.cpp
|
||||
api/api_global_privacy.h
|
||||
api/api_hash.cpp
|
||||
@@ -162,6 +165,10 @@ PRIVATE
|
||||
api/api_single_message_search.h
|
||||
api/api_statistics.cpp
|
||||
api/api_statistics.h
|
||||
api/api_statistics_data_deserialize.cpp
|
||||
api/api_statistics_data_deserialize.h
|
||||
api/api_statistics_sender.cpp
|
||||
api/api_statistics_sender.h
|
||||
api/api_text_entities.cpp
|
||||
api/api_text_entities.h
|
||||
api/api_toggling_media.cpp
|
||||
@@ -299,6 +306,8 @@ PRIVATE
|
||||
boxes/ringtones_box.h
|
||||
boxes/self_destruction_box.cpp
|
||||
boxes/self_destruction_box.h
|
||||
boxes/send_credits_box.cpp
|
||||
boxes/send_credits_box.h
|
||||
boxes/send_files_box.cpp
|
||||
boxes/send_files_box.h
|
||||
boxes/sessions_box.cpp
|
||||
@@ -441,6 +450,8 @@ PRIVATE
|
||||
core/launcher.h
|
||||
core/local_url_handlers.cpp
|
||||
core/local_url_handlers.h
|
||||
core/phone_click_handler.cpp
|
||||
core/phone_click_handler.h
|
||||
core/sandbox.cpp
|
||||
core/sandbox.h
|
||||
core/shortcuts.cpp
|
||||
@@ -462,6 +473,8 @@ PRIVATE
|
||||
data/business/data_business_info.h
|
||||
data/business/data_shortcut_messages.cpp
|
||||
data/business/data_shortcut_messages.h
|
||||
data/components/factchecks.cpp
|
||||
data/components/factchecks.h
|
||||
data/components/recent_peers.cpp
|
||||
data/components/recent_peers.h
|
||||
data/components/scheduled_messages.cpp
|
||||
@@ -539,6 +552,8 @@ PRIVATE
|
||||
data/data_groups.h
|
||||
data/data_histories.cpp
|
||||
data/data_histories.h
|
||||
data/data_history_messages.cpp
|
||||
data/data_history_messages.h
|
||||
data/data_lastseen_status.h
|
||||
data/data_location.cpp
|
||||
data/data_location.h
|
||||
@@ -712,8 +727,6 @@ PRIVATE
|
||||
history/view/media/history_view_dice.h
|
||||
history/view/media/history_view_document.cpp
|
||||
history/view/media/history_view_document.h
|
||||
history/view/media/history_view_extended_preview.cpp
|
||||
history/view/media/history_view_extended_preview.h
|
||||
history/view/media/history_view_file.cpp
|
||||
history/view/media/history_view_file.h
|
||||
history/view/media/history_view_game.cpp
|
||||
@@ -781,6 +794,8 @@ PRIVATE
|
||||
history/view/history_view_about_view.h
|
||||
history/view/history_view_bottom_info.cpp
|
||||
history/view/history_view_bottom_info.h
|
||||
history/view/history_view_chat_preview.cpp
|
||||
history/view/history_view_chat_preview.h
|
||||
history/view/history_view_contact_status.cpp
|
||||
history/view/history_view_contact_status.h
|
||||
history/view/history_view_context_menu.cpp
|
||||
@@ -795,6 +810,8 @@ PRIVATE
|
||||
history/view/history_view_emoji_interactions.h
|
||||
history/view/history_view_empty_list_bubble.cpp
|
||||
history/view/history_view_empty_list_bubble.h
|
||||
history/view/history_view_fake_items.cpp
|
||||
history/view/history_view_fake_items.h
|
||||
history/view/history_view_group_call_bar.cpp
|
||||
history/view/history_view_group_call_bar.h
|
||||
history/view/history_view_item_preview.h
|
||||
@@ -825,14 +842,14 @@ PRIVATE
|
||||
history/view/history_view_send_action.h
|
||||
history/view/history_view_service_message.cpp
|
||||
history/view/history_view_service_message.h
|
||||
history/view/history_view_spoiler_click_handler.cpp
|
||||
history/view/history_view_spoiler_click_handler.h
|
||||
history/view/history_view_sponsored_click_handler.cpp
|
||||
history/view/history_view_sponsored_click_handler.h
|
||||
history/view/history_view_sticker_toast.cpp
|
||||
history/view/history_view_sticker_toast.h
|
||||
history/view/history_view_sublist_section.cpp
|
||||
history/view/history_view_sublist_section.h
|
||||
history/view/history_view_text_helper.cpp
|
||||
history/view/history_view_text_helper.h
|
||||
history/view/history_view_transcribe_button.cpp
|
||||
history/view/history_view_transcribe_button.h
|
||||
history/view/history_view_translate_bar.cpp
|
||||
@@ -873,6 +890,10 @@ PRIVATE
|
||||
history/history_view_highlight_manager.h
|
||||
history/history_widget.cpp
|
||||
history/history_widget.h
|
||||
info/bot/earn/info_bot_earn_list.cpp
|
||||
info/bot/earn/info_bot_earn_list.h
|
||||
info/bot/earn/info_bot_earn_widget.cpp
|
||||
info/bot/earn/info_bot_earn_widget.h
|
||||
info/channel_statistics/boosts/create_giveaway_box.cpp
|
||||
info/channel_statistics/boosts/create_giveaway_box.h
|
||||
info/channel_statistics/boosts/giveaway/giveaway_list_controllers.cpp
|
||||
@@ -881,10 +902,10 @@ PRIVATE
|
||||
info/channel_statistics/boosts/info_boosts_inner_widget.h
|
||||
info/channel_statistics/boosts/info_boosts_widget.cpp
|
||||
info/channel_statistics/boosts/info_boosts_widget.h
|
||||
info/channel_statistics/earn/info_earn_inner_widget.cpp
|
||||
info/channel_statistics/earn/info_earn_inner_widget.h
|
||||
info/channel_statistics/earn/info_earn_widget.cpp
|
||||
info/channel_statistics/earn/info_earn_widget.h
|
||||
info/channel_statistics/earn/info_channel_earn_list.cpp
|
||||
info/channel_statistics/earn/info_channel_earn_list.h
|
||||
info/channel_statistics/earn/info_channel_earn_widget.cpp
|
||||
info/channel_statistics/earn/info_channel_earn_widget.h
|
||||
info/common_groups/info_common_groups_inner_widget.cpp
|
||||
info/common_groups/info_common_groups_inner_widget.h
|
||||
info/common_groups/info_common_groups_widget.cpp
|
||||
@@ -1209,6 +1230,8 @@ PRIVATE
|
||||
payments/payments_checkout_process.h
|
||||
payments/payments_form.cpp
|
||||
payments/payments_form.h
|
||||
payments/payments_non_panel_process.cpp
|
||||
payments/payments_non_panel_process.h
|
||||
platform/linux/file_utilities_linux.cpp
|
||||
platform/linux/file_utilities_linux.h
|
||||
platform/linux/launcher_linux.cpp
|
||||
@@ -1354,6 +1377,10 @@ PRIVATE
|
||||
settings/settings_codes.h
|
||||
settings/settings_common_session.cpp
|
||||
settings/settings_common_session.h
|
||||
settings/settings_credits.cpp
|
||||
settings/settings_credits.h
|
||||
settings/settings_credits_graphics.cpp
|
||||
settings/settings_credits_graphics.h
|
||||
settings/settings_experimental.cpp
|
||||
settings/settings_experimental.h
|
||||
settings/settings_folders.cpp
|
||||
@@ -1449,6 +1476,8 @@ PRIVATE
|
||||
ui/controls/silent_toggle.h
|
||||
ui/controls/userpic_button.cpp
|
||||
ui/controls/userpic_button.h
|
||||
ui/effects/credits_graphics.cpp
|
||||
ui/effects/credits_graphics.h
|
||||
ui/effects/emoji_fly_animation.cpp
|
||||
ui/effects/emoji_fly_animation.h
|
||||
ui/effects/message_sending_animation_common.h
|
||||
@@ -1496,6 +1525,8 @@ PRIVATE
|
||||
window/section_widget.h
|
||||
window/window_adaptive.cpp
|
||||
window/window_adaptive.h
|
||||
window/window_chat_preview.cpp
|
||||
window/window_chat_preview.h
|
||||
window/window_connecting_widget.cpp
|
||||
window/window_connecting_widget.h
|
||||
window/window_controller.cpp
|
||||
@@ -1515,6 +1546,8 @@ PRIVATE
|
||||
window/window_peer_menu.cpp
|
||||
window/window_peer_menu.h
|
||||
window/window_section_common.h
|
||||
window/window_separate_id.cpp
|
||||
window/window_separate_id.h
|
||||
window/window_session_controller.cpp
|
||||
window/window_session_controller.h
|
||||
window/window_session_controller_link_info.h
|
||||
@@ -1804,12 +1837,44 @@ if (WIN32)
|
||||
/DELAYLOAD:uxtheme.dll
|
||||
/DELAYLOAD:crypt32.dll
|
||||
/DELAYLOAD:bcrypt.dll
|
||||
/DELAYLOAD:imm32.dll
|
||||
/DELAYLOAD:netapi32.dll
|
||||
/DELAYLOAD:imm32.dll
|
||||
/DELAYLOAD:userenv.dll
|
||||
/DELAYLOAD:wtsapi32.dll
|
||||
/DELAYLOAD:propsys.dll
|
||||
)
|
||||
if (QT_VERSION GREATER 6)
|
||||
target_link_options(Telegram
|
||||
PRIVATE
|
||||
/DELAYLOAD:API-MS-Win-EventLog-Legacy-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Console-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Fibers-l2-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Fibers-l2-1-1.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-File-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-LibraryLoader-l1-2-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Localization-l1-2-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Memory-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Memory-l1-1-1.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-ProcessThreads-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Synch-l1-2-0.dll # Synchronization.lib
|
||||
/DELAYLOAD:API-MS-Win-Core-SysInfo-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-Timezone-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-WinRT-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-WinRT-Error-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Core-WinRT-String-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Security-CryptoAPI-l1-1-0.dll
|
||||
/DELAYLOAD:API-MS-Win-Shcore-Scaling-l1-1-1.dll
|
||||
/DELAYLOAD:authz.dll # Authz.lib
|
||||
/DELAYLOAD:comdlg32.dll
|
||||
/DELAYLOAD:dwrite.dll # DWrite.lib
|
||||
/DELAYLOAD:dxgi.dll # DXGI.lib
|
||||
/DELAYLOAD:d3d9.dll # D3D9.lib
|
||||
/DELAYLOAD:d3d11.dll # D3D11.lib
|
||||
/DELAYLOAD:d3d12.dll # D3D12.lib
|
||||
/DELAYLOAD:setupapi.dll # SetupAPI.lib
|
||||
/DELAYLOAD:winhttp.dll
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_prepare_qrc(Telegram)
|
||||
|
||||
BIN
Telegram/Resources/icons/menu/chats.png
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
Telegram/Resources/icons/menu/chats@2x.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
Telegram/Resources/icons/menu/chats@3x.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Telegram/Resources/icons/menu/factcheck.png
Normal file
|
After Width: | Height: | Size: 588 B |
BIN
Telegram/Resources/icons/menu/factcheck@2x.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Telegram/Resources/icons/menu/factcheck@3x.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
Telegram/Resources/icons/menu/passcode_finger.png
Normal file
|
After Width: | Height: | Size: 911 B |
BIN
Telegram/Resources/icons/menu/passcode_finger@2x.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
Telegram/Resources/icons/menu/passcode_finger@3x.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
Telegram/Resources/icons/menu/passcode_watch.png
Normal file
|
After Width: | Height: | Size: 438 B |
BIN
Telegram/Resources/icons/menu/passcode_watch@2x.png
Normal file
|
After Width: | Height: | Size: 631 B |
BIN
Telegram/Resources/icons/menu/passcode_watch@3x.png
Normal file
|
After Width: | Height: | Size: 886 B |
BIN
Telegram/Resources/icons/menu/passcode_winhello.png
Normal file
|
After Width: | Height: | Size: 454 B |
BIN
Telegram/Resources/icons/menu/passcode_winhello@2x.png
Normal file
|
After Width: | Height: | Size: 772 B |
BIN
Telegram/Resources/icons/menu/passcode_winhello@3x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/payments/small_star.png
Normal file
|
After Width: | Height: | Size: 484 B |
BIN
Telegram/Resources/icons/payments/small_star@2x.png
Normal file
|
After Width: | Height: | Size: 860 B |
BIN
Telegram/Resources/icons/payments/small_star@3x.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/settings/premium/effects.png
Normal file
|
After Width: | Height: | Size: 726 B |
BIN
Telegram/Resources/icons/settings/premium/effects@2x.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Telegram/Resources/icons/settings/premium/effects@3x.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
@@ -251,6 +251,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_caption_limit2#other" = "Make the caption shorter or subscribe to **Telegram Premium** to double the limit to **{count}** characters.";
|
||||
"lng_caption_limit_reached#one" = "You've reached the media caption limit. Please make the caption shorter by {count} character.";
|
||||
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
||||
"lng_caption_move_up" = "Move Caption Up";
|
||||
"lng_caption_move_down" = "Move Caption Down";
|
||||
|
||||
"lng_file_size_limit_title" = "File Too Large";
|
||||
"lng_file_size_limit#one" = "{count} Gb";
|
||||
@@ -302,6 +304,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_sure_ban_admin" = "This user is an admin. Are you sure you want to go ahead and restrict them?";
|
||||
"lng_sure_enable_socks" = "Are you sure you want to enable this proxy?\n\nServer: {server}\nPort: {port}\n\nYou can change your proxy server later in the Settings (Connection Type).";
|
||||
"lng_sure_enable" = "Enable";
|
||||
"lng_proxy_box_title" = "Enable proxy";
|
||||
"lng_proxy_box_server" = "Server";
|
||||
"lng_proxy_box_port" = "Port";
|
||||
"lng_proxy_box_secret" = "Secret";
|
||||
"lng_proxy_box_status" = "Status";
|
||||
"lng_proxy_box_username" = "Username";
|
||||
"lng_proxy_box_password" = "Password";
|
||||
"lng_proxy_invalid" = "The proxy link is invalid.";
|
||||
"lng_proxy_unsupported" = "Your Telegram Desktop version doesn't support this proxy type or the proxy link is invalid. Please update Telegram Desktop to the latest version.";
|
||||
|
||||
@@ -561,6 +570,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_reaction_invoice" = "{reaction} to your invoice";
|
||||
"lng_reaction_gif" = "{reaction} to your GIF";
|
||||
|
||||
"lng_effect_add_title" = "Add an animated effect";
|
||||
"lng_effect_stickers_title" = "Effects from stickers";
|
||||
"lng_effect_send" = "Send with Effect";
|
||||
"lng_effect_none" = "No effects found.";
|
||||
"lng_effect_premium" = "Subscribe to {link} to add this animated effect.";
|
||||
"lng_effect_premium_link" = "Telegram Premium";
|
||||
|
||||
"lng_languages" = "Languages";
|
||||
"lng_languages_none" = "No languages found.";
|
||||
"lng_languages_count#one" = "{count} language";
|
||||
@@ -667,6 +683,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_privacy_premium_link" = "Telegram Premium";
|
||||
"lng_settings_passcode_disable" = "Disable Passcode";
|
||||
"lng_settings_passcode_disable_sure" = "Are you sure you want to disable passcode?";
|
||||
"lng_settings_use_winhello" = "Unlock with Windows Hello";
|
||||
"lng_settings_use_winhello_about" = "You need to enter your passcode once before unlocking Telegram with Windows Hello.";
|
||||
"lng_settings_use_touchid" = "Unlock with Touch ID";
|
||||
"lng_settings_use_touchid_about" = "You need to enter your passcode once before unlocking Telegram with Touch ID.";
|
||||
"lng_settings_use_applewatch" = "Unlock with Apple Watch";
|
||||
"lng_settings_use_applewatch_about" = "You need to enter your passcode once before unlocking Telegram with Apple Watch.";
|
||||
"lng_settings_use_systempwd" = "Unlock with System Password";
|
||||
"lng_settings_use_systempwd_about" = "You need to enter your passcode once before unlocking Telegram with System Password.";
|
||||
"lng_settings_password_disable" = "Disable Cloud Password";
|
||||
"lng_settings_password_abort" = "Abort two-step verification setup";
|
||||
"lng_settings_about_bio" = "Any details such as age, occupation or city.\nExample: 23 y.o. designer from San Francisco";
|
||||
@@ -769,6 +793,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_power_chat" = "Animations in Chats";
|
||||
"lng_settings_power_chat_background" = "Background rotation";
|
||||
"lng_settings_power_chat_spoiler" = "Animated spoiler effect";
|
||||
"lng_settings_power_chat_effects" = "Effects in messages";
|
||||
"lng_settings_power_calls" = "Animations in Calls";
|
||||
"lng_settings_power_ui" = "Interface animations";
|
||||
"lng_settings_power_auto" = "Save Power on Low Battery";
|
||||
@@ -880,6 +905,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_gift_premium_users_confirm" = "Proceed";
|
||||
"lng_settings_gift_premium_users_error#one" = "You can select maximum {count} user.";
|
||||
"lng_settings_gift_premium_users_error#other" = "You can select maximum {count} users.";
|
||||
"lng_settings_gift_premium_choose" = "Please choose at least one recipient.";
|
||||
|
||||
"lng_backgrounds_header" = "Choose Wallpaper";
|
||||
"lng_theme_sure_keep" = "Keep this theme?";
|
||||
@@ -974,6 +1000,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_passcode_ph" = "Your passcode";
|
||||
"lng_passcode_submit" = "Submit";
|
||||
"lng_passcode_logout" = "Log out";
|
||||
"lng_passcode_winhello" = "You need to enter your passcode\nbefore you can use Windows Hello.";
|
||||
"lng_passcode_touchid" = "You need to enter your passcode\nbefore you can use Touch ID.";
|
||||
"lng_passcode_applewatch" = "You need to enter your passcode\nbefore you can use Watch to unlock.";
|
||||
"lng_passcode_systempwd" = "You need to enter your passcode\nbefore you can use system password.";
|
||||
"lng_passcode_winhello_unlock" = "Telegram wants to unlock with Windows Hello.";
|
||||
"lng_passcode_touchid_unlock" = "unlock";
|
||||
"lng_passcode_create_button" = "Save Passcode";
|
||||
"lng_passcode_check_button" = "Submit";
|
||||
"lng_passcode_change_button" = "Save Passcode";
|
||||
@@ -1053,6 +1085,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_proxy_sponsor" = "Proxy sponsor";
|
||||
"lng_proxy_sponsor_about" = "This channel is shown by your proxy server.\nTo remove this channel from your chats list,\ndisable the proxy in Telegram Settings.";
|
||||
"lng_proxy_sponsor_warning" = "This proxy may display a sponsored channel in your chat list. This doesn't reveal any of your Telegram traffic.";
|
||||
"lng_proxy_add_from_clipboard" = "Add proxy from clipboard";
|
||||
"lng_proxy_add_from_clipboard_good_toast" = "Proxy was added from clipboard.";
|
||||
"lng_proxy_add_from_clipboard_failed_toast" = "This is not a proxy link.";
|
||||
"lng_proxy_add_from_clipboard_existing_toast" = "This proxy is already in the list.";
|
||||
"lng_badge_psa_default" = "PSA";
|
||||
"lng_about_psa_default" = "This message provides you with a public service announcement. To remove it from your chats list, right click it and select **Hide**.";
|
||||
"lng_tooltip_psa_default" = "This message provides you with a public service announcement.";
|
||||
@@ -1522,8 +1558,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_manage_peer_link_invite" = "Invite link";
|
||||
"lng_manage_peer_link_expired" = "Expired link";
|
||||
"lng_manage_private_group_title" = "Private";
|
||||
"lng_manage_private_group_noforwards_title" = "Private restricted";
|
||||
"lng_manage_public_group_title" = "Public";
|
||||
"lng_manage_private_peer_title" = "Private";
|
||||
"lng_manage_private_peer_noforwards_title" = "Private restricted";
|
||||
"lng_manage_public_peer_title" = "Public";
|
||||
"lng_manage_peer_send_title" = "Who can send new messages?";
|
||||
"lng_manage_peer_send_only_members" = "Only members";
|
||||
@@ -1537,6 +1575,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_manage_peer_bot_public_link" = "Public Link";
|
||||
"lng_manage_peer_bot_public_links" = "Public Links";
|
||||
"lng_manage_peer_bot_balance" = "Balance";
|
||||
"lng_manage_peer_bot_edit_intro" = "Edit Intro";
|
||||
"lng_manage_peer_bot_edit_commands" = "Edit Commands";
|
||||
"lng_manage_peer_bot_edit_settings" = "Change Bot Settings";
|
||||
@@ -2162,6 +2201,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_premium_summary_about_translation" = "Real-time translation of channels and chats into other languages.";
|
||||
"lng_premium_summary_subtitle_business" = "Telegram Business";
|
||||
"lng_premium_summary_about_business" = "Upgrade your account with business features such as location, opening hours and quick replies.";
|
||||
"lng_premium_summary_subtitle_effects" = "Message Effects";
|
||||
"lng_premium_summary_about_effects" = "Add over 500 animated effects to private messages.";
|
||||
"lng_premium_summary_bottom_subtitle" = "About Telegram Premium";
|
||||
"lng_premium_summary_bottom_about" = "While the free version of Telegram already gives its users more than any other messaging application, **Telegram Premium** pushes its capabilities even further.\n\n**Telegram Premium** is a paid option, because most Premium Features require additional expenses from Telegram to third parties such as data center providers and server manufacturers. Contributions from **Telegram Premium** users allow us to cover such costs and also help Telegram stay free for everyone.";
|
||||
"lng_premium_summary_button" = "Subscribe for {cost} per month";
|
||||
@@ -2285,6 +2326,59 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_business_about_sponsored_link" = "Telegram Ad Platform {emoji}";
|
||||
"lng_business_about_sponsored_url" = "https://ads.telegram.org";
|
||||
|
||||
"lng_credits_summary_title" = "Telegram Stars";
|
||||
"lng_credits_summary_about" = "Buy Stars to unlock content and services in miniapps on Telegram.";
|
||||
"lng_credits_summary_options_subtitle" = "Choose package";
|
||||
"lng_credits_summary_options_credits#one" = "{count} Star";
|
||||
"lng_credits_summary_options_credits#other" = "{count} Stars";
|
||||
"lng_credits_summary_options_more" = "More Options";
|
||||
"lng_credits_summary_options_about" = "By proceeding and purchasing Stars, you agree with the {link}.";
|
||||
"lng_credits_summary_options_about_link" = "Terms and Conditions";
|
||||
"lng_credits_summary_options_about_url" = "https://telegram.org/tos/stars";
|
||||
"lng_credits_summary_history_tab_full" = "All Transactions";
|
||||
"lng_credits_summary_history_tab_in" = "Incoming";
|
||||
"lng_credits_summary_history_tab_out" = "Outgoing";
|
||||
"lng_credits_summary_history_entry_inner_in" = "In-App Purchase";
|
||||
"lng_credits_summary_balance" = "Balance";
|
||||
"lng_credits_box_out_title" = "Confirm Your Purchase";
|
||||
"lng_credits_box_out_sure#one" = "Do you want to buy **\"{text}\"** in **{bot}** for **{count} Star**?";
|
||||
"lng_credits_box_out_sure#other" = "Do you want to buy **\"{text}\"** in **{bot}** for **{count} Stars**?";
|
||||
"lng_credits_box_out_media#one" = "Do you want to unlock {media} in {chat} for **{count} Star**?";
|
||||
"lng_credits_box_out_media#other" = "Do you want to unlock {media} in {chat} for **{count} Stars**?";
|
||||
"lng_credits_box_out_photo" = "a photo";
|
||||
"lng_credits_box_out_photos#one" = "{count} photo";
|
||||
"lng_credits_box_out_photos#other" = "{count} photos";
|
||||
"lng_credits_box_out_video" = "a video";
|
||||
"lng_credits_box_out_videos#one" = "{count} video";
|
||||
"lng_credits_box_out_videos#other" = "{count} videos";
|
||||
"lng_credits_box_out_both" = "{photo} and {video}";
|
||||
"lng_credits_box_out_confirm#one" = "Confirm and Pay {emoji} {count} Star";
|
||||
"lng_credits_box_out_confirm#other" = "Confirm and Pay {emoji} {count} Stars";
|
||||
"lng_credits_box_out_about" = "Review the {link} for Stars.";
|
||||
"lng_credits_media_done_title" = "Media Unlocked";
|
||||
"lng_credits_media_done_text#one" = "**{count} Star** transferred to {chat}.";
|
||||
"lng_credits_media_done_text#other" = "**{count} Stars** transferred to {chat}.";
|
||||
"lng_credits_summary_in_toast_title" = "Stars Acquired";
|
||||
"lng_credits_summary_in_toast_about#one" = "**{count}** Star added to your balance.";
|
||||
"lng_credits_summary_in_toast_about#other" = "**{count}** Stars added to your balance.";
|
||||
"lng_credits_box_history_entry_peer" = "Recipient";
|
||||
"lng_credits_box_history_entry_via" = "Via";
|
||||
"lng_credits_box_history_entry_play_market" = "Play Market";
|
||||
"lng_credits_box_history_entry_app_store" = "App Store";
|
||||
"lng_credits_box_history_entry_fragment" = "Fragment";
|
||||
"lng_credits_box_history_entry_ads" = "Ads Platform";
|
||||
"lng_credits_box_history_entry_id" = "Transaction ID";
|
||||
"lng_credits_box_history_entry_id_copied" = "Transaction ID copied to clipboard.";
|
||||
"lng_credits_box_history_entry_success_date" = "Transaction date";
|
||||
"lng_credits_box_history_entry_success_url" = "Transaction link";
|
||||
"lng_credits_box_history_entry_media" = "Media";
|
||||
"lng_credits_box_history_entry_about" = "You can dispute this transaction {link}.";
|
||||
"lng_credits_box_history_entry_about_link" = "here";
|
||||
"lng_credits_small_balance_title#one" = "{count} Star Needed";
|
||||
"lng_credits_small_balance_title#other" = "{count} Stars Needed";
|
||||
"lng_credits_small_balance_about" = "Buy **Stars** and use them on **{bot}** and other miniapps.";
|
||||
"lng_credits_purchase_blocked" = "Sorry, you can't purchase this item with Telegram Stars.";
|
||||
|
||||
"lng_location_title" = "Location";
|
||||
"lng_location_about" = "Display the location of your business on your account.";
|
||||
"lng_location_address" = "Enter Address";
|
||||
@@ -3177,6 +3271,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_context_reply_msg" = "Reply";
|
||||
"lng_context_quote_and_reply" = "Quote & Reply";
|
||||
"lng_context_edit_msg" = "Edit";
|
||||
"lng_context_add_factcheck" = "Add Fact Check";
|
||||
"lng_context_edit_factcheck" = "Edit Fact Check";
|
||||
"lng_context_forward_msg" = "Forward Message";
|
||||
"lng_context_send_now_msg" = "Send now";
|
||||
"lng_context_reschedule" = "Reschedule";
|
||||
@@ -3247,6 +3343,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_context_spoiler_effect" = "Hide with Spoiler";
|
||||
"lng_context_disable_spoiler" = "Remove Spoiler";
|
||||
"lng_context_make_paid" = "Make This Content Paid";
|
||||
"lng_context_change_price" = "Change Price";
|
||||
|
||||
"lng_factcheck_title" = "Fact Check";
|
||||
"lng_factcheck_placeholder" = "Add Facts or Context";
|
||||
"lng_factcheck_whats_this" = "what's this?";
|
||||
"lng_factcheck_about" = "This clarification was provided by a fact checking agency assigned by the department of the government of your country ({country}) responsible for combatting misinformation.";
|
||||
"lng_factcheck_add_done" = "Fact check added.";
|
||||
"lng_factcheck_edit_done" = "Fact check edited.";
|
||||
"lng_factcheck_remove_done" = "Fact check removed.";
|
||||
"lng_factcheck_bottom" = "This clarification was provided by a fact checking agency assigned by the department of the government of your country ({country}) responsible for combatting misinformation.";
|
||||
"lng_factcheck_links" = "Only **t.me/** links are allowed.";
|
||||
|
||||
"lng_paid_title" = "Paid Content";
|
||||
"lng_paid_enter_cost" = "Enter Unlock Cost";
|
||||
"lng_paid_cost_placeholder" = "Stars to Unlock";
|
||||
"lng_paid_about" = "Users will have to transfer this amount of Stars to your channel in order to view this media. {link}";
|
||||
"lng_paid_about_link" = "More about stars >";
|
||||
"lng_paid_about_link_url" = "https://telegram.org/blog/telegram-stars";
|
||||
"lng_paid_price" = "Unlock for {price}";
|
||||
|
||||
"lng_translate_show_original" = "Show Original";
|
||||
"lng_translate_bar_to" = "Translate to {name}";
|
||||
@@ -3368,6 +3484,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_add_contact" = "Create";
|
||||
"lng_add_contact_button" = "New contact";
|
||||
"lng_contacts_header" = "Contacts";
|
||||
"lng_menu_not_contact" = "This number is not on Telegram";
|
||||
"lng_contacts_hidden_stories" = "Hidden Stories";
|
||||
"lng_contacts_stories_status#one" = "{count} story";
|
||||
"lng_contacts_stories_status#other" = "{count} stories";
|
||||
@@ -3513,6 +3630,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_formatting_link_text" = "Text";
|
||||
"lng_formatting_link_url" = "URL";
|
||||
"lng_formatting_link_create" = "Create";
|
||||
"lng_formatting_code_title" = "Code Language";
|
||||
"lng_formatting_code_language" = "Language for syntax highlighting.";
|
||||
"lng_formatting_code_auto" = "Auto-Detect";
|
||||
|
||||
"lng_text_copied" = "Text copied to clipboard.";
|
||||
"lng_code_copied" = "Block copied to clipboard.";
|
||||
@@ -4063,6 +4183,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_restricted_send_polls_all" = "Posting polls isn't allowed in this group.";
|
||||
|
||||
"lng_restricted_send_public_polls" = "Sorry, public polls can't be forwarded to channels.";
|
||||
"lng_restricted_send_paid_media" = "Sorry, paid media can't be sent to this channel.";
|
||||
|
||||
"lng_restricted_send_voice_messages" = "{user} restricted sending of voice messages to them.";
|
||||
"lng_restricted_send_video_messages" = "{user} restricted sending of video messages to them.";
|
||||
@@ -5090,6 +5211,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_channel_earn_history_return" = "Refund";
|
||||
"lng_channel_earn_history_return_about" = "Refunded back";
|
||||
"lng_channel_earn_history_pending" = "Pending";
|
||||
"lng_channel_earn_history_failed" = "Failed";
|
||||
"lng_channel_earn_history_show_more#one" = "Show {count} More Transaction";
|
||||
"lng_channel_earn_history_show_more#other" = "Show {count} More Transactions";
|
||||
"lng_channel_earn_off" = "Switch Off Ads";
|
||||
@@ -5112,6 +5234,30 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_channel_earn_chart_revenue" = "Ad revenue";
|
||||
"lng_channel_earn_chart_overriden_detail_currency" = "Revenue in TON";
|
||||
"lng_channel_earn_chart_overriden_detail_usd" = "Revenue in USD";
|
||||
"lng_channel_earn_currency_history" = "TON Transactions";
|
||||
"lng_channel_earn_credits_history" = "Stars Transactions";
|
||||
"lng_channel_earn_out_check_password_about" = "You can withdraw only if you have:";
|
||||
|
||||
"lng_bot_earn_title" = "Stars Balance";
|
||||
"lng_bot_earn_chart_revenue" = "Revenue";
|
||||
"lng_bot_earn_overview_title" = "Proceeds overview";
|
||||
"lng_bot_earn_available" = "Available balance";
|
||||
"lng_bot_earn_total" = "Total lifetime proceeds";
|
||||
"lng_bot_earn_balance_title" = "Available balance";
|
||||
"lng_bot_earn_balance_about" = "Stars from your total balance become available for spending on ads and rewards 21 days after they are earned.";
|
||||
"lng_bot_earn_balance_about_url" = "https://telegram.org/tos/stars";
|
||||
"lng_bot_earn_balance_button#one" = "Withdraw {emoji} {count}";
|
||||
"lng_bot_earn_balance_button#other" = "Withdraw {emoji} {count}";
|
||||
"lng_bot_earn_balance_button_all" = "Withdraw all stars";
|
||||
"lng_bot_earn_balance_button_locked" = "Withdraw";
|
||||
"lng_bot_earn_balance_button_buy_ads" = "Buy Ads";
|
||||
"lng_bot_earn_learn_credits_out_about" = "You can withdraw Stars using Fragment, or use Stars to advertise your bot. {link}";
|
||||
"lng_bot_earn_out_ph" = "Enter amount to withdraw";
|
||||
"lng_bot_earn_balance_password_title" = "Two-step verification";
|
||||
"lng_bot_earn_balance_password_description" = "Please enter your password to collect.";
|
||||
"lng_bot_earn_credits_out_minimal" = "You cannot withdraw less then {link}.";
|
||||
"lng_bot_earn_credits_out_minimal_link#one" = "{count} star";
|
||||
"lng_bot_earn_credits_out_minimal_link#other" = "{count} stars";
|
||||
|
||||
"lng_contact_add" = "Add";
|
||||
"lng_contact_send_message" = "message";
|
||||
@@ -5161,6 +5307,32 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_font_system" = "System font";
|
||||
"lng_font_not_found" = "Font not found.";
|
||||
|
||||
"lng_search_tab_my_messages" = "My Messages";
|
||||
"lng_search_tab_this_topic" = "This Topic";
|
||||
"lng_search_tab_this_chat" = "This Chat";
|
||||
"lng_search_tab_this_channel" = "This Channel";
|
||||
"lng_search_tab_this_group" = "This Group";
|
||||
"lng_search_tab_public_posts" = "Public Posts";
|
||||
"lng_search_tab_no_results" = "No Results";
|
||||
"lng_search_tab_no_results_text" = "There were no results for \"{query}\".";
|
||||
"lng_search_tab_no_results_retry" = "Try another hashtag.";
|
||||
"lng_search_tab_by_hashtag" = "Enter a hashtag to find messages containing it.";
|
||||
|
||||
"lng_contact_details_button" = "View Contact";
|
||||
"lng_contact_details_title" = "Contact details";
|
||||
"lng_contact_details_phone" = "Phone";
|
||||
"lng_contact_details_phone_main" = "Main Phone";
|
||||
"lng_contact_details_phone_home" = "Home Phone";
|
||||
"lng_contact_details_phone_mobile" = "Mobile Phone";
|
||||
"lng_contact_details_phone_work" = "Work Phone";
|
||||
"lng_contact_details_phone_other" = "Other Phone";
|
||||
"lng_contact_details_email" = "Email";
|
||||
"lng_contact_details_address" = "Address";
|
||||
"lng_contact_details_url" = "URL";
|
||||
"lng_contact_details_note" = "Note";
|
||||
"lng_contact_details_birthday" = "Birthday";
|
||||
"lng_contact_details_organization" = "Organization";
|
||||
|
||||
// Wnd specific
|
||||
|
||||
"lng_wnd_choose_program_menu" = "Choose Default Program...";
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
|
||||
ProcessorArchitecture="ARCHITECTURE"
|
||||
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
|
||||
Version="5.0.3.0" />
|
||||
Version="5.2.1.0" />
|
||||
<Properties>
|
||||
<DisplayName>Telegram Desktop</DisplayName>
|
||||
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>
|
||||
|
||||
@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 5,0,3,0
|
||||
PRODUCTVERSION 5,0,3,0
|
||||
FILEVERSION 5,2,1,0
|
||||
PRODUCTVERSION 5,2,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -62,10 +62,10 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Telegram FZ-LLC"
|
||||
VALUE "FileDescription", "Telegram Desktop"
|
||||
VALUE "FileVersion", "5.0.3.0"
|
||||
VALUE "FileVersion", "5.2.1.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2024"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "5.0.3.0"
|
||||
VALUE "ProductVersion", "5.2.1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 5,0,3,0
|
||||
PRODUCTVERSION 5,0,3,0
|
||||
FILEVERSION 5,2,1,0
|
||||
PRODUCTVERSION 5,2,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -53,10 +53,10 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Telegram FZ-LLC"
|
||||
VALUE "FileDescription", "Telegram Desktop Updater"
|
||||
VALUE "FileVersion", "5.0.3.0"
|
||||
VALUE "FileVersion", "5.2.1.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2024"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "5.0.3.0"
|
||||
VALUE "ProductVersion", "5.2.1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history_item_components.h"
|
||||
#include "inline_bots/bot_attach_web_view.h"
|
||||
#include "payments/payments_checkout_process.h"
|
||||
#include "payments/payments_non_panel_process.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
@@ -335,7 +336,8 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
|
||||
Payments::Mode::Payment,
|
||||
crl::guard(controller, [=](auto) {
|
||||
controller->widget()->activate();
|
||||
}));
|
||||
}),
|
||||
Payments::ProcessNonPanelPaymentFormFactory(controller, item));
|
||||
} break;
|
||||
|
||||
case ButtonType::Url: {
|
||||
|
||||
@@ -20,11 +20,14 @@ namespace Api {
|
||||
inline constexpr auto kScheduledUntilOnlineTimestamp = TimeId(0x7FFFFFFE);
|
||||
|
||||
struct SendOptions {
|
||||
uint64 price = 0;
|
||||
PeerData *sendAs = nullptr;
|
||||
TimeId scheduled = 0;
|
||||
BusinessShortcutId shortcutId = 0;
|
||||
EffectId effectId = 0;
|
||||
bool silent = false;
|
||||
bool handleSupportSwitch = false;
|
||||
bool invertCaption = false;
|
||||
bool hideViaBot = false;
|
||||
crl::time ttlSeconds = 0;
|
||||
};
|
||||
|
||||
@@ -97,8 +97,10 @@ void ConfirmPhone::resolve(
|
||||
box->resendRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
_api.request(MTPauth_ResendCode(
|
||||
MTP_flags(0),
|
||||
MTP_string(phone),
|
||||
MTP_string(phoneHash)
|
||||
MTP_string(phoneHash),
|
||||
MTPstring() // reason
|
||||
)).done([=] {
|
||||
if (boxWeak) {
|
||||
boxWeak->callDone();
|
||||
|
||||
306
Telegram/SourceFiles/api/api_credits.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "api/api_credits.h"
|
||||
|
||||
#include "api/api_statistics_data_deserialize.h"
|
||||
#include "api/api_updates.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
constexpr auto kTransactionsLimit = 100;
|
||||
|
||||
[[nodiscard]] Data::CreditsHistoryEntry HistoryFromTL(
|
||||
const MTPStarsTransaction &tl,
|
||||
not_null<PeerData*> peer) {
|
||||
using HistoryPeerTL = MTPDstarsTransactionPeer;
|
||||
using namespace Data;
|
||||
const auto owner = &peer->owner();
|
||||
const auto photo = tl.data().vphoto()
|
||||
? owner->photoFromWeb(*tl.data().vphoto(), ImageLocation())
|
||||
: nullptr;
|
||||
auto extended = std::vector<CreditsHistoryMedia>();
|
||||
if (const auto list = tl.data().vextended_media()) {
|
||||
extended.reserve(list->v.size());
|
||||
for (const auto &media : list->v) {
|
||||
media.match([&](const MTPDmessageMediaPhoto &photo) {
|
||||
if (const auto inner = photo.vphoto()) {
|
||||
const auto photo = owner->processPhoto(*inner);
|
||||
if (!photo->isNull()) {
|
||||
extended.push_back(CreditsHistoryMedia{
|
||||
.type = CreditsHistoryMediaType::Photo,
|
||||
.id = photo->id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [&](const MTPDmessageMediaDocument &document) {
|
||||
if (const auto inner = document.vdocument()) {
|
||||
const auto document = owner->processDocument(*inner);
|
||||
if (document->isAnimation()
|
||||
|| document->isVideoFile()
|
||||
|| document->isGifv()) {
|
||||
extended.push_back(CreditsHistoryMedia{
|
||||
.type = CreditsHistoryMediaType::Video,
|
||||
.id = document->id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [&](const auto &) {});
|
||||
}
|
||||
}
|
||||
const auto barePeerId = tl.data().vpeer().match([](
|
||||
const HistoryPeerTL &p) {
|
||||
return peerFromMTP(p.vpeer());
|
||||
}, [](const auto &) {
|
||||
return PeerId(0);
|
||||
}).value;
|
||||
return Data::CreditsHistoryEntry{
|
||||
.id = qs(tl.data().vid()),
|
||||
.title = qs(tl.data().vtitle().value_or_empty()),
|
||||
.description = qs(tl.data().vdescription().value_or_empty()),
|
||||
.date = base::unixtime::parse(tl.data().vdate().v),
|
||||
.photoId = photo ? photo->id : 0,
|
||||
.extended = std::move(extended),
|
||||
.credits = tl.data().vstars().v,
|
||||
.bareMsgId = uint64(tl.data().vmsg_id().value_or_empty()),
|
||||
.barePeerId = barePeerId,
|
||||
.peerType = tl.data().vpeer().match([](const HistoryPeerTL &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::Peer;
|
||||
}, [](const MTPDstarsTransactionPeerPlayMarket &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::PlayMarket;
|
||||
}, [](const MTPDstarsTransactionPeerFragment &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::Fragment;
|
||||
}, [](const MTPDstarsTransactionPeerAppStore &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::AppStore;
|
||||
}, [](const MTPDstarsTransactionPeerUnsupported &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::Unsupported;
|
||||
}, [](const MTPDstarsTransactionPeerPremiumBot &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::PremiumBot;
|
||||
}, [](const MTPDstarsTransactionPeerAds &) {
|
||||
return Data::CreditsHistoryEntry::PeerType::Ads;
|
||||
}),
|
||||
.refunded = tl.data().is_refund(),
|
||||
.pending = tl.data().is_pending(),
|
||||
.failed = tl.data().is_failed(),
|
||||
.successDate = tl.data().vtransaction_date()
|
||||
? base::unixtime::parse(tl.data().vtransaction_date()->v)
|
||||
: QDateTime(),
|
||||
.successLink = qs(tl.data().vtransaction_url().value_or_empty()),
|
||||
.in = (int64(tl.data().vstars().v) >= 0),
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] Data::CreditsStatusSlice StatusFromTL(
|
||||
const MTPpayments_StarsStatus &status,
|
||||
not_null<PeerData*> peer) {
|
||||
peer->owner().processUsers(status.data().vusers());
|
||||
peer->owner().processChats(status.data().vchats());
|
||||
return Data::CreditsStatusSlice{
|
||||
.list = ranges::views::all(
|
||||
status.data().vhistory().v
|
||||
) | ranges::views::transform([&](const MTPStarsTransaction &tl) {
|
||||
return HistoryFromTL(tl, peer);
|
||||
}) | ranges::to_vector,
|
||||
.balance = status.data().vbalance().v,
|
||||
.allLoaded = !status.data().vnext_offset().has_value(),
|
||||
.token = qs(status.data().vnext_offset().value_or_empty()),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CreditsTopupOptions::CreditsTopupOptions(not_null<PeerData*> peer)
|
||||
: _peer(peer)
|
||||
, _api(&peer->session().api().instance()) {
|
||||
}
|
||||
|
||||
rpl::producer<rpl::no_value, QString> CreditsTopupOptions::request() {
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
|
||||
using TLOption = MTPStarsTopupOption;
|
||||
_api.request(MTPpayments_GetStarsTopupOptions(
|
||||
)).done([=](const MTPVector<TLOption> &result) {
|
||||
_options = ranges::views::all(
|
||||
result.v
|
||||
) | ranges::views::transform([](const TLOption &option) {
|
||||
return Data::CreditTopupOption{
|
||||
.credits = option.data().vstars().v,
|
||||
.product = qs(
|
||||
option.data().vstore_product().value_or_empty()),
|
||||
.currency = qs(option.data().vcurrency()),
|
||||
.amount = option.data().vamount().v,
|
||||
.extended = option.data().is_extended(),
|
||||
};
|
||||
}) | ranges::to_vector;
|
||||
consumer.put_done();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
consumer.put_error_copy(error.type());
|
||||
}).send();
|
||||
|
||||
return lifetime;
|
||||
};
|
||||
}
|
||||
|
||||
CreditsStatus::CreditsStatus(not_null<PeerData*> peer)
|
||||
: _peer(peer)
|
||||
, _api(&peer->session().api().instance()) {
|
||||
}
|
||||
|
||||
void CreditsStatus::request(
|
||||
const Data::CreditsStatusSlice::OffsetToken &token,
|
||||
Fn<void(Data::CreditsStatusSlice)> done) {
|
||||
if (_requestId) {
|
||||
return;
|
||||
}
|
||||
|
||||
using TLResult = MTPpayments_StarsStatus;
|
||||
|
||||
_requestId = _api.request(MTPpayments_GetStarsStatus(
|
||||
_peer->isSelf() ? MTP_inputPeerSelf() : _peer->input
|
||||
)).done([=](const TLResult &result) {
|
||||
_requestId = 0;
|
||||
done(StatusFromTL(result, _peer));
|
||||
}).fail([=] {
|
||||
_requestId = 0;
|
||||
done({});
|
||||
}).send();
|
||||
}
|
||||
|
||||
CreditsHistory::CreditsHistory(not_null<PeerData*> peer, bool in, bool out)
|
||||
: _peer(peer)
|
||||
, _flags((in == out)
|
||||
? HistoryTL::Flags(0)
|
||||
: HistoryTL::Flags(0)
|
||||
| (in ? HistoryTL::Flag::f_inbound : HistoryTL::Flags(0))
|
||||
| (out ? HistoryTL::Flag::f_outbound : HistoryTL::Flags(0)))
|
||||
, _api(&peer->session().api().instance()) {
|
||||
}
|
||||
|
||||
void CreditsHistory::request(
|
||||
const Data::CreditsStatusSlice::OffsetToken &token,
|
||||
Fn<void(Data::CreditsStatusSlice)> done) {
|
||||
if (_requestId) {
|
||||
return;
|
||||
}
|
||||
_requestId = _api.request(MTPpayments_GetStarsTransactions(
|
||||
MTP_flags(_flags),
|
||||
_peer->isSelf() ? MTP_inputPeerSelf() : _peer->input,
|
||||
MTP_string(token),
|
||||
MTP_int(kTransactionsLimit)
|
||||
)).done([=](const MTPpayments_StarsStatus &result) {
|
||||
_requestId = 0;
|
||||
done(StatusFromTL(result, _peer));
|
||||
}).fail([=] {
|
||||
_requestId = 0;
|
||||
done({});
|
||||
}).send();
|
||||
}
|
||||
|
||||
Data::CreditTopupOptions CreditsTopupOptions::options() const {
|
||||
return _options;
|
||||
}
|
||||
|
||||
rpl::producer<not_null<PeerData*>> PremiumPeerBot(
|
||||
not_null<Main::Session*> session) {
|
||||
const auto username = session->appConfig().get<QString>(
|
||||
u"premium_bot_username"_q,
|
||||
QString());
|
||||
if (username.isEmpty()) {
|
||||
return rpl::never<not_null<PeerData*>>();
|
||||
}
|
||||
if (const auto p = session->data().peerByUsername(username)) {
|
||||
return rpl::single<not_null<PeerData*>>(p);
|
||||
}
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
|
||||
const auto api = lifetime.make_state<MTP::Sender>(&session->mtp());
|
||||
|
||||
api->request(MTPcontacts_ResolveUsername(
|
||||
MTP_string(username)
|
||||
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||
session->data().processUsers(result.data().vusers());
|
||||
session->data().processChats(result.data().vchats());
|
||||
const auto botPeer = session->data().peerLoaded(
|
||||
peerFromMTP(result.data().vpeer()));
|
||||
if (!botPeer) {
|
||||
return consumer.put_done();
|
||||
}
|
||||
consumer.put_next(not_null{ botPeer });
|
||||
}).send();
|
||||
|
||||
return lifetime;
|
||||
};
|
||||
}
|
||||
|
||||
CreditsEarnStatistics::CreditsEarnStatistics(not_null<PeerData*> peer)
|
||||
: StatisticsRequestSender(peer)
|
||||
, _isUser(peer->isUser()) {
|
||||
}
|
||||
|
||||
rpl::producer<rpl::no_value, QString> CreditsEarnStatistics::request() {
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
|
||||
const auto finish = [=](const QString &url) {
|
||||
makeRequest(MTPpayments_GetStarsRevenueStats(
|
||||
MTP_flags(0),
|
||||
(_isUser ? user()->input : channel()->input)
|
||||
)).done([=](const MTPpayments_StarsRevenueStats &result) {
|
||||
const auto &data = result.data();
|
||||
const auto &status = data.vstatus().data();
|
||||
_data = Data::CreditsEarnStatistics{
|
||||
.revenueGraph = StatisticalGraphFromTL(
|
||||
data.vrevenue_graph()),
|
||||
.currentBalance = status.vcurrent_balance().v,
|
||||
.availableBalance = status.vavailable_balance().v,
|
||||
.overallRevenue = status.voverall_revenue().v,
|
||||
.usdRate = data.vusd_rate().v,
|
||||
.isWithdrawalEnabled = status.is_withdrawal_enabled(),
|
||||
.nextWithdrawalAt = status.vnext_withdrawal_at()
|
||||
? base::unixtime::parse(
|
||||
status.vnext_withdrawal_at()->v)
|
||||
: QDateTime(),
|
||||
.buyAdsUrl = url,
|
||||
};
|
||||
|
||||
consumer.put_done();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
consumer.put_error_copy(error.type());
|
||||
}).send();
|
||||
};
|
||||
|
||||
makeRequest(
|
||||
MTPpayments_GetStarsRevenueAdsAccountUrl(
|
||||
(_isUser ? user()->input : channel()->input))
|
||||
).done([=](const MTPpayments_StarsRevenueAdsAccountUrl &result) {
|
||||
finish(qs(result.data().vurl()));
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
finish({});
|
||||
}).send();
|
||||
|
||||
return lifetime;
|
||||
};
|
||||
}
|
||||
|
||||
Data::CreditsEarnStatistics CreditsEarnStatistics::data() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
93
Telegram/SourceFiles/api/api_credits.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "api/api_statistics_sender.h"
|
||||
#include "data/data_credits.h"
|
||||
#include "data/data_credits_earn.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
class UserData;
|
||||
|
||||
namespace Api {
|
||||
|
||||
class CreditsTopupOptions final {
|
||||
public:
|
||||
CreditsTopupOptions(not_null<PeerData*> peer);
|
||||
|
||||
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
||||
[[nodiscard]] Data::CreditTopupOptions options() const;
|
||||
|
||||
private:
|
||||
const not_null<PeerData*> _peer;
|
||||
|
||||
Data::CreditTopupOptions _options;
|
||||
|
||||
MTP::Sender _api;
|
||||
|
||||
};
|
||||
|
||||
class CreditsStatus final {
|
||||
public:
|
||||
CreditsStatus(not_null<PeerData*> peer);
|
||||
|
||||
void request(
|
||||
const Data::CreditsStatusSlice::OffsetToken &token,
|
||||
Fn<void(Data::CreditsStatusSlice)> done);
|
||||
|
||||
private:
|
||||
const not_null<PeerData*> _peer;
|
||||
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
MTP::Sender _api;
|
||||
|
||||
};
|
||||
|
||||
class CreditsHistory final {
|
||||
public:
|
||||
CreditsHistory(not_null<PeerData*> peer, bool in, bool out);
|
||||
|
||||
void request(
|
||||
const Data::CreditsStatusSlice::OffsetToken &token,
|
||||
Fn<void(Data::CreditsStatusSlice)> done);
|
||||
|
||||
private:
|
||||
using HistoryTL = MTPpayments_GetStarsTransactions;
|
||||
const not_null<PeerData*> _peer;
|
||||
const HistoryTL::Flags _flags;
|
||||
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
MTP::Sender _api;
|
||||
|
||||
};
|
||||
|
||||
class CreditsEarnStatistics final : public StatisticsRequestSender {
|
||||
public:
|
||||
explicit CreditsEarnStatistics(not_null<PeerData*>);
|
||||
|
||||
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
||||
[[nodiscard]] Data::CreditsEarnStatistics data() const;
|
||||
|
||||
private:
|
||||
Data::CreditsEarnStatistics _data;
|
||||
bool _isUser = false;
|
||||
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] rpl::producer<not_null<PeerData*>> PremiumPeerBot(
|
||||
not_null<Main::Session*> session);
|
||||
|
||||
} // namespace Api
|
||||
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "api/api_cloud_password.h"
|
||||
#include "apiwrap.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "boxes/passcode_box.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_session.h"
|
||||
@@ -34,22 +35,33 @@ void RestrictSponsored(
|
||||
}
|
||||
|
||||
void HandleWithdrawalButton(
|
||||
not_null<ChannelData*> channel,
|
||||
RewardReceiver receiver,
|
||||
not_null<Ui::RippleButton*> button,
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
Expects(receiver.currencyReceiver
|
||||
|| (receiver.creditsReceiver && receiver.creditsAmount));
|
||||
struct State {
|
||||
rpl::lifetime lifetime;
|
||||
bool loading = false;
|
||||
};
|
||||
|
||||
const auto channel = receiver.currencyReceiver;
|
||||
const auto peer = receiver.creditsReceiver;
|
||||
|
||||
const auto state = button->lifetime().make_state<State>();
|
||||
const auto session = &channel->session();
|
||||
const auto session = (channel ? &channel->session() : &peer->session());
|
||||
|
||||
using ChannelOutUrl = MTPstats_BroadcastRevenueWithdrawalUrl;
|
||||
using CreditsOutUrl = MTPpayments_StarsRevenueWithdrawalUrl;
|
||||
|
||||
session->api().cloudPassword().reload();
|
||||
button->setClickedCallback([=] {
|
||||
const auto processOut = [=] {
|
||||
if (state->loading) {
|
||||
return;
|
||||
}
|
||||
if (peer && !receiver.creditsAmount()) {
|
||||
return;
|
||||
}
|
||||
state->loading = true;
|
||||
state->lifetime = session->api().cloudPassword().state(
|
||||
) | rpl::take(
|
||||
@@ -58,10 +70,12 @@ void HandleWithdrawalButton(
|
||||
state->loading = false;
|
||||
|
||||
auto fields = PasscodeBox::CloudFields::From(pass);
|
||||
fields.customTitle
|
||||
= tr::lng_channel_earn_balance_password_title();
|
||||
fields.customDescription
|
||||
= tr::lng_channel_earn_balance_password_description(tr::now);
|
||||
fields.customTitle = channel
|
||||
? tr::lng_channel_earn_balance_password_title()
|
||||
: tr::lng_bot_earn_balance_password_title();
|
||||
fields.customDescription = channel
|
||||
? tr::lng_channel_earn_balance_password_description(tr::now)
|
||||
: tr::lng_bot_earn_balance_password_description(tr::now);
|
||||
fields.customSubmitButton = tr::lng_passcode_submit();
|
||||
fields.customCheckCallback = crl::guard(button, [=](
|
||||
const Core::CloudPasswordResult &result,
|
||||
@@ -74,22 +88,63 @@ void HandleWithdrawalButton(
|
||||
}
|
||||
}
|
||||
};
|
||||
const auto fail = [=](const QString &error) {
|
||||
show->showToast(error);
|
||||
const auto fail = [=](const MTP::Error &error) {
|
||||
show->showToast(error.type());
|
||||
};
|
||||
session->api().request(
|
||||
MTPstats_GetBroadcastRevenueWithdrawalUrl(
|
||||
channel->inputChannel,
|
||||
result.result
|
||||
)).done([=](const MTPstats_BroadcastRevenueWithdrawalUrl &r) {
|
||||
done(qs(r.data().vurl()));
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
fail(error.type());
|
||||
}).send();
|
||||
if (channel) {
|
||||
session->api().request(
|
||||
MTPstats_GetBroadcastRevenueWithdrawalUrl(
|
||||
channel->inputChannel,
|
||||
result.result
|
||||
)).done([=](const ChannelOutUrl &r) {
|
||||
done(qs(r.data().vurl()));
|
||||
}).fail(fail).send();
|
||||
} else if (peer) {
|
||||
session->api().request(
|
||||
MTPpayments_GetStarsRevenueWithdrawalUrl(
|
||||
peer->input,
|
||||
MTP_long(receiver.creditsAmount()),
|
||||
result.result
|
||||
)).done([=](const CreditsOutUrl &r) {
|
||||
done(qs(r.data().vurl()));
|
||||
}).fail(fail).send();
|
||||
}
|
||||
});
|
||||
show->show(Box<PasscodeBox>(session, fields));
|
||||
});
|
||||
|
||||
};
|
||||
button->setClickedCallback([=] {
|
||||
if (state->loading) {
|
||||
return;
|
||||
}
|
||||
const auto fail = [=](const MTP::Error &error) {
|
||||
auto box = PrePasswordErrorBox(
|
||||
error.type(),
|
||||
session,
|
||||
TextWithEntities{
|
||||
tr::lng_channel_earn_out_check_password_about(tr::now),
|
||||
});
|
||||
if (box) {
|
||||
show->show(std::move(box));
|
||||
state->loading = false;
|
||||
} else {
|
||||
processOut();
|
||||
}
|
||||
};
|
||||
if (channel) {
|
||||
session->api().request(
|
||||
MTPstats_GetBroadcastRevenueWithdrawalUrl(
|
||||
channel->inputChannel,
|
||||
MTP_inputCheckPasswordEmpty()
|
||||
)).fail(fail).send();
|
||||
} else if (peer) {
|
||||
session->api().request(
|
||||
MTPpayments_GetStarsRevenueWithdrawalUrl(
|
||||
peer->input,
|
||||
MTP_long(std::numeric_limits<int64_t>::max()),
|
||||
MTP_inputCheckPasswordEmpty()
|
||||
)).fail(fail).send();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,14 @@ void RestrictSponsored(
|
||||
bool restricted,
|
||||
Fn<void(QString)> failed);
|
||||
|
||||
struct RewardReceiver final {
|
||||
ChannelData *currencyReceiver = nullptr;
|
||||
PeerData *creditsReceiver = nullptr;
|
||||
Fn<uint64()> creditsAmount;
|
||||
};
|
||||
|
||||
void HandleWithdrawalButton(
|
||||
not_null<ChannelData*> channel,
|
||||
RewardReceiver receiver,
|
||||
not_null<Ui::RippleButton*> button,
|
||||
std::shared_ptr<Ui::Show> show);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_histories.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_web_page.h"
|
||||
#include "history/view/controls/history_view_compose_media_edit_manager.h"
|
||||
#include "history/history.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -81,7 +82,8 @@ mtpRequestId EditMessage(
|
||||
| ((!webpage.removed && !webpage.url.isEmpty())
|
||||
? MTPmessages_EditMessage::Flag::f_media
|
||||
: emptyFlag)
|
||||
| ((!webpage.removed && !webpage.url.isEmpty() && webpage.invert)
|
||||
| (((!webpage.removed && !webpage.url.isEmpty() && webpage.invert)
|
||||
|| options.invertCaption)
|
||||
? MTPmessages_EditMessage::Flag::f_invert_media
|
||||
: emptyFlag)
|
||||
| (!sentEntities.v.isEmpty()
|
||||
@@ -203,6 +205,7 @@ void RescheduleMessage(
|
||||
not_null<HistoryItem*> item,
|
||||
SendOptions options) {
|
||||
const auto empty = [] {};
|
||||
options.invertCaption = item->invertMedia();
|
||||
EditMessage(item, options, empty, empty);
|
||||
}
|
||||
|
||||
@@ -254,85 +257,85 @@ mtpRequestId EditTextMessage(
|
||||
SendOptions options,
|
||||
Fn<void(mtpRequestId requestId)> done,
|
||||
Fn<void(const QString &error, mtpRequestId requestId)> fail,
|
||||
std::optional<bool> spoilerMediaOverride) {
|
||||
if (spoilerMediaOverride) {
|
||||
const auto spoiler = *spoilerMediaOverride;
|
||||
if (const auto media = item->media()) {
|
||||
auto takeInputMedia = Fn<std::optional<MTPInputMedia>()>(nullptr);
|
||||
auto takeFileReference = Fn<QByteArray()>(nullptr);
|
||||
if (const auto photo = media->photo()) {
|
||||
using Flag = MTPDinputMediaPhoto::Flag;
|
||||
const auto flags = Flag()
|
||||
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
|
||||
| (spoiler ? Flag::f_spoiler : Flag());
|
||||
takeInputMedia = [=] {
|
||||
return MTP_inputMediaPhoto(
|
||||
MTP_flags(flags),
|
||||
photo->mtpInput(),
|
||||
MTP_int(media->ttlSeconds()));
|
||||
};
|
||||
takeFileReference = [=] { return photo->fileReference(); };
|
||||
} else if (const auto document = media->document()) {
|
||||
using Flag = MTPDinputMediaDocument::Flag;
|
||||
const auto flags = Flag()
|
||||
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
|
||||
| (spoiler ? Flag::f_spoiler : Flag());
|
||||
takeInputMedia = [=] {
|
||||
return MTP_inputMediaDocument(
|
||||
MTP_flags(flags),
|
||||
document->mtpInput(),
|
||||
MTP_int(media->ttlSeconds()),
|
||||
MTPstring()); // query
|
||||
};
|
||||
takeFileReference = [=] { return document->fileReference(); };
|
||||
}
|
||||
|
||||
const auto usedFileReference = takeFileReference
|
||||
? takeFileReference()
|
||||
: QByteArray();
|
||||
const auto origin = item->fullId();
|
||||
const auto api = &item->history()->session().api();
|
||||
const auto performRequest = [=](
|
||||
const auto &repeatRequest,
|
||||
mtpRequestId originalRequestId) -> mtpRequestId {
|
||||
const auto handleReference = [=](
|
||||
const QString &error,
|
||||
mtpRequestId requestId) {
|
||||
if (error.startsWith(u"FILE_REFERENCE_"_q)) {
|
||||
api->refreshFileReference(origin, [=](const auto &) {
|
||||
if (takeFileReference &&
|
||||
(takeFileReference() != usedFileReference)) {
|
||||
repeatRequest(
|
||||
repeatRequest,
|
||||
originalRequestId
|
||||
? originalRequestId
|
||||
: requestId);
|
||||
} else {
|
||||
fail(error, requestId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fail(error, requestId);
|
||||
}
|
||||
};
|
||||
const auto callback = [=](
|
||||
Fn<void()> applyUpdates,
|
||||
mtpRequestId requestId) {
|
||||
applyUpdates();
|
||||
done(originalRequestId ? originalRequestId : requestId);
|
||||
};
|
||||
const auto requestId = EditMessage(
|
||||
item,
|
||||
caption,
|
||||
webpage,
|
||||
options,
|
||||
callback,
|
||||
handleReference,
|
||||
takeInputMedia ? takeInputMedia() : std::nullopt);
|
||||
return originalRequestId ? originalRequestId : requestId;
|
||||
bool spoilered) {
|
||||
const auto media = item->media();
|
||||
if (media
|
||||
&& HistoryView::MediaEditManager::CanBeSpoilered(item)
|
||||
&& spoilered != media->hasSpoiler()) {
|
||||
auto takeInputMedia = Fn<std::optional<MTPInputMedia>()>(nullptr);
|
||||
auto takeFileReference = Fn<QByteArray()>(nullptr);
|
||||
if (const auto photo = media->photo()) {
|
||||
using Flag = MTPDinputMediaPhoto::Flag;
|
||||
const auto flags = Flag()
|
||||
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
|
||||
| (spoilered ? Flag::f_spoiler : Flag());
|
||||
takeInputMedia = [=] {
|
||||
return MTP_inputMediaPhoto(
|
||||
MTP_flags(flags),
|
||||
photo->mtpInput(),
|
||||
MTP_int(media->ttlSeconds()));
|
||||
};
|
||||
return performRequest(performRequest, 0);
|
||||
takeFileReference = [=] { return photo->fileReference(); };
|
||||
} else if (const auto document = media->document()) {
|
||||
using Flag = MTPDinputMediaDocument::Flag;
|
||||
const auto flags = Flag()
|
||||
| (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag())
|
||||
| (spoilered ? Flag::f_spoiler : Flag());
|
||||
takeInputMedia = [=] {
|
||||
return MTP_inputMediaDocument(
|
||||
MTP_flags(flags),
|
||||
document->mtpInput(),
|
||||
MTP_int(media->ttlSeconds()),
|
||||
MTPstring()); // query
|
||||
};
|
||||
takeFileReference = [=] { return document->fileReference(); };
|
||||
}
|
||||
|
||||
const auto usedFileReference = takeFileReference
|
||||
? takeFileReference()
|
||||
: QByteArray();
|
||||
const auto origin = item->fullId();
|
||||
const auto api = &item->history()->session().api();
|
||||
const auto performRequest = [=](
|
||||
const auto &repeatRequest,
|
||||
mtpRequestId originalRequestId) -> mtpRequestId {
|
||||
const auto handleReference = [=](
|
||||
const QString &error,
|
||||
mtpRequestId requestId) {
|
||||
if (error.startsWith(u"FILE_REFERENCE_"_q)) {
|
||||
api->refreshFileReference(origin, [=](const auto &) {
|
||||
if (takeFileReference &&
|
||||
(takeFileReference() != usedFileReference)) {
|
||||
repeatRequest(
|
||||
repeatRequest,
|
||||
originalRequestId
|
||||
? originalRequestId
|
||||
: requestId);
|
||||
} else {
|
||||
fail(error, requestId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fail(error, requestId);
|
||||
}
|
||||
};
|
||||
const auto callback = [=](
|
||||
Fn<void()> applyUpdates,
|
||||
mtpRequestId requestId) {
|
||||
applyUpdates();
|
||||
done(originalRequestId ? originalRequestId : requestId);
|
||||
};
|
||||
const auto requestId = EditMessage(
|
||||
item,
|
||||
caption,
|
||||
webpage,
|
||||
options,
|
||||
callback,
|
||||
handleReference,
|
||||
takeInputMedia ? takeInputMedia() : std::nullopt);
|
||||
return originalRequestId ? originalRequestId : requestId;
|
||||
};
|
||||
return performRequest(performRequest, 0);
|
||||
}
|
||||
|
||||
const auto callback = [=](Fn<void()> applyUpdates, mtpRequestId id) {
|
||||
|
||||
@@ -56,6 +56,6 @@ mtpRequestId EditTextMessage(
|
||||
SendOptions options,
|
||||
Fn<void(mtpRequestId requestId)> done,
|
||||
Fn<void(const QString &error, mtpRequestId requestId)> fail,
|
||||
std::optional<bool> spoilerMediaOverride);
|
||||
bool spoilered);
|
||||
|
||||
} // namespace Api
|
||||
|
||||
27
Telegram/SourceFiles/api/api_filter_updates.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Api {
|
||||
|
||||
template <typename Type>
|
||||
void PerformForUpdate(
|
||||
const MTPUpdates &updates,
|
||||
Fn<void(const Type &)> callback) {
|
||||
updates.match([&](const MTPDupdates &updates) {
|
||||
for (const auto &update : updates.vupdates().v) {
|
||||
update.match([&](const Type &d) {
|
||||
callback(d);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
@@ -68,6 +68,9 @@ void Polls::create(
|
||||
if (action.options.shortcutId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut;
|
||||
}
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
const auto sendAs = action.options.sendAs;
|
||||
if (sendAs) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||
@@ -89,7 +92,8 @@ void Polls::create(
|
||||
MTPVector<MTPMessageEntity>(),
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, action.options.shortcutId)
|
||||
Data::ShortcutIdToMTP(_session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (clearCloudDraft) {
|
||||
history->finishSavingCloudDraft(
|
||||
|
||||
@@ -133,6 +133,13 @@ void SendExistingMedia(
|
||||
flags |= MessageFlag::ShortcutMessage;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut;
|
||||
}
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
}
|
||||
|
||||
session->data().registerMessageRandomId(randomId, newId);
|
||||
|
||||
@@ -144,6 +151,7 @@ void SendExistingMedia(
|
||||
.date = HistoryItem::NewMessageDate(action.options),
|
||||
.shortcutId = action.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
.effectId = action.options.effectId,
|
||||
}, media, caption);
|
||||
|
||||
const auto performRequest = [=](const auto &repeatRequest) -> void {
|
||||
@@ -165,7 +173,8 @@ void SendExistingMedia(
|
||||
sentEntities,
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId)
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
if (error.code() == 400
|
||||
@@ -306,6 +315,13 @@ bool SendDice(MessageToSend &message) {
|
||||
flags |= MessageFlag::ShortcutMessage;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut;
|
||||
}
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
if (action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
}
|
||||
|
||||
session->data().registerMessageRandomId(randomId, newId);
|
||||
|
||||
@@ -317,6 +333,7 @@ bool SendDice(MessageToSend &message) {
|
||||
.date = HistoryItem::NewMessageDate(action.options),
|
||||
.shortcutId = action.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
.effectId = action.options.effectId,
|
||||
}, TextWithEntities(), MTP_messageMediaDice(
|
||||
MTP_int(0),
|
||||
MTP_string(emoji)));
|
||||
@@ -335,7 +352,8 @@ bool SendDice(MessageToSend &message) {
|
||||
MTP_vector<MTPMessageEntity>(),
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId)
|
||||
Data::ShortcutIdToMTP(session, action.options.shortcutId),
|
||||
MTP_long(action.options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
api->sendMessageFail(error, peer, randomId, newId);
|
||||
@@ -430,6 +448,9 @@ void SendConfirmedFile(
|
||||
flags |= MessageFlag::MediaIsUnread;
|
||||
}
|
||||
}
|
||||
if (file->to.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
}
|
||||
|
||||
const auto messageFromId = file->to.options.sendAs
|
||||
? file->to.options.sendAs->id
|
||||
@@ -493,6 +514,7 @@ void SendConfirmedFile(
|
||||
edition.ttl = 0;
|
||||
edition.mtpMedia = &media;
|
||||
edition.textWithEntities = caption;
|
||||
edition.invertMedia = file->to.options.invertCaption;
|
||||
edition.useSameViews = true;
|
||||
edition.useSameForwards = true;
|
||||
edition.useSameMarkup = true;
|
||||
@@ -510,6 +532,7 @@ void SendConfirmedFile(
|
||||
.shortcutId = file->to.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
.groupedId = groupId,
|
||||
.effectId = file->to.options.effectId,
|
||||
}, caption, media);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "api/api_statistics.h"
|
||||
|
||||
#include "api/api_statistics_data_deserialize.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "data/data_channel.h"
|
||||
@@ -15,33 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_story.h"
|
||||
#include "history/history.h"
|
||||
#include "main/main_session.h"
|
||||
#include "statistics/statistics_data_deserialize.h"
|
||||
|
||||
namespace Api {
|
||||
namespace {
|
||||
|
||||
constexpr auto kCheckRequestsTimer = 10 * crl::time(1000);
|
||||
|
||||
[[nodiscard]] Data::StatisticalGraph StatisticalGraphFromTL(
|
||||
const MTPStatsGraph &tl) {
|
||||
return tl.match([&](const MTPDstatsGraph &d) {
|
||||
using namespace Statistic;
|
||||
const auto zoomToken = d.vzoom_token().has_value()
|
||||
? qs(*d.vzoom_token()).toUtf8()
|
||||
: QByteArray();
|
||||
return Data::StatisticalGraph{
|
||||
StatisticalChartFromJSON(qs(d.vjson().data().vdata()).toUtf8()),
|
||||
zoomToken,
|
||||
};
|
||||
}, [&](const MTPDstatsGraphAsync &data) {
|
||||
return Data::StatisticalGraph{
|
||||
.zoomToken = qs(data.vtoken()).toUtf8(),
|
||||
};
|
||||
}, [&](const MTPDstatsGraphError &data) {
|
||||
return Data::StatisticalGraph{ .error = qs(data.verror()) };
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] Data::StatisticalValue StatisticalValueFromTL(
|
||||
const MTPStatsAbsValueAndPrev &tl) {
|
||||
const auto current = tl.data().vcurrent().v;
|
||||
@@ -223,61 +201,6 @@ Statistics::Statistics(not_null<ChannelData*> channel)
|
||||
: StatisticsRequestSender(channel) {
|
||||
}
|
||||
|
||||
StatisticsRequestSender::StatisticsRequestSender(not_null<ChannelData *> channel)
|
||||
: _channel(channel)
|
||||
, _api(&_channel->session().api().instance())
|
||||
, _timer([=] { checkRequests(); }) {
|
||||
}
|
||||
|
||||
StatisticsRequestSender::~StatisticsRequestSender() {
|
||||
for (const auto &[dcId, ids] : _requests) {
|
||||
for (const auto id : ids) {
|
||||
_channel->session().api().unregisterStatsRequest(dcId, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatisticsRequestSender::checkRequests() {
|
||||
for (auto i = begin(_requests); i != end(_requests);) {
|
||||
for (auto j = begin(i->second); j != end(i->second);) {
|
||||
if (_api.pending(*j)) {
|
||||
++j;
|
||||
} else {
|
||||
_channel->session().api().unregisterStatsRequest(
|
||||
i->first,
|
||||
*j);
|
||||
j = i->second.erase(j);
|
||||
}
|
||||
}
|
||||
if (i->second.empty()) {
|
||||
i = _requests.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (_requests.empty()) {
|
||||
_timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Request, typename, typename>
|
||||
auto StatisticsRequestSender::makeRequest(Request &&request) {
|
||||
const auto id = _api.allocateRequestId();
|
||||
const auto dcId = _channel->owner().statsDcId(_channel);
|
||||
if (dcId) {
|
||||
_channel->session().api().registerStatsRequest(dcId, id);
|
||||
_requests[dcId].emplace(id);
|
||||
if (!_timer.isActive()) {
|
||||
_timer.callEach(kCheckRequestsTimer);
|
||||
}
|
||||
}
|
||||
return std::move(_api.request(
|
||||
std::forward<Request>(request)
|
||||
).toDC(
|
||||
dcId ? MTP::ShiftDcId(dcId, MTP::kStatsDcShift) : 0
|
||||
).overrideId(id));
|
||||
}
|
||||
|
||||
rpl::producer<rpl::no_value, QString> Statistics::request() {
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
@@ -747,11 +670,11 @@ Data::BoostStatus Boosts::boostStatus() const {
|
||||
return _boostStatus;
|
||||
}
|
||||
|
||||
EarnStatistics::EarnStatistics(not_null<ChannelData*> channel)
|
||||
ChannelEarnStatistics::ChannelEarnStatistics(not_null<ChannelData*> channel)
|
||||
: StatisticsRequestSender(channel) {
|
||||
}
|
||||
|
||||
rpl::producer<rpl::no_value, QString> EarnStatistics::request() {
|
||||
rpl::producer<rpl::no_value, QString> ChannelEarnStatistics::request() {
|
||||
return [=](auto consumer) {
|
||||
auto lifetime = rpl::lifetime();
|
||||
|
||||
@@ -795,7 +718,7 @@ rpl::producer<rpl::no_value, QString> EarnStatistics::request() {
|
||||
};
|
||||
}
|
||||
|
||||
void EarnStatistics::requestHistory(
|
||||
void ChannelEarnStatistics::requestHistory(
|
||||
const Data::EarnHistorySlice::OffsetToken &token,
|
||||
Fn<void(Data::EarnHistorySlice)> done) {
|
||||
if (_requestId) {
|
||||
@@ -865,7 +788,7 @@ void EarnStatistics::requestHistory(
|
||||
}).send();
|
||||
}
|
||||
|
||||
Data::EarnStatistics EarnStatistics::data() const {
|
||||
Data::EarnStatistics ChannelEarnStatistics::data() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,45 +7,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "api/api_statistics_sender.h"
|
||||
#include "data/data_boosts.h"
|
||||
#include "data/data_channel_earn.h"
|
||||
#include "data/data_statistics.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
class ChannelData;
|
||||
class PeerData;
|
||||
|
||||
namespace Api {
|
||||
|
||||
class StatisticsRequestSender {
|
||||
protected:
|
||||
explicit StatisticsRequestSender(not_null<ChannelData*> channel);
|
||||
~StatisticsRequestSender();
|
||||
|
||||
template <
|
||||
typename Request,
|
||||
typename = std::enable_if_t<!std::is_reference_v<Request>>,
|
||||
typename = typename Request::Unboxed>
|
||||
[[nodiscard]] auto makeRequest(Request &&request);
|
||||
|
||||
[[nodiscard]] MTP::Sender &api() {
|
||||
return _api;
|
||||
}
|
||||
[[nodiscard]] not_null<ChannelData*> channel() {
|
||||
return _channel;
|
||||
}
|
||||
|
||||
private:
|
||||
void checkRequests();
|
||||
|
||||
const not_null<ChannelData*> _channel;
|
||||
MTP::Sender _api;
|
||||
base::Timer _timer;
|
||||
base::flat_map<MTP::DcId, base::flat_set<mtpRequestId>> _requests;
|
||||
|
||||
};
|
||||
|
||||
class Statistics final : public StatisticsRequestSender {
|
||||
public:
|
||||
explicit Statistics(not_null<ChannelData*> channel);
|
||||
@@ -108,9 +79,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class EarnStatistics final : public StatisticsRequestSender {
|
||||
class ChannelEarnStatistics final : public StatisticsRequestSender {
|
||||
public:
|
||||
explicit EarnStatistics(not_null<ChannelData*> channel);
|
||||
explicit ChannelEarnStatistics(not_null<ChannelData*> channel);
|
||||
|
||||
[[nodiscard]] rpl::producer<rpl::no_value, QString> request();
|
||||
void requestHistory(
|
||||
|
||||
35
Telegram/SourceFiles/api/api_statistics_data_deserialize.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "api/api_statistics_data_deserialize.h"
|
||||
|
||||
#include "data/data_statistics_chart.h"
|
||||
#include "statistics/statistics_data_deserialize.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
Data::StatisticalGraph StatisticalGraphFromTL(const MTPStatsGraph &tl) {
|
||||
return tl.match([&](const MTPDstatsGraph &d) {
|
||||
using namespace Statistic;
|
||||
const auto zoomToken = d.vzoom_token().has_value()
|
||||
? qs(*d.vzoom_token()).toUtf8()
|
||||
: QByteArray();
|
||||
return Data::StatisticalGraph{
|
||||
StatisticalChartFromJSON(qs(d.vjson().data().vdata()).toUtf8()),
|
||||
zoomToken,
|
||||
};
|
||||
}, [&](const MTPDstatsGraphAsync &data) {
|
||||
return Data::StatisticalGraph{
|
||||
.zoomToken = qs(data.vtoken()).toUtf8(),
|
||||
};
|
||||
}, [&](const MTPDstatsGraphError &data) {
|
||||
return Data::StatisticalGraph{ .error = qs(data.verror()) };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
} // namespace Api
|
||||
19
Telegram/SourceFiles/api/api_statistics_data_deserialize.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Data {
|
||||
struct StatisticalGraph;
|
||||
} // namespace Data
|
||||
|
||||
namespace Api {
|
||||
|
||||
[[nodiscard]] Data::StatisticalGraph StatisticalGraphFromTL(
|
||||
const MTPStatsGraph &tl);
|
||||
|
||||
} // namespace Api
|
||||
86
Telegram/SourceFiles/api/api_statistics_sender.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "api/api_statistics_sender.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
StatisticsRequestSender::StatisticsRequestSender(
|
||||
not_null<PeerData*> peer)
|
||||
: _peer(peer)
|
||||
, _channel(peer->asChannel())
|
||||
, _user(peer->asUser())
|
||||
, _api(&_peer->session().api().instance())
|
||||
, _timer([=] { checkRequests(); }) {
|
||||
}
|
||||
|
||||
MTP::Sender &StatisticsRequestSender::api() {
|
||||
return _api;
|
||||
}
|
||||
|
||||
not_null<ChannelData*> StatisticsRequestSender::channel() {
|
||||
Expects(_channel);
|
||||
return _channel;
|
||||
}
|
||||
|
||||
not_null<UserData*> StatisticsRequestSender::user() {
|
||||
Expects(_user);
|
||||
return _user;
|
||||
}
|
||||
|
||||
void StatisticsRequestSender::checkRequests() {
|
||||
for (auto i = begin(_requests); i != end(_requests);) {
|
||||
for (auto j = begin(i->second); j != end(i->second);) {
|
||||
if (_api.pending(*j)) {
|
||||
++j;
|
||||
} else {
|
||||
_peer->session().api().unregisterStatsRequest(
|
||||
i->first,
|
||||
*j);
|
||||
j = i->second.erase(j);
|
||||
}
|
||||
}
|
||||
if (i->second.empty()) {
|
||||
i = _requests.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (_requests.empty()) {
|
||||
_timer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
auto StatisticsRequestSender::ensureRequestIsRegistered()
|
||||
-> StatisticsRequestSender::Registered {
|
||||
const auto id = _api.allocateRequestId();
|
||||
const auto dcId = _peer->owner().statsDcId(_peer);
|
||||
if (dcId) {
|
||||
_peer->session().api().registerStatsRequest(dcId, id);
|
||||
_requests[dcId].emplace(id);
|
||||
if (!_timer.isActive()) {
|
||||
constexpr auto kCheckRequestsTimer = 10 * crl::time(1000);
|
||||
_timer.callEach(kCheckRequestsTimer);
|
||||
}
|
||||
}
|
||||
return StatisticsRequestSender::Registered{ id, dcId };
|
||||
}
|
||||
|
||||
StatisticsRequestSender::~StatisticsRequestSender() {
|
||||
for (const auto &[dcId, ids] : _requests) {
|
||||
for (const auto id : ids) {
|
||||
_peer->session().api().unregisterStatsRequest(dcId, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
58
Telegram/SourceFiles/api/api_statistics_sender.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
class ChannelData;
|
||||
class PeerData;
|
||||
class UserData;
|
||||
|
||||
namespace Api {
|
||||
|
||||
class StatisticsRequestSender {
|
||||
protected:
|
||||
explicit StatisticsRequestSender(not_null<PeerData*> peer);
|
||||
~StatisticsRequestSender();
|
||||
|
||||
template <
|
||||
typename Request,
|
||||
typename = std::enable_if_t<!std::is_reference_v<Request>>,
|
||||
typename = typename Request::Unboxed>
|
||||
[[nodiscard]] auto makeRequest(Request &&request) {
|
||||
const auto [id, dcId] = ensureRequestIsRegistered();
|
||||
return std::move(_api.request(
|
||||
std::forward<Request>(request)
|
||||
).toDC(
|
||||
dcId ? MTP::ShiftDcId(dcId, MTP::kStatsDcShift) : 0
|
||||
).overrideId(id));
|
||||
}
|
||||
|
||||
[[nodiscard]] MTP::Sender &api();
|
||||
[[nodiscard]] not_null<ChannelData*> channel();
|
||||
[[nodiscard]] not_null<UserData*> user();
|
||||
|
||||
private:
|
||||
struct Registered final {
|
||||
mtpRequestId id;
|
||||
MTP::DcId dcId;
|
||||
};
|
||||
[[nodiscard]] Registered ensureRequestIsRegistered();
|
||||
void checkRequests();
|
||||
|
||||
const not_null<PeerData*> _peer;
|
||||
ChannelData * const _channel;
|
||||
UserData * const _user;
|
||||
MTP::Sender _api;
|
||||
base::Timer _timer;
|
||||
base::flat_map<MTP::DcId, base::flat_set<mtpRequestId>> _requests;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Api
|
||||
@@ -178,7 +178,11 @@ EntitiesInText EntitiesFromMTP(
|
||||
});
|
||||
}
|
||||
}, [&](const MTPDmessageEntityPhone &d) {
|
||||
// Skipping phones.
|
||||
result.push_back({
|
||||
EntityType::Phone,
|
||||
d.voffset().v,
|
||||
d.vlength().v,
|
||||
});
|
||||
}, [&](const MTPDmessageEntityCashtag &d) {
|
||||
result.push_back({
|
||||
EntityType::Cashtag,
|
||||
@@ -217,6 +221,7 @@ EntitiesInText EntitiesFromMTP(
|
||||
EntityType::Blockquote,
|
||||
d.voffset().v,
|
||||
d.vlength().v,
|
||||
d.is_collapsed() ? u"1"_q : QString(),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -265,6 +270,9 @@ MTPVector<MTPMessageEntity> EntitiesToMTP(
|
||||
case EntityType::Email: {
|
||||
v.push_back(MTP_messageEntityEmail(offset, length));
|
||||
} break;
|
||||
case EntityType::Phone: {
|
||||
v.push_back(MTP_messageEntityPhone(offset, length));
|
||||
} break;
|
||||
case EntityType::Hashtag: {
|
||||
v.push_back(MTP_messageEntityHashtag(offset, length));
|
||||
} break;
|
||||
@@ -311,7 +319,13 @@ MTPVector<MTPMessageEntity> EntitiesToMTP(
|
||||
MTP_string(entity.data())));
|
||||
} break;
|
||||
case EntityType::Blockquote: {
|
||||
v.push_back(MTP_messageEntityBlockquote(offset, length));
|
||||
using Flag = MTPDmessageEntityBlockquote::Flag;
|
||||
const auto collapsed = !entity.data().isEmpty();
|
||||
v.push_back(
|
||||
MTP_messageEntityBlockquote(
|
||||
MTP_flags(collapsed ? Flag::f_collapsed : Flag()),
|
||||
offset,
|
||||
length));
|
||||
} break;
|
||||
case EntityType::Spoiler: {
|
||||
v.push_back(MTP_messageEntitySpoiler(offset, length));
|
||||
|
||||
@@ -1137,7 +1137,9 @@ void Updates::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
|
||||
MTPMessageReactions(),
|
||||
MTPVector<MTPRestrictionReason>(),
|
||||
MTP_int(d.vttl_period().value_or_empty()),
|
||||
MTPint()), // quick_reply_shortcut_id
|
||||
MTPint(), // quick_reply_shortcut_id
|
||||
MTPlong(), // effect
|
||||
MTPFactCheck()),
|
||||
MessageFlags(),
|
||||
NewMessageType::Unread);
|
||||
} break;
|
||||
@@ -1172,7 +1174,9 @@ void Updates::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
|
||||
MTPMessageReactions(),
|
||||
MTPVector<MTPRestrictionReason>(),
|
||||
MTP_int(d.vttl_period().value_or_empty()),
|
||||
MTPint()), // quick_reply_shortcut_id
|
||||
MTPint(), // quick_reply_shortcut_id
|
||||
MTPlong(), // effect
|
||||
MTPFactCheck()),
|
||||
MessageFlags(),
|
||||
NewMessageType::Unread);
|
||||
} break;
|
||||
@@ -1692,7 +1696,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
const auto peerId = peerFromMTP(d.vpeer());
|
||||
const auto msgId = d.vmsg_id().v;
|
||||
if (const auto item = session().data().message(peerId, msgId)) {
|
||||
item->applyEdition(d.vextended_media());
|
||||
item->applyEdition(d.vextended_media().v);
|
||||
}
|
||||
} break;
|
||||
|
||||
@@ -2117,6 +2121,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
};
|
||||
if (IsForceLogoutNotification(d)) {
|
||||
Core::App().forceLogOut(&session().account(), text);
|
||||
} else if (IsWithdrawalNotification(d)) {
|
||||
return;
|
||||
} else if (d.is_popup()) {
|
||||
const auto &windows = session().windows();
|
||||
if (!windows.empty()) {
|
||||
@@ -2610,7 +2616,16 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
_session->data().stories().apply(data.vstealth_mode());
|
||||
} break;
|
||||
|
||||
case mtpc_updateStarsBalance: {
|
||||
const auto &data = update.c_updateStarsBalance();
|
||||
_session->setCredits(data.vbalance().v);
|
||||
} break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool IsWithdrawalNotification(const MTPDupdateServiceNotification &data) {
|
||||
return qs(data.vtype()).startsWith(u"API_WITHDRAWAL_FEATURE_DISABLED_"_q);
|
||||
}
|
||||
|
||||
} // namespace Api
|
||||
|
||||
@@ -211,4 +211,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] bool IsWithdrawalNotification(
|
||||
const MTPDupdateServiceNotification &);
|
||||
|
||||
} // namespace Api
|
||||
|
||||
@@ -55,7 +55,9 @@ void ViewsManager::removeIncremented(not_null<PeerData*> peer) {
|
||||
_incremented.remove(peer);
|
||||
}
|
||||
|
||||
void ViewsManager::pollExtendedMedia(not_null<HistoryItem*> item) {
|
||||
void ViewsManager::pollExtendedMedia(
|
||||
not_null<HistoryItem*> item,
|
||||
bool force) {
|
||||
if (!item->isRegular()) {
|
||||
return;
|
||||
}
|
||||
@@ -63,14 +65,20 @@ void ViewsManager::pollExtendedMedia(not_null<HistoryItem*> item) {
|
||||
const auto peer = item->history()->peer;
|
||||
auto &request = _pollRequests[peer];
|
||||
if (request.ids.contains(id) || request.sent.contains(id)) {
|
||||
return;
|
||||
if (!force || request.forced) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
request.ids.emplace(id);
|
||||
if (!request.id && !request.when) {
|
||||
request.when = crl::now() + kPollExtendedMediaPeriod;
|
||||
if (force) {
|
||||
request.forced = true;
|
||||
}
|
||||
if (!_pollTimer.isActive()) {
|
||||
_pollTimer.callOnce(kPollExtendedMediaPeriod);
|
||||
const auto delay = force ? 1 : kPollExtendedMediaPeriod;
|
||||
if (!request.id && (!request.when || force)) {
|
||||
request.when = crl::now() + delay;
|
||||
}
|
||||
if (!_pollTimer.isActive() || force) {
|
||||
_pollTimer.callOnce(delay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,9 +168,12 @@ void ViewsManager::sendPollRequests(
|
||||
if (i->second.ids.empty()) {
|
||||
i = _pollRequests.erase(i);
|
||||
} else {
|
||||
i->second.when = now + kPollExtendedMediaPeriod;
|
||||
if (!_pollTimer.isActive()) {
|
||||
_pollTimer.callOnce(kPollExtendedMediaPeriod);
|
||||
const auto delay = i->second.forced
|
||||
? 1
|
||||
: kPollExtendedMediaPeriod;
|
||||
i->second.when = now + delay;
|
||||
if (!_pollTimer.isActive() || i->second.forced) {
|
||||
_pollTimer.callOnce(delay);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
void scheduleIncrement(not_null<HistoryItem*> item);
|
||||
void removeIncremented(not_null<PeerData*> peer);
|
||||
|
||||
void pollExtendedMedia(not_null<HistoryItem*> item);
|
||||
void pollExtendedMedia(not_null<HistoryItem*> item, bool force = false);
|
||||
|
||||
private:
|
||||
struct PollExtendedMediaRequest {
|
||||
@@ -34,6 +34,7 @@ private:
|
||||
mtpRequestId id = 0;
|
||||
base::flat_set<MsgId> ids;
|
||||
base::flat_set<MsgId> sent;
|
||||
bool forced = false;
|
||||
};
|
||||
|
||||
void viewsIncrement();
|
||||
|
||||
@@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_histories.h"
|
||||
#include "data/data_history_messages.h"
|
||||
#include "core/core_cloud_password.h"
|
||||
#include "core/application.h"
|
||||
#include "base/unixtime.h"
|
||||
@@ -2164,7 +2165,8 @@ void ApiWrap::saveDraftsToCloud() {
|
||||
entities,
|
||||
Data::WebPageForMTP(
|
||||
cloudDraft->webpage,
|
||||
textWithTags.text.isEmpty())
|
||||
textWithTags.text.isEmpty()),
|
||||
MTP_long(0) // effect
|
||||
)).done([=](const MTPBool &result, const MTP::Response &response) {
|
||||
const auto requestId = response.requestId;
|
||||
history->finishSavingCloudDraft(
|
||||
@@ -3078,6 +3080,46 @@ void ApiWrap::resolveJumpToHistoryDate(
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::requestHistory(
|
||||
not_null<History*> history,
|
||||
MsgId messageId,
|
||||
SliceType slice) {
|
||||
const auto peer = history->peer;
|
||||
const auto key = HistoryRequest{
|
||||
peer,
|
||||
messageId,
|
||||
slice,
|
||||
};
|
||||
if (_historyRequests.contains(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto prepared = Api::PrepareHistoryRequest(peer, messageId, slice);
|
||||
auto &histories = history->owner().histories();
|
||||
const auto requestType = Data::Histories::RequestType::History;
|
||||
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
||||
return request(
|
||||
std::move(prepared)
|
||||
).done([=](const Api::HistoryRequestResult &result) {
|
||||
_historyRequests.remove(key);
|
||||
auto parsed = Api::ParseHistoryResult(
|
||||
peer,
|
||||
messageId,
|
||||
slice,
|
||||
result);
|
||||
history->messages().addSlice(
|
||||
std::move(parsed.messageIds),
|
||||
parsed.noSkipRange,
|
||||
parsed.fullCount);
|
||||
finish();
|
||||
}).fail([=] {
|
||||
_historyRequests.remove(key);
|
||||
finish();
|
||||
}).send();
|
||||
});
|
||||
_historyRequests.emplace(key);
|
||||
}
|
||||
|
||||
void ApiWrap::requestSharedMedia(
|
||||
not_null<PeerData*> peer,
|
||||
MsgId topicRootId,
|
||||
@@ -3342,6 +3384,9 @@ void ApiWrap::forwardMessages(
|
||||
.date = HistoryItem::NewMessageDate(action.options),
|
||||
.shortcutId = action.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
|
||||
// forwarded messages don't have effects
|
||||
//.effectId = action.options.effectId,
|
||||
}, item);
|
||||
_session->data().registerMessageRandomId(randomId, newId);
|
||||
if (!localIds) {
|
||||
@@ -3442,6 +3487,7 @@ void ApiWrap::sendSharedContact(
|
||||
.date = HistoryItem::NewMessageDate(action.options),
|
||||
.shortcutId = action.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
.effectId = action.options.effectId,
|
||||
}, TextWithEntities(), MTP_messageMediaContact(
|
||||
MTP_string(phone),
|
||||
MTP_string(firstName),
|
||||
@@ -3729,7 +3775,8 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||
const auto anonymousPost = peer->amAnonymous();
|
||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||
FillMessagePostFlags(action, peer, flags);
|
||||
if (exactWebPage && !ignoreWebPage && message.webPage.invert) {
|
||||
if ((exactWebPage && !ignoreWebPage && message.webPage.invert)
|
||||
|| action.options.invertCaption) {
|
||||
flags |= MessageFlag::InvertMedia;
|
||||
sendFlags |= MTPmessages_SendMessage::Flag::f_invert_media;
|
||||
mediaFlags |= MTPmessages_SendMedia::Flag::f_invert_media;
|
||||
@@ -3775,6 +3822,10 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||
sendFlags |= MTPmessages_SendMessage::Flag::f_quick_reply_shortcut;
|
||||
mediaFlags |= MTPmessages_SendMedia::Flag::f_quick_reply_shortcut;
|
||||
}
|
||||
if (action.options.effectId) {
|
||||
sendFlags |= MTPmessages_SendMessage::Flag::f_effect;
|
||||
mediaFlags |= MTPmessages_SendMedia::Flag::f_effect;
|
||||
}
|
||||
lastMessage = history->addNewLocalMessage({
|
||||
.id = newId.msg,
|
||||
.flags = flags,
|
||||
@@ -3783,6 +3834,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||
.date = HistoryItem::NewMessageDate(action.options),
|
||||
.shortcutId = action.options.shortcutId,
|
||||
.postAuthor = messagePostAuthor,
|
||||
.effectId = action.options.effectId,
|
||||
}, sending, media);
|
||||
const auto done = [=](
|
||||
const MTPUpdates &result,
|
||||
@@ -3828,7 +3880,8 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||
sentEntities,
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
mtpShortcut
|
||||
mtpShortcut,
|
||||
MTP_long(action.options.effectId)
|
||||
), done, fail);
|
||||
} else {
|
||||
histories.sendPreparedMessage(
|
||||
@@ -3845,7 +3898,8 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||
sentEntities,
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
mtpShortcut
|
||||
mtpShortcut,
|
||||
MTP_long(action.options.effectId)
|
||||
), done, fail);
|
||||
}
|
||||
isFirst = false;
|
||||
@@ -4119,7 +4173,9 @@ void ApiWrap::sendMediaWithRandomId(
|
||||
| (!sentEntities.v.isEmpty() ? Flag::f_entities : Flag(0))
|
||||
| (options.scheduled ? Flag::f_schedule_date : Flag(0))
|
||||
| (options.sendAs ? Flag::f_send_as : Flag(0))
|
||||
| (options.shortcutId ? Flag::f_quick_reply_shortcut : Flag(0));
|
||||
| (options.shortcutId ? Flag::f_quick_reply_shortcut : Flag(0))
|
||||
| (options.effectId ? Flag::f_effect : Flag(0))
|
||||
| (options.invertCaption ? Flag::f_invert_media : Flag(0));
|
||||
|
||||
auto &histories = history->owner().histories();
|
||||
const auto peer = history->peer;
|
||||
@@ -4132,14 +4188,19 @@ void ApiWrap::sendMediaWithRandomId(
|
||||
MTP_flags(flags),
|
||||
peer->input,
|
||||
Data::Histories::ReplyToPlaceholder(),
|
||||
media,
|
||||
(options.price
|
||||
? MTPInputMedia(MTP_inputMediaPaidMedia(
|
||||
MTP_long(options.price),
|
||||
MTP_vector<MTPInputMedia>(1, media)))
|
||||
: media),
|
||||
MTP_string(caption.text),
|
||||
MTP_long(randomId),
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(options.scheduled),
|
||||
(options.sendAs ? options.sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, options.shortcutId)
|
||||
Data::ShortcutIdToMTP(_session, options.shortcutId),
|
||||
MTP_long(options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (done) done(true);
|
||||
if (updateRecentStickers) {
|
||||
@@ -4151,6 +4212,82 @@ void ApiWrap::sendMediaWithRandomId(
|
||||
});
|
||||
}
|
||||
|
||||
void ApiWrap::sendMultiPaidMedia(
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<SendingAlbum*> album,
|
||||
Fn<void(bool)> done) {
|
||||
Expects(album->options.price > 0);
|
||||
|
||||
const auto groupId = album->groupId;
|
||||
const auto &options = album->options;
|
||||
const auto randomId = album->items.front().randomId;
|
||||
auto medias = album->items | ranges::view::transform([](
|
||||
const SendingAlbum::Item &part) {
|
||||
Assert(part.media.has_value());
|
||||
return MTPInputMedia(part.media->data().vmedia());
|
||||
}) | ranges::to<QVector<MTPInputMedia>>();
|
||||
|
||||
const auto history = item->history();
|
||||
const auto replyTo = item->replyTo();
|
||||
|
||||
auto caption = item->originalText();
|
||||
TextUtilities::Trim(caption);
|
||||
auto sentEntities = Api::EntitiesToMTP(
|
||||
_session,
|
||||
caption.entities,
|
||||
Api::ConvertOption::SkipLocal);
|
||||
|
||||
using Flag = MTPmessages_SendMedia::Flag;
|
||||
const auto flags = Flag(0)
|
||||
| (replyTo ? Flag::f_reply_to : Flag(0))
|
||||
| (ShouldSendSilent(history->peer, options)
|
||||
? Flag::f_silent
|
||||
: Flag(0))
|
||||
| (!sentEntities.v.isEmpty() ? Flag::f_entities : Flag(0))
|
||||
| (options.scheduled ? Flag::f_schedule_date : Flag(0))
|
||||
| (options.sendAs ? Flag::f_send_as : Flag(0))
|
||||
| (options.shortcutId ? Flag::f_quick_reply_shortcut : Flag(0))
|
||||
| (options.effectId ? Flag::f_effect : Flag(0))
|
||||
| (options.invertCaption ? Flag::f_invert_media : Flag(0));
|
||||
|
||||
auto &histories = history->owner().histories();
|
||||
const auto peer = history->peer;
|
||||
const auto itemId = item->fullId();
|
||||
histories.sendPreparedMessage(
|
||||
history,
|
||||
replyTo,
|
||||
randomId,
|
||||
Data::Histories::PrepareMessage<MTPmessages_SendMedia>(
|
||||
MTP_flags(flags),
|
||||
peer->input,
|
||||
Data::Histories::ReplyToPlaceholder(),
|
||||
MTP_inputMediaPaidMedia(
|
||||
MTP_long(options.price),
|
||||
MTP_vector<MTPInputMedia>(std::move(medias))),
|
||||
MTP_string(caption.text),
|
||||
MTP_long(randomId),
|
||||
MTPReplyMarkup(),
|
||||
sentEntities,
|
||||
MTP_int(options.scheduled),
|
||||
(options.sendAs ? options.sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, options.shortcutId),
|
||||
MTP_long(options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (const auto album = _sendingAlbums.take(groupId)) {
|
||||
const auto copy = (*album)->items;
|
||||
for (const auto &part : copy) {
|
||||
if (const auto item = history->owner().message(part.msgId)) {
|
||||
item->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) done(true);
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
if (done) done(false);
|
||||
sendMessageFail(error, peer, randomId, itemId);
|
||||
});
|
||||
}
|
||||
|
||||
void ApiWrap::sendAlbumWithUploaded(
|
||||
not_null<HistoryItem*> item,
|
||||
const MessageGroupId &groupId,
|
||||
@@ -4204,8 +4341,11 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||
if (!sample) {
|
||||
_sendingAlbums.remove(groupId);
|
||||
return;
|
||||
} else if (album->options.price > 0) {
|
||||
sendMultiPaidMedia(sample, album);
|
||||
return;
|
||||
} else if (medias.size() < 2) {
|
||||
const auto &single = medias.front().c_inputSingleMedia();
|
||||
const auto &single = medias.front().data();
|
||||
sendMediaWithRandomId(
|
||||
sample,
|
||||
single.vmedia(),
|
||||
@@ -4227,7 +4367,9 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||
| (sendAs ? Flag::f_send_as : Flag(0))
|
||||
| (album->options.shortcutId
|
||||
? Flag::f_quick_reply_shortcut
|
||||
: Flag(0));
|
||||
: Flag(0))
|
||||
| (album->options.effectId ? Flag::f_effect : Flag(0))
|
||||
| (album->options.invertCaption ? Flag::f_invert_media : Flag(0));
|
||||
auto &histories = history->owner().histories();
|
||||
const auto peer = history->peer;
|
||||
histories.sendPreparedMessage(
|
||||
@@ -4241,7 +4383,8 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||
MTP_vector<MTPInputSingleMedia>(medias),
|
||||
MTP_int(album->options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
Data::ShortcutIdToMTP(_session, album->options.shortcutId)
|
||||
Data::ShortcutIdToMTP(_session, album->options.shortcutId),
|
||||
MTP_long(album->options.effectId)
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
_sendingAlbums.remove(groupId);
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
|
||||
@@ -274,6 +274,10 @@ public:
|
||||
Fn<void(not_null<PeerData*>, MsgId)> callback);
|
||||
|
||||
using SliceType = Data::LoadDirection;
|
||||
void requestHistory(
|
||||
not_null<History*> history,
|
||||
MsgId messageId,
|
||||
SliceType slice);
|
||||
void requestSharedMedia(
|
||||
not_null<PeerData*> peer,
|
||||
MsgId topicRootId,
|
||||
@@ -511,7 +515,8 @@ private:
|
||||
not_null<PeerData*> peer,
|
||||
bool justClear,
|
||||
bool revoke);
|
||||
void applyAffectedMessages(const MTPmessages_AffectedMessages &result) const;
|
||||
void applyAffectedMessages(
|
||||
const MTPmessages_AffectedMessages &result) const;
|
||||
|
||||
void deleteAllFromParticipantSend(
|
||||
not_null<ChannelData*> channel,
|
||||
@@ -540,6 +545,10 @@ private:
|
||||
Api::SendOptions options,
|
||||
uint64 randomId,
|
||||
Fn<void(bool)> done = nullptr);
|
||||
void sendMultiPaidMedia(
|
||||
not_null<HistoryItem*> item,
|
||||
not_null<SendingAlbum*> album,
|
||||
Fn<void(bool)> done = nullptr);
|
||||
|
||||
void getTopPromotionDelayed(TimeId now, TimeId next);
|
||||
void topPromotionDone(const MTPhelp_PromoData &proxy);
|
||||
@@ -645,6 +654,17 @@ private:
|
||||
};
|
||||
base::flat_set<SharedMediaRequest> _sharedMediaRequests;
|
||||
|
||||
struct HistoryRequest {
|
||||
not_null<PeerData*> peer;
|
||||
MsgId aroundId = 0;
|
||||
SliceType sliceType = {};
|
||||
|
||||
friend inline auto operator<=>(
|
||||
const HistoryRequest&,
|
||||
const HistoryRequest&) = default;
|
||||
};
|
||||
base::flat_set<HistoryRequest> _historyRequests;
|
||||
|
||||
std::unique_ptr<DialogsLoadState> _dialogsLoadState;
|
||||
TimeId _dialogsLoadTill = 0;
|
||||
rpl::variable<bool> _dialogsLoadMayBlockByDate = false;
|
||||
|
||||
@@ -192,20 +192,27 @@ void ShowAddParticipantsError(
|
||||
&& channel
|
||||
&& !channel->isMegagroup()
|
||||
&& channel->canAddAdmins()) {
|
||||
const auto makeAdmin = [=] {
|
||||
const auto makeAdmin = [=](Fn<void()> close) {
|
||||
const auto user = forbidden.users.front();
|
||||
const auto weak = std::make_shared<QPointer<EditAdminBox>>();
|
||||
const auto close = [=](auto&&...) {
|
||||
if (*weak) {
|
||||
(*weak)->closeBox();
|
||||
const auto done = [=](auto&&...) {
|
||||
if (const auto strong = weak->data()) {
|
||||
strong->uiShow()->showToast(
|
||||
tr::lng_box_done(tr::now));
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
const auto fail = [=] {
|
||||
if (const auto strong = weak->data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
const auto saveCallback = SaveAdminCallback(
|
||||
show,
|
||||
channel,
|
||||
user,
|
||||
close,
|
||||
close);
|
||||
done,
|
||||
fail);
|
||||
auto box = Box<EditAdminBox>(
|
||||
channel,
|
||||
user,
|
||||
@@ -214,6 +221,7 @@ void ShowAddParticipantsError(
|
||||
box->setSaveCallback(saveCallback);
|
||||
*weak = box.data();
|
||||
show->showBox(std::move(box));
|
||||
close();
|
||||
};
|
||||
show->showBox(
|
||||
Ui::MakeConfirmBox({
|
||||
|
||||
@@ -237,7 +237,7 @@ shareColumnSkip: 6px;
|
||||
shareActivateDuration: 150;
|
||||
shareScrollDuration: 300;
|
||||
shareComment: InputField(defaultInputField) {
|
||||
font: normalFont;
|
||||
style: defaultTextStyle;
|
||||
textMargins: margins(8px, 8px, 8px, 6px);
|
||||
heightMin: 36px;
|
||||
heightMax: 72px;
|
||||
@@ -290,6 +290,26 @@ passcodeTextLine: 28px;
|
||||
passcodeLittleSkip: 5px;
|
||||
passcodeAboutSkip: 7px;
|
||||
passcodeSkip: 23px;
|
||||
passcodeSystemUnlock: IconButton(defaultIconButton) {
|
||||
width: 32px;
|
||||
height: 36px;
|
||||
icon: icon{{ "menu/passcode_winhello", lightButtonFg }};
|
||||
iconOver: icon{{ "menu/passcode_winhello", lightButtonFg }};
|
||||
iconPosition: point(4px, 4px);
|
||||
rippleAreaSize: 32px;
|
||||
rippleAreaPosition: point(0px, 0px);
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: lightButtonBgOver;
|
||||
}
|
||||
}
|
||||
passcodeSystemTouchID: icon{{ "menu/passcode_finger", lightButtonFg }};
|
||||
passcodeSystemAppleWatch: icon{{ "menu/passcode_watch", lightButtonFg }};
|
||||
passcodeSystemSystemPwd: icon{{ "menu/permissions", lightButtonFg }};
|
||||
passcodeSystemUnlockLater: FlatLabel(defaultFlatLabel) {
|
||||
align: align(top);
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
passcodeSystemUnlockSkip: 12px;
|
||||
|
||||
newGroupAboutFg: windowSubTextFg;
|
||||
newGroupPadding: margins(4px, 6px, 4px, 3px);
|
||||
@@ -585,7 +605,7 @@ groupStickersRemovePosition: point(6px, 6px);
|
||||
groupStickersFieldPadding: margins(8px, 6px, 8px, 6px);
|
||||
groupStickersField: InputField(defaultMultiSelectSearchField) {
|
||||
placeholderFont: boxTextFont;
|
||||
font: boxTextFont;
|
||||
style: boxTextStyle;
|
||||
placeholderMargins: margins(0px, 0px, 0px, 0px);
|
||||
textMargins: margins(0px, 7px, 0px, 0px);
|
||||
textBg: boxBg;
|
||||
@@ -642,6 +662,10 @@ proxyDropdownUpPosition: point(-2px, 20px);
|
||||
proxyAboutPadding: margins(22px, 7px, 22px, 14px);
|
||||
proxyAboutSponsorPadding: margins(22px, 7px, 22px, 0px);
|
||||
|
||||
proxyApplyBoxLabel : FlatLabel(defaultFlatLabel) {
|
||||
maxHeight: 30px;
|
||||
}
|
||||
|
||||
markdownLinkFieldPadding: margins(22px, 0px, 22px, 10px);
|
||||
|
||||
termsContent: FlatLabel(defaultFlatLabel) {
|
||||
@@ -668,7 +692,6 @@ themesMenuToggle: IconButton(defaultIconButton) {
|
||||
themesMenuPosition: point(-2px, 25px);
|
||||
|
||||
createPollField: InputField(defaultInputField) {
|
||||
font: boxTextFont;
|
||||
textMargins: margins(0px, 4px, 0px, 4px);
|
||||
textAlign: align(left);
|
||||
heightMin: 36px;
|
||||
@@ -873,7 +896,6 @@ scheduleDateField: InputField(defaultInputField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(top);
|
||||
font: font(14px);
|
||||
}
|
||||
scheduleTimeField: InputField(scheduleDateField) {
|
||||
border: 0px;
|
||||
@@ -901,7 +923,6 @@ muteBoxTimeField: InputField(scheduleDateField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(left);
|
||||
font: font(14px);
|
||||
}
|
||||
muteBoxTimeFieldPadding: margins(5px, 0px, 5px, 0px);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ void ChangeFilterById(
|
||||
MTP_int(filter.id()),
|
||||
filter.tl()
|
||||
)).done([=, chat = history->peer->name(), name = filter.title()] {
|
||||
const auto account = &history->session().account();
|
||||
const auto account = not_null(&history->session().account());
|
||||
if (const auto controller = Core::App().windowFor(account)) {
|
||||
controller->showToast((add
|
||||
? tr::lng_filters_toast_add
|
||||
|
||||
@@ -7,32 +7,37 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/connection_box.h"
|
||||
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/local_url_handlers.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_account.h"
|
||||
#include "mtproto/facade.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "ui/widgets/fields/number_input.h"
|
||||
#include "ui/widgets/fields/password_input.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "boxes/abstract_box.h" // Ui::show().
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
@@ -48,6 +53,22 @@ constexpr auto kSaveSettingsDelayedTimeout = crl::time(1000);
|
||||
|
||||
using ProxyData = MTP::ProxyData;
|
||||
|
||||
[[nodiscard]] ProxyData ProxyDataFromFields(
|
||||
ProxyData::Type type,
|
||||
const QMap<QString, QString> &fields) {
|
||||
auto proxy = ProxyData();
|
||||
proxy.type = type;
|
||||
proxy.host = fields.value(u"server"_q);
|
||||
proxy.port = fields.value(u"port"_q).toUInt();
|
||||
if (type == ProxyData::Type::Socks5) {
|
||||
proxy.user = fields.value(u"user"_q);
|
||||
proxy.password = fields.value(u"pass"_q);
|
||||
} else if (type == ProxyData::Type::Mtproto) {
|
||||
proxy.password = fields.value(u"secret"_q);
|
||||
}
|
||||
return proxy;
|
||||
};
|
||||
|
||||
class HostInput : public Ui::MaskedInputField {
|
||||
public:
|
||||
HostInput(
|
||||
@@ -203,6 +224,7 @@ protected:
|
||||
|
||||
private:
|
||||
void setupContent();
|
||||
void setupTopButton();
|
||||
void createNoRowsLabel();
|
||||
void addNewProxy();
|
||||
void applyView(View &&view);
|
||||
@@ -600,9 +622,80 @@ void ProxiesBox::prepare() {
|
||||
addButton(tr::lng_proxy_add(), [=] { addNewProxy(); });
|
||||
addButton(tr::lng_close(), [=] { closeBox(); });
|
||||
|
||||
setupTopButton();
|
||||
setupContent();
|
||||
}
|
||||
|
||||
void ProxiesBox::setupTopButton() {
|
||||
const auto top = addTopButton(st::infoTopBarMenu);
|
||||
const auto menu
|
||||
= top->lifetime().make_state<base::unique_qptr<Ui::PopupMenu>>();
|
||||
const auto callback = [=] {
|
||||
const auto maybeUrl = QGuiApplication::clipboard()->text();
|
||||
const auto local = Core::TryConvertUrlToLocal(maybeUrl);
|
||||
|
||||
const auto proxyString = u"proxy"_q;
|
||||
const auto socksString = u"socks"_q;
|
||||
const auto protocol = u"tg://"_q;
|
||||
const auto command = base::StringViewMid(
|
||||
local,
|
||||
protocol.size(),
|
||||
8192);
|
||||
|
||||
if (local.startsWith(protocol + proxyString)
|
||||
|| local.startsWith(protocol + socksString)) {
|
||||
|
||||
using namespace qthelp;
|
||||
const auto options = RegExOption::CaseInsensitive;
|
||||
for (const auto &[expression, _] : Core::LocalUrlHandlers()) {
|
||||
const auto midExpression = base::StringViewMid(
|
||||
expression,
|
||||
1);
|
||||
const auto isSocks = midExpression.startsWith(
|
||||
socksString);
|
||||
if (!midExpression.startsWith(proxyString)
|
||||
&& !isSocks) {
|
||||
continue;
|
||||
}
|
||||
const auto match = regex_match(
|
||||
expression,
|
||||
command,
|
||||
options);
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
const auto type = isSocks
|
||||
? ProxyData::Type::Socks5
|
||||
: ProxyData::Type::Mtproto;
|
||||
const auto fields = url_parse_params(
|
||||
match->captured(1),
|
||||
qthelp::UrlParamNameTransform::ToLower);
|
||||
const auto proxy = ProxyDataFromFields(type, fields);
|
||||
const auto contains = _controller->contains(proxy);
|
||||
const auto toast = (contains
|
||||
? tr::lng_proxy_add_from_clipboard_existing_toast
|
||||
: tr::lng_proxy_add_from_clipboard_good_toast)(tr::now);
|
||||
uiShow()->showToast(toast);
|
||||
if (!contains) {
|
||||
_controller->addNewItem(proxy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
uiShow()->showToast(
|
||||
tr::lng_proxy_add_from_clipboard_failed_toast(tr::now));
|
||||
}
|
||||
};
|
||||
top->setClickedCallback([=] {
|
||||
*menu = base::make_unique_q<Ui::PopupMenu>(top, st::defaultPopupMenu);
|
||||
(*menu)->addAction(
|
||||
tr::lng_proxy_add_from_clipboard(tr::now),
|
||||
callback);
|
||||
(*menu)->popup(QCursor::pos());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void ProxiesBox::setupContent() {
|
||||
const auto inner = setInnerWidget(object_ptr<Ui::VerticalLayout>(this));
|
||||
|
||||
@@ -1094,70 +1187,84 @@ ProxiesBoxController::ProxiesBoxController(not_null<Main::Account*> account)
|
||||
}
|
||||
|
||||
void ProxiesBoxController::ShowApplyConfirmation(
|
||||
Window::SessionController *controller,
|
||||
Type type,
|
||||
const QMap<QString, QString> &fields) {
|
||||
const auto server = fields.value(u"server"_q);
|
||||
const auto port = fields.value(u"port"_q).toUInt();
|
||||
auto proxy = ProxyData();
|
||||
proxy.type = type;
|
||||
proxy.host = server;
|
||||
proxy.port = port;
|
||||
if (type == Type::Socks5) {
|
||||
proxy.user = fields.value(u"user"_q);
|
||||
proxy.password = fields.value(u"pass"_q);
|
||||
} else if (type == Type::Mtproto) {
|
||||
proxy.password = fields.value(u"secret"_q);
|
||||
const auto proxy = ProxyDataFromFields(type, fields);
|
||||
if (!proxy) {
|
||||
auto box = Ui::MakeInformBox(
|
||||
(proxy.status() == ProxyData::Status::Unsupported
|
||||
? tr::lng_proxy_unsupported(tr::now)
|
||||
: tr::lng_proxy_invalid(tr::now)));
|
||||
if (controller) {
|
||||
controller->uiShow()->showBox(std::move(box));
|
||||
} else {
|
||||
Ui::show(std::move(box));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (proxy) {
|
||||
static const auto UrlStartRegExp = QRegularExpression(
|
||||
"^https://",
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
static const auto UrlEndRegExp = QRegularExpression("/$");
|
||||
const auto displayed = "https://" + server + "/";
|
||||
const auto parsed = QUrl::fromUserInput(displayed);
|
||||
const auto displayUrl = !UrlClickHandler::IsSuspicious(displayed)
|
||||
? displayed
|
||||
: parsed.isValid()
|
||||
? QString::fromUtf8(parsed.toEncoded())
|
||||
: UrlClickHandler::ShowEncoded(displayed);
|
||||
const auto displayServer = QString(
|
||||
displayUrl
|
||||
).replace(
|
||||
UrlStartRegExp,
|
||||
QString()
|
||||
).replace(UrlEndRegExp, QString());
|
||||
const auto text = tr::lng_sure_enable_socks(
|
||||
tr::now,
|
||||
lt_server,
|
||||
displayServer,
|
||||
lt_port,
|
||||
QString::number(port))
|
||||
+ (proxy.type == Type::Mtproto
|
||||
? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now)
|
||||
: QString());
|
||||
auto callback = [=](Fn<void()> &&close) {
|
||||
static const auto UrlStartRegExp = QRegularExpression(
|
||||
"^https://",
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
static const auto UrlEndRegExp = QRegularExpression("/$");
|
||||
const auto displayed = "https://" + proxy.host + "/";
|
||||
const auto parsed = QUrl::fromUserInput(displayed);
|
||||
const auto displayUrl = !UrlClickHandler::IsSuspicious(displayed)
|
||||
? displayed
|
||||
: parsed.isValid()
|
||||
? QString::fromUtf8(parsed.toEncoded())
|
||||
: UrlClickHandler::ShowEncoded(displayed);
|
||||
const auto displayServer = QString(
|
||||
displayUrl
|
||||
).replace(
|
||||
UrlStartRegExp,
|
||||
QString()
|
||||
).replace(UrlEndRegExp, QString());
|
||||
const auto box = [=](not_null<Ui::GenericBox*> box) {
|
||||
box->setTitle(tr::lng_proxy_box_title());
|
||||
if (type == Type::Mtproto) {
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_proxy_sponsor_warning(),
|
||||
st::boxDividerLabel));
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
}
|
||||
const auto &stL = st::proxyApplyBoxLabel;
|
||||
const auto &stSubL = st::boxDividerLabel;
|
||||
const auto add = [&](const QString &s, tr::phrase<> phrase) {
|
||||
if (!s.isEmpty()) {
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(box, s, stL));
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(box, phrase(), stSubL));
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
}
|
||||
};
|
||||
if (!displayServer.isEmpty()) {
|
||||
add(displayServer, tr::lng_proxy_box_server);
|
||||
}
|
||||
add(QString::number(proxy.port), tr::lng_proxy_box_port);
|
||||
if (type == Type::Socks5) {
|
||||
add(proxy.user, tr::lng_proxy_box_username);
|
||||
add(proxy.password, tr::lng_proxy_box_password);
|
||||
} else if (type == Type::Mtproto) {
|
||||
add(proxy.password, tr::lng_proxy_box_secret);
|
||||
}
|
||||
box->addButton(tr::lng_sure_enable(), [=] {
|
||||
auto &proxies = Core::App().settings().proxy().list();
|
||||
if (!ranges::contains(proxies, proxy)) {
|
||||
proxies.push_back(proxy);
|
||||
}
|
||||
Core::App().setCurrentProxy(
|
||||
proxy,
|
||||
ProxyData::Settings::Enabled);
|
||||
Core::App().setCurrentProxy(proxy, ProxyData::Settings::Enabled);
|
||||
Local::writeSettings();
|
||||
close();
|
||||
};
|
||||
Ui::show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = text,
|
||||
.confirmed = std::move(callback),
|
||||
.confirmText = tr::lng_sure_enable(),
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
box->closeBox();
|
||||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
};
|
||||
if (controller) {
|
||||
controller->uiShow()->showBox(Box(box));
|
||||
} else {
|
||||
Ui::show(Ui::MakeInformBox(
|
||||
(proxy.status() == ProxyData::Status::Unsupported
|
||||
? tr::lng_proxy_unsupported(tr::now)
|
||||
: tr::lng_proxy_invalid(tr::now))));
|
||||
Ui::show(Box(box));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1448,6 +1555,14 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::addNewItemBox() {
|
||||
});
|
||||
}
|
||||
|
||||
bool ProxiesBoxController::contains(const ProxyData &proxy) const {
|
||||
const auto j = ranges::find(
|
||||
_list,
|
||||
proxy,
|
||||
[](const Item &item) { return item.data; });
|
||||
return (j != end(_list));
|
||||
}
|
||||
|
||||
void ProxiesBoxController::addNewItem(const ProxyData &proxy) {
|
||||
auto &proxies = _settings.list();
|
||||
proxies.push_back(proxy);
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace Main {
|
||||
class Account;
|
||||
} // namespace Main
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
class ProxiesBoxController {
|
||||
public:
|
||||
using ProxyData = MTP::ProxyData;
|
||||
@@ -38,6 +42,7 @@ public:
|
||||
explicit ProxiesBoxController(not_null<Main::Account*> account);
|
||||
|
||||
static void ShowApplyConfirmation(
|
||||
Window::SessionController *controller,
|
||||
Type type,
|
||||
const QMap<QString, QString> &fields);
|
||||
|
||||
@@ -77,6 +82,9 @@ public:
|
||||
void setTryIPv6(bool enabled);
|
||||
rpl::producer<ProxyData::Settings> proxySettingsValue() const;
|
||||
|
||||
[[nodiscard]] bool contains(const ProxyData &proxy) const;
|
||||
void addNewItem(const ProxyData &proxy);
|
||||
|
||||
rpl::producer<ItemView> views() const;
|
||||
|
||||
~ProxiesBoxController();
|
||||
@@ -109,7 +117,6 @@ private:
|
||||
void replaceItemValue(
|
||||
std::vector<Item>::iterator which,
|
||||
const ProxyData &proxy);
|
||||
void addNewItem(const ProxyData &proxy);
|
||||
|
||||
const not_null<Main::Account*> _account;
|
||||
Core::SettingsProxy &_settings;
|
||||
|
||||
@@ -910,12 +910,12 @@ CreatePollBox::CreatePollBox(
|
||||
PollData::Flags chosen,
|
||||
PollData::Flags disabled,
|
||||
Api::SendType sendType,
|
||||
SendMenu::Type sendMenuType)
|
||||
SendMenu::Details sendMenuDetails)
|
||||
: _controller(controller)
|
||||
, _chosen(chosen)
|
||||
, _disabled(disabled)
|
||||
, _sendType(sendType)
|
||||
, _sendMenuType(sendMenuType) {
|
||||
, _sendMenuDetails([result = sendMenuDetails] { return result; }) {
|
||||
}
|
||||
|
||||
rpl::producer<CreatePollBox::Result> CreatePollBox::submitRequests() const {
|
||||
@@ -1044,7 +1044,16 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
|
||||
solution->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
solution->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
solution->setMarkdownReplacesEnabled(rpl::single(true));
|
||||
solution->setMarkdownReplacesEnabled(rpl::single(
|
||||
Ui::MarkdownEnabledState{ Ui::MarkdownEnabled{ {
|
||||
Ui::InputField::kTagBold,
|
||||
Ui::InputField::kTagItalic,
|
||||
Ui::InputField::kTagUnderline,
|
||||
Ui::InputField::kTagStrikeOut,
|
||||
Ui::InputField::kTagCode,
|
||||
Ui::InputField::kTagSpoiler,
|
||||
} } }
|
||||
));
|
||||
solution->setEditLinkCallback(
|
||||
DefaultEditLinkCallback(_controller->uiShow(), solution));
|
||||
solution->customTab(true);
|
||||
@@ -1288,19 +1297,9 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
_submitRequests.fire({ collectResult(), sendOptions });
|
||||
}
|
||||
};
|
||||
const auto sendSilent = [=] {
|
||||
send({ .silent = true });
|
||||
};
|
||||
const auto sendScheduled = [=] {
|
||||
_controller->show(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
SendMenu::Type::Scheduled,
|
||||
send));
|
||||
};
|
||||
const auto sendWhenOnline = [=] {
|
||||
send(Api::DefaultSendWhenOnlineOptions());
|
||||
};
|
||||
const auto sendAction = SendMenu::DefaultCallback(
|
||||
_controller->uiShow(),
|
||||
crl::guard(this, send));
|
||||
|
||||
options->scrollToWidget(
|
||||
) | rpl::start_with_next([=](not_null<QWidget*> widget) {
|
||||
@@ -1313,24 +1312,25 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||
}, lifetime());
|
||||
|
||||
const auto isNormal = (_sendType == Api::SendType::Normal);
|
||||
|
||||
const auto schedule = [=] {
|
||||
sendAction(
|
||||
{ .type = SendMenu::ActionType::Schedule },
|
||||
_sendMenuDetails());
|
||||
};
|
||||
const auto submit = addButton(
|
||||
isNormal
|
||||
(isNormal
|
||||
? tr::lng_polls_create_button()
|
||||
: tr::lng_schedule_button(),
|
||||
[=] { isNormal ? send({}) : sendScheduled(); });
|
||||
const auto sendMenuType = [=] {
|
||||
: tr::lng_schedule_button()),
|
||||
[=] { isNormal ? send({}) : schedule(); });
|
||||
const auto sendMenuDetails = [=] {
|
||||
collectError();
|
||||
return (*error)
|
||||
? SendMenu::Type::Disabled
|
||||
: _sendMenuType;
|
||||
return (*error) ? SendMenu::Details() : _sendMenuDetails();
|
||||
};
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
submit.data(),
|
||||
sendMenuType,
|
||||
sendSilent,
|
||||
sendScheduled,
|
||||
sendWhenOnline);
|
||||
_controller->uiShow(),
|
||||
sendMenuDetails,
|
||||
sendAction);
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
return result;
|
||||
|
||||
@@ -27,7 +27,7 @@ class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
} // namespace SendMenu
|
||||
|
||||
class CreatePollBox : public Ui::BoxContent {
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
PollData::Flags chosen,
|
||||
PollData::Flags disabled,
|
||||
Api::SendType sendType,
|
||||
SendMenu::Type sendMenuType);
|
||||
SendMenu::Details sendMenuDetails);
|
||||
|
||||
[[nodiscard]] rpl::producer<Result> submitRequests() const;
|
||||
void submitFailed(const QString &error);
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
const PollData::Flags _chosen = PollData::Flags();
|
||||
const PollData::Flags _disabled = PollData::Flags();
|
||||
const Api::SendType _sendType = Api::SendType();
|
||||
const SendMenu::Type _sendMenuType;
|
||||
const Fn<SendMenu::Details()> _sendMenuDetails;
|
||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||
Fn<void()> _setInnerFocus;
|
||||
Fn<rpl::producer<bool>()> _dataIsValidValue;
|
||||
|
||||
@@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "mainwidget.h" // controller->content() -> QWidget*
|
||||
#include "menu/menu_send.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "storage/localimageloader.h" // SendMediaType
|
||||
@@ -175,7 +176,7 @@ void ChooseReplacement(
|
||||
void EditPhotoImage(
|
||||
not_null<Window::SessionController*> controller,
|
||||
std::shared_ptr<Data::PhotoMedia> media,
|
||||
bool wasSpoiler,
|
||||
bool spoilered,
|
||||
Fn<void(Ui::PreparedList)> done) {
|
||||
const auto large = media
|
||||
? media->image(Data::PhotoSize::Large)
|
||||
@@ -198,7 +199,7 @@ void EditPhotoImage(
|
||||
|
||||
using ImageInfo = Ui::PreparedFileInformation::Image;
|
||||
auto &file = list.files.front();
|
||||
file.spoiler = wasSpoiler;
|
||||
file.spoiler = spoilered;
|
||||
const auto image = std::get_if<ImageInfo>(&file.information->media);
|
||||
|
||||
image->modifications = mods;
|
||||
@@ -225,25 +226,18 @@ void EditPhotoImage(
|
||||
|
||||
} // namespace
|
||||
|
||||
EditCaptionBox::EditCaptionBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item)
|
||||
: EditCaptionBox({}, controller, item, PrepareEditText(item), {}, {}) {
|
||||
}
|
||||
|
||||
EditCaptionBox::EditCaptionBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
TextWithTags &&text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Ui::PreparedList &&list,
|
||||
Fn<void()> saved)
|
||||
: _controller(controller)
|
||||
, _historyItem(item)
|
||||
, _isAllowedEditMedia(item->media()
|
||||
? item->media()->allowsEditMedia()
|
||||
: false)
|
||||
, _isAllowedEditMedia(item->media() && item->media()->allowsEditMedia())
|
||||
, _albumType(ComputeAlbumType(item))
|
||||
, _controls(base::make_unique_q<Ui::VerticalLayout>(this))
|
||||
, _scroll(base::make_unique_q<Ui::ScrollArea>(this, st::boxScroll))
|
||||
@@ -261,6 +255,8 @@ EditCaptionBox::EditCaptionBox(
|
||||
Expects(item->media() != nullptr);
|
||||
Expects(item->media()->allowsEditCaption());
|
||||
|
||||
_mediaEditManager.start(item, spoilered, invertCaption);
|
||||
|
||||
_controller->session().data().itemRemoved(
|
||||
_historyItem->fullId()
|
||||
) | rpl::start_with_next([=] {
|
||||
@@ -274,6 +270,8 @@ void EditCaptionBox::StartMediaReplace(
|
||||
not_null<Window::SessionController*> controller,
|
||||
FullMsgId itemId,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved) {
|
||||
const auto session = &controller->session();
|
||||
const auto item = session->data().message(itemId);
|
||||
@@ -285,6 +283,8 @@ void EditCaptionBox::StartMediaReplace(
|
||||
controller,
|
||||
item,
|
||||
std::move(text),
|
||||
spoilered,
|
||||
invertCaption,
|
||||
std::move(list),
|
||||
std::move(saved)));
|
||||
};
|
||||
@@ -299,6 +299,8 @@ void EditCaptionBox::StartMediaReplace(
|
||||
FullMsgId itemId,
|
||||
Ui::PreparedList &&list,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved) {
|
||||
const auto session = &controller->session();
|
||||
const auto item = session->data().message(itemId);
|
||||
@@ -332,6 +334,8 @@ void EditCaptionBox::StartMediaReplace(
|
||||
controller,
|
||||
item,
|
||||
std::move(text),
|
||||
spoilered,
|
||||
invertCaption,
|
||||
std::move(list),
|
||||
std::move(saved)));
|
||||
}
|
||||
@@ -342,14 +346,15 @@ void EditCaptionBox::StartPhotoEdit(
|
||||
std::shared_ptr<Data::PhotoMedia> media,
|
||||
FullMsgId itemId,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved) {
|
||||
const auto session = &controller->session();
|
||||
const auto item = session->data().message(itemId);
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
const auto hasSpoiler = item->media() && item->media()->hasSpoiler();
|
||||
EditPhotoImage(controller, media, hasSpoiler, [=](
|
||||
EditPhotoImage(controller, media, spoilered, [=](
|
||||
Ui::PreparedList &&list) mutable {
|
||||
const auto item = session->data().message(itemId);
|
||||
if (!item) {
|
||||
@@ -359,15 +364,48 @@ void EditCaptionBox::StartPhotoEdit(
|
||||
controller,
|
||||
item,
|
||||
std::move(text),
|
||||
spoilered,
|
||||
invertCaption,
|
||||
std::move(list),
|
||||
std::move(saved)));
|
||||
});
|
||||
}
|
||||
|
||||
void EditCaptionBox::prepare() {
|
||||
addButton(tr::lng_settings_save(), [=] { save(); });
|
||||
const auto button = addButton(tr::lng_settings_save(), [=] { save(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
const auto details = crl::guard(this, [=] {
|
||||
auto result = SendMenu::Details();
|
||||
const auto allWithSpoilers = ranges::all_of(
|
||||
_preparedList.files,
|
||||
&Ui::PreparedFile::spoiler);
|
||||
result.spoiler = !_preparedList.hasSpoilerMenu(!_asFile)
|
||||
? SendMenu::SpoilerState::None
|
||||
: allWithSpoilers
|
||||
? SendMenu::SpoilerState::Enabled
|
||||
: SendMenu::SpoilerState::Possible;
|
||||
const auto canMoveCaption = _preparedList.canMoveCaption(
|
||||
false,
|
||||
!_asFile
|
||||
) && _field && HasSendText(_field);
|
||||
result.caption = !canMoveCaption
|
||||
? SendMenu::CaptionState::None
|
||||
: _mediaEditManager.invertCaption()
|
||||
? SendMenu::CaptionState::Above
|
||||
: SendMenu::CaptionState::Below;
|
||||
return result;
|
||||
});
|
||||
const auto callback = [=](SendMenu::Action action, const auto &) {
|
||||
_mediaEditManager.apply(action);
|
||||
rebuildPreview();
|
||||
};
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
button,
|
||||
nullptr,
|
||||
details,
|
||||
crl::guard(this, callback));
|
||||
|
||||
updateBoxSize();
|
||||
|
||||
setupField();
|
||||
@@ -396,7 +434,6 @@ void EditCaptionBox::rebuildPreview() {
|
||||
|
||||
applyChanges();
|
||||
|
||||
_previewHasSpoiler = nullptr;
|
||||
if (_preparedList.files.empty()) {
|
||||
const auto media = _historyItem->media();
|
||||
const auto photo = media->photo();
|
||||
@@ -426,11 +463,18 @@ void EditCaptionBox::rebuildPreview() {
|
||||
st::defaultComposeControls,
|
||||
gifPaused,
|
||||
file,
|
||||
[] { return true; },
|
||||
Ui::AttachControls::Type::EditOnly);
|
||||
_isPhoto = (media && media->isPhoto());
|
||||
const auto withCheckbox = _isPhoto && CanBeCompressed(_albumType);
|
||||
if (media && (!withCheckbox || !_asFile)) {
|
||||
_previewHasSpoiler = [media] { return media->hasSpoiler(); };
|
||||
media->spoileredChanges(
|
||||
) | rpl::start_with_next([=](bool spoilered) {
|
||||
_mediaEditManager.apply({ .type = spoilered
|
||||
? SendMenu::ActionType::SpoilerOn
|
||||
: SendMenu::ActionType::SpoilerOff
|
||||
});
|
||||
}, media->lifetime());
|
||||
_content.reset(media);
|
||||
} else {
|
||||
_content.reset(Ui::CreateChild<Ui::SingleFilePreview>(
|
||||
@@ -757,10 +801,7 @@ bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) {
|
||||
}
|
||||
|
||||
bool EditCaptionBox::hasSpoiler() const {
|
||||
return _preparedList.files.empty()
|
||||
? (_historyItem->media()
|
||||
&& _historyItem->media()->hasSpoiler())
|
||||
: _preparedList.files.front().spoiler;
|
||||
return _mediaEditManager.spoilered();
|
||||
}
|
||||
|
||||
void EditCaptionBox::captionResized() {
|
||||
@@ -869,8 +910,8 @@ bool EditCaptionBox::validateLength(const QString &text) const {
|
||||
}
|
||||
|
||||
void EditCaptionBox::applyChanges() {
|
||||
if (!_preparedList.files.empty() && _previewHasSpoiler) {
|
||||
_preparedList.files.front().spoiler = _previewHasSpoiler();
|
||||
if (!_preparedList.files.empty()) {
|
||||
_preparedList.files.front().spoiler = _mediaEditManager.spoilered();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,6 +940,7 @@ void EditCaptionBox::save() {
|
||||
auto options = Api::SendOptions();
|
||||
options.scheduled = item->isScheduled() ? item->date() : 0;
|
||||
options.shortcutId = item->shortcutId();
|
||||
options.invertCaption = _mediaEditManager.invertCaption();
|
||||
|
||||
if (!_preparedList.files.empty()) {
|
||||
if ((_albumType != Ui::AlbumType::None)
|
||||
|
||||
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "history/view/controls/history_view_compose_media_edit_manager.h"
|
||||
#include "ui/layers/box_content.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
|
||||
@@ -32,15 +33,13 @@ enum class AlbumType;
|
||||
|
||||
class EditCaptionBox final : public Ui::BoxContent {
|
||||
public:
|
||||
EditCaptionBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item);
|
||||
EditCaptionBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item,
|
||||
TextWithTags &&text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Ui::PreparedList &&list,
|
||||
Fn<void()> saved);
|
||||
~EditCaptionBox();
|
||||
@@ -49,18 +48,24 @@ public:
|
||||
not_null<Window::SessionController*> controller,
|
||||
FullMsgId itemId,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved);
|
||||
static void StartMediaReplace(
|
||||
not_null<Window::SessionController*> controller,
|
||||
FullMsgId itemId,
|
||||
Ui::PreparedList &&list,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved);
|
||||
static void StartPhotoEdit(
|
||||
not_null<Window::SessionController*> controller,
|
||||
std::shared_ptr<Data::PhotoMedia> media,
|
||||
FullMsgId itemId,
|
||||
TextWithTags text,
|
||||
bool spoilered,
|
||||
bool invertCaption,
|
||||
Fn<void()> saved);
|
||||
|
||||
protected:
|
||||
@@ -111,7 +116,6 @@ private:
|
||||
const base::unique_qptr<Ui::EmojiButton> _emojiToggle;
|
||||
|
||||
base::unique_qptr<Ui::AbstractSinglePreview> _content;
|
||||
Fn<bool()> _previewHasSpoiler;
|
||||
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
||||
base::unique_qptr<QObject> _emojiFilter;
|
||||
|
||||
@@ -122,6 +126,7 @@ private:
|
||||
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
||||
|
||||
Ui::PreparedList _preparedList;
|
||||
HistoryView::MediaEditManager _mediaEditManager;
|
||||
|
||||
mtpRequestId _saveRequestId = 0;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_boosts.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_credits.h"
|
||||
#include "data/data_media_types.h" // Data::GiveawayStart.
|
||||
#include "data/data_peer_values.h" // Data::PeerPremiumValue.
|
||||
#include "data/data_session.h"
|
||||
@@ -1010,14 +1011,16 @@ void GiftPremiumValidator::showChoosePeerBox(const QString &ref) {
|
||||
}) | ranges::views::filter([](UserData *u) -> bool {
|
||||
return u;
|
||||
}) | ranges::to<std::vector<not_null<UserData*>>>();
|
||||
if (!users.empty()) {
|
||||
const auto giftBox = show->show(
|
||||
Box(GiftsBox, _controller, users, api, ref));
|
||||
giftBox->boxClosing(
|
||||
) | rpl::start_with_next([=] {
|
||||
_manyGiftsLifetime.destroy();
|
||||
}, giftBox->lifetime());
|
||||
if (users.empty()) {
|
||||
show->showToast(
|
||||
tr::lng_settings_gift_premium_choose(tr::now));
|
||||
}
|
||||
const auto giftBox = show->show(
|
||||
Box(GiftsBox, _controller, users, api, ref));
|
||||
giftBox->boxClosing(
|
||||
) | rpl::start_with_next([=] {
|
||||
_manyGiftsLifetime.destroy();
|
||||
}, giftBox->lifetime());
|
||||
(*ignoreClose) = true;
|
||||
peersBox->closeBox();
|
||||
};
|
||||
@@ -1147,16 +1150,18 @@ void GiftCodeBox(
|
||||
object_ptr<Ui::Premium::TopBar>(
|
||||
box,
|
||||
st::giveawayGiftCodeCover,
|
||||
nullptr,
|
||||
rpl::conditional(
|
||||
state->used.value(),
|
||||
tr::lng_gift_link_used_title(),
|
||||
tr::lng_gift_link_title()),
|
||||
rpl::conditional(
|
||||
state->used.value(),
|
||||
tr::lng_gift_link_used_about(Ui::Text::RichLangValue),
|
||||
tr::lng_gift_link_about(Ui::Text::RichLangValue)),
|
||||
true));
|
||||
Ui::Premium::TopBarDescriptor{
|
||||
.clickContextOther = nullptr,
|
||||
.title = rpl::conditional(
|
||||
state->used.value(),
|
||||
tr::lng_gift_link_used_title(),
|
||||
tr::lng_gift_link_title()),
|
||||
.about = rpl::conditional(
|
||||
state->used.value(),
|
||||
tr::lng_gift_link_used_about(Ui::Text::RichLangValue),
|
||||
tr::lng_gift_link_about(Ui::Text::RichLangValue)),
|
||||
.light = true,
|
||||
}));
|
||||
|
||||
const auto max = st::giveawayGiftCodeTopHeight;
|
||||
bar->setMaximumHeight(max);
|
||||
@@ -1283,13 +1288,15 @@ void GiftCodePendingBox(
|
||||
object_ptr<Ui::Premium::TopBar>(
|
||||
box,
|
||||
st,
|
||||
clickContext,
|
||||
tr::lng_gift_link_title(),
|
||||
tr::lng_gift_link_pending_about(
|
||||
lt_user,
|
||||
rpl::single(Ui::Text::Link(resultToName)),
|
||||
Ui::Text::RichLangValue),
|
||||
true));
|
||||
Ui::Premium::TopBarDescriptor{
|
||||
.clickContextOther = clickContext,
|
||||
.title = tr::lng_gift_link_title(),
|
||||
.about = tr::lng_gift_link_pending_about(
|
||||
lt_user,
|
||||
rpl::single(Ui::Text::Link(resultToName)),
|
||||
Ui::Text::RichLangValue),
|
||||
.light = true,
|
||||
}));
|
||||
|
||||
const auto max = st::giveawayGiftCodeTopHeight;
|
||||
bar->setMaximumHeight(max);
|
||||
@@ -1629,3 +1636,111 @@ void ResolveGiveawayInfo(
|
||||
messageId,
|
||||
crl::guard(controller, show));
|
||||
}
|
||||
|
||||
void AddCreditsHistoryEntryTable(
|
||||
not_null<Window::SessionNavigation*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const Data::CreditsHistoryEntry &entry) {
|
||||
auto table = container->add(
|
||||
object_ptr<Ui::TableLayout>(
|
||||
container,
|
||||
st::giveawayGiftCodeTable),
|
||||
st::giveawayGiftCodeTableMargin);
|
||||
const auto peerId = PeerId(entry.barePeerId);
|
||||
if (peerId) {
|
||||
auto text = tr::lng_credits_box_history_entry_peer();
|
||||
AddTableRow(table, std::move(text), controller, peerId);
|
||||
}
|
||||
if (const auto msgId = MsgId(peerId ? entry.bareMsgId : 0)) {
|
||||
const auto session = &controller->session();
|
||||
const auto peer = session->data().peer(peerId);
|
||||
if (const auto channel = peer->asBroadcast()) {
|
||||
const auto username = channel->username();
|
||||
const auto base = username.isEmpty()
|
||||
? u"c/%1"_q.arg(peerToChannel(channel->id).bare)
|
||||
: username;
|
||||
const auto query = base + '/' + QString::number(msgId.bare);
|
||||
const auto link = session->createInternalLink(query);
|
||||
auto label = object_ptr<Ui::FlatLabel>(
|
||||
table,
|
||||
rpl::single(Ui::Text::Link(link)),
|
||||
st::giveawayGiftCodeValue);
|
||||
label->setClickHandlerFilter([=](const auto &...) {
|
||||
controller->showPeerHistory(channel, {}, msgId);
|
||||
return false;
|
||||
});
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_media(),
|
||||
std::move(label),
|
||||
st::giveawayGiftCodeValueMargin);
|
||||
}
|
||||
}
|
||||
using Type = Data::CreditsHistoryEntry::PeerType;
|
||||
if (entry.peerType == Type::AppStore) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_via(),
|
||||
tr::lng_credits_box_history_entry_app_store(
|
||||
Ui::Text::RichLangValue));
|
||||
} else if (entry.peerType == Type::PlayMarket) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_via(),
|
||||
tr::lng_credits_box_history_entry_play_market(
|
||||
Ui::Text::RichLangValue));
|
||||
} else if (entry.peerType == Type::Fragment) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_via(),
|
||||
tr::lng_credits_box_history_entry_fragment(
|
||||
Ui::Text::RichLangValue));
|
||||
} else if (entry.peerType == Type::Ads) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_via(),
|
||||
tr::lng_credits_box_history_entry_ads(Ui::Text::RichLangValue));
|
||||
}
|
||||
if (!entry.id.isEmpty()) {
|
||||
constexpr auto kOneLineCount = 18;
|
||||
const auto oneLine = entry.id.length() <= kOneLineCount;
|
||||
auto label = object_ptr<Ui::FlatLabel>(
|
||||
table,
|
||||
rpl::single(
|
||||
Ui::Text::Wrapped({ entry.id }, EntityType::Code, {})),
|
||||
oneLine
|
||||
? st::giveawayGiftCodeValue
|
||||
: st::giveawayGiftCodeValueMultiline);
|
||||
label->setClickHandlerFilter([=](const auto &...) {
|
||||
TextUtilities::SetClipboardText(
|
||||
TextForMimeData::Simple(entry.id));
|
||||
controller->showToast(
|
||||
tr::lng_credits_box_history_entry_id_copied(tr::now));
|
||||
return false;
|
||||
});
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_id(),
|
||||
std::move(label),
|
||||
st::giveawayGiftCodeValueMargin);
|
||||
}
|
||||
if (!entry.date.isNull()) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_gift_link_label_date(),
|
||||
rpl::single(Ui::Text::WithEntities(langDateTime(entry.date))));
|
||||
}
|
||||
if (!entry.successDate.isNull()) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_success_date(),
|
||||
rpl::single(Ui::Text::WithEntities(langDateTime(entry.date))));
|
||||
}
|
||||
if (!entry.successLink.isEmpty()) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_success_url(),
|
||||
rpl::single(
|
||||
Ui::Text::Link(entry.successLink, entry.successLink)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@ struct GiftCode;
|
||||
} // namespace Api
|
||||
|
||||
namespace Data {
|
||||
struct CreditsHistoryEntry;
|
||||
struct GiveawayStart;
|
||||
struct GiveawayResults;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
@@ -71,3 +73,8 @@ void ResolveGiveawayInfo(
|
||||
MsgId messageId,
|
||||
std::optional<Data::GiveawayStart> start,
|
||||
std::optional<Data::GiveawayResults> results);
|
||||
|
||||
void AddCreditsHistoryEntryTable(
|
||||
not_null<Window::SessionNavigation*> controller,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
const Data::CreditsHistoryEntry &entry);
|
||||
|
||||
@@ -133,8 +133,8 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
|
||||
auto option = QTextOption(style::al_left);
|
||||
option.setWrapMode(QTextOption::WrapAnywhere);
|
||||
p.setFont(_linkOver
|
||||
? st::defaultInputField.font->underline()
|
||||
: st::defaultInputField.font);
|
||||
? st::defaultInputField.style.font->underline()
|
||||
: st::defaultInputField.style.font);
|
||||
p.setPen(st::defaultLinkButton.color);
|
||||
const auto inviteLinkText = _channel->inviteLink().isEmpty()
|
||||
? tr::lng_group_invite_create(tr::now)
|
||||
|
||||
@@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
#include <xxhash.h> // XXH64.
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
[[nodiscard]] PeerListRowId UniqueRowIdFromString(const QString &d) {
|
||||
return XXH64(d.data(), d.size() * sizeof(ushort), 0);
|
||||
@@ -1552,15 +1553,44 @@ void PeerListContent::handleMouseMove(QPoint globalPosition) {
|
||||
&& *_lastMousePosition == globalPosition) {
|
||||
return;
|
||||
}
|
||||
if (_trackPressStart
|
||||
&& ((*_trackPressStart - globalPosition).manhattanLength()
|
||||
> QApplication::startDragDistance())) {
|
||||
_trackPressStart = {};
|
||||
_controller->rowTrackPressCancel();
|
||||
}
|
||||
if (!_controller->rowTrackPressSkipMouseSelection()) {
|
||||
selectByMouse(globalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
void PeerListContent::pressLeftToContextMenu(bool shown) {
|
||||
if (shown) {
|
||||
setContexted(_pressed);
|
||||
setPressed(Selected());
|
||||
} else {
|
||||
setContexted(Selected());
|
||||
}
|
||||
}
|
||||
|
||||
bool PeerListContent::trackRowPressFromGlobal(QPoint globalPosition) {
|
||||
selectByMouse(globalPosition);
|
||||
if (const auto row = getRow(_selected.index)) {
|
||||
if (_controller->rowTrackPress(row)) {
|
||||
_trackPressStart = globalPosition;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PeerListContent::mousePressEvent(QMouseEvent *e) {
|
||||
_pressButton = e->button();
|
||||
selectByMouse(e->globalPos());
|
||||
setPressed(_selected);
|
||||
if (auto row = getRow(_selected.index)) {
|
||||
auto updateCallback = [this, row, hint = _selected.index] {
|
||||
_trackPressStart = {};
|
||||
if (const auto row = getRow(_selected.index)) {
|
||||
const auto updateCallback = [this, row, hint = _selected.index] {
|
||||
updateRow(row, hint);
|
||||
};
|
||||
if (_selected.element) {
|
||||
@@ -1586,8 +1616,11 @@ void PeerListContent::mousePressEvent(QMouseEvent *e) {
|
||||
row->addRipple(_st.item, maskGenerator, point, std::move(updateCallback));
|
||||
}
|
||||
}
|
||||
if (_pressButton == Qt::LeftButton && _controller->rowTrackPress(row)) {
|
||||
_trackPressStart = e->globalPos();
|
||||
}
|
||||
}
|
||||
if (anim::Disabled() && !_selected.element) {
|
||||
if (anim::Disabled() && !_trackPressStart && !_selected.element) {
|
||||
mousePressReleased(e->button());
|
||||
}
|
||||
}
|
||||
@@ -1597,6 +1630,9 @@ void PeerListContent::mouseReleaseEvent(QMouseEvent *e) {
|
||||
}
|
||||
|
||||
void PeerListContent::mousePressReleased(Qt::MouseButton button) {
|
||||
_trackPressStart = {};
|
||||
_controller->rowTrackPressCancel();
|
||||
|
||||
updateRow(_pressed.index);
|
||||
updateRow(_selected.index);
|
||||
|
||||
|
||||
@@ -348,6 +348,9 @@ public:
|
||||
virtual int peerListPartitionRows(Fn<bool(const PeerListRow &a)> border) = 0;
|
||||
virtual std::shared_ptr<Main::SessionShow> peerListUiShow() = 0;
|
||||
|
||||
virtual void peerListPressLeftToContextMenu(bool shown) = 0;
|
||||
virtual bool peerListTrackRowPressFromGlobal(QPoint globalPosition) = 0;
|
||||
|
||||
template <typename PeerDataRange>
|
||||
void peerListAddSelectedPeers(PeerDataRange &&range) {
|
||||
for (const auto peer : range) {
|
||||
@@ -478,6 +481,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool rowTrackPress(not_null<PeerListRow*> row) {
|
||||
return false;
|
||||
}
|
||||
virtual void rowTrackPressCancel() {
|
||||
}
|
||||
virtual bool rowTrackPressSkipMouseSelection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void loadMoreRows() {
|
||||
}
|
||||
virtual void itemDeselectedHook(not_null<PeerData*> peer) {
|
||||
@@ -655,6 +667,8 @@ public:
|
||||
void refreshRows();
|
||||
|
||||
void mouseLeftGeometry();
|
||||
void pressLeftToContextMenu(bool shown);
|
||||
bool trackRowPressFromGlobal(QPoint globalPosition);
|
||||
|
||||
void setSearchMode(PeerListSearchMode mode);
|
||||
void changeCheckState(
|
||||
@@ -829,6 +843,7 @@ private:
|
||||
bool _mouseSelection = false;
|
||||
std::optional<QPoint> _lastMousePosition;
|
||||
Qt::MouseButton _pressButton = Qt::LeftButton;
|
||||
std::optional<QPoint> _trackPressStart;
|
||||
|
||||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||
|
||||
@@ -992,6 +1007,13 @@ public:
|
||||
bool highlightRow,
|
||||
Fn<void(not_null<Ui::PopupMenu*>)> destroyed = nullptr) override;
|
||||
|
||||
void peerListPressLeftToContextMenu(bool shown) override {
|
||||
_content->pressLeftToContextMenu(shown);
|
||||
}
|
||||
bool peerListTrackRowPressFromGlobal(QPoint globalPosition) override {
|
||||
return _content->trackRowPressFromGlobal(globalPosition);
|
||||
}
|
||||
|
||||
protected:
|
||||
not_null<PeerListContent*> content() const {
|
||||
return _content;
|
||||
|
||||
@@ -42,16 +42,14 @@ namespace {
|
||||
|
||||
constexpr auto kDefaultIconId = DocumentId(0x7FFF'FFFF'FFFF'FFFFULL);
|
||||
|
||||
struct DefaultIcon {
|
||||
QString title;
|
||||
int32 colorId = 0;
|
||||
};
|
||||
using DefaultIcon = Data::TopicIconDescriptor;
|
||||
|
||||
class DefaultIconEmoji final : public Ui::Text::CustomEmoji {
|
||||
public:
|
||||
DefaultIconEmoji(
|
||||
rpl::producer<DefaultIcon> value,
|
||||
Fn<void()> repaint);
|
||||
Fn<void()> repaint,
|
||||
Data::CustomEmojiSizeTag tag);
|
||||
|
||||
int width() override;
|
||||
QString entityData() override;
|
||||
@@ -64,14 +62,17 @@ public:
|
||||
private:
|
||||
DefaultIcon _icon = {};
|
||||
QImage _image;
|
||||
Data::CustomEmojiSizeTag _tag = {};
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
DefaultIconEmoji::DefaultIconEmoji(
|
||||
rpl::producer<DefaultIcon> value,
|
||||
Fn<void()> repaint) {
|
||||
rpl::producer<DefaultIcon> value,
|
||||
Fn<void()> repaint,
|
||||
Data::CustomEmojiSizeTag tag)
|
||||
: _tag(tag) {
|
||||
std::move(value) | rpl::start_with_next([=](DefaultIcon value) {
|
||||
_icon = value;
|
||||
_image = QImage();
|
||||
@@ -88,15 +89,22 @@ QString DefaultIconEmoji::entityData() {
|
||||
}
|
||||
|
||||
void DefaultIconEmoji::paint(QPainter &p, const Context &context) {
|
||||
const auto &st = (_tag == Data::CustomEmojiSizeTag::Normal)
|
||||
? st::normalForumTopicIcon
|
||||
: st::defaultForumTopicIcon;
|
||||
if (_image.isNull()) {
|
||||
_image = Data::ForumTopicIconFrame(
|
||||
_icon.colorId,
|
||||
_icon.title,
|
||||
st::defaultForumTopicIcon);
|
||||
_image = Data::IsForumGeneralIconTitle(_icon.title)
|
||||
? Data::ForumTopicGeneralIconFrame(
|
||||
st.size,
|
||||
Data::ParseForumGeneralIconColor(_icon.colorId))
|
||||
: Data::ForumTopicIconFrame(_icon.colorId, _icon.title, st);
|
||||
}
|
||||
const auto esize = Ui::Emoji::GetSizeLarge() / style::DevicePixelRatio();
|
||||
const auto full = (_tag == Data::CustomEmojiSizeTag::Normal)
|
||||
? Ui::Emoji::GetSizeNormal()
|
||||
: Ui::Emoji::GetSizeLarge();
|
||||
const auto esize = full / style::DevicePixelRatio();
|
||||
const auto customSize = Ui::Text::AdjustCustomEmojiSize(esize);
|
||||
const auto skip = (customSize - st::defaultForumTopicIcon.size) / 2;
|
||||
const auto skip = (customSize - st.size) / 2;
|
||||
p.drawImage(context.position + QPoint(skip, skip), _image);
|
||||
}
|
||||
|
||||
@@ -212,7 +220,7 @@ bool DefaultIconEmoji::readyInDefaultState() {
|
||||
) | rpl::start_with_next([=] {
|
||||
state->frame = Data::ForumTopicGeneralIconFrame(
|
||||
st::largeForumTopicIcon.size,
|
||||
st::windowSubTextFg);
|
||||
st::windowSubTextFg->c);
|
||||
result->update();
|
||||
}, result->lifetime());
|
||||
|
||||
@@ -261,7 +269,8 @@ struct IconSelector {
|
||||
if (id == kDefaultIconId) {
|
||||
return std::make_unique<DefaultIconEmoji>(
|
||||
rpl::duplicate(defaultIcon),
|
||||
repaint);
|
||||
std::move(repaint),
|
||||
tag);
|
||||
}
|
||||
return manager->create(id, std::move(repaint), tag);
|
||||
};
|
||||
@@ -572,3 +581,13 @@ void EditForumTopicBox(
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> MakeTopicIconEmoji(
|
||||
Data::TopicIconDescriptor descriptor,
|
||||
Fn<void()> repaint,
|
||||
Data::CustomEmojiSizeTag tag) {
|
||||
return std::make_unique<DefaultIconEmoji>(
|
||||
rpl::single(descriptor),
|
||||
std::move(repaint),
|
||||
tag);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
class History;
|
||||
|
||||
namespace Data {
|
||||
struct TopicIconDescriptor;
|
||||
enum class CustomEmojiSizeTag : uchar;
|
||||
} // namespace Data
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
@@ -25,3 +30,8 @@ void EditForumTopicBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<History*> forum,
|
||||
MsgId rootId);
|
||||
|
||||
[[nodiscard]] std::unique_ptr<Ui::Text::CustomEmoji> MakeTopicIconEmoji(
|
||||
Data::TopicIconDescriptor descriptor,
|
||||
Fn<void()> repaint,
|
||||
Data::CustomEmojiSizeTag tag);
|
||||
|
||||
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/peers/edit_peer_info_box.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_credits.h"
|
||||
#include "api/api_peer_photo.h"
|
||||
#include "api/api_user_names.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -42,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_premium_limits.h"
|
||||
#include "data/data_user.h"
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "info/bot/earn/info_bot_earn_widget.h"
|
||||
#include "info/channel_statistics/boosts/info_boosts_widget.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "info/info_memento.h"
|
||||
@@ -52,6 +54,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/boxes/boost_box.h"
|
||||
#include "ui/controls/emoji_button.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/toast/toast.h"
|
||||
@@ -71,6 +75,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kBotManagerUsername = "BotFather"_cs;
|
||||
@@ -343,6 +349,7 @@ private:
|
||||
void fillPendingRequestsButton();
|
||||
|
||||
void fillBotUsernamesButton();
|
||||
void fillBotBalanceButton();
|
||||
void fillBotEditIntroButton();
|
||||
void fillBotEditCommandsButton();
|
||||
void fillBotEditSettingsButton();
|
||||
@@ -415,7 +422,12 @@ private:
|
||||
std::deque<FnMut<void()>> _saveStagesQueue;
|
||||
Saving _savingData;
|
||||
|
||||
const rpl::event_stream<Privacy> _privacyTypeUpdates;
|
||||
struct PrivacyAndForwards {
|
||||
Privacy privacy;
|
||||
bool noForwards = false;
|
||||
};
|
||||
|
||||
const rpl::event_stream<PrivacyAndForwards> _privacyTypeUpdates;
|
||||
const rpl::event_stream<ChannelData*> _linkedChatUpdates;
|
||||
mtpRequestId _linkedChatsRequestId = 0;
|
||||
|
||||
@@ -761,7 +773,7 @@ void Controller::refreshHistoryVisibility() {
|
||||
void Controller::showEditPeerTypeBox(
|
||||
std::optional<rpl::producer<QString>> error) {
|
||||
const auto boxCallback = crl::guard(this, [=](EditPeerTypeData data) {
|
||||
_privacyTypeUpdates.fire_copy(data.privacy);
|
||||
_privacyTypeUpdates.fire({ data.privacy, data.noForwards });
|
||||
_typeDataSavedValue = data;
|
||||
refreshHistoryVisibility();
|
||||
});
|
||||
@@ -882,7 +894,8 @@ void Controller::fillPrivacyTypeButton() {
|
||||
? tr::lng_manage_peer_group_type
|
||||
: tr::lng_manage_peer_channel_type)(),
|
||||
_privacyTypeUpdates.events(
|
||||
) | rpl::map([=](Privacy flag) {
|
||||
) | rpl::map([=](PrivacyAndForwards data) {
|
||||
const auto flag = data.privacy;
|
||||
if (flag == Privacy::HasUsername) {
|
||||
_peer->session().api().usernames().requestToCache(_peer);
|
||||
}
|
||||
@@ -894,14 +907,21 @@ void Controller::fillPrivacyTypeButton() {
|
||||
: tr::lng_manage_public_peer_title)()
|
||||
: (hasLocation
|
||||
? tr::lng_manage_peer_link_invite
|
||||
: isGroup
|
||||
: ((!data.noForwards) && isGroup)
|
||||
? tr::lng_manage_private_group_title
|
||||
: tr::lng_manage_private_peer_title)();
|
||||
: ((!data.noForwards) && !isGroup)
|
||||
? tr::lng_manage_private_peer_title
|
||||
: isGroup
|
||||
? tr::lng_manage_private_group_noforwards_title
|
||||
: tr::lng_manage_private_peer_noforwards_title)();
|
||||
}) | rpl::flatten_latest(),
|
||||
[=] { showEditPeerTypeBox(); },
|
||||
{ &st::menuIconCustomize });
|
||||
|
||||
_privacyTypeUpdates.fire_copy(_typeDataSavedValue->privacy);
|
||||
_privacyTypeUpdates.fire_copy({
|
||||
_typeDataSavedValue->privacy,
|
||||
_typeDataSavedValue->noForwards,
|
||||
});
|
||||
}
|
||||
|
||||
void Controller::fillLinkedChatButton() {
|
||||
@@ -1113,6 +1133,7 @@ void Controller::fillManageSection() {
|
||||
|
||||
::AddSkip(container, 0);
|
||||
fillBotUsernamesButton();
|
||||
fillBotBalanceButton();
|
||||
fillBotEditIntroButton();
|
||||
fillBotEditCommandsButton();
|
||||
fillBotEditSettingsButton();
|
||||
@@ -1523,6 +1544,84 @@ void Controller::fillBotUsernamesButton() {
|
||||
{ &st::menuIconLinks });
|
||||
}
|
||||
|
||||
void Controller::fillBotBalanceButton() {
|
||||
Expects(_isBot);
|
||||
|
||||
struct State final {
|
||||
rpl::variable<QString> balance;
|
||||
};
|
||||
|
||||
auto &lifetime = _controls.buttonsLayout->lifetime();
|
||||
const auto state = lifetime.make_state<State>();
|
||||
|
||||
const auto wrap = _controls.buttonsLayout->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
_controls.buttonsLayout,
|
||||
EditPeerInfoBox::CreateButton(
|
||||
_controls.buttonsLayout,
|
||||
tr::lng_manage_peer_bot_balance(),
|
||||
state->balance.value(),
|
||||
[controller = _navigation->parentController(), peer = _peer] {
|
||||
controller->showSection(Info::BotEarn::Make(peer));
|
||||
},
|
||||
st::manageGroupButton,
|
||||
{})));
|
||||
wrap->toggle(false, anim::type::instant);
|
||||
|
||||
const auto button = wrap->entity();
|
||||
{
|
||||
const auto api = button->lifetime().make_state<Api::CreditsStatus>(
|
||||
_peer);
|
||||
api->request({}, [=](Data::CreditsStatusSlice data) {
|
||||
if (data.balance) {
|
||||
wrap->toggle(true, anim::type::normal);
|
||||
}
|
||||
state->balance = QString::number(data.balance);
|
||||
});
|
||||
}
|
||||
{
|
||||
constexpr auto kSizeShift = 3;
|
||||
constexpr auto kStrokeWidth = 5;
|
||||
|
||||
const auto icon = Ui::CreateChild<Ui::RpWidget>(button);
|
||||
icon->resize(Size(st::menuIconLinks.width() - kSizeShift));
|
||||
|
||||
auto colorized = [&] {
|
||||
auto f = QFile(Ui::Premium::Svg());
|
||||
if (!f.open(QIODevice::ReadOnly)) {
|
||||
return QString();
|
||||
}
|
||||
return QString::fromUtf8(
|
||||
f.readAll()).replace(u"#fff"_q, u"#ffffff00"_q);
|
||||
}();
|
||||
colorized.replace(
|
||||
u"stroke=\"none\""_q,
|
||||
u"stroke=\"%1\""_q.arg(st::menuIconColor->c.name()));
|
||||
colorized.replace(
|
||||
u"stroke-width=\"1\""_q,
|
||||
u"stroke-width=\"%1\""_q.arg(kStrokeWidth));
|
||||
const auto svg = icon->lifetime().make_state<QSvgRenderer>(
|
||||
colorized.toUtf8());
|
||||
svg->setViewBox(svg->viewBox() + Margins(kStrokeWidth));
|
||||
|
||||
const auto starSize = Size(icon->height());
|
||||
|
||||
icon->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(icon);
|
||||
svg->render(&p, Rect(starSize));
|
||||
}, icon->lifetime());
|
||||
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
icon->moveToLeft(
|
||||
button->st().iconLeft + kSizeShift / 2.,
|
||||
(size.height() - icon->height()) / 2);
|
||||
}, icon->lifetime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Controller::fillBotEditIntroButton() {
|
||||
Expects(_isBot);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/event_filter.h"
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_document.h"
|
||||
@@ -351,8 +352,8 @@ object_ptr<Ui::RpWidget> AddReactionsSelector(
|
||||
const auto customEmojiPaused = [controller = args.controller] {
|
||||
return controller->isGifPausedAtLeastFor(PauseReason::Layer);
|
||||
};
|
||||
raw->setCustomEmojiFactory([=](QStringView data, Fn<void()> update)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
auto factory = [=](QStringView data, Fn<void()> update)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||
const auto id = Data::ParseCustomEmojiData(data);
|
||||
auto result = owner->customEmojiManager().create(
|
||||
data,
|
||||
@@ -364,7 +365,13 @@ object_ptr<Ui::RpWidget> AddReactionsSelector(
|
||||
}
|
||||
using namespace Ui::Text;
|
||||
return std::make_unique<FirstFrameEmoji>(std::move(result));
|
||||
}, std::move(customEmojiPaused));
|
||||
};
|
||||
raw->setCustomTextContext([=](Fn<void()> repaint) {
|
||||
return std::any(Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = std::move(repaint),
|
||||
});
|
||||
}, customEmojiPaused, customEmojiPaused, std::move(factory));
|
||||
|
||||
const auto callback = args.callback;
|
||||
const auto isCustom = [=](DocumentId id) {
|
||||
|
||||
@@ -398,7 +398,7 @@ void PeerShortInfoCover::paintRadial(QPainter &p) {
|
||||
QImage PeerShortInfoCover::currentVideoFrame() const {
|
||||
const auto size = QSize(_st.size, _st.size);
|
||||
const auto request = Media::Streaming::FrameRequest{
|
||||
.resize = size * style::DevicePixelRatio(),
|
||||
.resize = size,
|
||||
.outer = size,
|
||||
};
|
||||
return (_videoInstance
|
||||
|
||||
@@ -131,6 +131,8 @@ void PreloadSticker(const std::shared_ptr<Data::DocumentMedia> &media) {
|
||||
return tr::lng_premium_summary_subtitle_translation();
|
||||
case PremiumFeature::Business:
|
||||
return tr::lng_premium_summary_subtitle_business();
|
||||
case PremiumFeature::Effects:
|
||||
return tr::lng_premium_summary_subtitle_effects();
|
||||
|
||||
case PremiumFeature::BusinessLocation:
|
||||
return tr::lng_business_subtitle_location();
|
||||
@@ -192,6 +194,8 @@ void PreloadSticker(const std::shared_ptr<Data::DocumentMedia> &media) {
|
||||
return tr::lng_premium_summary_about_translation();
|
||||
case PremiumFeature::Business:
|
||||
return tr::lng_premium_summary_about_business();
|
||||
case PremiumFeature::Effects:
|
||||
return tr::lng_premium_summary_about_effects();
|
||||
|
||||
case PremiumFeature::BusinessLocation:
|
||||
return tr::lng_business_about_location();
|
||||
@@ -286,7 +290,7 @@ void PreloadSticker(const std::shared_ptr<Data::DocumentMedia> &media) {
|
||||
document,
|
||||
media->videoThumbnailContent(),
|
||||
QString(),
|
||||
true);
|
||||
Stickers::EffectType::PremiumSticker);
|
||||
|
||||
const auto update = [=] {
|
||||
if (!state->readyInvoked
|
||||
@@ -529,6 +533,7 @@ struct VideoPreviewDocument {
|
||||
case PremiumFeature::Wallpapers: return "wallpapers";
|
||||
case PremiumFeature::LastSeen: return "last_seen";
|
||||
case PremiumFeature::MessagePrivacy: return "message_privacy";
|
||||
case PremiumFeature::Effects: return "effects";
|
||||
|
||||
case PremiumFeature::BusinessLocation: return "business_location";
|
||||
case PremiumFeature::BusinessHours: return "business_hours";
|
||||
|
||||
@@ -70,6 +70,7 @@ enum class PremiumFeature {
|
||||
LastSeen,
|
||||
MessagePrivacy,
|
||||
Business,
|
||||
Effects,
|
||||
|
||||
// Business features.
|
||||
BusinessLocation,
|
||||
|
||||
@@ -16,8 +16,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/admin_log/history_admin_log_item.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/reactions/history_view_reactions_strip.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/history_view_fake_items.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/premium_preview_box.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -43,53 +44,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace {
|
||||
|
||||
PeerId GenerateUser(not_null<History*> history, const QString &name) {
|
||||
Expects(history->peer->isUser());
|
||||
|
||||
const auto peerId = Data::FakePeerIdForJustName(name);
|
||||
history->owner().processUser(MTP_user(
|
||||
MTP_flags(MTPDuser::Flag::f_first_name | MTPDuser::Flag::f_min),
|
||||
peerToBareMTPInt(peerId),
|
||||
MTP_long(0),
|
||||
MTP_string(tr::lng_settings_chat_message_reply_from(tr::now)),
|
||||
MTPstring(), // last name
|
||||
MTPstring(), // username
|
||||
MTPstring(), // phone
|
||||
MTPUserProfilePhoto(), // profile photo
|
||||
MTPUserStatus(), // status
|
||||
MTP_int(0), // bot info version
|
||||
MTPVector<MTPRestrictionReason>(), // restrictions
|
||||
MTPstring(), // bot placeholder
|
||||
MTPstring(), // lang code
|
||||
MTPEmojiStatus(),
|
||||
MTPVector<MTPUsername>(),
|
||||
MTPint(), // stories_max_id
|
||||
MTPPeerColor(), // color
|
||||
MTPPeerColor())); // profile_color
|
||||
return peerId;
|
||||
}
|
||||
|
||||
AdminLog::OwnedItem GenerateItem(
|
||||
not_null<HistoryView::ElementDelegate*> delegate,
|
||||
not_null<History*> history,
|
||||
PeerId from,
|
||||
FullMsgId replyTo,
|
||||
const QString &text) {
|
||||
Expects(history->peer->isUser());
|
||||
|
||||
const auto item = history->addNewLocalMessage({
|
||||
.id = history->nextNonHistoryEntryId(),
|
||||
.flags = (MessageFlag::FakeHistoryItem
|
||||
| MessageFlag::HasFromId
|
||||
| MessageFlag::HasReplyInfo),
|
||||
.from = from,
|
||||
.replyTo = FullReplyTo{ .messageId = replyTo },
|
||||
.date = base::unixtime::now(),
|
||||
}, TextWithEntities{ .text = text }, MTP_messageMediaEmpty());
|
||||
|
||||
return AdminLog::OwnedItem(delegate, item);
|
||||
}
|
||||
|
||||
void AddMessage(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller,
|
||||
@@ -135,15 +89,15 @@ void AddMessage(
|
||||
|
||||
const auto history = controller->session().data().history(
|
||||
PeerData::kServiceNotificationsId);
|
||||
state->reply = GenerateItem(
|
||||
state->reply = HistoryView::GenerateItem(
|
||||
state->delegate.get(),
|
||||
history,
|
||||
GenerateUser(
|
||||
HistoryView::GenerateUser(
|
||||
history,
|
||||
tr::lng_settings_chat_message_reply_from(tr::now)),
|
||||
FullMsgId(),
|
||||
tr::lng_settings_chat_message_reply(tr::now));
|
||||
auto message = GenerateItem(
|
||||
auto message = HistoryView::GenerateItem(
|
||||
state->delegate.get(),
|
||||
history,
|
||||
history->peer->id,
|
||||
|
||||
381
Telegram/SourceFiles/boxes/send_credits_box.cpp
Normal file
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/send_credits_box.h"
|
||||
|
||||
#include "api/api_credits.h"
|
||||
#include "apiwrap.h"
|
||||
#include "core/ui_integration.h" // Core::MarkedTextContext.
|
||||
#include "data/data_credits.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "payments/payments_checkout_process.h"
|
||||
#include "payments/payments_form.h"
|
||||
#include "settings/settings_credits_graphics.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_top_bar.h" // Ui::Premium::ColorizedSvg.
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_credits.h"
|
||||
#include "styles/style_giveaway.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_premium.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
struct PaidMediaData {
|
||||
const Data::Invoice *invoice = nullptr;
|
||||
HistoryItem *item = nullptr;
|
||||
PeerData *peer = nullptr;
|
||||
int photos = 0;
|
||||
int videos = 0;
|
||||
|
||||
explicit operator bool() const {
|
||||
return invoice && item && peer && (photos || videos);
|
||||
}
|
||||
};
|
||||
|
||||
[[nodiscard]] PaidMediaData LookupPaidMediaData(
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Payments::CreditsFormData*> form) {
|
||||
using namespace Payments;
|
||||
const auto message = std::get_if<InvoiceMessage>(&form->id.value);
|
||||
const auto item = message
|
||||
? session->data().message(message->peer, message->itemId)
|
||||
: nullptr;
|
||||
const auto media = item ? item->media() : nullptr;
|
||||
const auto invoice = media ? media->invoice() : nullptr;
|
||||
if (!invoice || !invoice->isPaidMedia) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto photos = 0;
|
||||
auto videos = 0;
|
||||
for (const auto &media : invoice->extendedMedia) {
|
||||
const auto photo = media->photo();
|
||||
if (photo && !photo->extendedMediaVideoDuration().has_value()) {
|
||||
++photos;
|
||||
} else {
|
||||
++videos;
|
||||
}
|
||||
}
|
||||
|
||||
const auto sender = item->originalSender();
|
||||
const auto broadcast = (sender && sender->isBroadcast())
|
||||
? sender
|
||||
: message->peer.get();
|
||||
return {
|
||||
.invoice = invoice,
|
||||
.item = item,
|
||||
.peer = broadcast,
|
||||
.photos = photos,
|
||||
.videos = videos,
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> SendCreditsConfirmText(
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Payments::CreditsFormData*> form) {
|
||||
if (const auto data = LookupPaidMediaData(session, form)) {
|
||||
auto photos = 0;
|
||||
auto videos = 0;
|
||||
for (const auto &media : data.invoice->extendedMedia) {
|
||||
const auto photo = media->photo();
|
||||
if (photo && !photo->extendedMediaVideoDuration().has_value()) {
|
||||
++photos;
|
||||
} else {
|
||||
++videos;
|
||||
}
|
||||
}
|
||||
|
||||
auto photosBold = tr::lng_credits_box_out_photos(
|
||||
lt_count,
|
||||
rpl::single(photos) | tr::to_count(),
|
||||
Ui::Text::Bold);
|
||||
auto videosBold = tr::lng_credits_box_out_videos(
|
||||
lt_count,
|
||||
rpl::single(videos) | tr::to_count(),
|
||||
Ui::Text::Bold);
|
||||
auto media = (!videos)
|
||||
? ((photos > 1)
|
||||
? std::move(photosBold)
|
||||
: tr::lng_credits_box_out_photo(Ui::Text::WithEntities))
|
||||
: (!photos)
|
||||
? ((videos > 1)
|
||||
? std::move(videosBold)
|
||||
: tr::lng_credits_box_out_video(Ui::Text::WithEntities))
|
||||
: tr::lng_credits_box_out_both(
|
||||
lt_photo,
|
||||
std::move(photosBold),
|
||||
lt_video,
|
||||
std::move(videosBold),
|
||||
Ui::Text::WithEntities);
|
||||
return tr::lng_credits_box_out_media(
|
||||
lt_count,
|
||||
rpl::single(form->invoice.amount) | tr::to_count(),
|
||||
lt_media,
|
||||
std::move(media),
|
||||
lt_chat,
|
||||
rpl::single(Ui::Text::Bold(data.peer->name())),
|
||||
Ui::Text::RichLangValue);
|
||||
}
|
||||
|
||||
const auto bot = session->data().user(form->botId);
|
||||
return tr::lng_credits_box_out_sure(
|
||||
lt_count,
|
||||
rpl::single(form->invoice.amount) | tr::to_count(),
|
||||
lt_text,
|
||||
rpl::single(TextWithEntities{ form->title }),
|
||||
lt_bot,
|
||||
rpl::single(TextWithEntities{ bot->name() }),
|
||||
Ui::Text::RichLangValue);
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> SendCreditsThumbnail(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Payments::CreditsFormData*> form,
|
||||
int photoSize) {
|
||||
if (const auto data = LookupPaidMediaData(session, form)) {
|
||||
const auto first = data.invoice->extendedMedia[0]->photo();
|
||||
const auto second = (data.photos > 1)
|
||||
? data.invoice->extendedMedia[1]->photo()
|
||||
: nullptr;
|
||||
const auto totalCount = int(data.invoice->extendedMedia.size());
|
||||
if (first && first->extendedMediaPreview()) {
|
||||
return Settings::PaidMediaThumbnail(
|
||||
parent,
|
||||
first,
|
||||
second,
|
||||
totalCount,
|
||||
photoSize);
|
||||
}
|
||||
}
|
||||
if (form->photo) {
|
||||
return Settings::HistoryEntryPhoto(parent, form->photo, photoSize);
|
||||
}
|
||||
const auto bot = session->data().user(form->botId);
|
||||
return object_ptr<Ui::UserpicButton>(
|
||||
parent,
|
||||
bot,
|
||||
st::defaultUserpicButton);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SendCreditsBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<Payments::CreditsFormData> form,
|
||||
Fn<void()> sent) {
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
struct State {
|
||||
rpl::variable<bool> confirmButtonBusy = false;
|
||||
};
|
||||
const auto state = box->lifetime().make_state<State>();
|
||||
box->setStyle(st::giveawayGiftCodeBox);
|
||||
box->setNoContentMargin(true);
|
||||
|
||||
const auto session = form->invoice.session;
|
||||
|
||||
const auto photoSize = st::defaultUserpicButton.photoSize;
|
||||
|
||||
const auto content = box->verticalLayout();
|
||||
Ui::AddSkip(content, photoSize / 2);
|
||||
|
||||
{
|
||||
const auto ministarsContainer = Ui::CreateChild<Ui::RpWidget>(box);
|
||||
const auto fullHeight = photoSize * 2;
|
||||
using MiniStars = Ui::Premium::ColoredMiniStars;
|
||||
const auto ministars = box->lifetime().make_state<MiniStars>(
|
||||
ministarsContainer,
|
||||
false,
|
||||
Ui::Premium::MiniStars::Type::BiStars);
|
||||
ministars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
||||
|
||||
ministarsContainer->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(ministarsContainer);
|
||||
ministars->paint(p);
|
||||
}, ministarsContainer->lifetime());
|
||||
|
||||
box->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
ministarsContainer->resize(width, fullHeight);
|
||||
const auto w = fullHeight / 3 * 2;
|
||||
ministars->setCenter(QRect(
|
||||
(width - w) / 2,
|
||||
(fullHeight - w) / 2,
|
||||
w,
|
||||
w));
|
||||
}, ministarsContainer->lifetime());
|
||||
}
|
||||
|
||||
const auto thumb = box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
SendCreditsThumbnail(content, session, form.get(), photoSize)));
|
||||
thumb->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
Ui::AddSkip(content);
|
||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_credits_box_out_title(),
|
||||
st::settingsPremiumUserTitle)));
|
||||
Ui::AddSkip(content);
|
||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
SendCreditsConfirmText(session, form.get()),
|
||||
st::creditsBoxAbout)));
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
const auto button = box->addButton(rpl::single(QString()), [=] {
|
||||
if (state->confirmButtonBusy.current()) {
|
||||
return;
|
||||
}
|
||||
state->confirmButtonBusy = true;
|
||||
session->api().request(
|
||||
MTPpayments_SendStarsForm(
|
||||
MTP_flags(0),
|
||||
MTP_long(form->formId),
|
||||
form->inputInvoice)
|
||||
).done([=](auto result) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->closeBox();
|
||||
sent();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->uiShow()->showToast(error.type());
|
||||
}).send();
|
||||
});
|
||||
{
|
||||
using namespace Info::Statistics;
|
||||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||
button,
|
||||
st::giveawayGiftCodeStartButton.height / 2);
|
||||
AddChildToWidgetCenter(button.data(), loadingAnimation);
|
||||
loadingAnimation->showOn(state->confirmButtonBusy.value());
|
||||
}
|
||||
{
|
||||
auto buttonText = tr::lng_credits_box_out_confirm(
|
||||
lt_count,
|
||||
rpl::single(form->invoice.amount) | tr::to_count(),
|
||||
lt_emoji,
|
||||
rpl::single(CreditsEmojiSmall(session)),
|
||||
Ui::Text::RichLangValue);
|
||||
const auto buttonLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
rpl::single(QString()),
|
||||
st::creditsBoxButtonLabel);
|
||||
std::move(
|
||||
buttonText
|
||||
) | rpl::start_with_next([=](const TextWithEntities &text) {
|
||||
buttonLabel->setMarkedText(
|
||||
text,
|
||||
Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = [=] { buttonLabel->update(); },
|
||||
});
|
||||
}, buttonLabel->lifetime());
|
||||
buttonLabel->setTextColorOverride(
|
||||
box->getDelegate()->style().button.textFg->c);
|
||||
button->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
buttonLabel->moveToLeft(
|
||||
(size.width() - buttonLabel->width()) / 2,
|
||||
(size.height() - buttonLabel->height()) / 2);
|
||||
}, buttonLabel->lifetime());
|
||||
buttonLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
state->confirmButtonBusy.value(
|
||||
) | rpl::start_with_next([=](bool busy) {
|
||||
buttonLabel->setVisible(!busy);
|
||||
}, buttonLabel->lifetime());
|
||||
}
|
||||
|
||||
const auto buttonWidth = st::boxWidth
|
||||
- rect::m::sum::h(st::giveawayGiftCodeBox.buttonPadding);
|
||||
button->widthValue() | rpl::filter([=] {
|
||||
return (button->widthNoMargins() != buttonWidth);
|
||||
}) | rpl::start_with_next([=] {
|
||||
button->resizeToWidth(buttonWidth);
|
||||
}, button->lifetime());
|
||||
|
||||
{
|
||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
||||
box.get(),
|
||||
st::boxTitleClose);
|
||||
close->setClickedCallback([=] {
|
||||
box->closeBox();
|
||||
});
|
||||
box->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
close->moveToRight(0, 0);
|
||||
close->raise();
|
||||
}, close->lifetime());
|
||||
}
|
||||
|
||||
{
|
||||
const auto balance = Settings::AddBalanceWidget(
|
||||
content,
|
||||
session->creditsValue(),
|
||||
false);
|
||||
const auto api = balance->lifetime().make_state<Api::CreditsStatus>(
|
||||
session->user());
|
||||
api->request({}, [=](Data::CreditsStatusSlice slice) {
|
||||
session->setCredits(slice.balance);
|
||||
});
|
||||
rpl::combine(
|
||||
balance->sizeValue(),
|
||||
content->sizeValue()
|
||||
) | rpl::start_with_next([=](const QSize &, const QSize &) {
|
||||
balance->moveToLeft(
|
||||
st::creditsHistoryRightSkip * 2,
|
||||
st::creditsHistoryRightSkip);
|
||||
balance->update();
|
||||
}, balance->lifetime());
|
||||
}
|
||||
}
|
||||
|
||||
TextWithEntities CreditsEmoji(not_null<Main::Session*> session) {
|
||||
return Ui::Text::SingleCustomEmoji(
|
||||
session->data().customEmojiManager().registerInternalEmoji(
|
||||
st::settingsPremiumIconStar,
|
||||
QMargins{ 0, -st::moderateBoxExpandInnerSkip, 0, 0 },
|
||||
true),
|
||||
QString(QChar(0x2B50)));
|
||||
}
|
||||
|
||||
TextWithEntities CreditsEmojiSmall(not_null<Main::Session*> session) {
|
||||
return Ui::Text::SingleCustomEmoji(
|
||||
session->data().customEmojiManager().registerInternalEmoji(
|
||||
st::starIconSmall,
|
||||
st::starIconSmallPadding,
|
||||
true),
|
||||
QString(QChar(0x2B50)));
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
35
Telegram/SourceFiles/boxes/send_credits_box.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
class HistoryItem;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Payments {
|
||||
struct CreditsFormData;
|
||||
} // namespace Payments
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class GenericBox;
|
||||
|
||||
void SendCreditsBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<Payments::CreditsFormData> data,
|
||||
Fn<void()> sent);
|
||||
|
||||
[[nodiscard]] TextWithEntities CreditsEmoji(
|
||||
not_null<Main::Session*> session);
|
||||
|
||||
[[nodiscard]] TextWithEntities CreditsEmojiSmall(
|
||||
not_null<Main::Session*> session);
|
||||
|
||||
} // namespace Ui
|
||||
@@ -10,7 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "storage/storage_media_prepare.h"
|
||||
#include "iv/iv_instance.h"
|
||||
#include "mainwidget.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
@@ -24,11 +26,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/controls/history_view_characters_limit.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "boxes/premium_limits_box.h"
|
||||
#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"
|
||||
@@ -36,10 +41,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/chat/attach/attach_single_file_preview.h"
|
||||
#include "ui/chat/attach/attach_single_media_preview.h"
|
||||
#include "ui/grouped_layout.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/controls/emoji_button.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "lottie/lottie_single_player.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
||||
@@ -103,6 +111,84 @@ rpl::producer<QString> FieldPlaceholder(
|
||||
: tr::lng_photos_comment();
|
||||
}
|
||||
|
||||
void EditPriceBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
uint64 price,
|
||||
Fn<void(uint64)> apply) {
|
||||
box->setTitle(tr::lng_paid_title());
|
||||
AddSubsectionTitle(
|
||||
box->verticalLayout(),
|
||||
tr::lng_paid_enter_cost(),
|
||||
(st::boxRowPadding - QMargins(
|
||||
st::defaultSubsectionTitlePadding.left(),
|
||||
0,
|
||||
st::defaultSubsectionTitlePadding.right(),
|
||||
0)));
|
||||
const auto limit = session->appConfig().get<int>(
|
||||
u"stars_paid_post_amount_max"_q,
|
||||
10'000);
|
||||
const auto wrap = box->addRow(object_ptr<Ui::FixedHeightWidget>(
|
||||
box,
|
||||
st::editTagField.heightMin));
|
||||
auto owned = object_ptr<Ui::NumberInput>(
|
||||
wrap,
|
||||
st::editTagField,
|
||||
tr::lng_paid_cost_placeholder(),
|
||||
price ? QString::number(price) : QString(),
|
||||
limit);
|
||||
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();
|
||||
box->setFocusCallback([=] {
|
||||
field->setFocusFast();
|
||||
});
|
||||
const auto about = box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_paid_about(
|
||||
lt_link,
|
||||
tr::lng_paid_about_link() | Ui::Text::ToLink(),
|
||||
Ui::Text::WithEntities),
|
||||
st::paidAmountAbout),
|
||||
st::boxRowPadding + QMargins(0, st::sendMediaRowSkip, 0, 0));
|
||||
about->setClickHandlerFilter([=](const auto &...) {
|
||||
Core::App().iv().openWithIvPreferred(
|
||||
session,
|
||||
tr::lng_paid_about_link_url(tr::now));
|
||||
return false;
|
||||
});
|
||||
|
||||
field->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
||||
auto p = QPainter(field);
|
||||
st::paidStarIcon.paint(p, 0, st::paidStarIconTop, field->width());
|
||||
}, field->lifetime());
|
||||
|
||||
const auto save = [=] {
|
||||
const auto now = field->getLastText().toULongLong();
|
||||
if (now > limit) {
|
||||
field->showError();
|
||||
return;
|
||||
}
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
apply(now);
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
|
||||
QObject::connect(field, &Ui::NumberInput::submitted, box, save);
|
||||
|
||||
box->addButton(tr::lng_settings_save(), save);
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SendFilesLimits DefaultLimitsForPeer(not_null<PeerData*> peer) {
|
||||
@@ -153,7 +239,8 @@ SendFilesBox::Block::Block(
|
||||
int from,
|
||||
int till,
|
||||
Fn<bool()> gifPaused,
|
||||
SendFilesWay way)
|
||||
SendFilesWay way,
|
||||
Fn<bool()> canToggleSpoiler)
|
||||
: _items(items)
|
||||
, _from(from)
|
||||
, _till(till) {
|
||||
@@ -170,14 +257,16 @@ SendFilesBox::Block::Block(
|
||||
parent.get(),
|
||||
st,
|
||||
my,
|
||||
way);
|
||||
way,
|
||||
std::move(canToggleSpoiler));
|
||||
_preview.reset(preview);
|
||||
} else {
|
||||
const auto media = Ui::SingleMediaPreview::Create(
|
||||
parent,
|
||||
st,
|
||||
gifPaused,
|
||||
first);
|
||||
first,
|
||||
std::move(canToggleSpoiler));
|
||||
if (media) {
|
||||
_isSingleMedia = true;
|
||||
_preview.reset(media);
|
||||
@@ -253,6 +342,14 @@ rpl::producer<int> SendFilesBox::Block::itemModifyRequest() const {
|
||||
}
|
||||
}
|
||||
|
||||
rpl::producer<> SendFilesBox::Block::orderUpdated() const {
|
||||
if (_isAlbum) {
|
||||
const auto album = static_cast<Ui::AlbumPreview*>(_preview.get());
|
||||
return album->orderUpdated();
|
||||
}
|
||||
return rpl::never<>();
|
||||
}
|
||||
|
||||
void SendFilesBox::Block::setSendWay(Ui::SendFilesWay way) {
|
||||
if (!_isAlbum) {
|
||||
if (_isSingleMedia) {
|
||||
@@ -321,6 +418,18 @@ void SendFilesBox::Block::applyChanges() {
|
||||
}
|
||||
}
|
||||
|
||||
QImage SendFilesBox::Block::generatePriceTagBackground() const {
|
||||
const auto preview = _preview.get();
|
||||
if (_isAlbum) {
|
||||
const auto album = static_cast<Ui::AlbumPreview*>(preview);
|
||||
return album->generatePriceTagBackground();
|
||||
} else if (_isSingleMedia) {
|
||||
const auto media = static_cast<Ui::SingleMediaPreview*>(preview);
|
||||
return media->generatePriceTagBackground();
|
||||
}
|
||||
return QImage();
|
||||
}
|
||||
|
||||
SendFilesBox::SendFilesBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
@@ -328,7 +437,7 @@ SendFilesBox::SendFilesBox(
|
||||
const TextWithTags &caption,
|
||||
not_null<PeerData*> toPeer,
|
||||
Api::SendType sendType,
|
||||
SendMenu::Type sendMenuType)
|
||||
SendMenu::Details sendMenuDetails)
|
||||
: SendFilesBox(nullptr, {
|
||||
.show = controller->uiShow(),
|
||||
.list = std::move(list),
|
||||
@@ -337,7 +446,7 @@ SendFilesBox::SendFilesBox(
|
||||
.limits = DefaultLimitsForPeer(toPeer),
|
||||
.check = DefaultCheckForPeer(controller, toPeer),
|
||||
.sendType = sendType,
|
||||
.sendMenuType = sendMenuType,
|
||||
.sendMenuDetails = [=] { return sendMenuDetails; },
|
||||
}) {
|
||||
}
|
||||
|
||||
@@ -350,7 +459,8 @@ SendFilesBox::SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor)
|
||||
, _titleHeight(st::boxTitleHeight)
|
||||
, _list(std::move(descriptor.list))
|
||||
, _limits(descriptor.limits)
|
||||
, _sendMenuType(descriptor.sendMenuType)
|
||||
, _sendMenuDetails(prepareSendMenuDetails(descriptor))
|
||||
, _sendMenuCallback(prepareSendMenuCallback())
|
||||
, _captionToPeer(descriptor.captionToPeer)
|
||||
, _check(std::move(descriptor.check))
|
||||
, _confirmedCallback(std::move(descriptor.confirmed))
|
||||
@@ -364,6 +474,54 @@ SendFilesBox::SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor)
|
||||
enqueueNextPrepare();
|
||||
}
|
||||
|
||||
Fn<SendMenu::Details()> SendFilesBox::prepareSendMenuDetails(
|
||||
const SendFilesBoxDescriptor &descriptor) {
|
||||
auto initial = descriptor.sendMenuDetails;
|
||||
return crl::guard(this, [=] {
|
||||
auto result = initial ? initial() : SendMenu::Details();
|
||||
result.spoiler = !hasSpoilerMenu()
|
||||
? SendMenu::SpoilerState::None
|
||||
: allWithSpoilers()
|
||||
? SendMenu::SpoilerState::Enabled
|
||||
: SendMenu::SpoilerState::Possible;
|
||||
const auto way = _sendWay.current();
|
||||
const auto canMoveCaption = _list.canMoveCaption(
|
||||
way.groupFiles() && way.sendImagesAsPhotos(),
|
||||
way.sendImagesAsPhotos()
|
||||
) && _caption && HasSendText(_caption);
|
||||
result.caption = !canMoveCaption
|
||||
? SendMenu::CaptionState::None
|
||||
: _invertCaption
|
||||
? SendMenu::CaptionState::Above
|
||||
: SendMenu::CaptionState::Below;
|
||||
result.price = canChangePrice()
|
||||
? _price.current()
|
||||
: std::optional<uint64>();
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
auto SendFilesBox::prepareSendMenuCallback()
|
||||
-> Fn<void(MenuAction, MenuDetails)> {
|
||||
return crl::guard(this, [=](MenuAction action, MenuDetails details) {
|
||||
using Type = SendMenu::ActionType;
|
||||
switch (action.type) {
|
||||
case Type::CaptionDown: _invertCaption = false; break;
|
||||
case Type::CaptionUp: _invertCaption = true; break;
|
||||
case Type::SpoilerOn: toggleSpoilers(true); break;
|
||||
case Type::SpoilerOff: toggleSpoilers(false); break;
|
||||
case Type::ChangePrice: changePrice(); break;
|
||||
default:
|
||||
SendMenu::DefaultCallback(
|
||||
_show,
|
||||
sendCallback())(
|
||||
action,
|
||||
details);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SendFilesBox::initPreview() {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
@@ -529,10 +687,9 @@ void SendFilesBox::refreshButtons() {
|
||||
if (_sendType == Api::SendType::Normal) {
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send,
|
||||
[=] { return _sendMenuType; },
|
||||
[=] { sendSilent(); },
|
||||
[=] { sendScheduled(); },
|
||||
[=] { sendWhenOnline(); });
|
||||
_show,
|
||||
_sendMenuDetails,
|
||||
_sendMenuCallback);
|
||||
}
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
_addFile = addLeftButton(
|
||||
@@ -544,21 +701,27 @@ void SendFilesBox::refreshButtons() {
|
||||
addMenuButton();
|
||||
}
|
||||
|
||||
bool SendFilesBox::hasSendMenu() const {
|
||||
return (_sendMenuType != SendMenu::Type::Disabled);
|
||||
bool SendFilesBox::hasSendMenu(const MenuDetails &details) const {
|
||||
return (details.type != SendMenu::Type::Disabled)
|
||||
|| (details.spoiler != SendMenu::SpoilerState::None)
|
||||
|| (details.caption != SendMenu::CaptionState::None);
|
||||
}
|
||||
|
||||
bool SendFilesBox::hasSpoilerMenu() const {
|
||||
const auto allAreVideo = !ranges::any_of(_list.files, [](const auto &f) {
|
||||
using Type = Ui::PreparedFile::Type;
|
||||
return (f.type != Type::Video);
|
||||
});
|
||||
const auto allAreMedia = !ranges::any_of(_list.files, [](const auto &f) {
|
||||
using Type = Ui::PreparedFile::Type;
|
||||
return (f.type != Type::Photo) && (f.type != Type::Video);
|
||||
});
|
||||
return allAreVideo
|
||||
|| (allAreMedia && _sendWay.current().sendImagesAsPhotos());
|
||||
return !hasPrice()
|
||||
&& _list.hasSpoilerMenu(_sendWay.current().sendImagesAsPhotos());
|
||||
}
|
||||
|
||||
bool SendFilesBox::canChangePrice() const {
|
||||
const auto way = _sendWay.current();
|
||||
const auto broadcast = _captionToPeer
|
||||
? _captionToPeer->asBroadcast()
|
||||
: nullptr;
|
||||
return broadcast
|
||||
&& broadcast->canPostPaidMedia()
|
||||
&& _list.canChangePrice(
|
||||
way.groupFiles() && way.sendImagesAsPhotos(),
|
||||
way.sendImagesAsPhotos());
|
||||
}
|
||||
|
||||
void SendFilesBox::applyBlockChanges() {
|
||||
@@ -581,41 +744,139 @@ void SendFilesBox::toggleSpoilers(bool enabled) {
|
||||
}
|
||||
}
|
||||
|
||||
void SendFilesBox::changePrice() {
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto session = &_show->session();
|
||||
const auto now = _price.current();
|
||||
_show->show(Box(EditPriceBox, session, now, [=](uint64 price) {
|
||||
if (weak && price != now) {
|
||||
_price = price;
|
||||
refreshPriceTag();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
bool SendFilesBox::hasPrice() const {
|
||||
return canChangePrice() && _price.current() > 0;
|
||||
}
|
||||
|
||||
void SendFilesBox::refreshPriceTag() {
|
||||
const auto resetSpoilers = hasPrice() || _priceTag;
|
||||
if (resetSpoilers) {
|
||||
for (auto &file : _list.files) {
|
||||
file.spoiler = false;
|
||||
}
|
||||
for (auto &block : _blocks) {
|
||||
block.toggleSpoilers(hasPrice());
|
||||
}
|
||||
}
|
||||
if (!hasPrice()) {
|
||||
_priceTag = nullptr;
|
||||
_priceTagBg = QImage();
|
||||
} else if (!_priceTag) {
|
||||
_priceTag = std::make_unique<Ui::RpWidget>(_inner.data());
|
||||
const auto raw = _priceTag.get();
|
||||
|
||||
raw->show();
|
||||
raw->paintRequest() | rpl::start_with_next([=] {
|
||||
if (_priceTagBg.isNull()) {
|
||||
_priceTagBg = preparePriceTagBg(raw->size());
|
||||
}
|
||||
QPainter(raw).drawImage(0, 0, _priceTagBg);
|
||||
}, raw->lifetime());
|
||||
|
||||
const auto session = &_show->session();
|
||||
auto price = _price.value() | rpl::map([=](uint64 amount) {
|
||||
auto result = Ui::Text::Colorized(Ui::CreditsEmoji(session));
|
||||
result.append(Lang::FormatCountDecimal(amount));
|
||||
return result;
|
||||
});
|
||||
auto text = tr::lng_paid_price(
|
||||
lt_price,
|
||||
std::move(price),
|
||||
Ui::Text::WithEntities);
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
raw,
|
||||
QString(),
|
||||
st::paidTagLabel);
|
||||
std::move(text) | rpl::start_with_next([=](TextWithEntities &&text) {
|
||||
label->setMarkedText(text, Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = [=] { label->update(); },
|
||||
});
|
||||
}, label->lifetime());
|
||||
label->show();
|
||||
label->sizeValue() | rpl::start_with_next([=](QSize size) {
|
||||
const auto inner = QRect(QPoint(), size);
|
||||
const auto rect = inner.marginsAdded(st::paidTagPadding);
|
||||
raw->resize(rect.size());
|
||||
label->move(-rect.topLeft());
|
||||
}, label->lifetime());
|
||||
_inner->sizeValue() | rpl::start_with_next([=](QSize size) {
|
||||
raw->move(
|
||||
(size.width() - raw->width()) / 2,
|
||||
(size.height() - raw->height()) / 2);
|
||||
}, raw->lifetime());
|
||||
} else {
|
||||
_priceTag->raise();
|
||||
_priceTag->update();
|
||||
_priceTagBg = QImage();
|
||||
}
|
||||
}
|
||||
|
||||
QImage SendFilesBox::preparePriceTagBg(QSize size) const {
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto outer = _blocks.empty()
|
||||
? size
|
||||
: _inner->widgetAt(0)->geometry().size();
|
||||
auto bg = _blocks.empty()
|
||||
? QImage()
|
||||
: _blocks.front().generatePriceTagBackground();
|
||||
if (bg.isNull()) {
|
||||
bg = QImage(ratio, ratio, QImage::Format_ARGB32_Premultiplied);
|
||||
bg.fill(Qt::black);
|
||||
}
|
||||
|
||||
auto result = QImage(size * ratio, QImage::Format_ARGB32_Premultiplied);
|
||||
result.setDevicePixelRatio(ratio);
|
||||
result.fill(Qt::black);
|
||||
auto p = QPainter(&result);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.drawImage(
|
||||
QRect(
|
||||
(size.width() - outer.width()) / 2,
|
||||
(size.height() - outer.height()) / 2,
|
||||
outer.width(),
|
||||
outer.height()),
|
||||
bg);
|
||||
p.fillRect(QRect(QPoint(), size), st::msgDateImgBg);
|
||||
p.end();
|
||||
|
||||
const auto radius = std::min(size.width(), size.height()) / 2;
|
||||
return Images::Round(std::move(result), Images::CornersMask(radius));
|
||||
}
|
||||
|
||||
void SendFilesBox::addMenuButton() {
|
||||
if (!hasSendMenu() && !hasSpoilerMenu()) {
|
||||
const auto details = _sendMenuDetails();
|
||||
if (!hasSendMenu(details)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto top = addTopButton(_st.files.menu);
|
||||
top->setClickedCallback([=] {
|
||||
const auto &tabbed = _st.tabbed;
|
||||
const auto &icons = tabbed.icons;
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(top, tabbed.menu);
|
||||
if (hasSpoilerMenu()) {
|
||||
const auto spoilered = allWithSpoilers();
|
||||
_menu->addAction(
|
||||
(spoilered
|
||||
? tr::lng_context_disable_spoiler(tr::now)
|
||||
: tr::lng_context_spoiler_effect(tr::now)),
|
||||
[=] { toggleSpoilers(!spoilered); },
|
||||
spoilered ? &icons.menuSpoilerOff : &icons.menuSpoiler);
|
||||
if (hasSendMenu()) {
|
||||
_menu->addSeparator(&tabbed.expandedSeparator);
|
||||
}
|
||||
}
|
||||
if (hasSendMenu()) {
|
||||
SendMenu::FillSendMenu(
|
||||
_menu.get(),
|
||||
_sendMenuType,
|
||||
[=] { sendSilent(); },
|
||||
[=] { sendScheduled(); },
|
||||
[=] { sendWhenOnline(); },
|
||||
&_st.tabbed.icons);
|
||||
}
|
||||
_menu->popup(QCursor::pos());
|
||||
const auto position = QCursor::pos();
|
||||
SendMenu::FillSendMenu(
|
||||
_menu.get(),
|
||||
_show,
|
||||
_sendMenuDetails(),
|
||||
_sendMenuCallback,
|
||||
&_st.tabbed.icons,
|
||||
position);
|
||||
_menu->popup(position);
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void SendFilesBox::initSendWay() {
|
||||
@@ -657,9 +918,8 @@ void SendFilesBox::initSendWay() {
|
||||
for (auto &block : _blocks) {
|
||||
block.setSendWay(value);
|
||||
}
|
||||
if (!hasSendMenu()) {
|
||||
refreshButtons();
|
||||
}
|
||||
refreshButtons();
|
||||
refreshPriceTag();
|
||||
if (was != hidden()) {
|
||||
updateBoxSize();
|
||||
updateControlsGeometry();
|
||||
@@ -745,7 +1005,8 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||
from,
|
||||
till,
|
||||
gifPaused,
|
||||
_sendWay.current());
|
||||
_sendWay.current(),
|
||||
[=] { return !hasPrice(); });
|
||||
auto &block = _blocks.back();
|
||||
const auto widget = _inner->add(
|
||||
block.takeWidget(),
|
||||
@@ -868,12 +1129,18 @@ void SendFilesBox::pushBlock(int from, int till) {
|
||||
st::sendMediaPreviewSize,
|
||||
[=] { refreshAllAfterChanges(from); });
|
||||
}, widget->lifetime());
|
||||
|
||||
block.orderUpdated() | rpl::start_with_next([=]{
|
||||
if (_priceTag) {
|
||||
_priceTagBg = QImage();
|
||||
_priceTag->update();
|
||||
}
|
||||
}, widget->lifetime());
|
||||
}
|
||||
|
||||
void SendFilesBox::refreshControls(bool initial) {
|
||||
if (initial || !hasSendMenu()) {
|
||||
refreshButtons();
|
||||
}
|
||||
refreshButtons();
|
||||
refreshPriceTag();
|
||||
refreshTitleText();
|
||||
updateSendWayControls();
|
||||
updateCaptionPlaceholder();
|
||||
@@ -1425,7 +1692,13 @@ void SendFilesBox::send(
|
||||
if ((_sendType == Api::SendType::Scheduled
|
||||
|| _sendType == Api::SendType::ScheduledToUser)
|
||||
&& !options.scheduled) {
|
||||
return sendScheduled();
|
||||
auto child = _sendMenuDetails();
|
||||
child.spoiler = SendMenu::SpoilerState::None;
|
||||
child.caption = SendMenu::CaptionState::None;
|
||||
child.price = std::nullopt;
|
||||
return SendMenu::DefaultCallback(_show, sendCallback())(
|
||||
{ .type = SendMenu::ActionType::Schedule },
|
||||
child);
|
||||
}
|
||||
if (_preparing) {
|
||||
_whenReadySend = [=] {
|
||||
@@ -1453,6 +1726,13 @@ void SendFilesBox::send(
|
||||
if (!validateLength(caption.text)) {
|
||||
return;
|
||||
}
|
||||
options.invertCaption = _invertCaption;
|
||||
options.price = hasPrice() ? _price.current() : 0;
|
||||
if (options.price > 0) {
|
||||
for (auto &file : _list.files) {
|
||||
file.spoiler = false;
|
||||
}
|
||||
}
|
||||
_confirmedCallback(
|
||||
std::move(_list),
|
||||
_sendWay.current(),
|
||||
@@ -1463,25 +1743,10 @@ void SendFilesBox::send(
|
||||
closeBox();
|
||||
}
|
||||
|
||||
void SendFilesBox::sendSilent() {
|
||||
send({ .silent = true });
|
||||
}
|
||||
|
||||
void SendFilesBox::sendScheduled() {
|
||||
const auto type = (_sendType == Api::SendType::ScheduledToUser)
|
||||
? SendMenu::Type::ScheduledToUser
|
||||
: _sendMenuType;
|
||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||
auto box = HistoryView::PrepareScheduleBox(this, type, callback);
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
_show->showBox(std::move(box));
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->setCloseByOutsideClick(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SendFilesBox::sendWhenOnline() {
|
||||
send(Api::DefaultSendWhenOnlineOptions());
|
||||
Fn<void(Api::SendOptions)> SendFilesBox::sendCallback() {
|
||||
return crl::guard(this, [=](Api::SendOptions options) {
|
||||
send(options, false);
|
||||
});
|
||||
}
|
||||
|
||||
SendFilesBox::~SendFilesBox() = default;
|
||||
|
||||
@@ -47,7 +47,8 @@ class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
struct Action;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace HistoryView::Controls {
|
||||
@@ -96,7 +97,7 @@ struct SendFilesBoxDescriptor {
|
||||
SendFilesLimits limits = {};
|
||||
SendFilesCheck check;
|
||||
Api::SendType sendType = {};
|
||||
SendMenu::Type sendMenuType = {};
|
||||
Fn<SendMenu::Details()> sendMenuDetails = nullptr;
|
||||
const style::ComposeControls *stOverride = nullptr;
|
||||
SendFilesConfirmed confirmed;
|
||||
Fn<void()> cancelled;
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
const TextWithTags &caption,
|
||||
not_null<PeerData*> toPeer,
|
||||
Api::SendType sendType,
|
||||
SendMenu::Type sendMenuType);
|
||||
SendMenu::Details sendMenuDetails);
|
||||
SendFilesBox(QWidget*, SendFilesBoxDescriptor &&descriptor);
|
||||
|
||||
void setConfirmedCallback(SendFilesConfirmed callback) {
|
||||
@@ -136,6 +137,9 @@ protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
using MenuAction = SendMenu::Action;
|
||||
using MenuDetails = SendMenu::Details;
|
||||
|
||||
class Block final {
|
||||
public:
|
||||
Block(
|
||||
@@ -145,7 +149,8 @@ private:
|
||||
int from,
|
||||
int till,
|
||||
Fn<bool()> gifPaused,
|
||||
Ui::SendFilesWay way);
|
||||
Ui::SendFilesWay way,
|
||||
Fn<bool()> canToggleSpoiler);
|
||||
Block(Block &&other) = default;
|
||||
Block &operator=(Block &&other) = default;
|
||||
|
||||
@@ -156,11 +161,14 @@ private:
|
||||
[[nodiscard]] rpl::producer<int> itemDeleteRequest() const;
|
||||
[[nodiscard]] rpl::producer<int> itemReplaceRequest() const;
|
||||
[[nodiscard]] rpl::producer<int> itemModifyRequest() const;
|
||||
[[nodiscard]] rpl::producer<> orderUpdated() const;
|
||||
|
||||
void setSendWay(Ui::SendFilesWay way);
|
||||
void toggleSpoilers(bool enabled);
|
||||
void applyChanges();
|
||||
|
||||
[[nodiscard]] QImage generatePriceTagBackground() const;
|
||||
|
||||
private:
|
||||
base::unique_qptr<Ui::RpWidget> _preview;
|
||||
not_null<std::vector<Ui::PreparedFile>*> _items;
|
||||
@@ -173,7 +181,7 @@ private:
|
||||
|
||||
void initSendWay();
|
||||
void initPreview();
|
||||
[[nodiscard]] bool hasSendMenu() const;
|
||||
[[nodiscard]] bool hasSendMenu(const MenuDetails &details) const;
|
||||
[[nodiscard]] bool hasSpoilerMenu() const;
|
||||
[[nodiscard]] bool allWithSpoilers();
|
||||
[[nodiscard]] bool checkWithWay(
|
||||
@@ -186,6 +194,12 @@ private:
|
||||
void addMenuButton();
|
||||
void applyBlockChanges();
|
||||
void toggleSpoilers(bool enabled);
|
||||
void changePrice();
|
||||
|
||||
[[nodiscard]] bool canChangePrice() const;
|
||||
[[nodiscard]] bool hasPrice() const;
|
||||
void refreshPriceTag();
|
||||
[[nodiscard]] QImage preparePriceTagBg(QSize size) const;
|
||||
|
||||
bool validateLength(const QString &text) const;
|
||||
void refreshButtons();
|
||||
@@ -202,9 +216,7 @@ private:
|
||||
void generatePreviewFrom(int fromBlock);
|
||||
|
||||
void send(Api::SendOptions options, bool ctrlShiftEnter = false);
|
||||
void sendSilent();
|
||||
void sendScheduled();
|
||||
void sendWhenOnline();
|
||||
[[nodiscard]] Fn<void(Api::SendOptions)> sendCallback();
|
||||
void captionResized();
|
||||
void saveSendWaySettings();
|
||||
|
||||
@@ -227,6 +239,11 @@ private:
|
||||
|
||||
void checkCharsLimitation();
|
||||
|
||||
[[nodiscard]] Fn<MenuDetails()> prepareSendMenuDetails(
|
||||
const SendFilesBoxDescriptor &descriptor);
|
||||
[[nodiscard]] auto prepareSendMenuCallback()
|
||||
-> Fn<void(MenuAction, MenuDetails)>;
|
||||
|
||||
const std::shared_ptr<ChatHelpers::Show> _show;
|
||||
const style::ComposeControls &_st;
|
||||
const Api::SendType _sendType = Api::SendType();
|
||||
@@ -238,12 +255,17 @@ private:
|
||||
std::optional<int> _removingIndex;
|
||||
|
||||
SendFilesLimits _limits = {};
|
||||
SendMenu::Type _sendMenuType = {};
|
||||
Fn<MenuDetails()> _sendMenuDetails;
|
||||
Fn<void(MenuAction, MenuDetails)> _sendMenuCallback;
|
||||
PeerData *_captionToPeer = nullptr;
|
||||
SendFilesCheck _check;
|
||||
SendFilesConfirmed _confirmedCallback;
|
||||
Fn<void()> _cancelledCallback;
|
||||
rpl::variable<uint64> _price = 0;
|
||||
std::unique_ptr<Ui::RpWidget> _priceTag;
|
||||
QImage _priceTagBg;
|
||||
bool _confirmed = false;
|
||||
bool _invertCaption = false;
|
||||
|
||||
object_ptr<Ui::InputField> _caption = { nullptr };
|
||||
TextWithTags _prefilledCaptionText;
|
||||
|
||||
@@ -473,15 +473,18 @@ void ShareBox::keyPressEvent(QKeyEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
SendMenu::Type ShareBox::sendMenuType() const {
|
||||
SendMenu::Details ShareBox::sendMenuDetails() const {
|
||||
const auto selected = _inner->selected();
|
||||
return ranges::all_of(
|
||||
const auto type = ranges::all_of(
|
||||
selected | ranges::views::transform(&Data::Thread::peer),
|
||||
HistoryView::CanScheduleUntilOnline)
|
||||
? SendMenu::Type::ScheduledToUser
|
||||
: (selected.size() == 1 && selected.front()->peer()->isSelf())
|
||||
? SendMenu::Type::Reminder
|
||||
: SendMenu::Type::Scheduled;
|
||||
|
||||
// We can't support effect here because we don't have ChatHelpers::Show.
|
||||
return { .type = type, .effectAllowed = false };
|
||||
}
|
||||
|
||||
void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) {
|
||||
@@ -518,15 +521,32 @@ void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) {
|
||||
_menu->addSeparator();
|
||||
}
|
||||
|
||||
const auto result = SendMenu::FillSendMenu(
|
||||
using namespace SendMenu;
|
||||
const auto sendAction = crl::guard(this, [=](Action action, Details) {
|
||||
if (action.type == ActionType::Send) {
|
||||
submit(action.options);
|
||||
return;
|
||||
}
|
||||
uiShow()->showBox(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
nullptr, // ChatHelpers::Show for effect attachment.
|
||||
sendMenuDetails(),
|
||||
[=](Api::SendOptions options) { submit(options); },
|
||||
action.options,
|
||||
HistoryView::DefaultScheduleTime(),
|
||||
_descriptor.scheduleBoxStyle));
|
||||
});
|
||||
_menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom);
|
||||
const auto result = FillSendMenu(
|
||||
_menu.get(),
|
||||
sendMenuType(),
|
||||
[=] { submitSilent(); },
|
||||
[=] { submitScheduled(); },
|
||||
[=] { submitWhenOnline(); });
|
||||
const auto success = (result == SendMenu::FillMenuResult::Success);
|
||||
if (_descriptor.forwardOptions.show || success) {
|
||||
_menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom);
|
||||
nullptr, // showForEffect.
|
||||
sendMenuDetails(),
|
||||
sendAction);
|
||||
if (result == SendMenu::FillMenuResult::Prepared) {
|
||||
_menu->popupPrepared();
|
||||
} else if (_descriptor.forwardOptions.show
|
||||
&& result != SendMenu::FillMenuResult::Failed) {
|
||||
_menu->popup(QCursor::pos());
|
||||
}
|
||||
}
|
||||
@@ -607,25 +627,6 @@ void ShareBox::submit(Api::SendOptions options) {
|
||||
}
|
||||
}
|
||||
|
||||
void ShareBox::submitSilent() {
|
||||
submit({ .silent = true });
|
||||
}
|
||||
|
||||
void ShareBox::submitScheduled() {
|
||||
const auto callback = [=](Api::SendOptions options) { submit(options); };
|
||||
uiShow()->showBox(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
sendMenuType(),
|
||||
callback,
|
||||
HistoryView::DefaultScheduleTime(),
|
||||
_descriptor.scheduleBoxStyle));
|
||||
}
|
||||
|
||||
void ShareBox::submitWhenOnline() {
|
||||
submit(Api::DefaultSendWhenOnlineOptions());
|
||||
}
|
||||
|
||||
void ShareBox::copyLink() const {
|
||||
if (const auto onstack = _descriptor.copyCallback) {
|
||||
onstack();
|
||||
|
||||
@@ -24,7 +24,7 @@ struct PeerList;
|
||||
} // namespace style
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace Window {
|
||||
@@ -130,13 +130,10 @@ private:
|
||||
void scrollAnimationCallback();
|
||||
|
||||
void submit(Api::SendOptions options);
|
||||
void submitSilent();
|
||||
void submitScheduled();
|
||||
void submitWhenOnline();
|
||||
void copyLink() const;
|
||||
bool searchByUsername(bool useCache = false);
|
||||
|
||||
SendMenu::Type sendMenuType() const;
|
||||
[[nodiscard]] SendMenu::Details sendMenuDetails() const;
|
||||
|
||||
void scrollTo(Ui::ScrollToRequest request);
|
||||
void needSearchByUsername();
|
||||
|
||||
@@ -73,7 +73,9 @@ using Data::StickersSet;
|
||||
using Data::StickersPack;
|
||||
using SetFlag = Data::StickersSetFlag;
|
||||
|
||||
[[nodiscard]] std::optional<QColor> ComputeImageColor(const QImage &frame) {
|
||||
[[nodiscard]] std::optional<QColor> ComputeImageColor(
|
||||
const style::icon &lockIcon,
|
||||
const QImage &frame) {
|
||||
if (frame.isNull()
|
||||
|| frame.format() != QImage::Format_ARGB32_Premultiplied) {
|
||||
return {};
|
||||
@@ -83,7 +85,7 @@ using SetFlag = Data::StickersSetFlag;
|
||||
auto sb = int64();
|
||||
auto sa = int64();
|
||||
const auto factor = frame.devicePixelRatio();
|
||||
const auto size = st::stickersPremiumLock.size() * factor;
|
||||
const auto size = lockIcon.size() * factor;
|
||||
const auto width = std::min(frame.width(), size.width());
|
||||
const auto height = std::min(frame.height(), size.height());
|
||||
const auto skipx = (frame.width() - width) / 2;
|
||||
@@ -110,22 +112,30 @@ using SetFlag = Data::StickersSetFlag;
|
||||
|
||||
}
|
||||
|
||||
[[nodiscard]] QColor ComputeLockColor(const QImage &frame) {
|
||||
return ComputeImageColor(frame).value_or(st::windowSubTextFg->c);
|
||||
[[nodiscard]] QColor ComputeLockColor(
|
||||
const style::icon &lockIcon,
|
||||
const QImage &frame) {
|
||||
return ComputeImageColor(
|
||||
lockIcon,
|
||||
frame
|
||||
).value_or(st::windowSubTextFg->c);
|
||||
}
|
||||
|
||||
void ValidatePremiumLockBg(QImage &image, const QImage &frame) {
|
||||
void ValidatePremiumLockBg(
|
||||
const style::icon &lockIcon,
|
||||
QImage &image,
|
||||
const QImage &frame) {
|
||||
if (!image.isNull()) {
|
||||
return;
|
||||
}
|
||||
const auto factor = style::DevicePixelRatio();
|
||||
const auto size = st::stickersPremiumLock.size();
|
||||
const auto size = lockIcon.size();
|
||||
image = QImage(
|
||||
size * factor,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
image.setDevicePixelRatio(factor);
|
||||
auto p = QPainter(&image);
|
||||
const auto color = ComputeLockColor(frame);
|
||||
const auto color = ComputeLockColor(lockIcon, frame);
|
||||
p.fillRect(
|
||||
QRect(QPoint(), size),
|
||||
anim::color(color, st::windowSubTextFg, kGrayLockOpacity));
|
||||
@@ -134,12 +144,12 @@ void ValidatePremiumLockBg(QImage &image, const QImage &frame) {
|
||||
image = Images::Circle(std::move(image));
|
||||
}
|
||||
|
||||
void ValidatePremiumStarFg(QImage &image) {
|
||||
void ValidatePremiumStarFg(const style::icon &lockIcon, QImage &image) {
|
||||
if (!image.isNull()) {
|
||||
return;
|
||||
}
|
||||
const auto factor = style::DevicePixelRatio();
|
||||
const auto size = st::stickersPremiumLock.size();
|
||||
const auto size = lockIcon.size();
|
||||
image = QImage(
|
||||
size * factor,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
@@ -176,7 +186,10 @@ void ValidatePremiumStarFg(QImage &image) {
|
||||
|
||||
} // namespace
|
||||
|
||||
StickerPremiumMark::StickerPremiumMark(not_null<Main::Session*> session) {
|
||||
StickerPremiumMark::StickerPremiumMark(
|
||||
not_null<Main::Session*> session,
|
||||
const style::icon &lockIcon)
|
||||
: _lockIcon(lockIcon) {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
_lockGray = QImage();
|
||||
@@ -202,16 +215,14 @@ void StickerPremiumMark::paint(
|
||||
const auto factor = style::DevicePixelRatio();
|
||||
const auto radius = st::roundRadiusSmall;
|
||||
const auto point = position + QPoint(
|
||||
(_premium
|
||||
? (singleSize.width() - (bg.width() / factor) - radius)
|
||||
: (singleSize.width() - (bg.width() / factor)) / 2),
|
||||
(singleSize.width() - (bg.width() / factor) - radius),
|
||||
singleSize.height() - (bg.height() / factor) - radius);
|
||||
p.drawImage(point, bg);
|
||||
if (_premium) {
|
||||
validateStar();
|
||||
p.drawImage(point, _star);
|
||||
} else {
|
||||
st::stickersPremiumLock.paint(p, point, outerWidth);
|
||||
_lockIcon.paint(p, point, outerWidth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,11 +230,11 @@ void StickerPremiumMark::validateLock(
|
||||
const QImage &frame,
|
||||
QImage &backCache) {
|
||||
auto &image = frame.isNull() ? _lockGray : backCache;
|
||||
ValidatePremiumLockBg(image, frame);
|
||||
ValidatePremiumLockBg(_lockIcon, image, frame);
|
||||
}
|
||||
|
||||
void StickerPremiumMark::validateStar() {
|
||||
ValidatePremiumStarFg(_star);
|
||||
ValidatePremiumStarFg(_lockIcon, _star);
|
||||
}
|
||||
|
||||
class StickerSetBox::Inner final : public Ui::RpWidget {
|
||||
@@ -664,7 +675,7 @@ StickerSetBox::Inner::Inner(
|
||||
st::windowBgRipple,
|
||||
st::windowBgOver,
|
||||
[=] { repaintItems(); }))
|
||||
, _premiumMark(_session)
|
||||
, _premiumMark(_session, st::stickersPremiumLock)
|
||||
, _updateItemsTimer([=] { updateItems(); })
|
||||
, _input(set)
|
||||
, _padding((type == Data::StickersType::Emoji)
|
||||
@@ -1014,7 +1025,7 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
const auto type = _show->sendMenuType();
|
||||
const auto details = _show->sendMenuDetails();
|
||||
if (setType() == Data::StickersType::Emoji) {
|
||||
if (const auto t = PrepareTextFromEmoji(_pack[index]); !t.empty()) {
|
||||
_menu->addAction(tr::lng_mediaview_copy(tr::now), [=] {
|
||||
@@ -1023,17 +1034,16 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
}
|
||||
}, &st::menuIconCopy);
|
||||
}
|
||||
} else if (type != SendMenu::Type::Disabled) {
|
||||
} else if (details.type != SendMenu::Type::Disabled) {
|
||||
const auto document = _pack[index];
|
||||
const auto sendSelected = [=](Api::SendOptions options) {
|
||||
const auto send = crl::guard(this, [=](Api::SendOptions options) {
|
||||
chosen(index, document, options);
|
||||
};
|
||||
});
|
||||
SendMenu::FillSendMenu(
|
||||
_menu.get(),
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(sendSelected),
|
||||
SendMenu::DefaultScheduleCallback(_show, type, sendSelected),
|
||||
SendMenu::DefaultWhenOnlineCallback(sendSelected));
|
||||
_show,
|
||||
details,
|
||||
SendMenu::DefaultCallback(_show, send));
|
||||
|
||||
const auto show = _show;
|
||||
const auto toggleFavedSticker = [=] {
|
||||
|
||||
@@ -23,10 +23,6 @@ namespace Data {
|
||||
class StickersSet;
|
||||
} // namespace Data
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace ChatHelpers {
|
||||
struct FileChosen;
|
||||
class Show;
|
||||
@@ -34,7 +30,9 @@ class Show;
|
||||
|
||||
class StickerPremiumMark final {
|
||||
public:
|
||||
explicit StickerPremiumMark(not_null<Main::Session*> session);
|
||||
StickerPremiumMark(
|
||||
not_null<Main::Session*> session,
|
||||
const style::icon &lockIcon);
|
||||
|
||||
void paint(
|
||||
QPainter &p,
|
||||
@@ -48,6 +46,7 @@ private:
|
||||
void validateLock(const QImage &frame, QImage &backCache);
|
||||
void validateStar();
|
||||
|
||||
const style::icon &_lockIcon;
|
||||
QImage _lockGray;
|
||||
QImage _star;
|
||||
bool _premium = false;
|
||||
|
||||
@@ -1393,7 +1393,6 @@ groupCallScheduleDateField: InputField(groupCallField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(top);
|
||||
font: font(14px);
|
||||
}
|
||||
groupCallScheduleTimeField: InputField(groupCallScheduleDateField) {
|
||||
textBg: groupCallMembersBg;
|
||||
|
||||
@@ -706,7 +706,8 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
|
||||
}
|
||||
}
|
||||
if (data.is_need_rating() && _id && _accessHash) {
|
||||
const auto window = Core::App().windowFor(_user);
|
||||
const auto window = Core::App().windowFor(
|
||||
Window::SeparateId(_user));
|
||||
const auto session = &_user->session();
|
||||
const auto callId = _id;
|
||||
const auto callAccessHash = _accessHash;
|
||||
@@ -1402,7 +1403,8 @@ void Call::handleRequestError(const QString &error) {
|
||||
_user->name())
|
||||
: QString();
|
||||
if (!inform.isEmpty()) {
|
||||
if (const auto window = Core::App().windowFor(_user)) {
|
||||
if (const auto window = Core::App().windowFor(
|
||||
Window::SeparateId(_user))) {
|
||||
window->show(Ui::MakeInformBox(inform));
|
||||
} else {
|
||||
Ui::show(Ui::MakeInformBox(inform));
|
||||
@@ -1420,7 +1422,8 @@ void Call::handleControllerError(const QString &error) {
|
||||
? tr::lng_call_error_audio_io(tr::now)
|
||||
: QString();
|
||||
if (!inform.isEmpty()) {
|
||||
if (const auto window = Core::App().windowFor(_user)) {
|
||||
if (const auto window = Core::App().windowFor(
|
||||
Window::SeparateId(_user))) {
|
||||
window->show(Ui::MakeInformBox(inform));
|
||||
} else {
|
||||
Ui::show(Ui::MakeInformBox(inform));
|
||||
|
||||
@@ -383,20 +383,14 @@ void Panel::initWindow() {
|
||||
&& _fullScreenOrMaximized.current()) {
|
||||
toggleFullScreen();
|
||||
}
|
||||
} else if (e->type() == QEvent::WindowStateChange && _call->rtmp()) {
|
||||
const auto state = window()->windowState();
|
||||
_fullScreenOrMaximized = (state & Qt::WindowFullScreen)
|
||||
|| (state & Qt::WindowMaximized);
|
||||
}
|
||||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
if (_call->rtmp()) {
|
||||
QObject::connect(
|
||||
window()->windowHandle(),
|
||||
&QWindow::windowStateChanged,
|
||||
[=](Qt::WindowState state) {
|
||||
_fullScreenOrMaximized = (state == Qt::WindowFullScreen)
|
||||
|| (state == Qt::WindowMaximized);
|
||||
});
|
||||
}
|
||||
|
||||
window()->setBodyTitleArea([=](QPoint widgetPoint) {
|
||||
using Flag = Ui::WindowTitleHitTestFlag;
|
||||
const auto titleRect = QRect(
|
||||
|
||||
@@ -585,7 +585,6 @@ void ChooseSourceProcess::setupSourcesGeometry() {
|
||||
|
||||
void ChooseSourceProcess::setupGeometryWithParent(
|
||||
not_null<QWidget*> parent) {
|
||||
_window->createWinId();
|
||||
const auto parentScreen = [&] {
|
||||
if (const auto screen = QGuiApplication::screenAt(
|
||||
parent->geometry().center())) {
|
||||
@@ -595,7 +594,12 @@ void ChooseSourceProcess::setupGeometryWithParent(
|
||||
}();
|
||||
const auto myScreen = _window->screen();
|
||||
if (parentScreen && myScreen != parentScreen) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
_window->setScreen(parentScreen);
|
||||
#else // Qt >= 6.0.0
|
||||
_window->createWinId();
|
||||
_window->windowHandle()->setScreen(parentScreen);
|
||||
#endif // Qt < 6.0.0
|
||||
}
|
||||
_window->setFixedSize(_fixedSize);
|
||||
_window->move(
|
||||
|
||||
@@ -69,6 +69,9 @@ ComposeIcons {
|
||||
menuWhenOnline: icon;
|
||||
menuSpoiler: icon;
|
||||
menuSpoilerOff: icon;
|
||||
menuBelow: icon;
|
||||
menuAbove: icon;
|
||||
menuPrice: icon;
|
||||
|
||||
stripBubble: icon;
|
||||
stripExpandPanel: icon;
|
||||
@@ -489,6 +492,7 @@ hashtagClose: IconButton {
|
||||
|
||||
stickerPanWidthMin: 64px;
|
||||
stickerPanSize: size(stickerPanWidthMin, stickerPanWidthMin);
|
||||
stickerEffectWidthMin: 48px;
|
||||
stickerPanPadding: 11px;
|
||||
stickerPanDeleteIconBg: icon {{ "emoji/emoji_delete_bg", stickerPanDeleteBg }};
|
||||
stickerPanDeleteIconFg: icon {{ "emoji/emoji_delete", stickerPanDeleteFg }};
|
||||
@@ -605,6 +609,9 @@ defaultComposeIcons: ComposeIcons {
|
||||
menuWhenOnline: menuIconWhenOnline;
|
||||
menuSpoiler: menuIconSpoiler;
|
||||
menuSpoilerOff: menuIconSpoilerOff;
|
||||
menuBelow: menuIconBelow;
|
||||
menuAbove: menuIconAbove;
|
||||
menuPrice: menuIconEarn;
|
||||
|
||||
stripBubble: icon{
|
||||
{ "chat/reactions_bubble_shadow", windowShadowFg },
|
||||
@@ -669,7 +676,7 @@ defaultEmojiPan: EmojiPan {
|
||||
boxLabel: boxLabel;
|
||||
icons: defaultComposeIcons;
|
||||
about: defaultEmojiPanAbout;
|
||||
aboutPadding: margins(12px, 2px, 12px, 2px);
|
||||
aboutPadding: margins(12px, 3px, 12px, 2px);
|
||||
autocompleteBottomSkip: 0px;
|
||||
}
|
||||
statusEmojiPan: EmojiPan(defaultEmojiPan) {
|
||||
@@ -753,6 +760,7 @@ inlineResultsMinWidth: 48px;
|
||||
inlineDurationMargin: 3px;
|
||||
|
||||
stickersPremiumLock: icon{{ "emoji/premium_lock", premiumButtonFg }};
|
||||
emojiPremiumLock: icon{{ "chat/mini_lock", premiumButtonFg }};
|
||||
|
||||
reactStripExtend: margins(21px, 49px, 39px, 0px);
|
||||
reactStripHeight: 40px;
|
||||
@@ -924,7 +932,12 @@ historyPinnedBotButton: RoundButton(defaultActiveButton) {
|
||||
textTop: 6px;
|
||||
padding: margins(2px, 10px, 10px, 9px);
|
||||
}
|
||||
historyPinnedBotButtonMaxWidth: 150px;
|
||||
historyPinnedBotLabel: FlatLabel(defaultFlatLabel) {
|
||||
style: semiboldTextStyle;
|
||||
align: align(center);
|
||||
maxHeight: 30px;
|
||||
}
|
||||
historyPinnedBotButtonMaxWidth: 120px;
|
||||
|
||||
historyToDownPosition: point(12px, 10px);
|
||||
historyToDownAbove: icon {{ "history_down_arrow", historyToDownFg }};
|
||||
@@ -978,8 +991,33 @@ historyUnreadReactions: TwoIconButton(historyToDown) {
|
||||
}
|
||||
historyUnreadThingsSkip: 4px;
|
||||
|
||||
historyQuoteStyle: QuoteStyle(defaultQuoteStyle) {
|
||||
padding: margins(10px, 2px, 4px, 2px);
|
||||
verticalSkip: 4px;
|
||||
outline: 3px;
|
||||
outlineShift: 2px;
|
||||
radius: 5px;
|
||||
}
|
||||
historyTextStyle: TextStyle(defaultTextStyle) {
|
||||
blockquote: QuoteStyle(historyQuoteStyle) {
|
||||
padding: margins(10px, 2px, 20px, 2px);
|
||||
icon: icon{{ "chat/mini_quote", windowFg }};
|
||||
iconPosition: point(4px, 4px);
|
||||
expand: icon{{ "intro_country_dropdown", windowFg }};
|
||||
expandPosition: point(6px, 4px);
|
||||
collapse: icon{{ "intro_country_dropdown-flip_vertical", windowFg }};
|
||||
collapsePosition: point(6px, 4px);
|
||||
}
|
||||
pre: QuoteStyle(historyQuoteStyle) {
|
||||
header: 20px;
|
||||
headerPosition: point(10px, 2px);
|
||||
scrollable: true;
|
||||
icon: icon{{ "chat/mini_copy", windowFg }};
|
||||
iconPosition: point(4px, 2px);
|
||||
}
|
||||
}
|
||||
historyComposeField: InputField(defaultInputField) {
|
||||
font: normalFont;
|
||||
style: historyTextStyle;
|
||||
textMargins: margins(0px, 0px, 0px, 0px);
|
||||
textAlign: align(left);
|
||||
textFg: historyComposeAreaFg;
|
||||
@@ -1370,3 +1408,18 @@ editTagField: InputField(defaultInputField) {
|
||||
editTagLimit: FlatLabel(defaultFlatLabel) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
|
||||
paidStarIcon: icon {{ "settings/premium/star", creditsBg1 }};
|
||||
paidStarIconTop: 7px;
|
||||
paidAmountAbout: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 256px;
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
paidTagLabel: FlatLabel(defaultFlatLabel) {
|
||||
textFg: radialFg;
|
||||
palette: TextPalette(defaultTextPalette) {
|
||||
linkFg: creditsBg1;
|
||||
}
|
||||
style: semiboldTextStyle;
|
||||
}
|
||||
paidTagPadding: margins(16px, 6px, 16px, 6px);
|
||||
|
||||
@@ -30,15 +30,15 @@ ResolveWindow ResolveWindowDefault() {
|
||||
return (Window::SessionController*)nullptr;
|
||||
};
|
||||
auto &app = Core::App();
|
||||
const auto account = not_null(&session->account());
|
||||
if (const auto a = check(app.activeWindow())) {
|
||||
return a;
|
||||
} else if (const auto b = check(app.activePrimaryWindow())) {
|
||||
return b;
|
||||
} else if (const auto c = check(app.windowFor(&session->account()))) {
|
||||
} else if (const auto c = check(app.windowFor(account))) {
|
||||
return c;
|
||||
} else if (const auto d = check(
|
||||
app.ensureSeparateWindowForAccount(
|
||||
&session->account()))) {
|
||||
} else if (const auto d = check(app.ensureSeparateWindowFor(
|
||||
account))) {
|
||||
return d;
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -22,7 +22,7 @@ class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace ChatHelpers {
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
[[nodiscard]] virtual rpl::producer<> pauseChanged() const = 0;
|
||||
|
||||
[[nodiscard]] virtual rpl::producer<bool> adjustShadowLeft() const;
|
||||
[[nodiscard]] virtual SendMenu::Type sendMenuType() const = 0;
|
||||
[[nodiscard]] virtual SendMenu::Details sendMenuDetails() const = 0;
|
||||
|
||||
virtual bool showMediaPreview(
|
||||
Data::FileOrigin origin,
|
||||
|
||||
@@ -136,6 +136,7 @@ struct EmojiListWidget::CustomEmojiInstance {
|
||||
struct EmojiListWidget::RecentOne {
|
||||
Ui::Text::CustomEmoji *custom = nullptr;
|
||||
RecentEmojiId id;
|
||||
mutable QImage premiumLock;
|
||||
};
|
||||
|
||||
EmojiColorPicker::EmojiColorPicker(
|
||||
@@ -478,8 +479,12 @@ EmojiListWidget::EmojiListWidget(
|
||||
, _localSetsManager(
|
||||
std::make_unique<LocalStickersManager>(&session()))
|
||||
, _customRecentFactory(std::move(descriptor.customRecentFactory))
|
||||
, _freeEffects(std::move(descriptor.freeEffects))
|
||||
, _customTextColor(std::move(descriptor.customTextColor))
|
||||
, _overBg(st::emojiPanRadius, st().overBg)
|
||||
, _premiumMark(std::make_unique<StickerPremiumMark>(
|
||||
&session(),
|
||||
st::emojiPremiumLock))
|
||||
, _collapsedBg(st::emojiPanExpand.height / 2, st().headerFg)
|
||||
, _picker(this, st())
|
||||
, _showPickerTimer([=] { showPicker(); })
|
||||
@@ -583,9 +588,18 @@ void EmojiListWidget::setupSearch() {
|
||||
InvokeQueued(this, [=] {
|
||||
applyNextSearchQuery();
|
||||
});
|
||||
_searchQueries.fire_copy(_nextSearchQuery);
|
||||
}, session, type);
|
||||
}
|
||||
|
||||
rpl::producer<std::vector<QString>> EmojiListWidget::searchQueries() const {
|
||||
return _searchQueries.events();
|
||||
}
|
||||
|
||||
rpl::producer<int> EmojiListWidget::recentShownCount() const {
|
||||
return _recentShownCount.value();
|
||||
}
|
||||
|
||||
void EmojiListWidget::applyNextSearchQuery() {
|
||||
if (_searchQuery == _nextSearchQuery) {
|
||||
return;
|
||||
@@ -607,6 +621,9 @@ void EmojiListWidget::applyNextSearchQuery() {
|
||||
_searchCustomIds.clear();
|
||||
}
|
||||
resizeToWidth(width());
|
||||
_recentShownCount = searching
|
||||
? _searchResults.size()
|
||||
: _recent.size();
|
||||
update();
|
||||
if (modeChanged) {
|
||||
visibleTopBottomUpdated(getVisibleTop(), getVisibleBottom());
|
||||
@@ -834,7 +851,8 @@ void EmojiListWidget::unloadCustomIn(const SectionInfo &info) {
|
||||
object_ptr<TabbedSelector::InnerFooter> EmojiListWidget::createFooter() {
|
||||
Expects(_footer == nullptr);
|
||||
|
||||
if (_mode == EmojiListMode::RecentReactions) {
|
||||
if (_mode == EmojiListMode::RecentReactions
|
||||
|| _mode == EmojiListMode::MessageEffects) {
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
@@ -1018,9 +1036,10 @@ int EmojiListWidget::countDesiredHeight(int newWidth) {
|
||||
const auto minimalLastHeight = std::max(
|
||||
minimalHeight - padding.bottom(),
|
||||
0);
|
||||
return qMax(
|
||||
minimalHeight,
|
||||
countResult(minimalLastHeight) + padding.bottom());
|
||||
const auto result = countResult(minimalLastHeight);
|
||||
return result
|
||||
? qMax(minimalHeight, result + padding.bottom())
|
||||
: 0;
|
||||
}
|
||||
|
||||
int EmojiListWidget::defaultMinimalHeight() const {
|
||||
@@ -1104,7 +1123,7 @@ void EmojiListWidget::fillRecentFrom(const std::vector<DocumentId> &list) {
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> EmojiListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
const SendMenu::Details &details) {
|
||||
if (v::is_null(_selected)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1285,6 +1304,8 @@ void EmojiListWidget::paint(
|
||||
QRect clip) {
|
||||
validateEmojiPaintContext(context);
|
||||
|
||||
_paintAsPremium = session().premium();
|
||||
|
||||
auto fromColumn = floorclamp(
|
||||
clip.x() - _rowsLeft,
|
||||
_singleSize.width(),
|
||||
@@ -1449,16 +1470,44 @@ void EmojiListWidget::drawRecent(
|
||||
QPoint position,
|
||||
const RecentOne &recent) {
|
||||
_recentPainted = true;
|
||||
const auto locked = (_mode == Mode::MessageEffects)
|
||||
&& !_paintAsPremium
|
||||
&& v::is<RecentEmojiDocument>(recent.id.data)
|
||||
&& !_freeEffects.contains(
|
||||
v::get<RecentEmojiDocument>(recent.id.data).id);
|
||||
auto lockedPainted = false;
|
||||
if (locked) {
|
||||
if (_premiumMarkFrameCache.isNull()) {
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
_premiumMarkFrameCache = QImage(
|
||||
QSize(_customSingleSize, _customSingleSize) * ratio,
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
_premiumMarkFrameCache.setDevicePixelRatio(ratio);
|
||||
}
|
||||
_premiumMarkFrameCache.fill(Qt::transparent);
|
||||
}
|
||||
if (const auto custom = recent.custom) {
|
||||
_emojiPaintContext->scale = context.progress;
|
||||
_emojiPaintContext->position = position
|
||||
const auto exactPosition = position
|
||||
+ _innerPosition
|
||||
+ _customPosition;
|
||||
_emojiPaintContext->scale = context.progress;
|
||||
if (_mode == Mode::ChannelStatus) {
|
||||
_emojiPaintContext->internal.forceFirstFrame
|
||||
= (recent.id == _recent.front().id);
|
||||
}
|
||||
custom->paint(p, *_emojiPaintContext);
|
||||
if (locked) {
|
||||
lockedPainted = custom->ready();
|
||||
|
||||
auto q = Painter(&_premiumMarkFrameCache);
|
||||
_emojiPaintContext->position = QPoint();
|
||||
custom->paint(q, *_emojiPaintContext);
|
||||
q.end();
|
||||
|
||||
p.drawImage(exactPosition, _premiumMarkFrameCache);
|
||||
} else {
|
||||
_emojiPaintContext->position = exactPosition;
|
||||
custom->paint(p, *_emojiPaintContext);
|
||||
}
|
||||
} else if (const auto emoji = std::get_if<EmojiPtr>(&recent.id.data)) {
|
||||
if (_mode == Mode::EmojiStatus) {
|
||||
position += QPoint(
|
||||
@@ -1472,6 +1521,16 @@ void EmojiListWidget::drawRecent(
|
||||
} else {
|
||||
Unexpected("Empty custom emoji in EmojiListWidget::drawRecent.");
|
||||
}
|
||||
|
||||
if (locked) {
|
||||
_premiumMark->paint(
|
||||
p,
|
||||
lockedPainted ? _premiumMarkFrameCache : QImage(),
|
||||
recent.premiumLock,
|
||||
position,
|
||||
_singleSize,
|
||||
width());
|
||||
}
|
||||
}
|
||||
|
||||
void EmojiListWidget::drawEmoji(
|
||||
@@ -2131,7 +2190,7 @@ void EmojiListWidget::refreshRecent() {
|
||||
}
|
||||
|
||||
void EmojiListWidget::refreshCustom() {
|
||||
if (_mode == Mode::RecentReactions) {
|
||||
if (_mode == Mode::RecentReactions || _mode == Mode::MessageEffects) {
|
||||
return;
|
||||
}
|
||||
auto old = base::take(_custom);
|
||||
|
||||
@@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/round_rect.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class StickerPremiumMark;
|
||||
|
||||
namespace style {
|
||||
struct EmojiPan;
|
||||
} // namespace style
|
||||
@@ -77,6 +79,7 @@ enum class EmojiListMode {
|
||||
UserpicBuilder,
|
||||
BackgroundEmoji,
|
||||
PeerTitle,
|
||||
MessageEffects,
|
||||
};
|
||||
|
||||
struct EmojiListDescriptor {
|
||||
@@ -88,6 +91,7 @@ struct EmojiListDescriptor {
|
||||
Fn<std::unique_ptr<Ui::Text::CustomEmoji>(
|
||||
DocumentId,
|
||||
Fn<void()>)> customRecentFactory;
|
||||
base::flat_set<DocumentId> freeEffects;
|
||||
const style::EmojiPan *st = nullptr;
|
||||
ComposeFeatures features;
|
||||
};
|
||||
@@ -144,7 +148,10 @@ public:
|
||||
RectPart origin);
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) override;
|
||||
const SendMenu::Details &details) override;
|
||||
|
||||
[[nodiscard]] rpl::producer<std::vector<QString>> searchQueries() const;
|
||||
[[nodiscard]] rpl::producer<int> recentShownCount() const;
|
||||
|
||||
protected:
|
||||
void visibleTopBottomUpdated(
|
||||
@@ -397,10 +404,13 @@ private:
|
||||
int _counts[kEmojiSectionCount];
|
||||
std::vector<RecentOne> _recent;
|
||||
base::flat_set<DocumentId> _recentCustomIds;
|
||||
base::flat_set<DocumentId> _freeEffects;
|
||||
base::flat_set<uint64> _repaintsScheduled;
|
||||
rpl::variable<int> _recentShownCount;
|
||||
std::unique_ptr<Ui::Text::CustomEmojiPaintContext> _emojiPaintContext;
|
||||
bool _recentPainted = false;
|
||||
bool _grabbingChosen = false;
|
||||
bool _paintAsPremium = false;
|
||||
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
||||
std::vector<CustomSet> _custom;
|
||||
base::flat_set<DocumentId> _restrictedCustomList;
|
||||
@@ -414,10 +424,13 @@ private:
|
||||
Ui::RoundRect _overBg;
|
||||
QImage _searchExpandCache;
|
||||
|
||||
std::unique_ptr<StickerPremiumMark> _premiumMark;
|
||||
QImage _premiumMarkFrameCache;
|
||||
mutable std::unique_ptr<Ui::RippleAnimation> _colorAllRipple;
|
||||
bool _colorAllRippleForced = false;
|
||||
rpl::lifetime _colorAllRippleForcedLifetime;
|
||||
|
||||
rpl::event_stream<std::vector<QString>> _searchQueries;
|
||||
std::vector<QString> _nextSearchQuery;
|
||||
std::vector<QString> _searchQuery;
|
||||
base::flat_set<EmojiPtr> _searchEmoji;
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
Api::SendOptions options = {}) const;
|
||||
|
||||
void setRecentInlineBotsInRows(int32 bots);
|
||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
|
||||
void setSendMenuDetails(Fn<SendMenu::Details()> &&callback);
|
||||
void rowsUpdated();
|
||||
|
||||
rpl::producer<FieldAutocomplete::MentionChosen> mentionChosen() const;
|
||||
@@ -155,7 +155,7 @@ private:
|
||||
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
|
||||
StickerPremiumMark _premiumMark;
|
||||
|
||||
Fn<SendMenu::Type()> _sendMenuType;
|
||||
Fn<SendMenu::Details()> _sendMenuDetails;
|
||||
|
||||
rpl::event_stream<FieldAutocomplete::MentionChosen> _mentionChosen;
|
||||
rpl::event_stream<FieldAutocomplete::HashtagChosen> _hashtagChosen;
|
||||
@@ -835,8 +835,9 @@ bool FieldAutocomplete::chooseSelected(ChooseMethod method) const {
|
||||
return _inner->chooseSelected(method);
|
||||
}
|
||||
|
||||
void FieldAutocomplete::setSendMenuType(Fn<SendMenu::Type()> &&callback) {
|
||||
_inner->setSendMenuType(std::move(callback));
|
||||
void FieldAutocomplete::setSendMenuDetails(
|
||||
Fn<SendMenu::Details()> &&callback) {
|
||||
_inner->setSendMenuDetails(std::move(callback));
|
||||
}
|
||||
|
||||
bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) {
|
||||
@@ -890,7 +891,7 @@ FieldAutocomplete::Inner::Inner(
|
||||
_st.pathBg,
|
||||
_st.pathFg,
|
||||
[=] { update(); }))
|
||||
, _premiumMark(_session)
|
||||
, _premiumMark(_session, st::stickersPremiumLock)
|
||||
, _previewTimer([=] { showPreview(); }) {
|
||||
_session->downloaderTaskFinished(
|
||||
) | rpl::start_with_next([=] {
|
||||
@@ -1364,24 +1365,22 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
return;
|
||||
}
|
||||
const auto index = _sel;
|
||||
const auto type = _sendMenuType
|
||||
? _sendMenuType()
|
||||
: SendMenu::Type::Disabled;
|
||||
const auto details = _sendMenuDetails
|
||||
? _sendMenuDetails()
|
||||
: SendMenu::Details();
|
||||
const auto method = FieldAutocomplete::ChooseMethod::ByClick;
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
this,
|
||||
st::popupMenuWithIcons);
|
||||
|
||||
const auto send = [=](Api::SendOptions options) {
|
||||
const auto send = crl::guard(this, [=](Api::SendOptions options) {
|
||||
chooseAtIndex(method, index, options);
|
||||
};
|
||||
});
|
||||
SendMenu::FillSendMenu(
|
||||
_menu,
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(_show, type, send),
|
||||
SendMenu::DefaultWhenOnlineCallback(send));
|
||||
|
||||
_show,
|
||||
details,
|
||||
SendMenu::DefaultCallback(_show, send));
|
||||
if (!_menu->empty()) {
|
||||
_menu->popup(QCursor::pos());
|
||||
}
|
||||
@@ -1604,9 +1603,9 @@ void FieldAutocomplete::Inner::showPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
void FieldAutocomplete::Inner::setSendMenuType(
|
||||
Fn<SendMenu::Type()> &&callback) {
|
||||
_sendMenuType = std::move(callback);
|
||||
void FieldAutocomplete::Inner::setSendMenuDetails(
|
||||
Fn<SendMenu::Details()> &&callback) {
|
||||
_sendMenuDetails = std::move(callback);
|
||||
}
|
||||
|
||||
auto FieldAutocomplete::Inner::mentionChosen() const
|
||||
|
||||
@@ -42,7 +42,7 @@ class DocumentMedia;
|
||||
} // namespace Data
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace ChatHelpers {
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
void setModerateKeyActivateCallback(Fn<bool(int)> callback) {
|
||||
_moderateKeyActivateCallback = std::move(callback);
|
||||
}
|
||||
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
|
||||
void setSendMenuDetails(Fn<SendMenu::Details()> &&callback);
|
||||
|
||||
void hideFast();
|
||||
void showAnimated();
|
||||
|
||||
@@ -380,22 +380,31 @@ void GifsListWidget::mousePressEvent(QMouseEvent *e) {
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> GifsListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
const SendMenu::Details &details) {
|
||||
if (_selected < 0 || _pressed >= 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(this, st().menu);
|
||||
const auto send = [=, selected = _selected](Api::SendOptions options) {
|
||||
const auto selected = _selected;
|
||||
const auto send = crl::guard(this, [=](Api::SendOptions options) {
|
||||
selectInlineResult(selected, options, true);
|
||||
};
|
||||
});
|
||||
const auto item = _mosaic.maybeItemAt(_selected);
|
||||
const auto isInlineResult = !item->getPhoto()
|
||||
&& !item->getDocument()
|
||||
&& item->getResult();
|
||||
const auto icons = &st().icons;
|
||||
auto copyDetails = details;
|
||||
if (isInlineResult) {
|
||||
// inline results don't have effects
|
||||
copyDetails.effectAllowed = false;
|
||||
}
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(_show, type, send),
|
||||
SendMenu::DefaultWhenOnlineCallback(send),
|
||||
_show,
|
||||
copyDetails,
|
||||
SendMenu::DefaultCallback(_show, send),
|
||||
icons);
|
||||
|
||||
if (const auto item = _mosaic.maybeItemAt(_selected)) {
|
||||
|
||||
@@ -40,7 +40,7 @@ class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
struct Details;
|
||||
} // namespace SendMenu
|
||||
|
||||
namespace Data {
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
rpl::producer<> cancelRequests() const;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> fillContextMenu(
|
||||
SendMenu::Type type) override;
|
||||
const SendMenu::Details &details) override;
|
||||
|
||||
~GifsListWidget();
|
||||
|
||||
|
||||
@@ -14,11 +14,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/rect.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
@@ -39,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
|
||||
#include <QtCore/QMimeData>
|
||||
@@ -57,63 +61,47 @@ using EditLinkSelection = Ui::InputField::EditLinkSelection;
|
||||
|
||||
constexpr auto kParseLinksTimeout = crl::time(1000);
|
||||
constexpr auto kTypesDuration = 4 * crl::time(1000);
|
||||
constexpr auto kCodeLanguageLimit = 32;
|
||||
|
||||
// For mention / custom emoji tags save and validate selfId,
|
||||
// ignore tags for different users.
|
||||
class FieldTagMimeProcessor final {
|
||||
public:
|
||||
FieldTagMimeProcessor(
|
||||
not_null<Main::Session*> _session,
|
||||
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji);
|
||||
|
||||
QString operator()(QStringView mimeTag);
|
||||
|
||||
private:
|
||||
const not_null<Main::Session*> _session;
|
||||
const Fn<bool(not_null<DocumentData*>)> _allowPremiumEmoji;
|
||||
|
||||
};
|
||||
|
||||
FieldTagMimeProcessor::FieldTagMimeProcessor(
|
||||
not_null<Main::Session*> session,
|
||||
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji)
|
||||
: _session(session)
|
||||
, _allowPremiumEmoji(allowPremiumEmoji) {
|
||||
}
|
||||
|
||||
QString FieldTagMimeProcessor::operator()(QStringView mimeTag) {
|
||||
const auto id = _session->userId().bare;
|
||||
auto all = TextUtilities::SplitTags(mimeTag);
|
||||
auto premiumSkipped = (DocumentData*)nullptr;
|
||||
for (auto i = all.begin(); i != all.end();) {
|
||||
const auto tag = *i;
|
||||
if (TextUtilities::IsMentionLink(tag)
|
||||
&& TextUtilities::MentionNameDataToFields(tag).selfId != id) {
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
} else if (Ui::InputField::IsCustomEmojiLink(tag)) {
|
||||
const auto data = Ui::InputField::CustomEmojiEntityData(tag);
|
||||
const auto emoji = Data::ParseCustomEmojiData(data);
|
||||
if (!emoji) {
|
||||
[[nodiscard]] Fn<QString(QStringView)> FieldTagMimeProcessor(
|
||||
not_null<Main::Session*> session,
|
||||
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
|
||||
return [=](QStringView mimeTag) {
|
||||
const auto id = session->userId().bare;
|
||||
auto all = TextUtilities::SplitTags(mimeTag);
|
||||
auto premiumSkipped = (DocumentData*)nullptr;
|
||||
for (auto i = all.begin(); i != all.end();) {
|
||||
const auto tag = *i;
|
||||
if (TextUtilities::IsMentionLink(tag)
|
||||
&& TextUtilities::MentionNameDataToFields(tag).selfId != id) {
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
} else if (!_session->premium()) {
|
||||
const auto document = _session->data().document(emoji);
|
||||
if (document->isPremiumEmoji()) {
|
||||
if (!_allowPremiumEmoji
|
||||
|| premiumSkipped
|
||||
|| !_session->premiumPossible()
|
||||
|| !_allowPremiumEmoji(document)) {
|
||||
premiumSkipped = document;
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
} else if (Ui::InputField::IsCustomEmojiLink(tag)) {
|
||||
const auto data = Ui::InputField::CustomEmojiEntityData(tag);
|
||||
const auto emoji = Data::ParseCustomEmojiData(data);
|
||||
if (!emoji) {
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
} else if (!session->premium()) {
|
||||
const auto document = session->data().document(emoji);
|
||||
if (document->isPremiumEmoji()) {
|
||||
if (!allowPremiumEmoji
|
||||
|| premiumSkipped
|
||||
|| !session->premiumPossible()
|
||||
|| !allowPremiumEmoji(document)) {
|
||||
premiumSkipped = document;
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return TextUtilities::JoinTag(all);
|
||||
return TextUtilities::JoinTag(all);
|
||||
};
|
||||
}
|
||||
|
||||
//bool ValidateUrl(const QString &value) {
|
||||
@@ -132,7 +120,8 @@ void EditLinkBox(
|
||||
const QString &startText,
|
||||
const QString &startLink,
|
||||
Fn<void(QString, QString)> callback,
|
||||
const style::InputField *fieldStyle) {
|
||||
const style::InputField *fieldStyle,
|
||||
Fn<QString(QString)> validate) {
|
||||
Expects(callback != nullptr);
|
||||
|
||||
const auto &fieldSt = fieldStyle ? *fieldStyle : st::defaultInputField;
|
||||
@@ -177,7 +166,7 @@ void EditLinkBox(
|
||||
|
||||
const auto submit = [=] {
|
||||
const auto linkText = text->getLastText();
|
||||
const auto linkUrl = qthelp::validate_url(url->getLastText());
|
||||
const auto linkUrl = validate(url->getLastText());
|
||||
if (linkText.isEmpty()) {
|
||||
text->showError();
|
||||
return;
|
||||
@@ -237,6 +226,51 @@ void EditLinkBox(
|
||||
}, text->lifetime());
|
||||
}
|
||||
|
||||
void EditCodeLanguageBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
QString now,
|
||||
Fn<void(QString)> save) {
|
||||
Expects(save != nullptr);
|
||||
|
||||
box->setTitle(tr::lng_formatting_code_title());
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_formatting_code_language(),
|
||||
st::settingsAddReplyLabel));
|
||||
const auto field = box->addRow(object_ptr<Ui::InputField>(
|
||||
box,
|
||||
st::settingsAddReplyField,
|
||||
tr::lng_formatting_code_auto(),
|
||||
now.trimmed()));
|
||||
box->setFocusCallback([=] {
|
||||
field->setFocusFast();
|
||||
});
|
||||
field->selectAll();
|
||||
field->setMaxLength(kCodeLanguageLimit);
|
||||
|
||||
Ui::AddLengthLimitLabel(field, kCodeLanguageLimit);
|
||||
|
||||
const auto callback = [=] {
|
||||
const auto name = field->getLastText().trimmed();
|
||||
const auto check = QRegularExpression("^[a-zA-Z0-9\\+\\-]*$");
|
||||
if (check.match(name).hasMatch()) {
|
||||
auto weak = Ui::MakeWeak(box);
|
||||
save(name);
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
} else {
|
||||
field->showError();
|
||||
}
|
||||
};
|
||||
field->submits(
|
||||
) | rpl::start_with_next(callback, field->lifetime());
|
||||
box->addButton(tr::lng_settings_save(), callback);
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
|
||||
TextWithEntities StripSupportHashtag(TextWithEntities text) {
|
||||
static const auto expression = QRegularExpression(
|
||||
u"\\n?#tsf[a-z0-9_-]*[\\s#a-z0-9_-]*$"_q,
|
||||
@@ -289,15 +323,24 @@ TextWithTags PrepareEditText(not_null<HistoryItem*> item) {
|
||||
|
||||
bool EditTextChanged(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithTags &updated) {
|
||||
TextWithTags updated) {
|
||||
const auto original = PrepareEditText(item);
|
||||
|
||||
auto originalWithEntities = TextWithEntities{
|
||||
std::move(original.text),
|
||||
TextUtilities::ConvertTextTagsToEntities(original.tags)
|
||||
};
|
||||
auto updatedWithEntities = TextWithEntities{
|
||||
std::move(updated.text),
|
||||
TextUtilities::ConvertTextTagsToEntities(updated.tags)
|
||||
};
|
||||
TextUtilities::PrepareForSending(originalWithEntities, 0);
|
||||
TextUtilities::PrepareForSending(updatedWithEntities, 0);
|
||||
|
||||
// Tags can be different for the same entities, because for
|
||||
// animated emoji each tag contains a different random number.
|
||||
// So we compare entities instead of tags.
|
||||
return (original.text != updated.text)
|
||||
|| (TextUtilities::ConvertTextTagsToEntities(original.tags)
|
||||
!= TextUtilities::ConvertTextTagsToEntities(updated.tags));
|
||||
return originalWithEntities != updatedWithEntities;
|
||||
}
|
||||
|
||||
Fn<bool(
|
||||
@@ -329,11 +372,19 @@ Fn<bool(
|
||||
text,
|
||||
link,
|
||||
std::move(callback),
|
||||
fieldStyle));
|
||||
fieldStyle,
|
||||
qthelp::validate_url));
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
Fn<void(QString now, Fn<void(QString)> save)> DefaultEditLanguageCallback(
|
||||
std::shared_ptr<Ui::Show> show) {
|
||||
return [=](QString now, Fn<void(QString)> save) {
|
||||
show->showBox(Box(EditCodeLanguageBox, now, save));
|
||||
};
|
||||
}
|
||||
|
||||
void InitMessageFieldHandlers(
|
||||
not_null<Main::Session*> session,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
@@ -343,21 +394,117 @@ void InitMessageFieldHandlers(
|
||||
const style::InputField *fieldStyle) {
|
||||
field->setTagMimeProcessor(
|
||||
FieldTagMimeProcessor(session, allowPremiumEmoji));
|
||||
const auto paused = [customEmojiPaused] {
|
||||
field->setCustomTextContext([=](Fn<void()> repaint) {
|
||||
return std::any(Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = std::move(repaint),
|
||||
});
|
||||
}, [customEmojiPaused] {
|
||||
return On(PowerSaving::kEmojiChat) || customEmojiPaused();
|
||||
};
|
||||
field->setCustomEmojiFactory(
|
||||
session->data().customEmojiManager().factory(),
|
||||
std::move(customEmojiPaused));
|
||||
}, [customEmojiPaused] {
|
||||
return On(PowerSaving::kChatSpoiler) || customEmojiPaused();
|
||||
});
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
field->setMarkdownReplacesEnabled(rpl::single(true));
|
||||
field->setMarkdownReplacesEnabled(true);
|
||||
if (show) {
|
||||
field->setEditLinkCallback(
|
||||
DefaultEditLinkCallback(show, field, fieldStyle));
|
||||
field->setEditLanguageCallback(DefaultEditLanguageCallback(show));
|
||||
InitSpellchecker(show, field, fieldStyle != nullptr);
|
||||
}
|
||||
const auto style = field->lifetime().make_state<Ui::ChatStyle>(
|
||||
session->colorIndicesValue());
|
||||
field->setPreCache([=] {
|
||||
return style->messageStyle(false, false).preCache.get();
|
||||
});
|
||||
field->setBlockquoteCache([=] {
|
||||
const auto colorIndex = session->user()->colorIndex();
|
||||
return style->coloredQuoteCache(false, colorIndex).get();
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsGoodFactcheckUrl(QStringView url) {
|
||||
return url.startsWith(u"t.me/"_q) || url.startsWith(u"https://t.me/"_q);
|
||||
}
|
||||
|
||||
[[nodiscard]] Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
QString link,
|
||||
EditLinkAction action)> FactcheckEditLinkCallback(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<Ui::InputField*> field) {
|
||||
const auto weak = Ui::MakeWeak(field);
|
||||
return [=](
|
||||
EditLinkSelection selection,
|
||||
QString text,
|
||||
QString link,
|
||||
EditLinkAction action) {
|
||||
const auto validate = [=](QString url) {
|
||||
if (IsGoodFactcheckUrl(url)) {
|
||||
const auto start = u"https://"_q;
|
||||
return url.startsWith(start) ? url : (start + url);
|
||||
}
|
||||
show->showToast(
|
||||
tr::lng_factcheck_links(tr::now, Ui::Text::RichLangValue));
|
||||
return QString();
|
||||
};
|
||||
if (action == EditLinkAction::Check) {
|
||||
return IsGoodFactcheckUrl(link);
|
||||
}
|
||||
auto callback = [=](const QString &text, const QString &link) {
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||
}
|
||||
};
|
||||
show->showBox(Box(
|
||||
EditLinkBox,
|
||||
show,
|
||||
text,
|
||||
link,
|
||||
std::move(callback),
|
||||
nullptr,
|
||||
validate));
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
Fn<void(not_null<Ui::InputField*>)> FactcheckFieldIniter(
|
||||
std::shared_ptr<Main::SessionShow> show) {
|
||||
Expects(show != nullptr);
|
||||
|
||||
return [=](not_null<Ui::InputField*> field) {
|
||||
field->setTagMimeProcessor([](QStringView mimeTag) {
|
||||
using Field = Ui::InputField;
|
||||
auto all = TextUtilities::SplitTags(mimeTag);
|
||||
for (auto i = all.begin(); i != all.end();) {
|
||||
const auto tag = *i;
|
||||
if (tag != Field::kTagBold
|
||||
&& tag != Field::kTagItalic
|
||||
&& (!Field::IsValidMarkdownLink(mimeTag)
|
||||
|| TextUtilities::IsMentionLink(mimeTag))) {
|
||||
i = all.erase(i);
|
||||
continue;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return TextUtilities::JoinTag(all);
|
||||
});
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
field->setMarkdownReplacesEnabled(rpl::single(
|
||||
Ui::MarkdownEnabledState{
|
||||
Ui::MarkdownEnabled{
|
||||
{ Ui::InputField::kTagBold, Ui::InputField::kTagItalic }
|
||||
}
|
||||
}
|
||||
));
|
||||
field->setEditLinkCallback(FactcheckEditLinkCallback(show, field));
|
||||
InitSpellchecker(show, field);
|
||||
};
|
||||
}
|
||||
|
||||
void InitMessageFieldHandlers(
|
||||
@@ -501,12 +648,26 @@ void InitMessageFieldFade(
|
||||
Ui::DestroyChild(b.data());
|
||||
}, topFade->lifetime());
|
||||
|
||||
topFade->show();
|
||||
bottomFade->showOn(
|
||||
field->scrollTop().value(
|
||||
) | rpl::map([field, descent = field->st().font->descent](int scroll) {
|
||||
return (scroll + descent) < field->scrollTopMax();
|
||||
}) | rpl::distinct_until_changed());
|
||||
const auto descent = field->st().style.font->descent;
|
||||
rpl::merge(
|
||||
field->changes(),
|
||||
field->scrollTop().changes() | rpl::to_empty,
|
||||
field->sizeValue() | rpl::to_empty
|
||||
) | rpl::start_with_next([=] {
|
||||
// InputField::changes fires before the auto-resize is being applied,
|
||||
// so for the scroll values to be accurate we enqueue the check.
|
||||
InvokeQueued(field, [=] {
|
||||
const auto topHidden = !field->scrollTop().current();
|
||||
if (topFade->isHidden() != topHidden) {
|
||||
topFade->setVisible(!topHidden);
|
||||
}
|
||||
const auto adjusted = field->scrollTop().current() + descent;
|
||||
const auto bottomHidden = (adjusted >= field->scrollTopMax());
|
||||
if (bottomFade->isHidden() != bottomHidden) {
|
||||
bottomFade->setVisible(!bottomHidden);
|
||||
}
|
||||
});
|
||||
}, topFade->lifetime());
|
||||
}
|
||||
|
||||
InlineBotQuery ParseInlineBotQuery(
|
||||
@@ -698,11 +859,7 @@ bool MessageLinksParser::eventFilter(QObject *object, QEvent *event) {
|
||||
const auto text = static_cast<QKeyEvent*>(event)->text();
|
||||
if (!text.isEmpty() && text.size() < 3) {
|
||||
const auto ch = text[0];
|
||||
if (false
|
||||
|| ch == '\n'
|
||||
|| ch == '\r'
|
||||
|| ch.isSpace()
|
||||
|| ch == QChar::LineSeparator) {
|
||||
if (IsSpace(ch)) {
|
||||
_timer.callOnce(0);
|
||||
}
|
||||
}
|
||||
@@ -729,7 +886,8 @@ void MessageLinksParser::parse() {
|
||||
|| (tag == Ui::InputField::kTagUnderline)
|
||||
|| (tag == Ui::InputField::kTagStrikeOut)
|
||||
|| (tag == Ui::InputField::kTagSpoiler)
|
||||
|| (tag == Ui::InputField::kTagBlockquote);
|
||||
|| (tag == Ui::InputField::kTagBlockquote)
|
||||
|| (tag == Ui::InputField::kTagBlockquoteCollapsed);
|
||||
};
|
||||
|
||||
_ranges.clear();
|
||||
@@ -1028,7 +1186,9 @@ base::unique_qptr<Ui::RpWidget> PremiumRequiredSendRestriction(
|
||||
const auto margins = (st.textMargins + st.placeholderMargins);
|
||||
const auto available = width - margins.left() - margins.right();
|
||||
label->resizeToWidth(available);
|
||||
label->moveToLeft(margins.left(), margins.top(), width);
|
||||
const auto height = label->height() + link->height();
|
||||
const auto top = (raw->height() - height) / 2;
|
||||
label->moveToLeft(margins.left(), top, width);
|
||||
link->move(
|
||||
(width - link->width()) / 2,
|
||||
label->y() + label->height());
|
||||
@@ -1048,8 +1208,8 @@ void SelectTextInFieldWithMargins(
|
||||
auto textCursor = field->textCursor();
|
||||
// Try to set equal margins for top and bottom sides.
|
||||
const auto charsCountInLine = field->width()
|
||||
/ field->st().font->width('W');
|
||||
const auto linesCount = (field->height() / field->st().font->height);
|
||||
/ field->st().style.font->width('W');
|
||||
const auto linesCount = field->height() / field->st().style.font->height;
|
||||
const auto selectedLines = (selection.to - selection.from)
|
||||
/ charsCountInLine;
|
||||
constexpr auto kMinDiff = ushort(3);
|
||||
|
||||
@@ -35,13 +35,14 @@ class Show;
|
||||
|
||||
namespace Ui {
|
||||
class PopupMenu;
|
||||
class Show;
|
||||
} // namespace Ui
|
||||
|
||||
[[nodiscard]] QString PrepareMentionTag(not_null<UserData*> user);
|
||||
[[nodiscard]] TextWithTags PrepareEditText(not_null<HistoryItem*> item);
|
||||
[[nodiscard]] bool EditTextChanged(
|
||||
not_null<HistoryItem*> item,
|
||||
const TextWithTags &updated);
|
||||
TextWithTags updated);
|
||||
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
@@ -51,6 +52,8 @@ Fn<bool(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<Ui::InputField*> field,
|
||||
const style::InputField *fieldStyle = nullptr);
|
||||
Fn<void(QString now, Fn<void(QString)> save)> DefaultEditLanguageCallback(
|
||||
std::shared_ptr<Ui::Show> show);
|
||||
void InitMessageFieldHandlers(
|
||||
not_null<Main::Session*> session,
|
||||
std::shared_ptr<Main::SessionShow> show, // may be null
|
||||
@@ -77,6 +80,9 @@ void InitSpellchecker(
|
||||
not_null<Ui::InputField*> field,
|
||||
bool skipDictionariesManager = false);
|
||||
|
||||
[[nodiscard]] Fn<void(not_null<Ui::InputField*>)> FactcheckFieldIniter(
|
||||
std::shared_ptr<Main::SessionShow> show);
|
||||
|
||||
bool HasSendText(not_null<const Ui::InputField*> field);
|
||||
|
||||
void InitMessageFieldFade(
|
||||
|
||||
@@ -269,10 +269,10 @@ std::unique_ptr<Lottie::SinglePlayer> EmojiPack::effectPlayer(
|
||||
not_null<DocumentData*> document,
|
||||
QByteArray data,
|
||||
QString filepath,
|
||||
bool premium) {
|
||||
EffectType type) {
|
||||
// Shortened copy from stickers_lottie module.
|
||||
const auto baseKey = document->bigFileBaseCacheKey();
|
||||
const auto tag = uint8(0);
|
||||
const auto tag = uint8(type);
|
||||
const auto keyShift = ((tag << 4) & 0xF0)
|
||||
| (uint8(ChatHelpers::StickerLottieSize::EmojiInteraction) & 0x0F);
|
||||
const auto key = Storage::Cache::Key{
|
||||
@@ -292,19 +292,24 @@ std::unique_ptr<Lottie::SinglePlayer> EmojiPack::effectPlayer(
|
||||
std::move(data));
|
||||
});
|
||||
};
|
||||
const auto size = premium
|
||||
const auto size = (type == EffectType::PremiumSticker)
|
||||
? HistoryView::Sticker::PremiumEffectSize(document)
|
||||
: HistoryView::Sticker::EmojiEffectSize();
|
||||
: (type == EffectType::EmojiInteraction)
|
||||
? HistoryView::Sticker::EmojiEffectSize()
|
||||
: HistoryView::Sticker::MessageEffectSize();
|
||||
const auto request = Lottie::FrameRequest{
|
||||
size * style::DevicePixelRatio(),
|
||||
};
|
||||
auto &weakProvider = _sharedProviders[document];
|
||||
auto &weakProvider = _sharedProviders[{ document, type }];
|
||||
auto shared = [&] {
|
||||
if (const auto result = weakProvider.lock()) {
|
||||
return result;
|
||||
}
|
||||
const auto count = (type == EffectType::PremiumSticker)
|
||||
? kPremiumCachesCount
|
||||
: kEmojiCachesCount;
|
||||
const auto result = Lottie::SinglePlayer::SharedProvider(
|
||||
premium ? kPremiumCachesCount : kEmojiCachesCount,
|
||||
count,
|
||||
get,
|
||||
put,
|
||||
Lottie::ReadContent(data, filepath),
|
||||
|
||||
@@ -50,6 +50,12 @@ struct LargeEmojiImage {
|
||||
[[nodiscard]] static QSize Size();
|
||||
};
|
||||
|
||||
enum class EffectType : uint8 {
|
||||
EmojiInteraction,
|
||||
PremiumSticker,
|
||||
MessageEffect,
|
||||
};
|
||||
|
||||
class EmojiPack final {
|
||||
public:
|
||||
using ViewElement = HistoryView::Element;
|
||||
@@ -95,11 +101,23 @@ public:
|
||||
not_null<DocumentData*> document,
|
||||
QByteArray data,
|
||||
QString filepath,
|
||||
bool premium);
|
||||
EffectType type);
|
||||
|
||||
private:
|
||||
class ImageLoader;
|
||||
|
||||
struct ProviderKey {
|
||||
not_null<DocumentData*> document;
|
||||
Stickers::EffectType type = {};
|
||||
|
||||
friend inline auto operator<=>(
|
||||
const ProviderKey &,
|
||||
const ProviderKey &) = default;
|
||||
friend inline bool operator==(
|
||||
const ProviderKey &,
|
||||
const ProviderKey &) = default;
|
||||
};
|
||||
|
||||
void refresh();
|
||||
void refreshDelayed();
|
||||
void refreshAnimations();
|
||||
@@ -135,7 +153,7 @@ private:
|
||||
mtpRequestId _animationsRequestId = 0;
|
||||
|
||||
base::flat_map<
|
||||
not_null<DocumentData*>,
|
||||
ProviderKey,
|
||||
std::weak_ptr<Lottie::FrameProvider>> _sharedProviders;
|
||||
|
||||
rpl::event_stream<> _refreshed;
|
||||
|
||||
@@ -189,8 +189,10 @@ StickersListWidget::StickersListWidget(
|
||||
, _overBg(st::roundRadiusLarge, st().overBg)
|
||||
, _api(&session().mtp())
|
||||
, _localSetsManager(std::make_unique<LocalStickersManager>(&session()))
|
||||
, _customRecentIds(std::move(descriptor.customRecentList))
|
||||
, _section(Section::Stickers)
|
||||
, _isMasks(_mode == Mode::Masks)
|
||||
, _isEffects(_mode == Mode::MessageEffects)
|
||||
, _updateItemsTimer([=] { updateItems(); })
|
||||
, _updateSetsTimer([=] { updateSets(); })
|
||||
, _trendingAddBgOver(
|
||||
@@ -217,12 +219,16 @@ StickersListWidget::StickersListWidget(
|
||||
, _installedWidth(st::stickersTrendingInstalled.font->width(_installedText))
|
||||
, _settings(this, tr::lng_stickers_you_have(tr::now))
|
||||
, _previewTimer([=] { showPreview(); })
|
||||
, _premiumMark(std::make_unique<StickerPremiumMark>(&session()))
|
||||
, _premiumMark(std::make_unique<StickerPremiumMark>(
|
||||
&session(),
|
||||
st::stickersPremiumLock))
|
||||
, _searchRequestTimer([=] { sendSearchRequest(); }) {
|
||||
setMouseTracking(true);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
if (st().bg->c.alpha() > 0) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
}
|
||||
|
||||
if (!_isMasks) {
|
||||
if (!_isMasks && !_isEffects) {
|
||||
setupSearch();
|
||||
}
|
||||
|
||||
@@ -254,23 +260,30 @@ StickersListWidget::StickersListWidget(
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
|
||||
session().data().stickers().recentUpdated(
|
||||
_isMasks ? Data::StickersType::Masks : Data::StickersType::Stickers
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshRecent();
|
||||
}, lifetime());
|
||||
if (!_isEffects) {
|
||||
session().data().stickers().recentUpdated(_isMasks
|
||||
? Data::StickersType::Masks
|
||||
: Data::StickersType::Stickers
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshRecent();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
positionValue(
|
||||
) | rpl::skip(1) | rpl::map_to(
|
||||
TabbedSelector::Action::Update
|
||||
) | rpl::start_to_stream(_choosingUpdated, lifetime());
|
||||
|
||||
rpl::merge(
|
||||
Data::AmPremiumValue(&session()) | rpl::to_empty,
|
||||
session().api().premium().cloudSetUpdated()
|
||||
) | rpl::start_with_next([=] {
|
||||
if (_isEffects) {
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
} else {
|
||||
rpl::merge(
|
||||
Data::AmPremiumValue(&session()) | rpl::to_empty,
|
||||
session().api().premium().cloudSetUpdated()
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
}
|
||||
}
|
||||
|
||||
rpl::producer<FileChosen> StickersListWidget::chosen() const {
|
||||
@@ -498,11 +511,14 @@ StickersListWidget::SectionInfo StickersListWidget::sectionInfoByOffset(int yOff
|
||||
}
|
||||
|
||||
int StickersListWidget::countDesiredHeight(int newWidth) {
|
||||
if (newWidth <= st::stickerPanWidthMin) {
|
||||
const auto minSize = _isEffects
|
||||
? st::stickerEffectWidthMin
|
||||
: st::stickerPanWidthMin;
|
||||
if (newWidth < 2 * minSize) {
|
||||
return 0;
|
||||
}
|
||||
auto availableWidth = newWidth - (st::stickerPanPadding - st().margin.left());
|
||||
auto columnCount = availableWidth / st::stickerPanWidthMin;
|
||||
auto columnCount = availableWidth / minSize;
|
||||
auto singleWidth = availableWidth / columnCount;
|
||||
auto fullWidth = (st().margin.left() + newWidth + st::emojiScroll.width);
|
||||
auto rowsRight = (fullWidth - columnCount * singleWidth) / 2;
|
||||
@@ -528,12 +544,12 @@ int StickersListWidget::countDesiredHeight(int newWidth) {
|
||||
const auto minimalLastHeight = (_section == Section::Stickers)
|
||||
? minimalHeight
|
||||
: 0;
|
||||
return qMax(minimalHeight, countResult(minimalLastHeight))
|
||||
+ st::stickerPanPadding;
|
||||
const auto result = qMax(minimalHeight, countResult(minimalLastHeight));
|
||||
return result ? (result + st::stickerPanPadding) : 0;
|
||||
}
|
||||
|
||||
void StickersListWidget::sendSearchRequest() {
|
||||
if (_searchRequestId || _searchNextQuery.isEmpty()) {
|
||||
if (_searchRequestId || _searchNextQuery.isEmpty() || _isEffects) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -542,14 +558,12 @@ void StickersListWidget::sendSearchRequest() {
|
||||
|
||||
auto it = _searchCache.find(_searchQuery);
|
||||
if (it != _searchCache.cend()) {
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_search->setLoading(true);
|
||||
|
||||
toggleSearchLoading(true);
|
||||
if (_searchQuery == Ui::PremiumGroupFakeEmoticon()) {
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
_searchRequestId = 0;
|
||||
_searchCache.emplace(_searchQuery, std::vector<uint64>());
|
||||
showSearchResults();
|
||||
@@ -565,7 +579,7 @@ void StickersListWidget::sendSearchRequest() {
|
||||
searchResultsDone(result);
|
||||
}).fail([=] {
|
||||
// show error?
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
_searchRequestId = 0;
|
||||
}).handleAllErrors().send();
|
||||
}
|
||||
@@ -579,7 +593,10 @@ void StickersListWidget::searchForSets(
|
||||
return;
|
||||
}
|
||||
|
||||
if (query == Ui::PremiumGroupFakeEmoticon()) {
|
||||
_filterStickersCornerEmoji.clear();
|
||||
if (_isEffects) {
|
||||
filterEffectsByEmoji(std::move(emoji));
|
||||
} else if (query == Ui::PremiumGroupFakeEmoticon()) {
|
||||
_filteredStickers = session().data().stickers().getPremiumList(0);
|
||||
} else {
|
||||
_filteredStickers = session().data().stickers().getListByEmoji(
|
||||
@@ -588,7 +605,7 @@ void StickersListWidget::searchForSets(
|
||||
true);
|
||||
}
|
||||
if (_searchQuery != cleaned) {
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
if (const auto requestId = base::take(_searchRequestId)) {
|
||||
_api.request(requestId).cancel();
|
||||
}
|
||||
@@ -604,13 +621,14 @@ void StickersListWidget::searchForSets(
|
||||
}
|
||||
|
||||
void StickersListWidget::cancelSetsSearch() {
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
if (const auto requestId = base::take(_searchRequestId)) {
|
||||
_api.request(requestId).cancel();
|
||||
}
|
||||
_searchRequestTimer.cancel();
|
||||
_searchQuery = _searchNextQuery = QString();
|
||||
_filteredStickers.clear();
|
||||
_filterStickersCornerEmoji.clear();
|
||||
_searchCache.clear();
|
||||
refreshSearchRows(nullptr);
|
||||
}
|
||||
@@ -641,8 +659,9 @@ void StickersListWidget::refreshSearchRows(
|
||||
});
|
||||
|
||||
fillFilteredStickersRow();
|
||||
fillLocalSearchRows(_searchNextQuery);
|
||||
|
||||
if (!_isEffects) {
|
||||
fillLocalSearchRows(_searchNextQuery);
|
||||
}
|
||||
if (!cloudSets && _searchNextQuery.isEmpty()) {
|
||||
showStickerSet(!_mySets.empty()
|
||||
? _mySets[0].id
|
||||
@@ -651,17 +670,21 @@ void StickersListWidget::refreshSearchRows(
|
||||
}
|
||||
|
||||
setSection(Section::Search);
|
||||
if (cloudSets) {
|
||||
if (!_isEffects && cloudSets) {
|
||||
fillCloudSearchRows(*cloudSets);
|
||||
}
|
||||
refreshIcons(ValidateIconAnimations::Scroll);
|
||||
|
||||
_lastMousePosition = QCursor::pos();
|
||||
|
||||
resizeToWidth(width());
|
||||
_recentShownCount = _filteredStickers.size();
|
||||
updateSelected();
|
||||
}
|
||||
|
||||
rpl::producer<int> StickersListWidget::recentShownCount() const {
|
||||
return _recentShownCount.value();
|
||||
}
|
||||
|
||||
void StickersListWidget::fillLocalSearchRows(const QString &query) {
|
||||
const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
|
||||
if (searchWordsList.isEmpty()) {
|
||||
@@ -721,7 +744,7 @@ void StickersListWidget::fillFilteredStickersRow() {
|
||||
SearchEmojiSectionSetId(),
|
||||
nullptr,
|
||||
Data::StickersSetFlag::Special,
|
||||
QString(), // title
|
||||
_isEffects ? tr::lng_effect_stickers_title(tr::now) : QString(),
|
||||
QString(), // shortName
|
||||
_filteredStickers.size(),
|
||||
false, // externalLayout
|
||||
@@ -744,6 +767,12 @@ void StickersListWidget::addSearchRow(not_null<StickersSet*> set) {
|
||||
std::move(elements));
|
||||
}
|
||||
|
||||
void StickersListWidget::toggleSearchLoading(bool loading) {
|
||||
if (_search) {
|
||||
_search->setLoading(loading);
|
||||
}
|
||||
}
|
||||
|
||||
void StickersListWidget::takeHeavyData(
|
||||
std::vector<Set> &to,
|
||||
std::vector<Set> &from) {
|
||||
@@ -825,7 +854,7 @@ auto StickersListWidget::shownSets() -> std::vector<Set> & {
|
||||
|
||||
void StickersListWidget::searchResultsDone(
|
||||
const MTPmessages_FoundStickerSets &result) {
|
||||
_search->setLoading(false);
|
||||
toggleSearchLoading(false);
|
||||
_searchRequestId = 0;
|
||||
|
||||
if (result.type() == mtpc_messages_foundStickerSetsNotModified) {
|
||||
@@ -872,7 +901,9 @@ QRect StickersListWidget::stickerRect(int section, int sel) {
|
||||
void StickersListWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
auto clip = e->rect();
|
||||
p.fillRect(clip, st().bg);
|
||||
if (st().bg->c.alpha() > 0) {
|
||||
p.fillRect(clip, st().bg);
|
||||
}
|
||||
|
||||
paintStickers(p, clip);
|
||||
}
|
||||
@@ -886,6 +917,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||
toColumn = _columnCount - toColumn;
|
||||
}
|
||||
|
||||
_paintAsPremium = session().premium();
|
||||
_pathGradient->startFrame(0, width(), width() / 2);
|
||||
|
||||
auto &sets = shownSets();
|
||||
@@ -1459,7 +1491,26 @@ void StickersListWidget::paintSticker(
|
||||
p.setOpacity(1.);
|
||||
}
|
||||
|
||||
if (premium) {
|
||||
auto cornerPainted = false;
|
||||
const auto corner = (set.id == Data::Stickers::RecentSetId)
|
||||
? &_cornerEmoji
|
||||
: (set.id == SearchEmojiSectionSetId())
|
||||
? &_filterStickersCornerEmoji
|
||||
: nullptr;
|
||||
if (corner && !corner->empty() && _paintAsPremium) {
|
||||
Assert(index < corner->size());
|
||||
if (const auto emoji = (*corner)[index]) {
|
||||
const auto size = Ui::Emoji::GetSizeNormal();
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto radius = st::roundRadiusSmall;
|
||||
const auto position = pos
|
||||
+ QPoint(_singleSize.width(), _singleSize.height())
|
||||
- QPoint(size / ratio + radius, size / ratio + radius);
|
||||
Ui::Emoji::Draw(p, emoji, size, position.x(), position.y());
|
||||
cornerPainted = true;
|
||||
}
|
||||
}
|
||||
if (!cornerPainted && premium) {
|
||||
_premiumMark->paint(
|
||||
p,
|
||||
lottieFrame,
|
||||
@@ -1634,7 +1685,7 @@ void StickersListWidget::showStickerSetBox(not_null<DocumentData*> document) {
|
||||
}
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
|
||||
SendMenu::Type type) {
|
||||
const SendMenu::Details &details) {
|
||||
auto selected = _selected;
|
||||
auto &sets = shownSets();
|
||||
if (v::is_null(selected) || !v::is_null(_pressed)) {
|
||||
@@ -1653,7 +1704,7 @@ base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
|
||||
auto menu = base::make_unique_q<Ui::PopupMenu>(this, st().menu);
|
||||
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
const auto send = [=](Api::SendOptions options) {
|
||||
const auto send = crl::guard(this, [=](Api::SendOptions options) {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.options = options,
|
||||
@@ -1661,14 +1712,13 @@ base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
|
||||
? Ui::MessageSendingAnimationFrom()
|
||||
: messageSentAnimationInfo(section, index, document),
|
||||
});
|
||||
};
|
||||
});
|
||||
const auto icons = &st().icons;
|
||||
SendMenu::FillSendMenu(
|
||||
menu,
|
||||
type,
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(_show, type, send),
|
||||
SendMenu::DefaultWhenOnlineCallback(send),
|
||||
_show,
|
||||
details,
|
||||
SendMenu::DefaultCallback(_show, send),
|
||||
icons);
|
||||
|
||||
const auto show = _show;
|
||||
@@ -1918,6 +1968,11 @@ void StickersListWidget::setSection(Section section) {
|
||||
}
|
||||
clearHeavyData();
|
||||
_section = section;
|
||||
_recentShownCount = (section == Section::Search)
|
||||
? _filteredStickers.size()
|
||||
: _mySets.empty()
|
||||
? 0
|
||||
: _mySets.front().stickers.size();
|
||||
}
|
||||
|
||||
void StickersListWidget::clearHeavyData() {
|
||||
@@ -1929,10 +1984,13 @@ void StickersListWidget::clearHeavyData() {
|
||||
void StickersListWidget::refreshStickers() {
|
||||
clearSelection();
|
||||
|
||||
refreshMySets();
|
||||
refreshFeaturedSets();
|
||||
refreshSearchSets();
|
||||
|
||||
if (_isEffects) {
|
||||
refreshEffects();
|
||||
} else {
|
||||
refreshMySets();
|
||||
refreshFeaturedSets();
|
||||
refreshSearchSets();
|
||||
}
|
||||
resizeToWidth(width());
|
||||
|
||||
if (_footer) {
|
||||
@@ -1947,6 +2005,13 @@ void StickersListWidget::refreshStickers() {
|
||||
visibleTopBottomUpdated(getVisibleTop(), getVisibleBottom());
|
||||
}
|
||||
|
||||
void StickersListWidget::refreshEffects() {
|
||||
auto wasSets = base::take(_mySets);
|
||||
_mySets.reserve(1);
|
||||
refreshRecentStickers(false);
|
||||
takeHeavyData(_mySets, wasSets);
|
||||
}
|
||||
|
||||
void StickersListWidget::refreshMySets() {
|
||||
auto wasSets = base::take(_mySets);
|
||||
_favedStickersMap.clear();
|
||||
@@ -2108,7 +2173,26 @@ void StickersListWidget::refreshRecent() {
|
||||
}
|
||||
}
|
||||
|
||||
auto StickersListWidget::collectCustomRecents() -> std::vector<Sticker> {
|
||||
_custom.clear();
|
||||
_cornerEmoji.clear();
|
||||
auto result = std::vector<Sticker>();
|
||||
|
||||
result.reserve(_customRecentIds.size());
|
||||
for (const auto &descriptor : _customRecentIds) {
|
||||
if (const auto document = descriptor.document; document->sticker()) {
|
||||
result.push_back(Sticker{ document });
|
||||
_custom.push_back(false);
|
||||
_cornerEmoji.push_back(Ui::Emoji::Find(descriptor.cornerEmoji));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
|
||||
if (_isEffects) {
|
||||
return collectCustomRecents();
|
||||
}
|
||||
_custom.clear();
|
||||
auto result = std::vector<Sticker>();
|
||||
|
||||
@@ -2170,6 +2254,9 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
||||
clearSelection();
|
||||
|
||||
auto recentPack = collectRecentStickers();
|
||||
if (_section == Section::Stickers) {
|
||||
_recentShownCount = recentPack.size();
|
||||
}
|
||||
auto recentIt = std::find_if(_mySets.begin(), _mySets.end(), [](auto &set) {
|
||||
return set.id == Data::Stickers::RecentSetId;
|
||||
});
|
||||
@@ -2180,7 +2267,9 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
||||
Data::Stickers::RecentSetId,
|
||||
nullptr,
|
||||
(SetFlag::Official | SetFlag::Special),
|
||||
tr::lng_recent_stickers(tr::now),
|
||||
(_isEffects
|
||||
? tr::lng_effect_stickers_title(tr::now)
|
||||
: tr::lng_recent_stickers(tr::now)),
|
||||
shortName,
|
||||
recentPack.size(),
|
||||
externalLayout,
|
||||
@@ -2431,7 +2520,9 @@ void StickersListWidget::updateSelected() {
|
||||
}
|
||||
|
||||
bool StickersListWidget::setHasTitle(const Set &set) const {
|
||||
if (set.id == Data::Stickers::FavedSetId
|
||||
if (_isEffects) {
|
||||
return true;
|
||||
} else if (set.id == Data::Stickers::FavedSetId
|
||||
|| set.id == SearchEmojiSectionSetId()) {
|
||||
return false;
|
||||
} else if (set.id == Data::Stickers::RecentSetId) {
|
||||
@@ -2518,9 +2609,10 @@ void StickersListWidget::showStickerSet(uint64 setId) {
|
||||
const auto guard = gsl::finally([&] { _showingSetById = false; });
|
||||
|
||||
clearSelection();
|
||||
if (_search
|
||||
&& (!_searchQuery.isEmpty() || !_searchNextQuery.isEmpty())) {
|
||||
_search->cancel();
|
||||
if (!_searchQuery.isEmpty() || !_searchNextQuery.isEmpty()) {
|
||||
if (_search) {
|
||||
_search->cancel();
|
||||
}
|
||||
cancelSetsSearch();
|
||||
}
|
||||
|
||||
@@ -2623,14 +2715,18 @@ void StickersListWidget::setupSearch() {
|
||||
? TabbedSearchType::Greeting
|
||||
: TabbedSearchType::Stickers;
|
||||
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
||||
auto set = base::flat_set<EmojiPtr>();
|
||||
auto text = ranges::accumulate(query, QString(), [](
|
||||
applySearchQuery(std::move(query));
|
||||
}, session, type);
|
||||
}
|
||||
|
||||
void StickersListWidget::applySearchQuery(std::vector<QString> &&query) {
|
||||
auto set = base::flat_set<EmojiPtr>();
|
||||
auto text = ranges::accumulate(query, QString(), [](
|
||||
QString a,
|
||||
QString b) {
|
||||
return a.isEmpty() ? b : (a + ' ' + b);
|
||||
});
|
||||
searchForSets(std::move(text), SearchEmoji(query, set));
|
||||
}, session, type);
|
||||
return a.isEmpty() ? b : (a + ' ' + b);
|
||||
});
|
||||
searchForSets(std::move(text), SearchEmoji(query, set));
|
||||
}
|
||||
|
||||
void StickersListWidget::displaySet(uint64 setId) {
|
||||
@@ -2705,6 +2801,32 @@ bool StickersListWidget::mySetsEmpty() const {
|
||||
return _mySets.empty();
|
||||
}
|
||||
|
||||
void StickersListWidget::filterEffectsByEmoji(
|
||||
const std::vector<EmojiPtr> &emoji) {
|
||||
_filteredStickers.clear();
|
||||
_filterStickersCornerEmoji.clear();
|
||||
if (_mySets.empty()
|
||||
|| _mySets.front().id != Data::Stickers::RecentSetId
|
||||
|| _mySets.front().stickers.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto &list = _mySets.front().stickers;
|
||||
auto all = base::flat_set<EmojiPtr>();
|
||||
for (const auto &one : emoji) {
|
||||
all.emplace(one->original());
|
||||
}
|
||||
const auto count = int(list.size());
|
||||
_filteredStickers.reserve(count);
|
||||
_filterStickersCornerEmoji.reserve(count);
|
||||
for (auto i = 0; i != count; ++i) {
|
||||
Assert(i < _cornerEmoji.size());
|
||||
if (all.contains(_cornerEmoji[i])) {
|
||||
_filteredStickers.push_back(list[i].document);
|
||||
_filterStickersCornerEmoji.push_back(_cornerEmoji[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StickersListWidget::~StickersListWidget() = default;
|
||||
|
||||
object_ptr<Ui::BoxContent> MakeConfirmRemoveSetBox(
|
||||
|
||||