Compare commits
331 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7c14f17a7 | ||
|
|
0b6bd7075a | ||
|
|
148690d8b1 | ||
|
|
a422aec99a | ||
|
|
813d0501da | ||
|
|
db80096e6b | ||
|
|
cf896aeb13 | ||
|
|
76314e3c03 | ||
|
|
8959679b3c | ||
|
|
bb6c94ef4f | ||
|
|
fb9ce6d3a8 | ||
|
|
dac4389e37 | ||
|
|
a25b2e9700 | ||
|
|
699a7bdc58 | ||
|
|
4108debca0 | ||
|
|
8b2bbfba6a | ||
|
|
4f37343e8b | ||
|
|
2dcf40817e | ||
|
|
3eeb01be61 | ||
|
|
6a8a85e395 | ||
|
|
031233ea98 | ||
|
|
4b09050061 | ||
|
|
992c876930 | ||
|
|
a5ffd8b7cf | ||
|
|
5fdd4eba80 | ||
|
|
54ce85f8e6 | ||
|
|
0bfb0fd045 | ||
|
|
8ad2d3d39a | ||
|
|
b8a19b56b6 | ||
|
|
24b93a5eff | ||
|
|
127f651d5e | ||
|
|
e760a0983f | ||
|
|
3f2cb8f8c9 | ||
|
|
bcb6e9e1af | ||
|
|
847d66c973 | ||
|
|
5c797d1f31 | ||
|
|
f749616dd8 | ||
|
|
3cc92e01fe | ||
|
|
06f2b23687 | ||
|
|
6a167b33f5 | ||
|
|
850155b3be | ||
|
|
358e586801 | ||
|
|
54214ff2ad | ||
|
|
06fc813e95 | ||
|
|
0046bae53f | ||
|
|
aeb5e57061 | ||
|
|
a32b781e49 | ||
|
|
caef698e54 | ||
|
|
e9650385ad | ||
|
|
f55584b160 | ||
|
|
b0981ea8e3 | ||
|
|
a141d01a23 | ||
|
|
6a000207ee | ||
|
|
ee6edf9caa | ||
|
|
37907636e6 | ||
|
|
3f0f3a3c11 | ||
|
|
db0856f71c | ||
|
|
86cdda2277 | ||
|
|
3888e8084a | ||
|
|
517b456670 | ||
|
|
77d6e19214 | ||
|
|
fb64452495 | ||
|
|
24fabf2590 | ||
|
|
9b2847a11d | ||
|
|
c18e8fd777 | ||
|
|
f4afa762d8 | ||
|
|
5e1fb6ebbf | ||
|
|
2c7922ce7b | ||
|
|
ac78ae823c | ||
|
|
1ef6f462f6 | ||
|
|
c81f406759 | ||
|
|
889ec0c731 | ||
|
|
677fbdd84e | ||
|
|
1ebe3255e0 | ||
|
|
c70866a995 | ||
|
|
fd982b90db | ||
|
|
9461095c88 | ||
|
|
a2fa1a52e2 | ||
|
|
a847969e9c | ||
|
|
4d647e64b7 | ||
|
|
f8b756d447 | ||
|
|
484c647b5b | ||
|
|
730c968b1e | ||
|
|
8a6a749296 | ||
|
|
2f22a8f46b | ||
|
|
f123a9e16c | ||
|
|
11c45b0342 | ||
|
|
2cd6bfef06 | ||
|
|
61ca619db4 | ||
|
|
675ee9088f | ||
|
|
28a6aa45b9 | ||
|
|
08ec9e6bfd | ||
|
|
ee9f99a754 | ||
|
|
2412183b83 | ||
|
|
e83704982f | ||
|
|
6f86acf712 | ||
|
|
c22698084f | ||
|
|
8c55364afa | ||
|
|
2c3ef13b01 | ||
|
|
03454ca3b4 | ||
|
|
8a92c89f39 | ||
|
|
b83b403b75 | ||
|
|
8aac07b3c0 | ||
|
|
b4dfc25df5 | ||
|
|
917d1841c1 | ||
|
|
8ce10d5503 | ||
|
|
a130bb1be6 | ||
|
|
de52ac6b28 | ||
|
|
310837c9e1 | ||
|
|
8e6d7bb190 | ||
|
|
025ab40687 | ||
|
|
2a5071b66c | ||
|
|
2a63496054 | ||
|
|
a52d4eb4e8 | ||
|
|
4f7a124f3e | ||
|
|
4b9eb37bd5 | ||
|
|
1d5e4040f4 | ||
|
|
6818b8d8dc | ||
|
|
3f0b962ae5 | ||
|
|
8ac1ad3484 | ||
|
|
c6e1cf639e | ||
|
|
5b9278eced | ||
|
|
03d4dd00d4 | ||
|
|
f7d698b9ff | ||
|
|
46b69a938b | ||
|
|
ebba58217c | ||
|
|
94ad8f9bc3 | ||
|
|
6effac7915 | ||
|
|
78093173a9 | ||
|
|
a01d48f063 | ||
|
|
149c69c9f5 | ||
|
|
df277b366b | ||
|
|
f20475f07e | ||
|
|
b6664625ea | ||
|
|
1028219276 | ||
|
|
219671a3bc | ||
|
|
8c97e915ec | ||
|
|
b648548001 | ||
|
|
b377c02ad3 | ||
|
|
66d6b461f3 | ||
|
|
054a6db3ae | ||
|
|
bf7042df44 | ||
|
|
aa140b2919 | ||
|
|
8d0d9bb0bd | ||
|
|
9ca9904732 | ||
|
|
e6e1b9446d | ||
|
|
a507d28b49 | ||
|
|
ec2faca145 | ||
|
|
17bb430006 | ||
|
|
8cbeadc68a | ||
|
|
3947056654 | ||
|
|
ad7d1fddf0 | ||
|
|
ab20f8eb31 | ||
|
|
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 |
4
.github/workflows/mac_packaged.yml
vendored
@@ -69,7 +69,7 @@ jobs:
|
||||
run: |
|
||||
brew update
|
||||
brew upgrade || true
|
||||
brew install autoconf automake boost cmake ffmpeg@6 openal-soft openssl opus ninja pkg-config python qt yasm xz
|
||||
brew install autoconf automake boost cmake ffmpeg@6 openal-soft openh264 openssl opus ninja pkg-config python qt yasm xz
|
||||
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
|
||||
|
||||
xcodebuild -version > CACHE_KEY.txt
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
run: |
|
||||
cd $LibrariesPath
|
||||
|
||||
git clone --recursive --depth=1 $GIT/desktop-app/tg_owt.git
|
||||
git clone --depth=1 --recursive --shallow-submodules $GIT/desktop-app/tg_owt.git
|
||||
cd tg_owt
|
||||
|
||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=Debug
|
||||
|
||||
2
.github/workflows/win.yml
vendored
@@ -169,6 +169,8 @@ jobs:
|
||||
%TDESKTOP_BUILD_GENERATOR% ^
|
||||
%TDESKTOP_BUILD_ARCH% ^
|
||||
%TDESKTOP_BUILD_API% ^
|
||||
-D CMAKE_C_FLAGS="/WX" ^
|
||||
-D CMAKE_CXX_FLAGS="/WX" ^
|
||||
-D DESKTOP_APP_DISABLE_AUTOUPDATE=OFF ^
|
||||
-D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF ^
|
||||
-D DESKTOP_APP_NO_PDB=ON ^
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -126,6 +126,7 @@ PRIVATE
|
||||
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
|
||||
@@ -164,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
|
||||
@@ -267,6 +272,8 @@ PRIVATE
|
||||
boxes/edit_caption_box.h
|
||||
boxes/edit_privacy_box.cpp
|
||||
boxes/edit_privacy_box.h
|
||||
boxes/gift_credits_box.cpp
|
||||
boxes/gift_credits_box.h
|
||||
boxes/gift_premium_box.cpp
|
||||
boxes/gift_premium_box.h
|
||||
boxes/language_box.cpp
|
||||
@@ -470,6 +477,8 @@ PRIVATE
|
||||
data/business/data_shortcut_messages.h
|
||||
data/components/factchecks.cpp
|
||||
data/components/factchecks.h
|
||||
data/components/location_pickers.cpp
|
||||
data/components/location_pickers.h
|
||||
data/components/recent_peers.cpp
|
||||
data/components/recent_peers.h
|
||||
data/components/scheduled_messages.cpp
|
||||
@@ -722,8 +731,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
|
||||
@@ -887,6 +894,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
|
||||
@@ -895,10 +906,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
|
||||
@@ -1465,6 +1476,8 @@ PRIVATE
|
||||
ui/chat/choose_send_as.h
|
||||
ui/chat/choose_theme_controller.cpp
|
||||
ui/chat/choose_theme_controller.h
|
||||
ui/controls/location_picker.cpp
|
||||
ui/controls/location_picker.h
|
||||
ui/controls/silent_toggle.cpp
|
||||
ui/controls/silent_toggle.h
|
||||
ui/controls/userpic_button.cpp
|
||||
@@ -1486,6 +1499,10 @@ PRIVATE
|
||||
ui/image/image_location.h
|
||||
ui/image/image_location_factory.cpp
|
||||
ui/image/image_location_factory.h
|
||||
ui/text/format_song_document_name.cpp
|
||||
ui/text/format_song_document_name.h
|
||||
ui/widgets/label_with_custom_emoji.cpp
|
||||
ui/widgets/label_with_custom_emoji.h
|
||||
ui/countryinput.cpp
|
||||
ui/countryinput.h
|
||||
ui/dynamic_thumbnails.cpp
|
||||
@@ -1499,10 +1516,6 @@ PRIVATE
|
||||
ui/resize_area.h
|
||||
ui/search_field_controller.cpp
|
||||
ui/search_field_controller.h
|
||||
ui/text/format_song_document_name.cpp
|
||||
ui/text/format_song_document_name.h
|
||||
ui/widgets/label_with_custom_emoji.cpp
|
||||
ui/widgets/label_with_custom_emoji.h
|
||||
ui/unread_badge.cpp
|
||||
ui/unread_badge.h
|
||||
window/main_window.cpp
|
||||
@@ -1539,6 +1552,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
|
||||
@@ -1605,6 +1620,7 @@ PRIVATE
|
||||
qrc/telegram/animations.qrc
|
||||
qrc/telegram/export.qrc
|
||||
qrc/telegram/iv.qrc
|
||||
qrc/telegram/picker.qrc
|
||||
qrc/telegram/telegram.qrc
|
||||
qrc/telegram/sounds.qrc
|
||||
winrc/Telegram.rc
|
||||
@@ -1828,12 +1844,49 @@ 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)
|
||||
if (NOT build_winarm)
|
||||
target_link_options(Telegram PRIVATE
|
||||
/DELAYLOAD:API-MS-Win-EventLog-Legacy-l1-1-0.dll
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_options(Telegram
|
||||
PRIVATE
|
||||
/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 # We shadowed GetDpiForMonitor
|
||||
/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/chat/filled_location.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
Telegram/Resources/icons/chat/filled_location@2x.png
Normal file
|
After Width: | Height: | Size: 987 B |
BIN
Telegram/Resources/icons/chat/filled_location@3x.png
Normal file
|
After Width: | Height: | Size: 1.5 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 |
|
After Width: | Height: | Size: 771 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -618,9 +618,6 @@ var IV = {
|
||||
element.getAnimations().forEach(
|
||||
(animation) => animation.finish());
|
||||
},
|
||||
back: function () {
|
||||
window.history.back();
|
||||
},
|
||||
menuShown: function (shown) {
|
||||
var already = document.getElementById('menu_page_blocker');
|
||||
if (already && shown) {
|
||||
|
||||
@@ -683,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";
|
||||
@@ -897,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?";
|
||||
@@ -991,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";
|
||||
@@ -1100,6 +1115,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_settings_faq" = "Telegram FAQ";
|
||||
"lng_settings_faq_link" = "https://telegram.org/faq#general-questions";
|
||||
"lng_settings_features" = "Telegram Features";
|
||||
"lng_settings_credits" = "Your Stars";
|
||||
"lng_settings_logout" = "Log Out";
|
||||
"lng_sure_logout" = "Are you sure you want to log out?";
|
||||
|
||||
@@ -1432,6 +1448,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_info_topic_title" = "Topic Info";
|
||||
"lng_profile_enable_notifications" = "Notifications";
|
||||
"lng_profile_send_message" = "Send Message";
|
||||
"lng_profile_open_app" = "Open App";
|
||||
"lng_profile_open_app_about" = "By launching this mini app, you agree to the {terms}.";
|
||||
"lng_profile_open_app_terms" = "Terms of Service for Mini Apps";
|
||||
"lng_info_add_as_contact" = "Add to contacts";
|
||||
"lng_profile_shared_media" = "Shared media";
|
||||
"lng_profile_suggest_photo" = "Suggest Profile Photo";
|
||||
@@ -1560,6 +1579,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";
|
||||
@@ -1828,6 +1848,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_action_webview_data_done" = "You have just successfully transferred data from the «{text}» button to the bot.";
|
||||
"lng_action_gift_received" = "{user} sent you a gift for {cost}";
|
||||
"lng_action_gift_received_me" = "You sent to {user} a gift for {cost}";
|
||||
"lng_action_gift_received_anonymous" = "Unknown user sent you a gift for {cost}";
|
||||
"lng_action_suggested_photo_me" = "You suggested {user} to use this profile photo.";
|
||||
"lng_action_suggested_photo" = "{user} suggests you to use this profile photo.";
|
||||
"lng_action_suggested_photo_button" = "View Photo";
|
||||
@@ -1872,6 +1893,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_action_boost_apply#one" = "{from} boosted the group";
|
||||
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";
|
||||
"lng_action_set_chat_intro" = "{from} added the message below for all empty chats. How?";
|
||||
"lng_action_payment_refunded" = "{peer} refunded back {amount}";
|
||||
|
||||
"lng_similar_channels_title" = "Similar channels";
|
||||
"lng_similar_channels_view_all" = "View all";
|
||||
@@ -2185,6 +2207,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";
|
||||
@@ -2322,18 +2346,50 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_credits_summary_history_tab_out" = "Outgoing";
|
||||
"lng_credits_summary_history_entry_inner_in" = "In-App Purchase";
|
||||
"lng_credits_summary_balance" = "Balance";
|
||||
"lng_credits_gift_button" = "Gift Stars to Friends";
|
||||
"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_box_out_about_link" = "https://telegram.org/tos/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_peer_in" = "From";
|
||||
"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_anonymous" = "Unknown User";
|
||||
"lng_credits_box_history_entry_gift_name" = "Received Gift";
|
||||
"lng_credits_box_history_entry_gift_sent" = "Sent Gift";
|
||||
"lng_credits_box_history_entry_gift_out_about" = "With Stars, **{user}** will be able to unlock content and services on Telegram.\n{link}";
|
||||
"lng_credits_box_history_entry_gift_in_about" = "Use Stars to unlock content and services on Telegram. {link}";
|
||||
"lng_credits_box_history_entry_gift_about_link" = "See Examples {emoji}";
|
||||
"lng_credits_box_history_entry_gift_about_url" = "https://telegram.org/blog/telegram-stars";
|
||||
"lng_credits_box_history_entry_ads" = "Ads Platform";
|
||||
"lng_credits_box_history_entry_premium_bot" = "Stars Top-Up";
|
||||
"lng_credits_box_history_entry_via_premium_bot" = "Premium Bot";
|
||||
"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";
|
||||
@@ -2341,9 +2397,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"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_credits_gift_title" = "Gift Telegram Stars";
|
||||
|
||||
"lng_location_title" = "Location";
|
||||
"lng_location_about" = "Display the location of your business on your account.";
|
||||
"lng_location_address" = "Enter Address";
|
||||
"lng_location_set_map" = "Set Location on Map";
|
||||
"lng_location_fallback" = "You can set your location on the map from your mobile device.";
|
||||
|
||||
"lng_hours_title" = "Business Hours";
|
||||
@@ -2772,12 +2831,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_prizes_badge" = "x{amount}";
|
||||
|
||||
"lng_prizes_results_title" = "Winners Selected!";
|
||||
"lng_prizes_results_title_one" = "Winner Selected!";
|
||||
"lng_prizes_results_about#one" = "**{count}** winner of the {link} was randomly selected by Telegram.";
|
||||
"lng_prizes_results_about#other" = "**{count}** winners of the {link} were randomly selected by Telegram.";
|
||||
"lng_prizes_results_link" = "Giveaway";
|
||||
"lng_prizes_results_winner" = "Winner";
|
||||
"lng_prizes_results_winners" = "Winners";
|
||||
"lng_prizes_results_more#one" = "and {count} more!";
|
||||
"lng_prizes_results_more#other" = "and {count} more!";
|
||||
"lng_prizes_results_one" = "The winner received their gift link in a private message.";
|
||||
"lng_prizes_results_all" = "All winners received gift links in private messages.";
|
||||
"lng_prizes_results_some" = "Some winners couldn't be selected.";
|
||||
|
||||
@@ -2807,6 +2869,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_gift_link_pending_toast" = "Only the recipient can see the link.";
|
||||
"lng_gift_link_pending_footer" = "This link hasn't been activated yet.";
|
||||
|
||||
"lng_gift_stars_title#one" = "{count} Star";
|
||||
"lng_gift_stars_title#other" = "{count} Stars";
|
||||
"lng_gift_stars_outgoing" = "With Stars, {user} will be able to unlock content and services on Telegram.";
|
||||
"lng_gift_stars_incoming" = "Use Stars to unlock content and services on Telegram.";
|
||||
|
||||
"lng_accounts_limit_title" = "Limit Reached";
|
||||
"lng_accounts_limit1#one" = "You have reached the limit of **{count}** connected accounts.";
|
||||
"lng_accounts_limit1#other" = "You have reached the limit of **{count}** connected accounts.";
|
||||
@@ -2882,6 +2949,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_masks_has_been_archived" = "Mask pack has been archived.";
|
||||
"lng_masks_installed" = "Mask pack has been installed.";
|
||||
"lng_emoji_nothing_found" = "No emoji found";
|
||||
"lng_stickers_context_reorder" = "Reorder";
|
||||
"lng_stickers_context_edit_name" = "Edit name";
|
||||
"lng_stickers_context_delete" = "Delete sticker";
|
||||
"lng_stickers_context_delete_sure" = "Are you sure you want to delete the sticker from your sticker set?";
|
||||
"lng_stickers_box_edit_name_title" = "Edit Sticker Set Name";
|
||||
"lng_stickers_box_edit_name_about" = "Choose a name for your set.";
|
||||
"lng_stickers_creator_badge" = "edit";
|
||||
|
||||
"lng_in_dlg_photo" = "Photo";
|
||||
"lng_in_dlg_album" = "Album";
|
||||
@@ -3113,6 +3187,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_bot_close_warning_sure" = "Close anyway";
|
||||
"lng_bot_add_to_side_menu" = "{bot} asks your permission to be added as an option to your main menu so you can access it any time.";
|
||||
"lng_bot_add_to_side_menu_done" = "Bot added to the main menu.";
|
||||
"lng_bot_no_scan_qr" = "QR Codes for bots are not supported on Desktop. Please use one of Telegram's mobile apps.";
|
||||
"lng_bot_click_to_start" = "Click here to use this bot.";
|
||||
"lng_bot_status_users#one" = "{count} user";
|
||||
"lng_bot_status_users#other" = "{count} users";
|
||||
|
||||
"lng_typing" = "typing";
|
||||
"lng_user_typing" = "{user} is typing";
|
||||
@@ -3148,6 +3226,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_unread_bar_some" = "Unread messages";
|
||||
|
||||
"lng_maps_point" = "Location";
|
||||
"lng_maps_select_on_map" = "Select on the Map";
|
||||
"lng_maps_point_send" = "Send This Location";
|
||||
"lng_maps_point_set" = "Set This Location";
|
||||
"lng_maps_or_choose" = "Or choose a venue";
|
||||
"lng_maps_places_in_area" = "Places in this area";
|
||||
"lng_maps_no_places" = "No places found";
|
||||
"lng_maps_choose_to_search" = "Choose location to see places nearby.";
|
||||
"lng_maps_venues_source" = "Powered by Foursquare";
|
||||
"lng_live_location" = "Live Location";
|
||||
"lng_live_location_now" = "updated just now";
|
||||
"lng_live_location_minutes#one" = "updated {count} minute ago";
|
||||
@@ -3305,6 +3391,8 @@ 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";
|
||||
@@ -3316,6 +3404,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"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}";
|
||||
"lng_translate_bar_to_other" = "Translate to {name}";
|
||||
@@ -3582,6 +3678,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.";
|
||||
@@ -3689,6 +3788,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_payments_card_declined" = "Your card was declined.";
|
||||
"lng_payments_payment_failed" = "Payment failed. Your card has not been billed.";
|
||||
"lng_payments_precheckout_failed" = "The bot couldn't process your payment. Your card has not been billed.";
|
||||
"lng_payments_precheckout_timeout" = "The bot didn't respond in time. Your card has not been billed.";
|
||||
"lng_payments_precheckout_stars_failed" = "The bot couldn't process your payment.";
|
||||
"lng_payments_precheckout_stars_timeout" = "The bot didn't respond in time.";
|
||||
"lng_payments_already_paid" = "You have already paid for this item.";
|
||||
|
||||
"lng_payments_terms_title" = "Terms of Service";
|
||||
@@ -4132,6 +4234,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.";
|
||||
@@ -5159,6 +5262,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";
|
||||
@@ -5181,6 +5285,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";
|
||||
@@ -5218,12 +5346,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_recent_none" = "Recent search results\nwill appear here.";
|
||||
"lng_recent_chats" = "Chats";
|
||||
"lng_recent_channels" = "Channels";
|
||||
"lng_recent_apps" = "Apps";
|
||||
"lng_channels_none_title" = "No channels yet...";
|
||||
"lng_channels_none_about" = "You are not currently subscribed to any channels.";
|
||||
"lng_channels_your_title" = "Channels you joined";
|
||||
"lng_channels_your_more" = "Show more";
|
||||
"lng_channels_your_less" = "Show less";
|
||||
"lng_channels_recommended" = "Recommended channels";
|
||||
"lng_bot_apps_your" = "Apps you use";
|
||||
"lng_bot_apps_popular" = "Popular apps";
|
||||
|
||||
"lng_font_box_title" = "Choose font family";
|
||||
"lng_font_default" = "Default";
|
||||
|
||||
120
Telegram/Resources/picker_html/picker.css
Normal file
@@ -0,0 +1,120 @@
|
||||
:root {
|
||||
--font-sans: -apple-system, BlinkMacSystemFont, avenir next, avenir, Segoe UI Variable Text, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, tahoma, arial, sans-serif;
|
||||
}
|
||||
|
||||
html {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-sans);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color: var(--td-window-bg);
|
||||
color: var(--td-window-fg);
|
||||
}
|
||||
|
||||
html.custom_scroll ::-webkit-scrollbar {
|
||||
border-radius: 5px !important;
|
||||
border: 3px solid transparent !important;
|
||||
background-color: var(--td-scroll-bg) !important;
|
||||
background-clip: content-box !important;
|
||||
width: 10px !important;
|
||||
}
|
||||
html.custom_scroll ::-webkit-scrollbar:hover {
|
||||
background-color: var(--td-scroll-bg-over) !important;
|
||||
}
|
||||
html.custom_scroll ::-webkit-scrollbar-thumb {
|
||||
border-radius: 5px !important;
|
||||
border: 3px solid transparent !important;
|
||||
background-color: var(--td-scroll-bar-bg) !important;
|
||||
background-clip: content-box !important;
|
||||
}
|
||||
html.custom_scroll ::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--td-scroll-bar-bg-over) !important;
|
||||
}
|
||||
|
||||
#map {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#marker {
|
||||
pointer-events: none;
|
||||
display: none;
|
||||
z-index: 2;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
#marker_drop {
|
||||
margin-bottom: 0px;
|
||||
transition: margin 160ms ease-in-out;
|
||||
}
|
||||
#marker_drop.moving {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
#marker_shadow {
|
||||
position: absolute;
|
||||
}
|
||||
#search_venues {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 2;
|
||||
top: -30px;
|
||||
transition: top 200ms ease-in-out;
|
||||
}
|
||||
#search_venues.shown {
|
||||
top: 6px;
|
||||
}
|
||||
#search_venues_inner {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
background: var(--td-window-bg);
|
||||
color: var(--td-window-active-text-fg);
|
||||
cursor: pointer;
|
||||
border-radius: 14px;
|
||||
padding: 5px 12px 6px;
|
||||
box-shadow: 0 0 3px 0px var(--td-history-to-down-shadow);
|
||||
}
|
||||
#search_venues_inner:hover {
|
||||
background: var(--td-window-bg-over);
|
||||
}
|
||||
#search_venues_content {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
#search_venues_content:before {
|
||||
content: var(--td-lng-maps-places-in-area);
|
||||
}
|
||||
#search_venues_inner .ripple .inner {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
transform: scale(0);
|
||||
opacity: 1;
|
||||
animation: ripple 650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
||||
background-color: var(--td-window-bg-ripple);
|
||||
}
|
||||
#search_venues_inner .ripple.hiding {
|
||||
animation: fadeOut 200ms linear forwards;
|
||||
}
|
||||
@keyframes ripple {
|
||||
to {
|
||||
transform: scale(2);
|
||||
}
|
||||
}
|
||||
@keyframes fadeOut {
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
199
Telegram/Resources/picker_html/picker.js
Normal file
@@ -0,0 +1,199 @@
|
||||
var LocationPicker = {
|
||||
startZoom: 14,
|
||||
flySpeed: 2.4,
|
||||
notify: function(message) {
|
||||
if (window.external && window.external.invoke) {
|
||||
window.external.invoke(JSON.stringify(message));
|
||||
}
|
||||
},
|
||||
frameKeyDown: function (e) {
|
||||
const keyW = (e.key === 'w')
|
||||
|| (e.code === 'KeyW')
|
||||
|| (e.keyCode === 87);
|
||||
const keyQ = (e.key === 'q')
|
||||
|| (e.code === 'KeyQ')
|
||||
|| (e.keyCode === 81);
|
||||
const keyM = (e.key === 'm')
|
||||
|| (e.code === 'KeyM')
|
||||
|| (e.keyCode === 77);
|
||||
if ((e.metaKey || e.ctrlKey) && (keyW || keyQ || keyM)) {
|
||||
e.preventDefault();
|
||||
LocationPicker.notify({
|
||||
event: 'keydown',
|
||||
modifier: e.ctrlKey ? 'ctrl' : 'cmd',
|
||||
key: keyW ? 'w' : keyQ ? 'q' : 'm',
|
||||
});
|
||||
} else if (e.key === 'Escape' || e.keyCode === 27) {
|
||||
e.preventDefault();
|
||||
LocationPicker.notify({
|
||||
event: 'keydown',
|
||||
key: 'escape',
|
||||
});
|
||||
}
|
||||
},
|
||||
isNight: function() {
|
||||
var html = document.getElementsByTagName('html')[0];
|
||||
return html.style.getPropertyValue('--td-night') == '1';
|
||||
},
|
||||
lightPreset: function() {
|
||||
return LocationPicker.isNight() ? 'night' : 'day';
|
||||
},
|
||||
updateStyles: function (styles) {
|
||||
if (LocationPicker.styles !== styles) {
|
||||
LocationPicker.styles = styles;
|
||||
document.getElementsByTagName('html')[0].style = styles;
|
||||
|
||||
LocationPicker.map.setConfigProperty(
|
||||
'basemap',
|
||||
'lightPreset',
|
||||
LocationPicker.lightPreset());
|
||||
}
|
||||
},
|
||||
init: function (params) {
|
||||
mapboxgl.accessToken = params.token;
|
||||
if (params.protocol) {
|
||||
mapboxgl.config.API_URL = params.protocol + '://domain/api.mapbox.com';
|
||||
}
|
||||
|
||||
var options = { container: 'map', config: {
|
||||
basemap: { lightPreset: LocationPicker.lightPreset() }
|
||||
} };
|
||||
var center = params.center;
|
||||
if (center) {
|
||||
center = [center[1], center[0]];
|
||||
options.center = center;
|
||||
options.zoom = LocationPicker.startZoom;
|
||||
} else if (params.bounds) {
|
||||
options.bounds = params.bounds;
|
||||
center = new mapboxgl.LngLatBounds(params.bounds).getCenter();
|
||||
} else {
|
||||
center = [0, 0];
|
||||
}
|
||||
LocationPicker.map = new mapboxgl.Map(options);
|
||||
LocationPicker.createMarker(center);
|
||||
LocationPicker.trackMovement();
|
||||
LocationPicker.initSearchVenueRipple();
|
||||
},
|
||||
marker: function() {
|
||||
return document.getElementById('marker_drop');
|
||||
},
|
||||
createMarker: function(center) {
|
||||
document.getElementById('marker').style.display = 'flex';
|
||||
},
|
||||
clearMovingTimer: function() {
|
||||
if (LocationPicker.clearMovingTimeoutId) {
|
||||
clearTimeout(LocationPicker.clearMovingTimeoutId);
|
||||
LocationPicker.clearMovingTimeoutId = 0;
|
||||
}
|
||||
},
|
||||
startMovingTimer: function(done) {
|
||||
LocationPicker.clearMovingTimer();
|
||||
LocationPicker.clearMovingTimeoutId = setTimeout(done, 500);
|
||||
},
|
||||
trackMovement: function() {
|
||||
LocationPicker.map.on('movestart', function() {
|
||||
LocationPicker.marker().classList.add('moving');
|
||||
LocationPicker.clearMovingTimer();
|
||||
LocationPicker.toggleSearchVenues(false);
|
||||
LocationPicker.notify({ event: 'move_start' });
|
||||
});
|
||||
LocationPicker.map.on('moveend', function() {
|
||||
LocationPicker.startMovingTimer(function() {
|
||||
LocationPicker.marker().classList.remove('moving');
|
||||
LocationPicker.notify({
|
||||
event: 'move_end',
|
||||
latitude: LocationPicker.map.getCenter().lat,
|
||||
longitude: LocationPicker.map.getCenter().lng
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
narrowTo: function (point) {
|
||||
LocationPicker.map.flyTo({
|
||||
center: [point[1], point[0]],
|
||||
zoom: LocationPicker.startZoom,
|
||||
speed: LocationPicker.flySpeed,
|
||||
});
|
||||
},
|
||||
send: function () {
|
||||
LocationPicker.notify({
|
||||
event: 'send',
|
||||
latitude: LocationPicker.map.getCenter().lat,
|
||||
longitude: LocationPicker.map.getCenter().lng
|
||||
});
|
||||
},
|
||||
addRipple: function (button, x, y) {
|
||||
const ripple = document.createElement('span');
|
||||
ripple.classList.add('ripple');
|
||||
|
||||
const inner = document.createElement('span');
|
||||
inner.classList.add('inner');
|
||||
|
||||
var rect = button.getBoundingClientRect();
|
||||
x -= rect.x;
|
||||
y -= rect.y;
|
||||
|
||||
const mx = button.clientWidth - x;
|
||||
const my = button.clientHeight - y;
|
||||
const sq1 = x * x + y * y;
|
||||
const sq2 = mx * mx + y * y;
|
||||
const sq3 = x * x + my * my;
|
||||
const sq4 = mx * mx + my * my;
|
||||
const radius = Math.sqrt(Math.max(sq1, sq2, sq3, sq4));
|
||||
|
||||
inner.style.width = inner.style.height = `${2 * radius}px`;
|
||||
inner.style.left = `${x - radius}px`;
|
||||
inner.style.top = `${y - radius}px`;
|
||||
inner.classList.add('inner');
|
||||
|
||||
ripple.addEventListener('animationend', function (e) {
|
||||
if (e.animationName === 'fadeOut') {
|
||||
ripple.remove();
|
||||
}
|
||||
});
|
||||
|
||||
ripple.appendChild(inner);
|
||||
button.appendChild(ripple);
|
||||
},
|
||||
stopRipples: function (button) {
|
||||
const id = button.id ? button.id : button;
|
||||
button = document.getElementById(id);
|
||||
const ripples = button.getElementsByClassName('ripple');
|
||||
for (var i = 0; i < ripples.length; ++i) {
|
||||
const ripple = ripples[i];
|
||||
if (!ripple.classList.contains('hiding')) {
|
||||
ripple.classList.add('hiding');
|
||||
}
|
||||
}
|
||||
},
|
||||
initSearchVenueRipple: function() {
|
||||
var button = document.getElementById('search_venues_inner');
|
||||
button.addEventListener('mousedown', function (e) {
|
||||
LocationPicker.addRipple(e.currentTarget, e.clientX, e.clientY);
|
||||
LocationPicker.searchVenuesPressed = true;
|
||||
});
|
||||
button.addEventListener('mouseup', function (e) {
|
||||
const id = e.currentTarget.id;
|
||||
setTimeout(function () {
|
||||
LocationPicker.stopRipples(id);
|
||||
}, 0);
|
||||
if (LocationPicker.searchVenuesPressed) {
|
||||
LocationPicker.searchVenuesPressed = false;
|
||||
LocationPicker.toggleSearchVenues(false);
|
||||
LocationPicker.notify({
|
||||
event: 'search_venues',
|
||||
latitude: LocationPicker.map.getCenter().lat,
|
||||
longitude: LocationPicker.map.getCenter().lng
|
||||
});
|
||||
}
|
||||
});
|
||||
button.addEventListener('mouseleave', function (e) {
|
||||
LocationPicker.stopRipples(e.currentTarget);
|
||||
LocationPicker.searchVenuesPressed = false;
|
||||
});
|
||||
},
|
||||
toggleSearchVenues: function(shown) {
|
||||
var button = document.getElementById('search_venues');
|
||||
button.classList.toggle('shown', shown);
|
||||
},
|
||||
};
|
||||
6
Telegram/Resources/qrc/telegram/picker.qrc
Normal file
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/picker">
|
||||
<file alias="picker.css">../../picker_html/picker.css</file>
|
||||
<file alias="picker.js">../../picker_html/picker.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -10,7 +10,7 @@
|
||||
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
|
||||
ProcessorArchitecture="ARCHITECTURE"
|
||||
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
|
||||
Version="5.1.4.0" />
|
||||
Version="5.3.0.0" />
|
||||
<Properties>
|
||||
<DisplayName>Telegram Desktop</DisplayName>
|
||||
<PublisherDisplayName>Telegram Messenger LLP</PublisherDisplayName>
|
||||
@@ -37,6 +37,9 @@
|
||||
<Extensions>
|
||||
<uap3:Extension Category="windows.protocol">
|
||||
<uap3:Protocol Name="tg" Parameters="-- "%1"" />
|
||||
<uap3:Extension Category="windows.protocol">
|
||||
</uap3:Extension>
|
||||
<uap3:Protocol Name="tonsite" Parameters="-- "%1"" />
|
||||
</uap3:Extension>
|
||||
<desktop:Extension
|
||||
Category="windows.startupTask"
|
||||
|
||||
@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 5,1,4,0
|
||||
PRODUCTVERSION 5,1,4,0
|
||||
FILEVERSION 5,3,0,0
|
||||
PRODUCTVERSION 5,3,0,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.1.4.0"
|
||||
VALUE "FileVersion", "5.3.0.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2024"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "5.1.4.0"
|
||||
VALUE "ProductVersion", "5.3.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 5,1,4,0
|
||||
PRODUCTVERSION 5,1,4,0
|
||||
FILEVERSION 5,3,0,0
|
||||
PRODUCTVERSION 5,3,0,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.1.4.0"
|
||||
VALUE "FileVersion", "5.3.0.0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2014-2024"
|
||||
VALUE "ProductName", "Telegram Desktop"
|
||||
VALUE "ProductVersion", "5.1.4.0"
|
||||
VALUE "ProductVersion", "5.3.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -155,6 +155,7 @@ int main(int argc, char *argv[])
|
||||
QString remove;
|
||||
int version = 0;
|
||||
[[maybe_unused]] bool targetwin64 = false;
|
||||
[[maybe_unused]] bool targetwinarm = false;
|
||||
[[maybe_unused]] bool targetarmac = false;
|
||||
QFileInfoList files;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
@@ -165,6 +166,7 @@ int main(int argc, char *argv[])
|
||||
if (remove.isEmpty()) remove = info.canonicalPath() + "/";
|
||||
} else if (string("-target") == argv[i] && i + 1 < argc) {
|
||||
targetwin64 = (string("win64") == argv[i + 1]);
|
||||
targetwinarm = (string("winarm") == argv[i + 1]);
|
||||
} else if (string("-arch") == argv[i] && i + 1 < argc) {
|
||||
targetarmac = (string("arm64") == argv[i + 1]);
|
||||
if (!targetarmac && string("x86_64") != argv[i + 1]) {
|
||||
@@ -493,7 +495,7 @@ int main(int argc, char *argv[])
|
||||
cout << "Signature verified!\n";
|
||||
RSA_free(pbKey);
|
||||
#ifdef Q_OS_WIN
|
||||
QString outName((targetwin64 ? QString("tx64upd%1") : QString("tupdate%1")).arg(AlphaVersion ? AlphaVersion : version));
|
||||
QString outName((targetwinarm ? QString("tarm64upd%1") : targetwin64 ? QString("tx64upd%1") : QString("tupdate%1")).arg(AlphaVersion ? AlphaVersion : version));
|
||||
#elif defined Q_OS_MAC
|
||||
QString outName((targetarmac ? QString("tarmacupd%1") : QString("tmacupd%1")).arg(AlphaVersion ? AlphaVersion : version));
|
||||
#else
|
||||
|
||||
@@ -571,8 +571,8 @@ void _generateDump(EXCEPTION_POINTERS* pExceptionPointers) {
|
||||
}
|
||||
if (!hDumpFile || hDumpFile == INVALID_HANDLE_VALUE) {
|
||||
WCHAR wstrPath[maxFileLen];
|
||||
DWORD wstrPathLen;
|
||||
if (wstrPathLen = GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) {
|
||||
DWORD wstrPathLen = GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen);
|
||||
if (wstrPathLen) {
|
||||
wsprintf(wstrPath + wstrPathLen, L"\\%s\\", _programName);
|
||||
hDumpFile = _generateDumpFileAtPath(wstrPath);
|
||||
}
|
||||
|
||||
@@ -127,11 +127,7 @@ void SendBotCallbackData(
|
||||
UrlClickHandler::Open(link);
|
||||
return;
|
||||
}
|
||||
const auto scoreLink = AppendShareGameScoreUrl(
|
||||
session,
|
||||
link,
|
||||
item->fullId());
|
||||
BotGameUrlClickHandler(bot, scoreLink).onClick({
|
||||
BotGameUrlClickHandler(bot, link).onClick({
|
||||
Qt::LeftButton,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
.itemId = item->fullId(),
|
||||
@@ -492,20 +488,23 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
|
||||
|
||||
case ButtonType::WebView: {
|
||||
if (const auto bot = item->getMessageBot()) {
|
||||
bot->session().attachWebView().request(
|
||||
controller,
|
||||
Api::SendAction(bot->owner().history(bot)),
|
||||
bot,
|
||||
{ .text = button->text, .url = button->data });
|
||||
bot->session().attachWebView().open({
|
||||
.bot = bot,
|
||||
.context = { .controller = controller },
|
||||
.button = { .text = button->text, .url = button->data },
|
||||
.source = InlineBots::WebViewSourceButton{ .simple = false },
|
||||
});
|
||||
}
|
||||
} break;
|
||||
|
||||
case ButtonType::SimpleWebView: {
|
||||
if (const auto bot = item->getMessageBot()) {
|
||||
bot->session().attachWebView().requestSimple(
|
||||
controller,
|
||||
bot,
|
||||
{ .text = button->text, .url = button->data });
|
||||
bot->session().attachWebView().open({
|
||||
.bot = bot,
|
||||
.context = { .controller = controller },
|
||||
.button = {.text = button->text, .url = button->data },
|
||||
.source = InlineBots::WebViewSourceButton{ .simple = true },
|
||||
});
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Api {
|
||||
inline constexpr auto kScheduledUntilOnlineTimestamp = TimeId(0x7FFFFFFE);
|
||||
|
||||
struct SendOptions {
|
||||
uint64 price = 0;
|
||||
PeerData *sendAs = nullptr;
|
||||
TimeId scheduled = 0;
|
||||
BusinessShortcutId shortcutId = 0;
|
||||
@@ -29,6 +30,10 @@ struct SendOptions {
|
||||
bool invertCaption = false;
|
||||
bool hideViaBot = false;
|
||||
crl::time ttlSeconds = 0;
|
||||
|
||||
friend inline bool operator==(
|
||||
const SendOptions &,
|
||||
const SendOptions &) = default;
|
||||
};
|
||||
[[nodiscard]] SendOptions DefaultSendWhenOnlineOptions();
|
||||
|
||||
@@ -51,6 +56,10 @@ struct SendAction {
|
||||
MsgId replaceMediaOf = 0;
|
||||
|
||||
[[nodiscard]] MTPInputReplyTo mtpReplyTo() const;
|
||||
|
||||
friend inline bool operator==(
|
||||
const SendAction &,
|
||||
const SendAction &) = default;
|
||||
};
|
||||
|
||||
struct MessageToSend {
|
||||
|
||||
@@ -7,9 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "api/api_credits.h"
|
||||
|
||||
#include "apiwrap.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"
|
||||
@@ -20,25 +23,62 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
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()
|
||||
? peer->owner().photoFromWeb(*tl.data().vphoto(), ImageLocation())
|
||||
? 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,
|
||||
.bareId = tl.data().vpeer().match([](const HistoryPeerTL &p) {
|
||||
return peerFromMTP(p.vpeer());
|
||||
}, [](const auto &) {
|
||||
return PeerId(0);
|
||||
}).value,
|
||||
.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 &) {
|
||||
@@ -51,8 +91,18 @@ namespace {
|
||||
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),
|
||||
.gift = tl.data().is_gift(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,12 +134,12 @@ 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) {
|
||||
const auto giftBarePeerId = !_peer->isSelf() ? _peer->id.value : 0;
|
||||
|
||||
const auto optionsFromTL = [giftBarePeerId](const auto &options) {
|
||||
return ranges::views::all(
|
||||
options
|
||||
) | ranges::views::transform([=](const auto &option) {
|
||||
return Data::CreditTopupOption{
|
||||
.credits = option.data().vstars().v,
|
||||
.product = qs(
|
||||
@@ -97,12 +147,31 @@ rpl::producer<rpl::no_value, QString> CreditsTopupOptions::request() {
|
||||
.currency = qs(option.data().vcurrency()),
|
||||
.amount = option.data().vamount().v,
|
||||
.extended = option.data().is_extended(),
|
||||
.giftBarePeerId = giftBarePeerId,
|
||||
};
|
||||
}) | ranges::to_vector;
|
||||
consumer.put_done();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
};
|
||||
const auto fail = [=](const MTP::Error &error) {
|
||||
consumer.put_error_copy(error.type());
|
||||
}).send();
|
||||
};
|
||||
|
||||
if (_peer->isSelf()) {
|
||||
using TLOption = MTPStarsTopupOption;
|
||||
_api.request(MTPpayments_GetStarsTopupOptions(
|
||||
)).done([=](const MTPVector<TLOption> &result) {
|
||||
_options = optionsFromTL(result.v);
|
||||
consumer.put_done();
|
||||
}).fail(fail).send();
|
||||
} else if (const auto user = _peer->asUser()) {
|
||||
using TLOption = MTPStarsGiftOption;
|
||||
_api.request(MTPpayments_GetStarsGiftOptions(
|
||||
MTP_flags(MTPpayments_GetStarsGiftOptions::Flag::f_user_id),
|
||||
user->inputUser
|
||||
)).done([=](const MTPVector<TLOption> &result) {
|
||||
_options = optionsFromTL(result.v);
|
||||
consumer.put_done();
|
||||
}).fail(fail).send();
|
||||
}
|
||||
|
||||
return lifetime;
|
||||
};
|
||||
@@ -152,7 +221,8 @@ void CreditsHistory::request(
|
||||
_requestId = _api.request(MTPpayments_GetStarsTransactions(
|
||||
MTP_flags(_flags),
|
||||
_peer->isSelf() ? MTP_inputPeerSelf() : _peer->input,
|
||||
MTP_string(token)
|
||||
MTP_string(token),
|
||||
MTP_int(kTransactionsLimit)
|
||||
)).done([=](const MTPpayments_StarsStatus &result) {
|
||||
_requestId = 0;
|
||||
done(StatusFromTL(result, _peer));
|
||||
@@ -199,4 +269,58 @@ rpl::producer<not_null<PeerData*>> PremiumPeerBot(
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -7,13 +7,17 @@ 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 {
|
||||
@@ -68,6 +72,21 @@ private:
|
||||
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ mtpRequestId EditMessage(
|
||||
}
|
||||
|
||||
if (updateRecentStickers) {
|
||||
api->requestRecentStickersForce(true);
|
||||
api->requestSpecialStickersForce(false, false, true);
|
||||
}
|
||||
}).fail([=](const MTP::Error &error, mtpRequestId requestId) {
|
||||
if constexpr (ErrorWithId<FailCallback>) {
|
||||
@@ -153,9 +153,7 @@ mtpRequestId EditMessage(
|
||||
const auto &text = item->originalText();
|
||||
const auto webpage = (!item->media() || !item->media()->webpage())
|
||||
? Data::WebPageDraft{ .removed = true }
|
||||
: Data::WebPageDraft{
|
||||
.id = item->media()->webpage()->id,
|
||||
};
|
||||
: Data::WebPageDraft::FromItem(item);
|
||||
return EditMessage(
|
||||
item,
|
||||
text,
|
||||
|
||||
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
|
||||
@@ -36,7 +36,8 @@ MTPVector<MTPDocumentAttribute> ComposeSendingDocumentAttributes(
|
||||
MTP_double(document->duration() / 1000.),
|
||||
MTP_int(dimensions.width()),
|
||||
MTP_int(dimensions.height()),
|
||||
MTPint())); // preload_prefix_size
|
||||
MTPint(), // preload_prefix_size
|
||||
MTPdouble())); // video_start_ts
|
||||
} else {
|
||||
attributes.push_back(MTP_documentAttributeImageSize(
|
||||
MTP_int(dimensions.width()),
|
||||
|
||||
@@ -62,6 +62,79 @@ void InnerFillMessagePostFlags(
|
||||
}
|
||||
}
|
||||
|
||||
void SendSimpleMedia(SendAction action, MTPInputMedia inputMedia) {
|
||||
const auto history = action.history;
|
||||
const auto peer = history->peer;
|
||||
const auto session = &history->session();
|
||||
const auto api = &session->api();
|
||||
|
||||
action.clearDraft = false;
|
||||
action.generateLocal = false;
|
||||
api->sendAction(action);
|
||||
|
||||
const auto randomId = base::RandomValue<uint64>();
|
||||
|
||||
auto flags = NewMessageFlags(peer);
|
||||
auto sendFlags = MTPmessages_SendMedia::Flags(0);
|
||||
if (action.replyTo) {
|
||||
flags |= MessageFlag::HasReplyInfo;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to;
|
||||
}
|
||||
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||
InnerFillMessagePostFlags(action.options, peer, flags);
|
||||
if (silentPost) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||
}
|
||||
const auto sendAs = action.options.sendAs;
|
||||
if (sendAs) {
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
|
||||
}
|
||||
const auto messagePostAuthor = peer->isBroadcast()
|
||||
? session->user()->name()
|
||||
: QString();
|
||||
|
||||
if (action.options.scheduled) {
|
||||
flags |= MessageFlag::IsOrWasScheduled;
|
||||
sendFlags |= MTPmessages_SendMedia::Flag::f_schedule_date;
|
||||
}
|
||||
if (action.options.shortcutId) {
|
||||
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;
|
||||
}
|
||||
|
||||
auto &histories = history->owner().histories();
|
||||
histories.sendPreparedMessage(
|
||||
history,
|
||||
action.replyTo,
|
||||
randomId,
|
||||
Data::Histories::PrepareMessage<MTPmessages_SendMedia>(
|
||||
MTP_flags(sendFlags),
|
||||
peer->input,
|
||||
Data::Histories::ReplyToPlaceholder(),
|
||||
std::move(inputMedia),
|
||||
MTPstring(),
|
||||
MTP_long(randomId),
|
||||
MTPReplyMarkup(),
|
||||
MTPvector<MTPMessageEntity>(),
|
||||
MTP_int(action.options.scheduled),
|
||||
(sendAs ? sendAs->input : MTP_inputPeerEmpty()),
|
||||
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);
|
||||
});
|
||||
|
||||
api->finishForwarding(action);
|
||||
}
|
||||
|
||||
template <typename MediaData>
|
||||
void SendExistingMedia(
|
||||
MessageToSend &&message,
|
||||
@@ -362,6 +435,33 @@ bool SendDice(MessageToSend &message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SendLocation(SendAction action, float64 lat, float64 lon) {
|
||||
SendSimpleMedia(
|
||||
action,
|
||||
MTP_inputMediaGeoPoint(
|
||||
MTP_inputGeoPoint(
|
||||
MTP_flags(0),
|
||||
MTP_double(lat),
|
||||
MTP_double(lon),
|
||||
MTPint()))); // accuracy_radius
|
||||
}
|
||||
|
||||
void SendVenue(SendAction action, Data::InputVenue venue) {
|
||||
SendSimpleMedia(
|
||||
action,
|
||||
MTP_inputMediaVenue(
|
||||
MTP_inputGeoPoint(
|
||||
MTP_flags(0),
|
||||
MTP_double(venue.lat),
|
||||
MTP_double(venue.lon),
|
||||
MTPint()), // accuracy_radius
|
||||
MTP_string(venue.title),
|
||||
MTP_string(venue.address),
|
||||
MTP_string(venue.provider),
|
||||
MTP_string(venue.id),
|
||||
MTP_string(venue.venueType)));
|
||||
}
|
||||
|
||||
void FillMessagePostFlags(
|
||||
const SendAction &action,
|
||||
not_null<PeerData*> peer,
|
||||
|
||||
@@ -7,15 +7,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
class History;
|
||||
class PhotoData;
|
||||
class DocumentData;
|
||||
struct FilePrepareResult;
|
||||
|
||||
namespace Data {
|
||||
struct InputVenue;
|
||||
} // namespace Data
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Api {
|
||||
|
||||
struct MessageToSend;
|
||||
@@ -33,6 +37,13 @@ void SendExistingPhoto(
|
||||
|
||||
bool SendDice(MessageToSend &message);
|
||||
|
||||
// We can't create Data::LocationPoint() and use it
|
||||
// for a local sending message, because we can't request
|
||||
// map thumbnail in messages history without access hash.
|
||||
void SendLocation(SendAction action, float64 lat, float64 lon);
|
||||
|
||||
void SendVenue(SendAction action, Data::InputVenue venue);
|
||||
|
||||
void FillMessagePostFlags(
|
||||
const SendAction &action,
|
||||
not_null<PeerData*> peer,
|
||||
|
||||
@@ -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
|
||||
@@ -1696,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;
|
||||
|
||||
@@ -2121,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()) {
|
||||
@@ -2622,4 +2624,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@@ -2165,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(
|
||||
@@ -2584,7 +2585,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &resu
|
||||
void ApiWrap::updateStickers() {
|
||||
const auto now = crl::now();
|
||||
requestStickers(now);
|
||||
requestRecentStickers(now);
|
||||
requestRecentStickers(now, false);
|
||||
requestFavedStickers(now);
|
||||
requestFeaturedStickers(now);
|
||||
}
|
||||
@@ -2606,8 +2607,15 @@ void ApiWrap::updateCustomEmoji() {
|
||||
requestFeaturedEmoji(now);
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickersForce(bool attached) {
|
||||
requestRecentStickersWithHash(0, attached);
|
||||
void ApiWrap::requestSpecialStickersForce(
|
||||
bool faved,
|
||||
bool recent,
|
||||
bool attached) {
|
||||
if (faved) {
|
||||
requestFavedStickers(std::nullopt);
|
||||
} else if (recent || attached) {
|
||||
requestRecentStickers(std::nullopt, attached);
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::setGroupStickerSet(
|
||||
@@ -2760,18 +2768,17 @@ void ApiWrap::requestCustomEmoji(TimeId now) {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickers(TimeId now, bool attached) {
|
||||
const auto needed = attached
|
||||
? _session->data().stickers().recentAttachedUpdateNeeded(now)
|
||||
: _session->data().stickers().recentUpdateNeeded(now);
|
||||
void ApiWrap::requestRecentStickers(
|
||||
std::optional<TimeId> now,
|
||||
bool attached) {
|
||||
const auto needed = !now
|
||||
? true
|
||||
: attached
|
||||
? _session->data().stickers().recentAttachedUpdateNeeded(*now)
|
||||
: _session->data().stickers().recentUpdateNeeded(*now);
|
||||
if (!needed) {
|
||||
return;
|
||||
}
|
||||
requestRecentStickersWithHash(
|
||||
Api::CountRecentStickersHash(_session, attached), attached);
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
||||
const auto requestId = [=]() -> mtpRequestId & {
|
||||
return attached
|
||||
? _recentAttachedStickersUpdateRequest
|
||||
@@ -2794,7 +2801,7 @@ void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
||||
: MTPmessages_getRecentStickers::Flags(0);
|
||||
requestId() = request(MTPmessages_GetRecentStickers(
|
||||
MTP_flags(flags),
|
||||
MTP_long(hash)
|
||||
MTP_long(now ? Api::CountRecentStickersHash(_session, attached) : 0)
|
||||
)).done([=](const MTPmessages_RecentStickers &result) {
|
||||
finish();
|
||||
|
||||
@@ -2821,13 +2828,15 @@ void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
||||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::requestFavedStickers(TimeId now) {
|
||||
if (!_session->data().stickers().favedUpdateNeeded(now)
|
||||
|| _favedStickersUpdateRequest) {
|
||||
return;
|
||||
void ApiWrap::requestFavedStickers(std::optional<TimeId> now) {
|
||||
if (now) {
|
||||
if (!_session->data().stickers().favedUpdateNeeded(*now)
|
||||
|| _favedStickersUpdateRequest) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_favedStickersUpdateRequest = request(MTPmessages_GetFavedStickers(
|
||||
MTP_long(Api::CountFavedStickersHash(_session))
|
||||
MTP_long(now ? Api::CountFavedStickersHash(_session) : 0)
|
||||
)).done([=](const MTPmessages_FavedStickers &result) {
|
||||
_session->data().stickers().setLastFavedUpdate(crl::now());
|
||||
_favedStickersUpdateRequest = 0;
|
||||
@@ -4187,7 +4196,11 @@ 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(),
|
||||
@@ -4199,7 +4212,7 @@ void ApiWrap::sendMediaWithRandomId(
|
||||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (done) done(true);
|
||||
if (updateRecentStickers) {
|
||||
requestRecentStickersForce(true);
|
||||
requestRecentStickers(std::nullopt, true);
|
||||
}
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
if (done) done(false);
|
||||
@@ -4207,6 +4220,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,
|
||||
@@ -4260,8 +4349,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(),
|
||||
|
||||
@@ -244,7 +244,10 @@ public:
|
||||
void updateSavedGifs();
|
||||
void updateMasks();
|
||||
void updateCustomEmoji();
|
||||
void requestRecentStickersForce(bool attached = false);
|
||||
void requestSpecialStickersForce(
|
||||
bool faved,
|
||||
bool recent,
|
||||
bool attached);
|
||||
void setGroupStickerSet(
|
||||
not_null<ChannelData*> megagroup,
|
||||
const StickerSetIdentifier &set);
|
||||
@@ -477,9 +480,10 @@ private:
|
||||
void requestStickers(TimeId now);
|
||||
void requestMasks(TimeId now);
|
||||
void requestCustomEmoji(TimeId now);
|
||||
void requestRecentStickers(TimeId now, bool attached = false);
|
||||
void requestRecentStickersWithHash(uint64 hash, bool attached = false);
|
||||
void requestFavedStickers(TimeId now);
|
||||
void requestRecentStickers(
|
||||
std::optional<TimeId> now,
|
||||
bool attached);
|
||||
void requestFavedStickers(std::optional<TimeId> now);
|
||||
void requestFeaturedStickers(TimeId now);
|
||||
void requestFeaturedEmoji(TimeId now);
|
||||
void requestSavedGifs(TimeId now);
|
||||
@@ -545,6 +549,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);
|
||||
|
||||
@@ -100,6 +100,8 @@ void AboutBox::showVersionHistory() {
|
||||
url += u"win/%1.zip"_q;
|
||||
} else if (Platform::IsWindows64Bit()) {
|
||||
url += u"win64/%1.zip"_q;
|
||||
} else if (Platform::IsWindowsARM64()) {
|
||||
url += u"winarm/%1.zip"_q;
|
||||
} else if (Platform::IsMac()) {
|
||||
url += u"mac/%1.zip"_q;
|
||||
} else if (Platform::IsLinux()) {
|
||||
@@ -155,6 +157,8 @@ QString currentVersionText() {
|
||||
}
|
||||
if (Platform::IsWindows64Bit()) {
|
||||
result += " x64";
|
||||
} else if (Platform::IsWindowsARM64()) {
|
||||
result += " arm64";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -672,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;
|
||||
@@ -877,7 +896,6 @@ scheduleDateField: InputField(defaultInputField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(top);
|
||||
font: font(14px);
|
||||
}
|
||||
scheduleTimeField: InputField(scheduleDateField) {
|
||||
border: 0px;
|
||||
@@ -905,7 +923,6 @@ muteBoxTimeField: InputField(scheduleDateField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(left);
|
||||
font: font(14px);
|
||||
}
|
||||
muteBoxTimeFieldPadding: margins(5px, 0px, 5px, 0px);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ Data::ChatFilter ChangedFilter(
|
||||
filter.id(),
|
||||
filter.title(),
|
||||
filter.iconEmoji(),
|
||||
filter.colorIndex(),
|
||||
filter.flags(),
|
||||
std::move(always),
|
||||
filter.pinned(),
|
||||
@@ -58,6 +59,7 @@ Data::ChatFilter ChangedFilter(
|
||||
filter.id(),
|
||||
filter.title(),
|
||||
filter.iconEmoji(),
|
||||
filter.colorIndex(),
|
||||
filter.flags(),
|
||||
std::move(always),
|
||||
filter.pinned(),
|
||||
@@ -81,7 +83,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
|
||||
|
||||
@@ -1044,7 +1044,16 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
|
||||
solution->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
solution->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
solution->setMarkdownReplacesEnabled(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);
|
||||
|
||||
@@ -463,6 +463,7 @@ void EditCaptionBox::rebuildPreview() {
|
||||
st::defaultComposeControls,
|
||||
gifPaused,
|
||||
file,
|
||||
[] { return true; },
|
||||
Ui::AttachControls::Type::EditOnly);
|
||||
_isPhoto = (media && media->isPhoto());
|
||||
const auto withCheckbox = _isPhoto && CanBeCompressed(_albumType);
|
||||
|
||||
@@ -83,6 +83,7 @@ not_null<FilterChatsPreview*> SetupChatsPreview(
|
||||
rules.id(),
|
||||
rules.title(),
|
||||
rules.iconEmoji(),
|
||||
rules.colorIndex(),
|
||||
(rules.flags() & ~flag),
|
||||
rules.always(),
|
||||
rules.pinned(),
|
||||
@@ -104,6 +105,7 @@ not_null<FilterChatsPreview*> SetupChatsPreview(
|
||||
rules.id(),
|
||||
rules.title(),
|
||||
rules.iconEmoji(),
|
||||
rules.colorIndex(),
|
||||
rules.flags(),
|
||||
std::move(always),
|
||||
std::move(pinned),
|
||||
@@ -170,6 +172,7 @@ void EditExceptions(
|
||||
rules.id(),
|
||||
rules.title(),
|
||||
rules.iconEmoji(),
|
||||
rules.colorIndex(),
|
||||
((rules.flags() & ~options)
|
||||
| rawController->chosenOptions()),
|
||||
include ? std::move(changed) : std::move(removeFrom),
|
||||
@@ -240,6 +243,7 @@ void CreateIconSelector(
|
||||
rules.id(),
|
||||
rules.title(),
|
||||
Ui::LookupFilterIcon(icon).emoji,
|
||||
rules.colorIndex(),
|
||||
rules.flags(),
|
||||
rules.always(),
|
||||
rules.pinned(),
|
||||
|
||||
180
Telegram/SourceFiles/boxes/gift_credits_box.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
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/gift_credits_box.h"
|
||||
|
||||
#include "api/api_credits.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/session/session_show.h"
|
||||
#include "settings/settings_credits_graphics.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_stars_colored.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/label_with_custom_emoji.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_channel_earn.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_credits.h"
|
||||
#include "styles/style_giveaway.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_premium.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void GiftCreditsBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<PeerData*> peer,
|
||||
Fn<void()> gifted) {
|
||||
box->setStyle(st::creditsGiftBox);
|
||||
box->setNoContentMargin(true);
|
||||
box->addButton(tr::lng_create_group_back(), [=] { box->closeBox(); });
|
||||
|
||||
const auto content = box->setPinnedToTopContent(
|
||||
object_ptr<Ui::VerticalLayout>(box));
|
||||
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
const auto &stUser = st::premiumGiftsUserpicButton;
|
||||
const auto userpicWrap = content->add(
|
||||
object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
object_ptr<Ui::UserpicButton>(content, peer, stUser)));
|
||||
userpicWrap->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
|
||||
{
|
||||
const auto widget = Ui::CreateChild<Ui::RpWidget>(content);
|
||||
using ColoredMiniStars = Ui::Premium::ColoredMiniStars;
|
||||
const auto stars = widget->lifetime().make_state<ColoredMiniStars>(
|
||||
widget,
|
||||
false,
|
||||
Ui::Premium::MiniStars::Type::BiStars);
|
||||
stars->setColorOverride(Ui::Premium::CreditsIconGradientStops());
|
||||
widget->resize(
|
||||
st::boxWidth - stUser.photoSize,
|
||||
stUser.photoSize * 2);
|
||||
content->sizeValue(
|
||||
) | rpl::start_with_next([=](const QSize &size) {
|
||||
widget->moveToLeft(stUser.photoSize / 2, 0);
|
||||
const auto starsRect = Rect(widget->size());
|
||||
stars->setPosition(starsRect.topLeft());
|
||||
stars->setSize(starsRect.size());
|
||||
widget->lower();
|
||||
}, widget->lifetime());
|
||||
widget->paintRequest(
|
||||
) | rpl::start_with_next([=](const QRect &r) {
|
||||
auto p = QPainter(widget);
|
||||
p.fillRect(r, Qt::transparent);
|
||||
stars->paint(p);
|
||||
}, widget->lifetime());
|
||||
}
|
||||
{
|
||||
Ui::AddSkip(content);
|
||||
const auto arrow = Ui::Text::SingleCustomEmoji(
|
||||
peer->owner().customEmojiManager().registerInternalEmoji(
|
||||
st::topicButtonArrow,
|
||||
st::channelEarnLearnArrowMargins,
|
||||
false));
|
||||
auto link = tr::lng_credits_box_history_entry_gift_about_link(
|
||||
lt_emoji,
|
||||
rpl::single(arrow),
|
||||
Ui::Text::RichLangValue
|
||||
) | rpl::map([](TextWithEntities text) {
|
||||
return Ui::Text::Link(
|
||||
std::move(text),
|
||||
tr::lng_credits_box_history_entry_gift_about_url(tr::now));
|
||||
});
|
||||
content->add(
|
||||
object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
Ui::CreateLabelWithCustomEmoji(
|
||||
content,
|
||||
tr::lng_credits_box_history_entry_gift_out_about(
|
||||
lt_user,
|
||||
rpl::single(TextWithEntities{ peer->shortName() }),
|
||||
lt_link,
|
||||
std::move(link),
|
||||
Ui::Text::RichLangValue),
|
||||
{ .session = &peer->session() },
|
||||
st::creditsBoxAbout)),
|
||||
st::boxRowPadding);
|
||||
}
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
|
||||
Settings::FillCreditOptions(
|
||||
Main::MakeSessionShow(box->uiShow(), &peer->session()),
|
||||
box->verticalLayout(),
|
||||
peer,
|
||||
0,
|
||||
[=] { gifted(); box->uiShow()->hideLayer(); });
|
||||
|
||||
box->setPinnedToBottomContent(
|
||||
object_ptr<Ui::VerticalLayout>(box));
|
||||
}
|
||||
|
||||
void ShowGiftCreditsBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void()> gifted) {
|
||||
|
||||
class Controller final : public ContactsBoxController {
|
||||
public:
|
||||
Controller(
|
||||
not_null<Main::Session*> session,
|
||||
Fn<void(not_null<PeerData*>)> choose)
|
||||
: ContactsBoxController(session)
|
||||
, _choose(std::move(choose)) {
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PeerListRow> createRow(
|
||||
not_null<UserData*> user) override {
|
||||
if (user->isSelf()
|
||||
|| user->isBot()
|
||||
|| user->isServiceUser()
|
||||
|| user->isInaccessible()) {
|
||||
return nullptr;
|
||||
}
|
||||
return ContactsBoxController::createRow(user);
|
||||
}
|
||||
|
||||
void rowClicked(not_null<PeerListRow*> row) override {
|
||||
_choose(row->peer());
|
||||
}
|
||||
|
||||
private:
|
||||
const Fn<void(not_null<PeerData*>)> _choose;
|
||||
|
||||
};
|
||||
auto initBox = [=](not_null<PeerListBox*> peersBox) {
|
||||
peersBox->setTitle(tr::lng_credits_gift_title());
|
||||
peersBox->addButton(tr::lng_cancel(), [=] { peersBox->closeBox(); });
|
||||
};
|
||||
|
||||
const auto show = controller->uiShow();
|
||||
auto listController = std::make_unique<Controller>(
|
||||
&controller->session(),
|
||||
[=](not_null<PeerData*> peer) {
|
||||
show->showBox(Box(GiftCreditsBox, peer, gifted));
|
||||
});
|
||||
show->showBox(
|
||||
Box<PeerListBox>(std::move(listController), std::move(initBox)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
20
Telegram/SourceFiles/boxes/gift_credits_box.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
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 Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void ShowGiftCreditsBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void()> gifted);
|
||||
|
||||
} // namespace Ui
|
||||
@@ -1011,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();
|
||||
};
|
||||
@@ -1644,12 +1646,72 @@ void AddCreditsHistoryEntryTable(
|
||||
container,
|
||||
st::giveawayGiftCodeTable),
|
||||
st::giveawayGiftCodeTableMargin);
|
||||
if (entry.bareId) {
|
||||
const auto peerId = PeerId(entry.barePeerId);
|
||||
if (peerId) {
|
||||
auto text = entry.in
|
||||
? tr::lng_credits_box_history_entry_peer_in()
|
||||
: 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_peer(),
|
||||
controller,
|
||||
PeerId(entry.bareId));
|
||||
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,
|
||||
(entry.gift
|
||||
? tr::lng_credits_box_history_entry_peer_in
|
||||
: tr::lng_credits_box_history_entry_via)(),
|
||||
(entry.gift
|
||||
? tr::lng_credits_box_history_entry_anonymous
|
||||
: 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));
|
||||
} else if (entry.peerType == Type::PremiumBot) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_credits_box_history_entry_via(),
|
||||
tr::lng_credits_box_history_entry_via_premium_bot(
|
||||
Ui::Text::RichLangValue));
|
||||
}
|
||||
if (!entry.id.isEmpty()) {
|
||||
constexpr auto kOneLineCount = 18;
|
||||
@@ -1680,4 +1742,17 @@ void AddCreditsHistoryEntryTable(
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
@@ -1126,6 +1133,7 @@ void Controller::fillManageSection() {
|
||||
|
||||
::AddSkip(container, 0);
|
||||
fillBotUsernamesButton();
|
||||
fillBotBalanceButton();
|
||||
fillBotEditIntroButton();
|
||||
fillBotEditCommandsButton();
|
||||
fillBotEditSettingsButton();
|
||||
@@ -1536,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);
|
||||
|
||||
@@ -2114,8 +2200,11 @@ void Controller::saveForum() {
|
||||
channel->inputChannel,
|
||||
MTP_bool(*_savingData.forum)
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
const auto weak = base::make_weak(this);
|
||||
channel->session().api().applyUpdates(result);
|
||||
continueSave();
|
||||
if (weak) { // todo better to be able to save in closed already box.
|
||||
continueSave();
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (error.type() == u"CHAT_NOT_MODIFIED"_q) {
|
||||
continueSave();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -459,6 +459,7 @@ Ui::BoostFeatures LookupBoostFeatures(not_null<ChannelData*> channel) {
|
||||
.customWallpaperLevel = group
|
||||
? levelLimits.groupCustomWallpaperLevelMin()
|
||||
: levelLimits.channelCustomWallpaperLevelMin(),
|
||||
.sponsoredLevel = levelLimits.channelRestrictSponsoredLevelMin(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,9 @@ void SimpleLimitBox(
|
||||
BoxShowFinishes(box),
|
||||
0,
|
||||
descriptor.current,
|
||||
descriptor.premiumLimit,
|
||||
(descriptor.complexRatio
|
||||
? descriptor.premiumLimit
|
||||
: 2 * descriptor.current),
|
||||
premiumPossible,
|
||||
descriptor.phrase,
|
||||
descriptor.icon);
|
||||
@@ -769,7 +771,7 @@ void FilterLinksLimitBox(
|
||||
premiumLimit,
|
||||
&st::premiumIconChats,
|
||||
std::nullopt,
|
||||
true });
|
||||
/*true */}); // Don't use real ratio, "Free" doesn't fit.
|
||||
}
|
||||
|
||||
|
||||
@@ -856,7 +858,7 @@ void ShareableFiltersLimitBox(
|
||||
premiumLimit,
|
||||
&st::premiumIconFolders,
|
||||
std::nullopt,
|
||||
true });
|
||||
/*true*/ }); // Don't use real ratio, "Free" doesn't fit.
|
||||
}
|
||||
|
||||
void FilterPinsLimitBox(
|
||||
|
||||
@@ -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();
|
||||
@@ -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,
|
||||
|
||||
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#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"
|
||||
@@ -22,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "payments/payments_checkout_process.h"
|
||||
#include "payments/payments_form.h"
|
||||
#include "settings/settings_credits_graphics.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/effects/premium_top_bar.h" // Ui::Premium::ColorizedSvg.
|
||||
@@ -39,6 +41,147 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#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,
|
||||
@@ -89,22 +232,10 @@ void SendCreditsBox(
|
||||
}, ministarsContainer->lifetime());
|
||||
}
|
||||
|
||||
const auto bot = session->data().user(form->botId);
|
||||
|
||||
if (form->photo) {
|
||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
Settings::HistoryEntryPhoto(content, form->photo, photoSize)));
|
||||
} else {
|
||||
const auto widget = box->addRow(
|
||||
object_ptr<Ui::CenterWrap<>>(
|
||||
content,
|
||||
object_ptr<Ui::UserpicButton>(
|
||||
content,
|
||||
bot,
|
||||
st::defaultUserpicButton)));
|
||||
widget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
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<>>(
|
||||
@@ -118,14 +249,7 @@ void SendCreditsBox(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
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),
|
||||
SendCreditsConfirmText(session, form.get()),
|
||||
st::creditsBoxAbout)));
|
||||
Ui::AddSkip(content);
|
||||
Ui::AddSkip(content);
|
||||
@@ -134,6 +258,8 @@ void SendCreditsBox(
|
||||
if (state->confirmButtonBusy.current()) {
|
||||
return;
|
||||
}
|
||||
const auto show = box->uiShow();
|
||||
const auto weak = MakeWeak(box.get());
|
||||
state->confirmButtonBusy = true;
|
||||
session->api().request(
|
||||
MTPpayments_SendStarsForm(
|
||||
@@ -141,12 +267,31 @@ void SendCreditsBox(
|
||||
MTP_long(form->formId),
|
||||
form->inputInvoice)
|
||||
).done([=](auto result) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->closeBox();
|
||||
if (weak) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->closeBox();
|
||||
}
|
||||
sent();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
state->confirmButtonBusy = false;
|
||||
box->uiShow()->showToast(error.type());
|
||||
if (weak) {
|
||||
state->confirmButtonBusy = false;
|
||||
}
|
||||
const auto id = error.type();
|
||||
if (id == u"BOT_PRECHECKOUT_FAILED"_q) {
|
||||
auto error = ::Ui::MakeInformBox(
|
||||
tr::lng_payments_precheckout_stars_failed(tr::now));
|
||||
error->boxClosing() | rpl::start_with_next([=] {
|
||||
if (const auto paybox = weak.data()) {
|
||||
paybox->closeBox();
|
||||
}
|
||||
}, error->lifetime());
|
||||
show->showBox(std::move(error));
|
||||
} else if (id == u"BOT_PRECHECKOUT_TIMEOUT"_q) {
|
||||
show->showToast(
|
||||
tr::lng_payments_precheckout_stars_timeout(tr::now));
|
||||
} else {
|
||||
show->showToast(id);
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
{
|
||||
@@ -158,26 +303,16 @@ void SendCreditsBox(
|
||||
loadingAnimation->showOn(state->confirmButtonBusy.value());
|
||||
}
|
||||
{
|
||||
const auto emojiMargin = QMargins(
|
||||
0,
|
||||
-st::moderateBoxExpandInnerSkip,
|
||||
0,
|
||||
0);
|
||||
const auto buttonEmoji = Ui::Text::SingleCustomEmoji(
|
||||
session->data().customEmojiManager().registerInternalEmoji(
|
||||
st::settingsPremiumIconStar,
|
||||
emojiMargin,
|
||||
true));
|
||||
auto buttonText = tr::lng_credits_box_out_confirm(
|
||||
lt_count,
|
||||
rpl::single(form->invoice.amount) | tr::to_count(),
|
||||
lt_emoji,
|
||||
rpl::single(buttonEmoji),
|
||||
rpl::single(CreditsEmojiSmall(session)),
|
||||
Ui::Text::RichLangValue);
|
||||
const auto buttonLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
button,
|
||||
rpl::single(QString()),
|
||||
st::defaultFlatLabel);
|
||||
st::creditsBoxButtonLabel);
|
||||
std::move(
|
||||
buttonText
|
||||
) | rpl::start_with_next([=](const TextWithEntities &text) {
|
||||
@@ -247,4 +382,22 @@ void SendCreditsBox(
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
class HistoryItem;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Payments {
|
||||
struct CreditsFormData;
|
||||
} // namespace Payments
|
||||
@@ -22,4 +26,10 @@ void SendCreditsBox(
|
||||
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,
|
||||
@@ -385,6 +494,9 @@ Fn<SendMenu::Details()> SendFilesBox::prepareSendMenuDetails(
|
||||
: _invertCaption
|
||||
? SendMenu::CaptionState::Above
|
||||
: SendMenu::CaptionState::Below;
|
||||
result.price = canChangePrice()
|
||||
? _price.current()
|
||||
: std::optional<uint64>();
|
||||
return result;
|
||||
});
|
||||
}
|
||||
@@ -398,6 +510,7 @@ auto SendFilesBox::prepareSendMenuCallback()
|
||||
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,
|
||||
@@ -588,14 +701,27 @@ void SendFilesBox::refreshButtons() {
|
||||
addMenuButton();
|
||||
}
|
||||
|
||||
bool SendFilesBox::hasSendMenu(const SendMenu::Details &details) const {
|
||||
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 {
|
||||
return _list.hasSpoilerMenu(_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() {
|
||||
@@ -618,6 +744,118 @@ 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() {
|
||||
const auto details = _sendMenuDetails();
|
||||
if (!hasSendMenu(details)) {
|
||||
@@ -681,6 +919,7 @@ void SendFilesBox::initSendWay() {
|
||||
block.setSendWay(value);
|
||||
}
|
||||
refreshButtons();
|
||||
refreshPriceTag();
|
||||
if (was != hidden()) {
|
||||
updateBoxSize();
|
||||
updateControlsGeometry();
|
||||
@@ -766,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(),
|
||||
@@ -889,10 +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) {
|
||||
refreshButtons();
|
||||
refreshPriceTag();
|
||||
refreshTitleText();
|
||||
updateSendWayControls();
|
||||
updateCaptionPlaceholder();
|
||||
@@ -1447,6 +1695,7 @@ void SendFilesBox::send(
|
||||
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);
|
||||
@@ -1474,10 +1723,16 @@ void SendFilesBox::send(
|
||||
auto caption = (_caption && !_caption->isHidden())
|
||||
? _caption->getTextWithAppliedMarkdown()
|
||||
: TextWithTags();
|
||||
options.invertCaption = _invertCaption;
|
||||
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(),
|
||||
|
||||
@@ -149,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;
|
||||
|
||||
@@ -160,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;
|
||||
@@ -190,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();
|
||||
@@ -251,6 +261,9 @@ private:
|
||||
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;
|
||||
|
||||
|
||||
@@ -1409,55 +1409,6 @@ std::vector<not_null<Data::Thread*>> ShareBox::Inner::selected() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
QString AppendShareGameScoreUrl(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &url,
|
||||
const FullMsgId &fullId) {
|
||||
auto shareHashData = QByteArray(0x20, Qt::Uninitialized);
|
||||
auto shareHashDataInts = reinterpret_cast<uint64*>(shareHashData.data());
|
||||
const auto peer = fullId.peer
|
||||
? session->data().peerLoaded(fullId.peer)
|
||||
: static_cast<PeerData*>(nullptr);
|
||||
const auto channelAccessHash = uint64((peer && peer->isChannel())
|
||||
? peer->asChannel()->access
|
||||
: 0);
|
||||
shareHashDataInts[0] = session->userId().bare;
|
||||
shareHashDataInts[1] = fullId.peer.value;
|
||||
shareHashDataInts[2] = uint64(fullId.msg.bare);
|
||||
shareHashDataInts[3] = channelAccessHash;
|
||||
|
||||
// Count SHA1() of data.
|
||||
auto key128Size = 0x10;
|
||||
auto shareHashEncrypted = QByteArray(key128Size + shareHashData.size(), Qt::Uninitialized);
|
||||
hashSha1(shareHashData.constData(), shareHashData.size(), shareHashEncrypted.data());
|
||||
|
||||
//// Mix in channel access hash to the first 64 bits of SHA1 of data.
|
||||
//*reinterpret_cast<uint64*>(shareHashEncrypted.data()) ^= channelAccessHash;
|
||||
|
||||
// Encrypt data.
|
||||
if (!session->local().encrypt(shareHashData.constData(), shareHashEncrypted.data() + key128Size, shareHashData.size(), shareHashEncrypted.constData())) {
|
||||
return url;
|
||||
}
|
||||
|
||||
auto shareHash = shareHashEncrypted.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
auto shareUrl = u"tg://share_game_score?hash="_q + QString::fromLatin1(shareHash);
|
||||
|
||||
auto shareComponent = u"tgShareScoreUrl="_q + qthelp::url_encode(shareUrl);
|
||||
|
||||
auto hashPosition = url.indexOf('#');
|
||||
if (hashPosition < 0) {
|
||||
return url + '#' + shareComponent;
|
||||
}
|
||||
auto hash = url.mid(hashPosition + 1);
|
||||
if (hash.indexOf('=') >= 0 || hash.indexOf('?') >= 0) {
|
||||
return url + '&' + shareComponent;
|
||||
}
|
||||
if (!hash.isEmpty()) {
|
||||
return url + '?' + shareComponent;
|
||||
}
|
||||
return url + shareComponent;
|
||||
}
|
||||
|
||||
ChatHelpers::ForwardedMessagePhraseArgs CreateForwardedMessagePhraseArgs(
|
||||
const std::vector<not_null<Data::Thread*>> &result,
|
||||
const MessageIdsList &msgIds) {
|
||||
@@ -1612,9 +1563,8 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
|
||||
}
|
||||
|
||||
void FastShareMessage(
|
||||
not_null<Window::SessionController*> controller,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<HistoryItem*> item) {
|
||||
const auto show = controller->uiShow();
|
||||
const auto history = item->history();
|
||||
const auto owner = &history->owner();
|
||||
const auto session = &history->session();
|
||||
@@ -1643,7 +1593,7 @@ void FastShareMessage(
|
||||
}
|
||||
if (item->hasDirectLink()) {
|
||||
using namespace HistoryView;
|
||||
CopyPostLink(controller, item->fullId(), Context::History);
|
||||
CopyPostLink(show, item->fullId(), Context::History);
|
||||
} else if (const auto bot = item->getMessageBot()) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto game = media->game()) {
|
||||
@@ -1675,23 +1625,27 @@ void FastShareMessage(
|
||||
auto copyLinkCallback = canCopyLink
|
||||
? Fn<void()>(std::move(copyCallback))
|
||||
: Fn<void()>();
|
||||
controller->show(
|
||||
Box<ShareBox>(ShareBox::Descriptor{
|
||||
.session = session,
|
||||
.copyCallback = std::move(copyLinkCallback),
|
||||
.submitCallback = ShareBox::DefaultForwardCallback(
|
||||
show,
|
||||
history,
|
||||
msgIds),
|
||||
.filterCallback = std::move(filterCallback),
|
||||
.forwardOptions = {
|
||||
.sendersCount = ItemsForwardSendersCount(items),
|
||||
.captionsCount = ItemsForwardCaptionsCount(items),
|
||||
.show = !hasOnlyForcedForwardedInfo,
|
||||
},
|
||||
.premiumRequiredError = SharePremiumRequiredError(),
|
||||
}),
|
||||
Ui::LayerOption::CloseOther);
|
||||
show->show(Box<ShareBox>(ShareBox::Descriptor{
|
||||
.session = session,
|
||||
.copyCallback = std::move(copyLinkCallback),
|
||||
.submitCallback = ShareBox::DefaultForwardCallback(
|
||||
show,
|
||||
history,
|
||||
msgIds),
|
||||
.filterCallback = std::move(filterCallback),
|
||||
.forwardOptions = {
|
||||
.sendersCount = ItemsForwardSendersCount(items),
|
||||
.captionsCount = ItemsForwardCaptionsCount(items),
|
||||
.show = !hasOnlyForcedForwardedInfo,
|
||||
},
|
||||
.premiumRequiredError = SharePremiumRequiredError(),
|
||||
}), Ui::LayerOption::CloseOther);
|
||||
}
|
||||
|
||||
void FastShareMessage(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item) {
|
||||
FastShareMessage(controller->uiShow(), item);
|
||||
}
|
||||
|
||||
void FastShareLink(
|
||||
@@ -1793,111 +1747,3 @@ auto SharePremiumRequiredError()
|
||||
-> Fn<RecipientPremiumRequiredError(not_null<UserData*>)> {
|
||||
return WritePremiumRequiredError;
|
||||
}
|
||||
|
||||
void ShareGameScoreByHash(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &hash) {
|
||||
auto &session = controller->session();
|
||||
auto key128Size = 0x10;
|
||||
|
||||
auto hashEncrypted = QByteArray::fromBase64(hash.toLatin1(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
|
||||
if (hashEncrypted.size() <= key128Size || (hashEncrypted.size() != key128Size + 0x20)) {
|
||||
controller->show(
|
||||
Ui::MakeInformBox(tr::lng_confirm_phone_link_invalid()),
|
||||
Ui::LayerOption::CloseOther);
|
||||
return;
|
||||
}
|
||||
|
||||
// Decrypt data.
|
||||
auto hashData = QByteArray(hashEncrypted.size() - key128Size, Qt::Uninitialized);
|
||||
if (!session.local().decrypt(hashEncrypted.constData() + key128Size, hashData.data(), hashEncrypted.size() - key128Size, hashEncrypted.constData())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Count SHA1() of data.
|
||||
char dataSha1[20] = { 0 };
|
||||
hashSha1(hashData.constData(), hashData.size(), dataSha1);
|
||||
|
||||
//// Mix out channel access hash from the first 64 bits of SHA1 of data.
|
||||
//auto channelAccessHash = *reinterpret_cast<uint64*>(hashEncrypted.data()) ^ *reinterpret_cast<uint64*>(dataSha1);
|
||||
|
||||
//// Check next 64 bits of SHA1() of data.
|
||||
//auto skipSha1Part = sizeof(channelAccessHash);
|
||||
//if (memcmp(dataSha1 + skipSha1Part, hashEncrypted.constData() + skipSha1Part, key128Size - skipSha1Part) != 0) {
|
||||
// Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
||||
// return;
|
||||
//}
|
||||
|
||||
// Check 128 bits of SHA1() of data.
|
||||
if (memcmp(dataSha1, hashEncrypted.constData(), key128Size) != 0) {
|
||||
controller->show(
|
||||
Ui::MakeInformBox(tr::lng_share_wrong_user()),
|
||||
Ui::LayerOption::CloseOther);
|
||||
return;
|
||||
}
|
||||
|
||||
auto hashDataInts = reinterpret_cast<uint64*>(hashData.data());
|
||||
if (hashDataInts[0] != session.userId().bare) {
|
||||
controller->show(
|
||||
Ui::MakeInformBox(tr::lng_share_wrong_user()),
|
||||
Ui::LayerOption::CloseOther);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto peerId = PeerId(hashDataInts[1]);
|
||||
const auto channelAccessHash = hashDataInts[3];
|
||||
if (!peerIsChannel(peerId) && channelAccessHash) {
|
||||
// If there is no channel id, there should be no channel access_hash.
|
||||
controller->show(
|
||||
Ui::MakeInformBox(tr::lng_share_wrong_user()),
|
||||
Ui::LayerOption::CloseOther);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto msgId = MsgId(int64(hashDataInts[2]));
|
||||
if (const auto item = session.data().message(peerId, msgId)) {
|
||||
FastShareMessage(controller, item);
|
||||
} else {
|
||||
const auto weak = base::make_weak(controller);
|
||||
const auto resolveMessageAndShareScore = crl::guard(weak, [=](
|
||||
PeerData *peer) {
|
||||
auto done = crl::guard(weak, [=] {
|
||||
const auto item = weak->session().data().message(
|
||||
peerId,
|
||||
msgId);
|
||||
if (item) {
|
||||
FastShareMessage(weak.get(), item);
|
||||
} else {
|
||||
weak->show(
|
||||
Ui::MakeInformBox(tr::lng_edit_deleted()),
|
||||
Ui::LayerOption::CloseOther);
|
||||
}
|
||||
});
|
||||
auto &api = weak->session().api();
|
||||
api.requestMessageData(peer, msgId, std::move(done));
|
||||
});
|
||||
|
||||
const auto peer = peerIsChannel(peerId)
|
||||
? controller->session().data().peerLoaded(peerId)
|
||||
: nullptr;
|
||||
if (peer || !peerIsChannel(peerId)) {
|
||||
resolveMessageAndShareScore(peer);
|
||||
} else {
|
||||
const auto owner = &controller->session().data();
|
||||
controller->session().api().request(MTPchannels_GetChannels(
|
||||
MTP_vector<MTPInputChannel>(
|
||||
1,
|
||||
MTP_inputChannel(
|
||||
MTP_long(peerToChannel(peerId).bare),
|
||||
MTP_long(channelAccessHash)))
|
||||
)).done([=](const MTPmessages_Chats &result) {
|
||||
result.match([&](const auto &data) {
|
||||
owner->processChats(data.vchats());
|
||||
});
|
||||
if (const auto peer = owner->peerLoaded(peerId)) {
|
||||
resolveMessageAndShareScore(peer);
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,11 @@ class SlideWrap;
|
||||
class PopupMenu;
|
||||
} // namespace Ui
|
||||
|
||||
QString AppendShareGameScoreUrl(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &url,
|
||||
const FullMsgId &fullId);
|
||||
void ShareGameScoreByHash(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &hash);
|
||||
class ShareBox;
|
||||
|
||||
void FastShareMessage(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
not_null<HistoryItem*> item);
|
||||
void FastShareMessage(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<HistoryItem*> item);
|
||||
|
||||
@@ -7,50 +7,55 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/sticker_set_box.h"
|
||||
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "menu/menu_send.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "api/api_common.h"
|
||||
#include "api/api_toggling_media.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/premium_preview_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
#include "chat_helpers/stickers_lottie.h"
|
||||
#include "core/application.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_peer_values.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "dialogs/ui/dialogs_layout.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/gradient_round_button.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/image/image_location_factory.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/text/custom_emoji_instance.h"
|
||||
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
||||
#include "lang/lang_keys.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
#include "lottie/lottie_multi_player.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mainwindow.h"
|
||||
#include "media/clip/media_clip_reader.h"
|
||||
#include "menu/menu_send.h"
|
||||
#include "mtproto/sender.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "ui/effects/animation_value_f.h"
|
||||
#include "ui/effects/path_shift_gradient.h"
|
||||
#include "ui/emoji_config.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/image/image_location_factory.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/power_saving.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/text/custom_emoji_instance.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "ui/widgets/gradient_round_button.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/cached_round_corners.h"
|
||||
#include "lottie/lottie_multi_player.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "chat_helpers/stickers_lottie.h"
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
#include "media/clip/media_clip_reader.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "main/main_session.h"
|
||||
#include "apiwrap.h"
|
||||
#include "api/api_toggling_media.h"
|
||||
#include "api/api_common.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_info.h"
|
||||
@@ -68,10 +73,12 @@ constexpr auto kEmojiPerRow = 8;
|
||||
constexpr auto kMinRepaintDelay = crl::time(33);
|
||||
constexpr auto kMinAfterScrollDelay = crl::time(33);
|
||||
constexpr auto kGrayLockOpacity = 0.3;
|
||||
constexpr auto kStickerMoveDuration = crl::time(200);
|
||||
|
||||
using Data::StickersSet;
|
||||
using Data::StickersPack;
|
||||
using SetFlag = Data::StickersSetFlag;
|
||||
using TLStickerSet = MTPmessages_StickerSet;
|
||||
|
||||
[[nodiscard]] std::optional<QColor> ComputeImageColor(
|
||||
const style::icon &lockIcon,
|
||||
@@ -259,6 +266,20 @@ public:
|
||||
[[nodiscard]] rpl::producer<uint64> setArchived() const;
|
||||
[[nodiscard]] rpl::producer<> updateControls() const;
|
||||
|
||||
void setReorderState(bool enabled) {
|
||||
_dragging.enabled = enabled;
|
||||
if (enabled) {
|
||||
_shakeAnimation.init([=] { update(); });
|
||||
_shakeAnimation.start();
|
||||
} else {
|
||||
_shakeAnimation.stop();
|
||||
update();
|
||||
}
|
||||
}
|
||||
[[nodiscard]] bool reorderState() const {
|
||||
return _dragging.enabled;
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<Error> errors() const;
|
||||
|
||||
void archiveStickers();
|
||||
@@ -271,6 +292,12 @@ public:
|
||||
: Data::StickersType::Stickers;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool amSetCreator() const {
|
||||
return _amSetCreator;
|
||||
}
|
||||
|
||||
void applySet(const TLStickerSet &set);
|
||||
|
||||
~Inner();
|
||||
|
||||
protected:
|
||||
@@ -306,6 +333,11 @@ private:
|
||||
QPoint position,
|
||||
bool paused,
|
||||
crl::time now) const;
|
||||
void shakeTransform(
|
||||
QPainter &p,
|
||||
int index,
|
||||
QPoint position,
|
||||
crl::time now) const;
|
||||
void setupLottie(int index);
|
||||
void setupWebm(int index);
|
||||
void clipCallback(
|
||||
@@ -322,14 +354,19 @@ private:
|
||||
void startOverAnimation(int index, float64 from, float64 to);
|
||||
int stickerFromGlobalPos(const QPoint &p) const;
|
||||
|
||||
void gotSet(const MTPmessages_StickerSet &set);
|
||||
void installDone(const MTPmessages_StickerSetInstallResult &result);
|
||||
|
||||
void requestReorder(not_null<DocumentData*> document, int index);
|
||||
void fillDeleteStickerBox(not_null<Ui::GenericBox*> box, int index);
|
||||
|
||||
void chosen(
|
||||
int index,
|
||||
not_null<DocumentData*> sticker,
|
||||
Api::SendOptions options);
|
||||
|
||||
[[nodiscard]] QPoint posFromIndex(int index) const;
|
||||
[[nodiscard]] bool isDraggedAnimating() const;
|
||||
|
||||
not_null<Lottie::MultiPlayer*> getLottiePlayer();
|
||||
|
||||
void showPreview();
|
||||
@@ -366,6 +403,24 @@ private:
|
||||
TimeId _setInstallDate = TimeId(0);
|
||||
StickerType _setThumbnailType = StickerType::Webp;
|
||||
ImageWithLocation _setThumbnail;
|
||||
bool _amSetCreator = false;
|
||||
|
||||
struct {
|
||||
bool enabled = false;
|
||||
int index = -1;
|
||||
int lastSelected = -1;
|
||||
QPoint point;
|
||||
} _dragging;
|
||||
Ui::Animations::Basic _shakeAnimation;
|
||||
std::deque<Fn<void()>> _reorderRequests;
|
||||
std::optional<MTP::Sender> _apiReorder;
|
||||
|
||||
struct ShiftAnimation final {
|
||||
Ui::Animations::Simple animation;
|
||||
Ui::Animations::Simple yAnimation;
|
||||
int shift = 0;
|
||||
};
|
||||
base::flat_map<int, ShiftAnimation> _shiftAnimations;
|
||||
|
||||
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
|
||||
mutable StickerPremiumMark _premiumMark;
|
||||
@@ -538,9 +593,112 @@ void StickerSetBox::updateTitleAndButtons() {
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void ChangeSetNameBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Data::Session*> data,
|
||||
const StickerSetIdentifier &input,
|
||||
Fn<void(TLStickerSet)> done) {
|
||||
struct State final {
|
||||
rpl::variable<mtpRequestId> requestId = 0;
|
||||
Ui::RpWidget* saveButton = nullptr;
|
||||
};
|
||||
box->setTitle(tr::lng_stickers_box_edit_name_title());
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_stickers_box_edit_name_about(),
|
||||
st::boxLabel));
|
||||
const auto state = box->lifetime().make_state<State>();
|
||||
|
||||
const auto wasName = [&] {
|
||||
const auto &sets = data->stickers().sets();
|
||||
const auto it = sets.find(input.id);
|
||||
return (it == sets.end()) ? QString() : it->second->title;
|
||||
}();
|
||||
const auto wrap = box->addRow(object_ptr<Ui::FixedHeightWidget>(
|
||||
box,
|
||||
st::editStickerSetNameField.heightMin));
|
||||
auto owned = object_ptr<Ui::InputField>(
|
||||
wrap,
|
||||
st::editStickerSetNameField,
|
||||
tr::lng_stickers_context_edit_name(),
|
||||
wasName);
|
||||
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();
|
||||
constexpr auto kMaxSetNameLength = 50;
|
||||
field->setMaxLength(kMaxSetNameLength);
|
||||
Ui::AddLengthLimitLabel(field, kMaxSetNameLength, kMaxSetNameLength + 1);
|
||||
box->setFocusCallback([=] { field->setFocusFast(); });
|
||||
const auto close = crl::guard(box, [=] { box->closeBox(); });
|
||||
const auto save = [=, show = box->uiShow()] {
|
||||
if (state->requestId.current()) {
|
||||
return;
|
||||
}
|
||||
const auto text = field->getLastText().trimmed();
|
||||
if ((Ui::ComputeRealUnicodeCharactersCount(text) > kMaxSetNameLength)
|
||||
|| text.isEmpty()) {
|
||||
field->showError();
|
||||
return;
|
||||
}
|
||||
const auto buttonWidth = state->saveButton
|
||||
? state->saveButton->width()
|
||||
: 0;
|
||||
state->requestId = data->session().api().request(
|
||||
MTPstickers_RenameStickerSet(
|
||||
Data::InputStickerSet(input),
|
||||
MTP_string(text))
|
||||
).done([=](const TLStickerSet &result) {
|
||||
result.match([&](const MTPDmessages_stickerSet &d) {
|
||||
data->stickers().feedSetFull(d);
|
||||
data->stickers().notifyUpdated(Data::StickersType::Stickers);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
done(result);
|
||||
close();
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
show->showToast(error.type());
|
||||
close();
|
||||
}).send();
|
||||
if (state->saveButton) {
|
||||
state->saveButton->resizeToWidth(buttonWidth);
|
||||
}
|
||||
};
|
||||
|
||||
state->saveButton = box->addButton(
|
||||
rpl::conditional(
|
||||
state->requestId.value() | rpl::map(rpl::mappers::_1 > 0),
|
||||
rpl::single(QString()),
|
||||
tr::lng_box_done()),
|
||||
save);
|
||||
if (const auto saveButton = state->saveButton) {
|
||||
using namespace Info::Statistics;
|
||||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||
saveButton,
|
||||
saveButton->height() / 2,
|
||||
&st::editStickerSetNameLoading);
|
||||
AddChildToWidgetCenter(saveButton, loadingAnimation);
|
||||
loadingAnimation->showOn(
|
||||
state->requestId.value() | rpl::map(rpl::mappers::_1 > 0));
|
||||
}
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
data->session().api().request(state->requestId.current()).cancel();
|
||||
close();
|
||||
});
|
||||
}
|
||||
|
||||
void StickerSetBox::updateButtons() {
|
||||
clearButtons();
|
||||
if (_inner->loaded()) {
|
||||
if (_inner->reorderState()) {
|
||||
addButton(tr::lng_box_done(), [=] {
|
||||
_inner->setReorderState(false);
|
||||
updateButtons();
|
||||
});
|
||||
} else if (_inner->loaded()) {
|
||||
const auto type = _inner->setType();
|
||||
const auto share = [=] {
|
||||
copyStickersLink();
|
||||
@@ -548,6 +706,34 @@ void StickerSetBox::updateButtons() {
|
||||
? tr::lng_stickers_copied_emoji(tr::now)
|
||||
: tr::lng_stickers_copied(tr::now));
|
||||
};
|
||||
const auto fillSetCreatorMenu = [&] {
|
||||
using Filler = Fn<void(not_null<Ui::PopupMenu*>)>;
|
||||
if (!_inner->amSetCreator()) {
|
||||
return Filler(nullptr);
|
||||
}
|
||||
const auto data = &_session->data();
|
||||
return Filler([=, show = _show, set = _set](
|
||||
not_null<Ui::PopupMenu*> menu) {
|
||||
const auto done = [inner = _inner](const TLStickerSet &set) {
|
||||
if (const auto raw = inner.data()) {
|
||||
raw->applySet(set);
|
||||
}
|
||||
};
|
||||
menu->addAction(
|
||||
tr::lng_stickers_context_edit_name(tr::now),
|
||||
[=] {
|
||||
show->showBox(Box(ChangeSetNameBox, data, set, done));
|
||||
},
|
||||
&st::menuIconEdit);
|
||||
menu->addAction(
|
||||
tr::lng_stickers_context_reorder(tr::now),
|
||||
[=] {
|
||||
_inner->setReorderState(true);
|
||||
updateButtons();
|
||||
},
|
||||
&st::menuIconManage);
|
||||
});
|
||||
}();
|
||||
if (_inner->notInstalled()) {
|
||||
if (!_session->premium()
|
||||
&& _session->premiumPossible()
|
||||
@@ -586,6 +772,9 @@ void StickerSetBox::updateButtons() {
|
||||
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
top,
|
||||
st::popupMenuWithIcons);
|
||||
if (fillSetCreatorMenu) {
|
||||
fillSetCreatorMenu(*menu);
|
||||
}
|
||||
(*menu)->addAction(
|
||||
((type == Data::StickersType::Emoji)
|
||||
? tr::lng_stickers_share_emoji
|
||||
@@ -636,6 +825,9 @@ void StickerSetBox::updateButtons() {
|
||||
remove,
|
||||
&st::menuIconRemove);
|
||||
} else {
|
||||
if (fillSetCreatorMenu) {
|
||||
fillSetCreatorMenu(*menu);
|
||||
}
|
||||
(*menu)->addAction(
|
||||
(type == Data::StickersType::Masks
|
||||
? tr::lng_masks_archive_pack(tr::now)
|
||||
@@ -687,8 +879,8 @@ StickerSetBox::Inner::Inner(
|
||||
_api.request(MTPmessages_GetStickerSet(
|
||||
Data::InputStickerSet(_input),
|
||||
MTP_int(0) // hash
|
||||
)).done([=](const MTPmessages_StickerSet &result) {
|
||||
gotSet(result);
|
||||
)).done([=](const TLStickerSet &result) {
|
||||
applySet(result);
|
||||
}).fail([=] {
|
||||
_loaded = true;
|
||||
_errors.fire(Error::NotFound);
|
||||
@@ -704,7 +896,7 @@ StickerSetBox::Inner::Inner(
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
void StickerSetBox::Inner::applySet(const TLStickerSet &set) {
|
||||
_pack.clear();
|
||||
_emoji.clear();
|
||||
_elements.clear();
|
||||
@@ -748,7 +940,9 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
}
|
||||
});
|
||||
}
|
||||
data.vset().match([&](const MTPDstickerSet &set) {
|
||||
|
||||
{
|
||||
const auto &set = data.vset().data();
|
||||
_setTitle = _session->data().stickers().getSetTitle(
|
||||
set);
|
||||
_setShortName = qs(set.vshort_name());
|
||||
@@ -759,6 +953,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
_setFlags = Data::ParseStickersSetFlags(set);
|
||||
_setInstallDate = set.vinstalled_date().value_or(0);
|
||||
_setThumbnailDocumentId = set.vthumb_document_id().value_or_empty();
|
||||
_amSetCreator = set.is_creator();
|
||||
_setThumbnail = [&] {
|
||||
if (const auto thumbs = set.vthumbs()) {
|
||||
for (const auto &thumb : thumbs->v) {
|
||||
@@ -791,7 +986,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||
set->emoji = _emoji;
|
||||
set->setThumbnail(_setThumbnail, _setThumbnailType);
|
||||
}
|
||||
});
|
||||
};
|
||||
}, [&](const MTPDmessages_stickerSetNotModified &data) {
|
||||
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
|
||||
});
|
||||
@@ -932,11 +1127,100 @@ void StickerSetBox::Inner::mousePressEvent(QMouseEvent *e) {
|
||||
if (index < 0 || index >= _pack.size()) {
|
||||
return;
|
||||
}
|
||||
if (_dragging.enabled) {
|
||||
_previewTimer.cancel();
|
||||
if (isDraggedAnimating()) {
|
||||
return;
|
||||
}
|
||||
_dragging.index = index;
|
||||
_dragging.point = mapFromGlobal(QCursor::pos()) - posFromIndex(index);
|
||||
return;
|
||||
}
|
||||
_previewTimer.callOnce(QApplication::startDragTime());
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
||||
updateSelected();
|
||||
const auto draggedAnimating = isDraggedAnimating();
|
||||
if (_selected >= 0 && !draggedAnimating) {
|
||||
_dragging.lastSelected = _selected;
|
||||
}
|
||||
if (_dragging.index >= 0
|
||||
&& _dragging.index < _pack.size()
|
||||
&& _dragging.lastSelected >= 0
|
||||
&& !draggedAnimating) {
|
||||
for (auto i = 0; i < _pack.size(); i++) {
|
||||
if (i == _dragging.index) {
|
||||
continue;
|
||||
}
|
||||
auto &entry = _shiftAnimations[i];
|
||||
const auto wasShift = entry.shift;
|
||||
if ((i >= _dragging.index) && (i <= _dragging.lastSelected)) {
|
||||
if (entry.shift == 0) {
|
||||
entry.shift = -1;
|
||||
} else if (entry.shift == 1) {
|
||||
entry.shift = 0;
|
||||
}
|
||||
} else if ((i < _dragging.index)
|
||||
&& (i >= _dragging.lastSelected)) {
|
||||
if (entry.shift == 0) {
|
||||
entry.shift = 1;
|
||||
} else if (entry.shift == -1) {
|
||||
entry.shift = 0;
|
||||
}
|
||||
}
|
||||
if ((i < std::min(_dragging.index, _dragging.lastSelected))
|
||||
|| (i > std::max(_dragging.index, _dragging.lastSelected))) {
|
||||
entry.shift = 0;
|
||||
}
|
||||
if (wasShift != entry.shift) {
|
||||
const auto fromPoint = posFromIndex(i + wasShift);
|
||||
const auto toPoint = posFromIndex(i + entry.shift);
|
||||
const auto toX = float64(toPoint.x());
|
||||
const auto toY = float64(toPoint.y());
|
||||
const auto ratio = [&] {
|
||||
const auto fromX = entry.animation.value(toX);
|
||||
const auto ratioX = std::min(toX, fromX)
|
||||
/ std::max(toX, fromX);
|
||||
const auto fromY = entry.yAnimation.value(toY);
|
||||
const auto ratioY = std::min(toY, fromY)
|
||||
/ std::max(toY, fromY);
|
||||
return (ratioX == 1.)
|
||||
? ratioY
|
||||
: (ratioY == 1.)
|
||||
? ratioX
|
||||
: std::max(ratioX, ratioY);
|
||||
}();
|
||||
if (!entry.animation.animating()) {
|
||||
entry.animation.stop();
|
||||
entry.animation.start(
|
||||
[=] { update(); },
|
||||
fromPoint.x(),
|
||||
toX,
|
||||
kStickerMoveDuration);
|
||||
} else {
|
||||
entry.animation.change(
|
||||
toX,
|
||||
kStickerMoveDuration * (1. - ratio),
|
||||
anim::linear);
|
||||
}
|
||||
if (!entry.yAnimation.animating()) {
|
||||
entry.yAnimation.stop();
|
||||
entry.yAnimation.start(
|
||||
[=] { update(); },
|
||||
fromPoint.y(),
|
||||
toY,
|
||||
kStickerMoveDuration);
|
||||
} else {
|
||||
entry.yAnimation.change(
|
||||
toY,
|
||||
kStickerMoveDuration * (1. - ratio),
|
||||
anim::linear);
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
if (_previewShown >= 0) {
|
||||
showPreviewAt(e->globalPos());
|
||||
}
|
||||
@@ -958,7 +1242,86 @@ void StickerSetBox::Inner::leaveEventHook(QEvent *e) {
|
||||
setSelected(-1);
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::requestReorder(
|
||||
not_null<DocumentData*> document,
|
||||
int index) {
|
||||
if (!_apiReorder) {
|
||||
_apiReorder.emplace(&_session->mtp());
|
||||
}
|
||||
_reorderRequests.emplace_back([document, index, this] {
|
||||
_apiReorder->request(
|
||||
MTPstickers_ChangeStickerPosition(
|
||||
document->mtpInput(),
|
||||
MTP_int(index))
|
||||
).done([this, document](const TLStickerSet &result) {
|
||||
result.match([&](const MTPDmessages_stickerSet &d) {
|
||||
document->owner().stickers().feedSetFull(d);
|
||||
document->owner().stickers().notifyUpdated(
|
||||
Data::StickersType::Stickers);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
if (!_reorderRequests.empty()) {
|
||||
_reorderRequests.pop_front();
|
||||
}
|
||||
if (_reorderRequests.empty()) {
|
||||
// applySet(result); // Causes stickers blink.
|
||||
} else {
|
||||
_reorderRequests.front()();
|
||||
}
|
||||
}).fail([show = _show](const MTP::Error &error) {
|
||||
show->showToast(error.type());
|
||||
}).send();
|
||||
});
|
||||
if (_reorderRequests.size() == 1) {
|
||||
_reorderRequests.front()();
|
||||
}
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
if (_dragging.index >= 0 && !isDraggedAnimating()) {
|
||||
const auto fromPos = mapFromGlobal(e->globalPos()) - _dragging.point;
|
||||
const auto toPos = posFromIndex(_dragging.lastSelected);
|
||||
const auto document = _pack[_dragging.index];
|
||||
const auto wasPosition = _dragging.index;
|
||||
const auto nowPosition = _dragging.lastSelected;
|
||||
const auto finish = [=, this] {
|
||||
requestReorder(document, nowPosition);
|
||||
base::reorder(_pack, wasPosition, nowPosition);
|
||||
base::reorder(_elements, wasPosition, nowPosition);
|
||||
_dragging = {};
|
||||
_dragging.enabled = true;
|
||||
_shiftAnimations.clear();
|
||||
};
|
||||
auto &entry = _shiftAnimations[_dragging.index];
|
||||
entry.animation.stop();
|
||||
entry.yAnimation.stop();
|
||||
entry.animation.start(
|
||||
[finish, toPos, this](float64 value) {
|
||||
const auto index = _dragging.index;
|
||||
if (value >= toPos.x()
|
||||
&& index >= 0
|
||||
&& !_shiftAnimations[index].yAnimation.animating()) {
|
||||
finish();
|
||||
}
|
||||
update();
|
||||
},
|
||||
fromPos.x(),
|
||||
toPos.x(),
|
||||
kStickerMoveDuration);
|
||||
entry.yAnimation.start(
|
||||
[finish, toPos, this](float64 value) {
|
||||
const auto index = _dragging.index;
|
||||
if (value >= toPos.y()
|
||||
&& index >= 0
|
||||
&& !_shiftAnimations[index].animation.animating()) {
|
||||
finish();
|
||||
}
|
||||
update();
|
||||
},
|
||||
fromPos.y(),
|
||||
toPos.y(),
|
||||
kStickerMoveDuration);
|
||||
}
|
||||
if (_previewShown >= 0) {
|
||||
_previewShown = -1;
|
||||
return;
|
||||
@@ -1061,6 +1424,20 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
(isFaved
|
||||
? &st::menuIconUnfave
|
||||
: &st::menuIconFave));
|
||||
if (amSetCreator()) {
|
||||
const auto addAction = Ui::Menu::CreateAddActionCallback(
|
||||
_menu.get());
|
||||
addAction({
|
||||
.text = tr::lng_stickers_context_delete(tr::now),
|
||||
.handler = [index, this, show = _show] {
|
||||
show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
fillDeleteStickerBox(box, index);
|
||||
}));
|
||||
},
|
||||
.icon = &st::menuIconDeleteAttention,
|
||||
.isAttention = true,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (_menu->empty()) {
|
||||
_menu = nullptr;
|
||||
@@ -1069,6 +1446,129 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::fillDeleteStickerBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
int index) {
|
||||
Expects(index >= 0 || index < _pack.size());
|
||||
const auto document = _pack[index];
|
||||
const auto weak = Ui::MakeWeak(this);
|
||||
const auto show = _show;
|
||||
|
||||
const auto container = box->verticalLayout();
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
const auto line = container->add(object_ptr<Ui::RpWidget>(container));
|
||||
line->resize(line->width(), _singleSize.height());
|
||||
|
||||
const auto sticker = Ui::CreateChild<Ui::RpWidget>(line);
|
||||
auto &lifetime = sticker->lifetime();
|
||||
struct State final {
|
||||
rpl::variable<mtpRequestId> requestId = 0;
|
||||
Ui::RpWidget* saveButton = nullptr;
|
||||
};
|
||||
const auto state = lifetime.make_state<State>();
|
||||
sticker->resize(_singleSize);
|
||||
{
|
||||
const auto animation = lifetime.make_state<Ui::Animations::Basic>();
|
||||
animation->init([=] { sticker->update(); });
|
||||
animation->start();
|
||||
}
|
||||
sticker->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = Painter(sticker);
|
||||
if (const auto strong = weak.data()) {
|
||||
const auto paused = On(PowerSaving::kStickersPanel)
|
||||
|| show->paused(ChatHelpers::PauseReason::Layer);
|
||||
paintSticker(p, index, QPoint(), paused, crl::now());
|
||||
if (_lottiePlayer && !paused) {
|
||||
_lottiePlayer->markFrameShown();
|
||||
}
|
||||
}
|
||||
}, sticker->lifetime());
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
line,
|
||||
tr::lng_stickers_context_delete(),
|
||||
box->getDelegate()->style().title);
|
||||
line->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
sticker->moveToLeft(st::boxRowPadding.left(), 0);
|
||||
const auto skip = st::defaultBoxCheckbox.textPosition.x();
|
||||
label->resizeToWidth(width
|
||||
- rect::right(sticker)
|
||||
- skip
|
||||
- st::boxRowPadding.right());
|
||||
label->moveToLeft(
|
||||
rect::right(sticker) + skip,
|
||||
((sticker->height() - label->height()) / 2));
|
||||
}, label->lifetime());
|
||||
|
||||
sticker->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
container,
|
||||
tr::lng_stickers_context_delete_sure(),
|
||||
st::boxLabel));
|
||||
const auto save = [=] {
|
||||
if (state->requestId.current()) {
|
||||
return;
|
||||
}
|
||||
const auto weakBox = Ui::MakeWeak(box);
|
||||
const auto buttonWidth = state->saveButton
|
||||
? state->saveButton->width()
|
||||
: 0;
|
||||
state->requestId = document->owner().session().api().request(
|
||||
MTPstickers_RemoveStickerFromSet(document->mtpInput()
|
||||
)).done([=](const TLStickerSet &result) {
|
||||
result.match([&](const MTPDmessages_stickerSet &d) {
|
||||
document->owner().stickers().feedSetFull(d);
|
||||
document->owner().stickers().notifyUpdated(
|
||||
Data::StickersType::Stickers);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
if (const auto strong = weak.data()) {
|
||||
applySet(result);
|
||||
}
|
||||
if (const auto strongBox = weakBox.data()) {
|
||||
strongBox->closeBox();
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
if (const auto strongBox = weakBox.data()) {
|
||||
strongBox->uiShow()->showToast(error.type());
|
||||
}
|
||||
}).send();
|
||||
if (state->saveButton) {
|
||||
state->saveButton->resizeToWidth(buttonWidth);
|
||||
}
|
||||
};
|
||||
state->saveButton = box->addButton(
|
||||
rpl::conditional(
|
||||
state->requestId.value() | rpl::map(rpl::mappers::_1 > 0),
|
||||
rpl::single(QString()),
|
||||
tr::lng_selected_delete()),
|
||||
save,
|
||||
st::attentionBoxButton);
|
||||
if (const auto saveButton = state->saveButton) {
|
||||
using namespace Info::Statistics;
|
||||
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||
saveButton,
|
||||
saveButton->height() / 2,
|
||||
&st::editStickerSetNameLoading);
|
||||
AddChildToWidgetCenter(saveButton, loadingAnimation);
|
||||
loadingAnimation->showOn(
|
||||
state->requestId.value() | rpl::map(rpl::mappers::_1 > 0));
|
||||
}
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
document->owner().session().api().request(
|
||||
state->requestId.current()).cancel();
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::updateSelected() {
|
||||
auto selected = stickerFromGlobalPos(QCursor::pos());
|
||||
setSelected(setType() == Data::StickersType::Masks ? -1 : selected);
|
||||
@@ -1079,7 +1579,11 @@ void StickerSetBox::Inner::setSelected(int selected) {
|
||||
startOverAnimation(_selected, 1., 0.);
|
||||
_selected = selected;
|
||||
startOverAnimation(_selected, 0., 1.);
|
||||
setCursor(_selected >= 0 ? style::cur_pointer : style::cur_default);
|
||||
setCursor((_selected < 0)
|
||||
? style::cur_default
|
||||
: _dragging.enabled
|
||||
? style::cur_sizeall
|
||||
: style::cur_pointer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1101,6 +1605,24 @@ void StickerSetBox::Inner::showPreview() {
|
||||
showPreviewAt(QCursor::pos());
|
||||
}
|
||||
|
||||
QPoint StickerSetBox::Inner::posFromIndex(int index) const {
|
||||
return {
|
||||
_padding.left() + (index % _perRow) * _singleSize.width(),
|
||||
_padding.top() + (index / _perRow) * _singleSize.height(),
|
||||
};
|
||||
}
|
||||
|
||||
bool StickerSetBox::Inner::isDraggedAnimating() const {
|
||||
if (_dragging.index < 0) {
|
||||
return false;
|
||||
}
|
||||
const auto it = _shiftAnimations.find(_dragging.index);
|
||||
return (it == _shiftAnimations.end())
|
||||
? false
|
||||
: (it->second.animation.animating()
|
||||
|| it->second.yAnimation.animating());
|
||||
}
|
||||
|
||||
not_null<Lottie::MultiPlayer*> StickerSetBox::Inner::getLottiePlayer() {
|
||||
if (!_lottiePlayer) {
|
||||
_lottiePlayer = std::make_unique<Lottie::MultiPlayer>(
|
||||
@@ -1140,12 +1662,36 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
|
||||
_pathGradient->startFrame(0, width(), width() / 2);
|
||||
|
||||
const auto indexUnderCursor = (_dragging.index >= 0
|
||||
&& _dragging.index < _elements.size())
|
||||
? stickerFromGlobalPos(QCursor::pos())
|
||||
: -2;
|
||||
const auto lastIndex = indexUnderCursor >= 0
|
||||
? indexUnderCursor
|
||||
: _dragging.lastSelected;
|
||||
|
||||
const auto now = crl::now();
|
||||
const auto paused = On(PowerSaving::kStickersPanel)
|
||||
|| _show->paused(ChatHelpers::PauseReason::Layer);
|
||||
for (int32 i = from; i < to; ++i) {
|
||||
for (int32 j = 0; j < _perRow; ++j) {
|
||||
int32 index = i * _perRow + j;
|
||||
|
||||
if (lastIndex >= 0) {
|
||||
if (_dragging.index == index) {
|
||||
continue;
|
||||
}
|
||||
const auto it = _shiftAnimations.find(index);
|
||||
if (it != _shiftAnimations.end()) {
|
||||
const auto &entry = it->second;
|
||||
const auto toPos = posFromIndex(index + entry.shift);
|
||||
const auto pos = QPoint(
|
||||
entry.animation.value(toPos.x()),
|
||||
entry.yAnimation.value(toPos.y()));
|
||||
paintSticker(p, index, pos, paused, now);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (index >= _elements.size()) {
|
||||
break;
|
||||
}
|
||||
@@ -1155,6 +1701,14 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
paintSticker(p, index, pos, paused, now);
|
||||
}
|
||||
}
|
||||
if (_dragging.index >= 0 && _dragging.index < _elements.size()) {
|
||||
const auto pos = isDraggedAnimating()
|
||||
? QPoint(
|
||||
_shiftAnimations[_dragging.index].animation.value(0),
|
||||
_shiftAnimations[_dragging.index].yAnimation.value(0))
|
||||
: (mapFromGlobal(QCursor::pos()) - _dragging.point);
|
||||
paintSticker(p, _dragging.index, pos, paused, now);
|
||||
}
|
||||
|
||||
if (_lottiePlayer && !paused) {
|
||||
_lottiePlayer->markFrameShown();
|
||||
@@ -1310,18 +1864,99 @@ void StickerSetBox::Inner::customEmojiRepaint() {
|
||||
update();
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::shakeTransform(
|
||||
QPainter &p,
|
||||
int index,
|
||||
QPoint position,
|
||||
crl::time now) const {
|
||||
constexpr auto kShakeADuration = crl::time(400);
|
||||
constexpr auto kShakeXDuration = crl::time(kShakeADuration * 1.2);
|
||||
constexpr auto kShakeYDuration = kShakeADuration;
|
||||
const auto diff = ((index % 2) ? 0 : kShakeYDuration / 2)
|
||||
+ (now - _shakeAnimation.started());
|
||||
const auto pX = (diff % kShakeXDuration)
|
||||
/ float64(kShakeXDuration);
|
||||
const auto pY = (diff % kShakeYDuration)
|
||||
/ float64(kShakeYDuration);
|
||||
const auto pA = (diff % kShakeADuration)
|
||||
/ float64(kShakeADuration);
|
||||
|
||||
constexpr auto kMaxA = 2.;
|
||||
constexpr auto kMaxTranslation = .5;
|
||||
constexpr auto kAStep = 1. / 5;
|
||||
constexpr auto kXStep = 1. / 5;
|
||||
constexpr auto kYStep = 1. / 4;
|
||||
|
||||
// 0, -kMaxA, 0, kMaxA, 0.
|
||||
const auto angle = (pA < kAStep)
|
||||
? anim::interpolateF(0., -kMaxA, pA / kAStep)
|
||||
: (pA < kAStep * 2.)
|
||||
? anim::interpolateF(-kMaxA, 0, (pA - kAStep) / kAStep)
|
||||
: (pA < kAStep * 3.)
|
||||
? anim::interpolateF(0, kMaxA, (pA - kAStep * 2.) / kAStep)
|
||||
: (pA < kAStep * 4.)
|
||||
? anim::interpolateF(kMaxA, 0, (pA - kAStep * 3.) / kAStep)
|
||||
: anim::interpolateF(0, 0., (pA - kAStep * 4.) / kAStep);
|
||||
|
||||
// 0, kMaxTranslation, 0, -kMaxTranslation, 0.
|
||||
const auto x = (pX < kXStep)
|
||||
? anim::interpolateF(0., kMaxTranslation, pX / kXStep)
|
||||
: (pX < kXStep * 2.)
|
||||
? anim::interpolateF(kMaxTranslation, 0, (pX - kXStep) / kXStep)
|
||||
: (pX < kXStep * 3.)
|
||||
? anim::interpolateF(0, -kMaxTranslation, (pX - kXStep * 2.) / kXStep)
|
||||
: (pX < kXStep * 4.)
|
||||
? anim::interpolateF(-kMaxTranslation, 0, (pX - kXStep * 3.) / kXStep)
|
||||
: anim::interpolateF(0, 0., (pX - kXStep * 4.) / kXStep);
|
||||
|
||||
// 0, kMaxTranslation, -kMaxTranslation, 0.
|
||||
const auto y = (pY < kYStep)
|
||||
? anim::interpolateF(0., kMaxTranslation, pY / kYStep)
|
||||
: (pY < kYStep * 2.)
|
||||
? anim::interpolateF(kMaxTranslation, 0, (pY - kYStep) / kYStep)
|
||||
: (pY < kYStep * 3.)
|
||||
? anim::interpolateF(0, -kMaxTranslation, (pY - kYStep * 2.) / kYStep)
|
||||
: anim::interpolateF(-kMaxTranslation, 0, (pY - kYStep * 3) / kYStep);
|
||||
|
||||
const auto center = position + QPoint(
|
||||
_singleSize.width() / 2,
|
||||
_singleSize.height() / 2);
|
||||
|
||||
p.translate(center);
|
||||
p.rotate(angle);
|
||||
p.translate(-center);
|
||||
p.translate(x, y);
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::paintSticker(
|
||||
Painter &p,
|
||||
int index,
|
||||
QPoint position,
|
||||
bool paused,
|
||||
crl::time now) const {
|
||||
if (const auto over = _elements[index].overAnimation.value((index == _selected) ? 1. : 0.)) {
|
||||
p.setOpacity(over);
|
||||
auto tl = position;
|
||||
if (rtl()) tl.setX(width() - tl.x() - _singleSize.width());
|
||||
Ui::FillRoundRect(p, QRect(tl, _singleSize), st::emojiPanHover, Ui::StickerHoverCorners);
|
||||
p.setOpacity(1);
|
||||
if (_dragging.index != index) {
|
||||
const auto over = _elements[index].overAnimation.value(
|
||||
(index == _selected) ? 1. : 0.);
|
||||
if (over) {
|
||||
p.setOpacity(over);
|
||||
Ui::FillRoundRect(
|
||||
p,
|
||||
QRect(
|
||||
rtl()
|
||||
? QPoint(
|
||||
width() - position.x() - _singleSize.width(),
|
||||
position.y())
|
||||
: position,
|
||||
_singleSize),
|
||||
st::emojiPanHover,
|
||||
Ui::StickerHoverCorners);
|
||||
p.setOpacity(1);
|
||||
}
|
||||
}
|
||||
|
||||
const auto hasShake = _shakeAnimation.animating();
|
||||
if (hasShake) {
|
||||
shakeTransform(p, index, position, now);
|
||||
}
|
||||
|
||||
const auto &element = _elements[index];
|
||||
@@ -1390,6 +2025,9 @@ void StickerSetBox::Inner::paintSticker(
|
||||
_singleSize,
|
||||
width());
|
||||
}
|
||||
if (hasShake) {
|
||||
p.resetTransform();
|
||||
}
|
||||
}
|
||||
|
||||
bool StickerSetBox::Inner::loaded() const {
|
||||
|
||||
@@ -1393,7 +1393,6 @@ groupCallScheduleDateField: InputField(groupCallField) {
|
||||
placeholderScale: 0.;
|
||||
heightMin: 30px;
|
||||
textAlign: align(top);
|
||||
font: font(14px);
|
||||
}
|
||||
groupCallScheduleTimeField: InputField(groupCallScheduleDateField) {
|
||||
textBg: groupCallMembersBg;
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace tgcalls {
|
||||
class InstanceImpl;
|
||||
class InstanceV2Impl;
|
||||
class InstanceV2ReferenceImpl;
|
||||
class InstanceV2_4_0_0Impl;
|
||||
class InstanceImplLegacy;
|
||||
void SetLegacyGlobalServerConfig(const std::string &serverConfig);
|
||||
} // namespace tgcalls
|
||||
@@ -56,7 +55,6 @@ const auto kDefaultVersion = "2.4.4"_q;
|
||||
const auto Register = tgcalls::Register<tgcalls::InstanceImpl>();
|
||||
const auto RegisterV2 = tgcalls::Register<tgcalls::InstanceV2Impl>();
|
||||
const auto RegV2Ref = tgcalls::Register<tgcalls::InstanceV2ReferenceImpl>();
|
||||
const auto RegisterV240 = tgcalls::Register<tgcalls::InstanceV2_4_0_0Impl>();
|
||||
const auto RegisterLegacy = tgcalls::Register<tgcalls::InstanceImplLegacy>();
|
||||
|
||||
[[nodiscard]] base::flat_set<int64> CollectEndpointIds(
|
||||
@@ -706,7 +704,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 +1401,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 +1420,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));
|
||||
|
||||
@@ -215,7 +215,7 @@ void Panel::initWindow() {
|
||||
}
|
||||
const auto shown = _layerBg->topShownLayer();
|
||||
return (!shown || !shown->geometry().contains(widgetPoint))
|
||||
? (Flag::Move | Flag::FullScreen)
|
||||
? (Flag::Move | Flag::Menu | Flag::FullScreen)
|
||||
: Flag::None;
|
||||
});
|
||||
|
||||
@@ -276,8 +276,8 @@ void Panel::initControls() {
|
||||
_layerBg->showBox(std::move(box));
|
||||
}
|
||||
} else if (const auto source = env->uniqueDesktopCaptureSource()) {
|
||||
if (_call->isSharingScreen()) {
|
||||
_call->toggleScreenSharing(std::nullopt);
|
||||
if (!chooseSourceActiveDeviceId().isEmpty()) {
|
||||
chooseSourceStop();
|
||||
} else {
|
||||
chooseSourceAccepted(*source, false);
|
||||
}
|
||||
|
||||
@@ -1195,24 +1195,7 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
|
||||
const auto addVolumeItem = (!muted || isMe(participantPeer));
|
||||
const auto admin = IsGroupCallAdmin(_peer, participantPeer);
|
||||
const auto session = &_peer->session();
|
||||
const auto getCurrentWindow = [=]() -> Window::SessionController* {
|
||||
if (const auto window = Core::App().windowFor(participantPeer)) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
if (&controller->session() == session) {
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
const auto getWindow = [=] {
|
||||
if (const auto current = getCurrentWindow()) {
|
||||
return current;
|
||||
} else if (&Core::App().domain().active() != &session->account()) {
|
||||
Core::App().domain().activate(&session->account());
|
||||
}
|
||||
return getCurrentWindow();
|
||||
};
|
||||
const auto account = &session->account();
|
||||
|
||||
auto result = base::make_unique_q<Ui::PopupMenu>(
|
||||
parent,
|
||||
@@ -1223,7 +1206,7 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
|
||||
: st::groupCallPopupMenu));
|
||||
const auto weakMenu = Ui::MakeWeak(result.get());
|
||||
const auto withActiveWindow = [=](auto callback) {
|
||||
if (const auto window = getWindow()) {
|
||||
if (const auto window = Core::App().activePrimaryWindow()) {
|
||||
if (const auto menu = weakMenu.data()) {
|
||||
menu->discardParentReActivate();
|
||||
|
||||
@@ -1232,8 +1215,13 @@ base::unique_qptr<Ui::PopupMenu> Members::Controller::createRowContextMenu(
|
||||
// PopupMenu::hide activates back the group call panel :(
|
||||
delete weakMenu;
|
||||
}
|
||||
callback(window);
|
||||
window->widget()->activate();
|
||||
window->invokeForSessionController(
|
||||
account,
|
||||
participantPeer,
|
||||
[&](not_null<Window::SessionController*> newController) {
|
||||
callback(newController);
|
||||
newController->widget()->activate();
|
||||
});
|
||||
}
|
||||
};
|
||||
const auto showProfile = [=] {
|
||||
|
||||
@@ -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(
|
||||
@@ -416,7 +410,7 @@ void Panel::initWindow() {
|
||||
}
|
||||
const auto shown = _layerBg->topShownLayer();
|
||||
return (!shown || !shown->geometry().contains(widgetPoint))
|
||||
? (Flag::Move | Flag::Maximize)
|
||||
? (Flag::Move | Flag::Menu | Flag::Maximize)
|
||||
: Flag::None;
|
||||
});
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -71,6 +71,7 @@ ComposeIcons {
|
||||
menuSpoilerOff: icon;
|
||||
menuBelow: icon;
|
||||
menuAbove: icon;
|
||||
menuPrice: icon;
|
||||
|
||||
stripBubble: icon;
|
||||
stripExpandPanel: icon;
|
||||
@@ -283,6 +284,10 @@ stickersTrendingSubheaderFont: normalFont;
|
||||
stickersTrendingSubheaderFg: windowSubTextFg;
|
||||
stickersTrendingSubheaderTop: 31px;
|
||||
|
||||
stickersHeaderBadgeFont: font(10px);
|
||||
stickersHeaderBadgeFontTop: 12px;
|
||||
stickersHeaderBadgeFontSkip: 12px;
|
||||
|
||||
emojiPanButtonRight: 7px;
|
||||
emojiPanButtonTop: 8px;
|
||||
emojiPanButton: RoundButton(defaultActiveButton) {
|
||||
@@ -610,6 +615,7 @@ defaultComposeIcons: ComposeIcons {
|
||||
menuSpoilerOff: menuIconSpoilerOff;
|
||||
menuBelow: menuIconBelow;
|
||||
menuAbove: menuIconAbove;
|
||||
menuPrice: menuIconEarn;
|
||||
|
||||
stripBubble: icon{
|
||||
{ "chat/reactions_bubble_shadow", windowShadowFg },
|
||||
@@ -989,8 +995,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;
|
||||
@@ -1381,3 +1412,85 @@ editTagField: InputField(defaultInputField) {
|
||||
editTagLimit: FlatLabel(defaultFlatLabel) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
|
||||
editStickerSetNameField: InputField(defaultInputField) {
|
||||
textMargins: margins(0px, 28px, 26px, 4px);
|
||||
heightMax: 55px;
|
||||
}
|
||||
editStickerSetNameLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
|
||||
color: lightButtonFg;
|
||||
thickness: 2px;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
pickLocationWindow: size(364px, 680px);
|
||||
pickLocationMapHeight: 220px;
|
||||
pickLocationCollapsedHeight: 92px;
|
||||
pickLocationRowHeight: 52px;
|
||||
pickLocationButton: FlatButton {
|
||||
height: pickLocationRowHeight;
|
||||
bgColor: contactsBg;
|
||||
overBgColor: contactsBgOver;
|
||||
ripple: defaultRippleAnimation;
|
||||
}
|
||||
pickLocationButtonText: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 128px;
|
||||
maxHeight: 20px;
|
||||
style: semiboldTextStyle;
|
||||
textFg: windowBoldFg;
|
||||
}
|
||||
pickLocationButtonStatus: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 128px;
|
||||
maxHeight: 20px;
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
pickLocationButtonSkip: 6px;
|
||||
pickLocationSendIcon: icon{{ "chat/filled_location", windowFgActive }};
|
||||
pickLocationVenueItem: PeerListItem(defaultPeerListItem) {
|
||||
height: pickLocationRowHeight;
|
||||
photoSize: 42px;
|
||||
photoPosition: point(18px, 5px);
|
||||
namePosition: point(70px, 7px);
|
||||
statusPosition: point(70px, 27px);
|
||||
button: OutlineButton(defaultPeerListButton) {
|
||||
textBg: contactsBg;
|
||||
textBgOver: contactsBgOver;
|
||||
font: normalFont;
|
||||
padding: margins(11px, 5px, 11px, 5px);
|
||||
ripple: defaultRippleAnimation;
|
||||
}
|
||||
statusFg: contactsStatusFg;
|
||||
statusFgOver: contactsStatusFgOver;
|
||||
statusFgActive: contactsStatusFgOnline;
|
||||
}
|
||||
pickLocationVenueList: PeerList(defaultPeerList) {
|
||||
item: pickLocationVenueItem;
|
||||
padding: margins(0px, 0px, 0px, 0px);
|
||||
}
|
||||
pickLocationIconSkip: 6px;
|
||||
pickLocationLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
|
||||
size: size(56px, 56px);
|
||||
color: windowSubTextFg;
|
||||
thickness: 4px;
|
||||
}
|
||||
pickLocationPromoHeight: 32px;
|
||||
pickLocationChooseOnMap: RoundButton(defaultActiveButton) {
|
||||
height: 44px;
|
||||
textTop: 11px;
|
||||
width: -96px;
|
||||
font: font(15px semibold);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_document_media.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "menu/menu_send.h" // SendMenu::FillSendMenu
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "ui/controls/tabbed_search.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
@@ -48,7 +49,6 @@ namespace ChatHelpers {
|
||||
namespace {
|
||||
|
||||
constexpr auto kSearchRequestDelay = 400;
|
||||
constexpr auto kSearchBotUsername = "gif"_cs;
|
||||
constexpr auto kMinRepaintDelay = crl::time(33);
|
||||
constexpr auto kMinAfterScrollDelay = crl::time(33);
|
||||
|
||||
@@ -864,13 +864,11 @@ void GifsListWidget::searchForGifs(const QString &query) {
|
||||
}
|
||||
|
||||
if (!_searchBot && !_searchBotRequestId) {
|
||||
auto username = kSearchBotUsername.utf16();
|
||||
const auto username = session().serverConfig().gifSearchUsername;
|
||||
_searchBotRequestId = _api.request(MTPcontacts_ResolveUsername(
|
||||
MTP_string(username)
|
||||
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||
|
||||
auto &data = result.c_contacts_resolvedPeer();
|
||||
auto &data = result.data();
|
||||
session().data().processUsers(data.vusers());
|
||||
session().data().processChats(data.vchats());
|
||||
const auto peer = session().data().peerLoaded(
|
||||
|
||||
@@ -14,11 +14,13 @@ 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"
|
||||
@@ -40,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>
|
||||
@@ -58,6 +61,7 @@ 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.
|
||||
@@ -222,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,
|
||||
@@ -274,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(
|
||||
@@ -320,6 +378,13 @@ Fn<bool(
|
||||
};
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -327,14 +392,21 @@ void InitMessageFieldHandlers(
|
||||
Fn<bool()> customEmojiPaused,
|
||||
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji,
|
||||
const style::InputField *fieldStyle) {
|
||||
const auto paused = [customEmojiPaused] {
|
||||
return customEmojiPaused && customEmojiPaused();
|
||||
};
|
||||
field->setTagMimeProcessor(
|
||||
FieldTagMimeProcessor(session, allowPremiumEmoji));
|
||||
const auto paused = [customEmojiPaused] {
|
||||
return On(PowerSaving::kEmojiChat) || customEmojiPaused();
|
||||
};
|
||||
field->setCustomEmojiFactory(
|
||||
session->data().customEmojiManager().factory(),
|
||||
std::move(customEmojiPaused));
|
||||
field->setCustomTextContext([=](Fn<void()> repaint) {
|
||||
return std::any(Core::MarkedTextContext{
|
||||
.session = session,
|
||||
.customEmojiRepaint = std::move(repaint),
|
||||
});
|
||||
}, [paused] {
|
||||
return On(PowerSaving::kEmojiChat) || paused();
|
||||
}, [paused] {
|
||||
return On(PowerSaving::kChatSpoiler) || paused();
|
||||
});
|
||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
field->setInstantReplacesEnabled(
|
||||
Core::App().settings().replaceEmojiValue());
|
||||
@@ -342,8 +414,18 @@ void InitMessageFieldHandlers(
|
||||
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) {
|
||||
@@ -446,7 +528,7 @@ void InitMessageFieldGeometry(not_null<Ui::InputField*> field) {
|
||||
st::historySendSize.height() - 2 * st::historySendPadding);
|
||||
field->setMaxHeight(st::historyComposeFieldMaxHeight);
|
||||
|
||||
field->document()->setDocumentMargin(4.);
|
||||
field->setDocumentMargin(4.);
|
||||
field->setAdditionalMargin(style::ConvertScale(4) - 4);
|
||||
}
|
||||
|
||||
@@ -569,12 +651,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(
|
||||
@@ -766,11 +862,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);
|
||||
}
|
||||
}
|
||||
@@ -1097,7 +1189,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());
|
||||
@@ -1117,8 +1211,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
|
||||
|
||||
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_session.h"
|
||||
|
||||
@@ -21,6 +22,16 @@ GiftBoxPack::GiftBoxPack(not_null<Main::Session*> session)
|
||||
|
||||
GiftBoxPack::~GiftBoxPack() = default;
|
||||
|
||||
int GiftBoxPack::monthsForStars(int stars) const {
|
||||
if (stars <= 1000) {
|
||||
return 3;
|
||||
} else if (stars < 2500) {
|
||||
return 6;
|
||||
} else {
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
|
||||
DocumentData *GiftBoxPack::lookup(int months) const {
|
||||
const auto it = ranges::lower_bound(_localMonths, months);
|
||||
const auto fallback = _documents.empty() ? nullptr : _documents[0];
|
||||
@@ -38,6 +49,10 @@ DocumentData *GiftBoxPack::lookup(int months) const {
|
||||
return (index >= _documents.size()) ? fallback : _documents[index];
|
||||
}
|
||||
|
||||
Data::FileOrigin GiftBoxPack::origin() const {
|
||||
return Data::FileOriginStickerSet(_setId, _accessHash);
|
||||
}
|
||||
|
||||
void GiftBoxPack::load() {
|
||||
if (_requestId || !_documents.empty()) {
|
||||
return;
|
||||
@@ -59,6 +74,7 @@ void GiftBoxPack::load() {
|
||||
|
||||
void GiftBoxPack::applySet(const MTPDmessages_stickerSet &data) {
|
||||
_setId = data.vset().data().vid().v;
|
||||
_accessHash = data.vset().data().vaccess_hash().v;
|
||||
auto documents = base::flat_map<DocumentId, not_null<DocumentData*>>();
|
||||
for (const auto &sticker : data.vdocuments().v) {
|
||||
const auto document = _session->data().processDocument(sticker);
|
||||
|
||||
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
class DocumentData;
|
||||
|
||||
namespace Data {
|
||||
struct FileOrigin;
|
||||
} // namespace Data
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
@@ -21,7 +25,9 @@ public:
|
||||
~GiftBoxPack();
|
||||
|
||||
void load();
|
||||
[[nodiscard]] int monthsForStars(int stars) const;
|
||||
[[nodiscard]] DocumentData *lookup(int months) const;
|
||||
[[nodiscard]] Data::FileOrigin origin() const;
|
||||
|
||||
private:
|
||||
using SetId = uint64;
|
||||
@@ -32,6 +38,7 @@ private:
|
||||
|
||||
std::vector<DocumentData*> _documents;
|
||||
SetId _setId = 0;
|
||||
uint64 _accessHash = 0;
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
|
||||
#include "base/timer_rpl.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_document_media.h"
|
||||
@@ -932,6 +933,9 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||
if (sets.empty() && _section == Section::Search) {
|
||||
paintEmptySearchResults(p);
|
||||
}
|
||||
const auto badgeText = tr::lng_stickers_creator_badge(tr::now);
|
||||
const auto &badgeFont = st::stickersHeaderBadgeFont;
|
||||
const auto badgeWidth = badgeFont->width(badgeText);
|
||||
enumerateSections([&](const SectionInfo &info) {
|
||||
if (clip.top() >= info.rowsBottom) {
|
||||
return true;
|
||||
@@ -1050,6 +1054,12 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||
|
||||
widthForTitle -= remove.width();
|
||||
}
|
||||
const auto amCreator = (set.flags & Data::StickersSetFlag::AmCreator);
|
||||
if (amCreator) {
|
||||
widthForTitle -= badgeWidth
|
||||
+ st::stickersFeaturedUnreadSkip
|
||||
+ st::stickersHeaderBadgeFontSkip;
|
||||
}
|
||||
if (titleWidth > widthForTitle) {
|
||||
titleText = st::stickersTrendingHeaderFont->elided(titleText, widthForTitle);
|
||||
titleWidth = st::stickersTrendingHeaderFont->width(titleText);
|
||||
@@ -1057,6 +1067,39 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||
p.setFont(st::emojiPanHeaderFont);
|
||||
p.setPen(st().headerFg);
|
||||
p.drawTextLeft(st().headerLeft - st().margin.left(), info.top + st().headerTop, width(), titleText, titleWidth);
|
||||
if (amCreator) {
|
||||
const auto badgeLeft = st().headerLeft
|
||||
- st().margin.left()
|
||||
+ titleWidth
|
||||
+ st::stickersFeaturedUnreadSkip;
|
||||
{
|
||||
auto color = st().headerFg->c;
|
||||
color.setAlphaF(st().headerFg->c.alphaF() * 0.15);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(color);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.drawRoundedRect(
|
||||
style::rtlrect(
|
||||
badgeLeft,
|
||||
info.top + st::stickersHeaderBadgeFontTop,
|
||||
badgeWidth + badgeFont->height,
|
||||
badgeFont->height,
|
||||
width()),
|
||||
badgeFont->height / 2.,
|
||||
badgeFont->height / 2.);
|
||||
}
|
||||
p.setPen(st().headerFg);
|
||||
p.setBrush(Qt::NoBrush);
|
||||
p.setFont(badgeFont);
|
||||
p.drawText(
|
||||
QRect(
|
||||
badgeLeft + badgeFont->height / 2,
|
||||
info.top + st::stickersHeaderBadgeFontTop,
|
||||
badgeWidth,
|
||||
badgeFont->height),
|
||||
badgeText,
|
||||
style::al_center);
|
||||
}
|
||||
}
|
||||
if (clip.top() + clip.height() <= info.rowsTop) {
|
||||
return true;
|
||||
@@ -1675,12 +1718,32 @@ QPoint StickersListWidget::buttonRippleTopLeft(int section) const {
|
||||
+ st().removeSet.rippleAreaPosition;
|
||||
}
|
||||
|
||||
void StickersListWidget::showStickerSetBox(not_null<DocumentData*> document) {
|
||||
void StickersListWidget::showStickerSetBox(
|
||||
not_null<DocumentData*> document,
|
||||
uint64 setId) {
|
||||
if (document->sticker() && document->sticker()->set) {
|
||||
checkHideWithBox(Box<StickerSetBox>(
|
||||
_show,
|
||||
document->sticker()->set,
|
||||
document->sticker()->setType));
|
||||
} else if ((setId == Data::Stickers::FavedSetId)
|
||||
|| (setId == Data::Stickers::RecentSetId)) {
|
||||
const auto lifetime = std::make_shared<rpl::lifetime>();
|
||||
constexpr auto kTimeout = 10000;
|
||||
rpl::merge(
|
||||
base::timer_once(kTimeout),
|
||||
document->owner().stickers().updated(
|
||||
Data::StickersType::Stickers)
|
||||
) | rpl::start_with_next([=, weak = Ui::MakeWeak(this)] {
|
||||
if (weak.data()) {
|
||||
showStickerSetBox(document, setId);
|
||||
}
|
||||
lifetime->destroy();
|
||||
}, *lifetime);
|
||||
document->owner().session().api().requestSpecialStickersForce(
|
||||
setId == Data::Stickers::FavedSetId,
|
||||
setId == Data::Stickers::RecentSetId,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1737,8 +1800,8 @@ base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
|
||||
isFaved ? &icons->menuUnfave : &icons->menuFave);
|
||||
|
||||
if (_features.openStickerSets) {
|
||||
menu->addAction(tr::lng_context_pack_info(tr::now), [=] {
|
||||
showStickerSetBox(document);
|
||||
menu->addAction(tr::lng_context_pack_info(tr::now), [=, id = set.id] {
|
||||
showStickerSetBox(document, id);
|
||||
}, &icons->menuStickerSet);
|
||||
}
|
||||
|
||||
@@ -1808,7 +1871,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
const auto document = set.stickers[sticker->index].document;
|
||||
if (_features.openStickerSets
|
||||
&& (e->modifiers() & Qt::ControlModifier)) {
|
||||
showStickerSetBox(document);
|
||||
showStickerSetBox(document, set.id);
|
||||
} else {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
|
||||
@@ -350,7 +350,9 @@ private:
|
||||
void refreshFooterIcons();
|
||||
void refreshIcons(ValidateIconAnimations animations);
|
||||
|
||||
void showStickerSetBox(not_null<DocumentData*> document);
|
||||
void showStickerSetBox(
|
||||
not_null<DocumentData*> document,
|
||||
uint64 setId);
|
||||
|
||||
void cancelSetsSearch();
|
||||
void showSearchResults();
|
||||
|
||||
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/application.h"
|
||||
|
||||
#include "data/data_abstract_structure.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
@@ -18,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/battery_saving.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "base/concurrent_timer.h"
|
||||
#include "base/options.h"
|
||||
#include "base/qt_signal_producer.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/unixtime.h"
|
||||
@@ -91,6 +93,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "payments/payments_checkout_process.h"
|
||||
#include "export/export_manager.h"
|
||||
#include "webrtc/webrtc_environment.h"
|
||||
#include "window/window_separate_id.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
@@ -118,7 +121,7 @@ constexpr auto kFileOpenTimeoutMs = crl::time(1000);
|
||||
LaunchState GlobalLaunchState/* = LaunchState::Running*/;
|
||||
|
||||
void SetCrashAnnotationsGL() {
|
||||
#ifdef Q_OS_WIN
|
||||
#ifdef DESKTOP_APP_USE_ANGLE
|
||||
CrashReports::SetAnnotation("OpenGL ANGLE", [] {
|
||||
if (Core::App().settings().disableOpenGL()) {
|
||||
return "Disabled";
|
||||
@@ -131,17 +134,25 @@ void SetCrashAnnotationsGL() {
|
||||
}
|
||||
Unexpected("Ui::GL::CurrentANGLE value in SetupANGLE.");
|
||||
}());
|
||||
#else // Q_OS_WIN
|
||||
#else // DESKTOP_APP_USE_ANGLE
|
||||
CrashReports::SetAnnotation(
|
||||
"OpenGL",
|
||||
Core::App().settings().disableOpenGL() ? "Disabled" : "Enabled");
|
||||
#endif // Q_OS_WIN
|
||||
#endif // DESKTOP_APP_USE_ANGLE
|
||||
}
|
||||
|
||||
base::options::toggle OptionSkipUrlSchemeRegister({
|
||||
.id = kOptionSkipUrlSchemeRegister,
|
||||
.name = "Skip URL scheme register",
|
||||
.description = "Don't re-register tg:// URL scheme on autoupdate.",
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
Application *Application::Instance = nullptr;
|
||||
|
||||
const char kOptionSkipUrlSchemeRegister[] = "skip-url-scheme-register";
|
||||
|
||||
struct Application::Private {
|
||||
base::Timer quitTimer;
|
||||
UiIntegration uiIntegration;
|
||||
@@ -177,8 +188,11 @@ Application::Application()
|
||||
_platformIntegration->init();
|
||||
|
||||
passcodeLockChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
) | rpl::start_with_next([=](bool locked) {
|
||||
_shouldLockAt = 0;
|
||||
if (locked) {
|
||||
closeAdditionalWindows();
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
passcodeLockChanges(
|
||||
@@ -200,6 +214,16 @@ Application::Application()
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void Application::closeAdditionalWindows() {
|
||||
Payments::CheckoutProcess::ClearAll();
|
||||
for (const auto &[index, account] : _domain->accounts()) {
|
||||
if (account->sessionExists()) {
|
||||
account->session().attachWebView().closeAll();
|
||||
}
|
||||
}
|
||||
_iv->closeAll();
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
if (_saveSettingsTimer && _saveSettingsTimer->isActive()) {
|
||||
Local::writeSettings();
|
||||
@@ -209,8 +233,7 @@ Application::~Application() {
|
||||
setLastActiveWindow(nullptr);
|
||||
_windowInSettings = _lastActivePrimaryWindow = nullptr;
|
||||
_closingAsyncWindows.clear();
|
||||
_secondaryWindows.clear();
|
||||
_primaryWindows.clear();
|
||||
_windows.clear();
|
||||
_mediaView = nullptr;
|
||||
_notifications->clearAllFast();
|
||||
|
||||
@@ -220,9 +243,7 @@ Application::~Application() {
|
||||
//
|
||||
// For example Domain::removeRedundantAccounts() is called from
|
||||
// Domain::finish() and there is a violation on Ensures(started()).
|
||||
Payments::CheckoutProcess::ClearAll();
|
||||
InlineBots::AttachWebView::ClearAll();
|
||||
_iv->closeAll();
|
||||
closeAdditionalWindows();
|
||||
|
||||
_domain->finish();
|
||||
|
||||
@@ -261,7 +282,7 @@ void Application::run() {
|
||||
refreshGlobalProxy(); // Depends on app settings being read.
|
||||
|
||||
if (const auto old = Local::oldSettingsVersion(); old < AppVersion) {
|
||||
InvokeQueued(this, [] { RegisterUrlScheme(); });
|
||||
autoRegisterUrlScheme();
|
||||
Platform::NewVersionLaunched(old);
|
||||
}
|
||||
|
||||
@@ -315,8 +336,8 @@ void Application::run() {
|
||||
// Create mime database, so it won't be slow later.
|
||||
QMimeDatabase().mimeTypeForName(u"text/plain"_q);
|
||||
|
||||
_primaryWindows.emplace(nullptr, std::make_unique<Window::Controller>());
|
||||
setLastActiveWindow(_primaryWindows.front().second.get());
|
||||
_windows.emplace(nullptr, std::make_unique<Window::Controller>());
|
||||
setLastActiveWindow(_windows.front().second.get());
|
||||
_windowInSettings = _lastActivePrimaryWindow = _lastActiveWindow;
|
||||
|
||||
_domain->activeChanges(
|
||||
@@ -404,8 +425,14 @@ void Application::run() {
|
||||
processCreatedWindow(_lastActivePrimaryWindow);
|
||||
}
|
||||
|
||||
void Application::autoRegisterUrlScheme() {
|
||||
if (!OptionSkipUrlSchemeRegister.value()) {
|
||||
InvokeQueued(this, [] { RegisterUrlScheme(); });
|
||||
}
|
||||
}
|
||||
|
||||
void Application::showAccount(not_null<Main::Account*> account) {
|
||||
if (const auto separate = separateWindowForAccount(account)) {
|
||||
if (const auto separate = separateWindowFor(account)) {
|
||||
_lastActivePrimaryWindow = separate;
|
||||
separate->activate();
|
||||
} else if (const auto last = activePrimaryWindow()) {
|
||||
@@ -413,13 +440,13 @@ void Application::showAccount(not_null<Main::Account*> account) {
|
||||
}
|
||||
}
|
||||
|
||||
void Application::checkWindowAccount(not_null<Window::Controller*> window) {
|
||||
const auto account = window->maybeAccount();
|
||||
for (auto &[key, existing] : _primaryWindows) {
|
||||
if (existing.get() == window && key != account) {
|
||||
void Application::checkWindowId(not_null<Window::Controller*> window) {
|
||||
const auto id = window->id();
|
||||
for (auto &[existingId, existing] : _windows) {
|
||||
if (existing.get() == window && existingId != id) {
|
||||
auto found = std::move(existing);
|
||||
_primaryWindows.remove(key);
|
||||
_primaryWindows.emplace(account, std::move(found));
|
||||
_windows.remove(existingId);
|
||||
_windows.emplace(id, std::move(found));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -495,10 +522,7 @@ void Application::startSystemDarkModeViewer() {
|
||||
|
||||
void Application::enumerateWindows(Fn<void(
|
||||
not_null<Window::Controller*>)> callback) const {
|
||||
for (const auto &window : ranges::views::values(_primaryWindows)) {
|
||||
callback(window.get());
|
||||
}
|
||||
for (const auto &window : ranges::views::values(_secondaryWindows)) {
|
||||
for (const auto &window : ranges::views::values(_windows)) {
|
||||
callback(window.get());
|
||||
}
|
||||
}
|
||||
@@ -607,10 +631,7 @@ void Application::clearEmojiSourceImages() {
|
||||
}
|
||||
|
||||
bool Application::isActiveForTrayMenu() const {
|
||||
return ranges::any_of(ranges::views::values(_primaryWindows), [=](
|
||||
const std::unique_ptr<Window::Controller> &controller) {
|
||||
return controller->widget()->isActiveForTrayMenu();
|
||||
}) || ranges::any_of(ranges::views::values(_secondaryWindows), [=](
|
||||
return ranges::any_of(ranges::views::values(_windows), [=](
|
||||
const std::unique_ptr<Window::Controller> &controller) {
|
||||
return controller->widget()->isActiveForTrayMenu();
|
||||
});
|
||||
@@ -669,7 +690,8 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
||||
if (const auto file = event->file(); !file.isEmpty()) {
|
||||
_filesToOpen.append(file);
|
||||
_fileOpenTimer.callOnce(kFileOpenTimeoutMs);
|
||||
} else if (event->url().scheme() == u"tg"_q) {
|
||||
} else if (event->url().scheme() == u"tg"_q
|
||||
|| event->url().scheme() == u"tonsite"_q) {
|
||||
const auto url = QString::fromUtf8(
|
||||
event->url().toEncoded().trimmed());
|
||||
cSetStartUrl(url.mid(0, 8192));
|
||||
@@ -1070,13 +1092,18 @@ void Application::checkSendPaths() {
|
||||
}
|
||||
|
||||
void Application::checkStartUrl() {
|
||||
if (!cStartUrl().isEmpty()
|
||||
&& _lastActivePrimaryWindow
|
||||
&& !_lastActivePrimaryWindow->locked()) {
|
||||
if (!cStartUrl().isEmpty()) {
|
||||
const auto url = cStartUrl();
|
||||
cSetStartUrl(QString());
|
||||
if (!openLocalUrl(url, {})) {
|
||||
cSetStartUrl(url);
|
||||
if (!Core::App().passcodeLocked()) {
|
||||
if (url.startsWith("tonsite://", Qt::CaseInsensitive)) {
|
||||
cSetStartUrl(QString());
|
||||
iv().showTonSite(url, {});
|
||||
} else if (_lastActivePrimaryWindow) {
|
||||
cSetStartUrl(QString());
|
||||
if (!openLocalUrl(url, {})) {
|
||||
cSetStartUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1287,44 +1314,36 @@ Window::Controller *Application::activePrimaryWindow() const {
|
||||
return _lastActivePrimaryWindow;
|
||||
}
|
||||
|
||||
Window::Controller *Application::separateWindowForAccount(
|
||||
not_null<Main::Account*> account) const {
|
||||
for (const auto &[openedAccount, window] : _primaryWindows) {
|
||||
if (openedAccount == account.get()) {
|
||||
Window::Controller *Application::separateWindowFor(
|
||||
Window::SeparateId id) const {
|
||||
for (const auto &[existingId, window] : _windows) {
|
||||
if (existingId == id) {
|
||||
return window.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Window::Controller *Application::separateWindowForPeer(
|
||||
not_null<PeerData*> peer) const {
|
||||
for (const auto &[history, window] : _secondaryWindows) {
|
||||
if (history->peer == peer) {
|
||||
return window.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Window::Controller *Application::ensureSeparateWindowForPeer(
|
||||
not_null<PeerData*> peer,
|
||||
Window::Controller *Application::ensureSeparateWindowFor(
|
||||
Window::SeparateId id,
|
||||
MsgId showAtMsgId) {
|
||||
const auto activate = [&](not_null<Window::Controller*> window) {
|
||||
window->activate();
|
||||
return window;
|
||||
};
|
||||
|
||||
if (const auto existing = separateWindowForPeer(peer)) {
|
||||
existing->sessionController()->showPeerHistory(
|
||||
peer,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
showAtMsgId);
|
||||
if (const auto existing = separateWindowFor(id)) {
|
||||
if (id.thread && id.type == Window::SeparateType::Chat) {
|
||||
existing->sessionController()->showThread(
|
||||
id.thread,
|
||||
showAtMsgId,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
}
|
||||
return activate(existing);
|
||||
}
|
||||
const auto result = _secondaryWindows.emplace(
|
||||
peer->owner().history(peer),
|
||||
std::make_unique<Window::Controller>(peer, showAtMsgId)
|
||||
|
||||
const auto result = _windows.emplace(
|
||||
id,
|
||||
std::make_unique<Window::Controller>(id, showAtMsgId)
|
||||
).first->second.get();
|
||||
processCreatedWindow(result);
|
||||
result->firstShow();
|
||||
@@ -1332,55 +1351,63 @@ Window::Controller *Application::ensureSeparateWindowForPeer(
|
||||
return activate(result);
|
||||
}
|
||||
|
||||
Window::Controller *Application::ensureSeparateWindowForAccount(
|
||||
not_null<Main::Account*> account) {
|
||||
const auto activate = [&](not_null<Window::Controller*> window) {
|
||||
window->activate();
|
||||
return window;
|
||||
};
|
||||
|
||||
if (const auto existing = separateWindowForAccount(account)) {
|
||||
return activate(existing);
|
||||
}
|
||||
const auto result = _primaryWindows.emplace(
|
||||
account,
|
||||
std::make_unique<Window::Controller>(account)
|
||||
).first->second.get();
|
||||
processCreatedWindow(result);
|
||||
result->firstShow();
|
||||
result->finishFirstShow();
|
||||
return activate(result);
|
||||
}
|
||||
|
||||
Window::Controller *Application::windowFor(not_null<PeerData*> peer) const {
|
||||
if (const auto separate = separateWindowForPeer(peer)) {
|
||||
return separate;
|
||||
}
|
||||
return windowFor(&peer->account());
|
||||
}
|
||||
|
||||
Window::Controller *Application::windowFor(
|
||||
not_null<Main::Account*> account) const {
|
||||
if (const auto separate = separateWindowForAccount(account)) {
|
||||
Window::Controller *Application::windowFor(Window::SeparateId id) const {
|
||||
if (const auto separate = separateWindowFor(id)) {
|
||||
return separate;
|
||||
} else if (id && !id.primary()) {
|
||||
return windowFor(not_null(id.account));
|
||||
}
|
||||
return activePrimaryWindow();
|
||||
}
|
||||
|
||||
Window::Controller *Application::windowForShowingHistory(
|
||||
not_null<PeerData*> peer) const {
|
||||
if (const auto separate = separateWindowFor(peer)) {
|
||||
return separate;
|
||||
}
|
||||
auto result = (Window::Controller*)nullptr;
|
||||
enumerateWindows([&](not_null<Window::Controller*> window) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
const auto current = controller->activeChatCurrent();
|
||||
if (const auto history = current.history()) {
|
||||
if (history->peer == peer) {
|
||||
result = window;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Window::Controller *Application::windowForShowingForum(
|
||||
not_null<Data::Forum*> forum) const {
|
||||
const auto id = Window::SeparateId(
|
||||
Window::SeparateType::Forum,
|
||||
forum->history());
|
||||
if (const auto separate = separateWindowFor(id)) {
|
||||
return separate;
|
||||
}
|
||||
auto result = (Window::Controller*)nullptr;
|
||||
enumerateWindows([&](not_null<Window::Controller*> window) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
const auto current = controller->shownForum().current();
|
||||
if (forum == current) {
|
||||
result = window;
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Window::Controller *Application::findWindow(
|
||||
not_null<QWidget*> widget) const {
|
||||
const auto window = widget->window();
|
||||
if (_lastActiveWindow && _lastActiveWindow->widget() == window) {
|
||||
return _lastActiveWindow;
|
||||
}
|
||||
for (const auto &[account, primary] : _primaryWindows) {
|
||||
if (primary->widget() == window) {
|
||||
return primary.get();
|
||||
}
|
||||
}
|
||||
for (const auto &[history, secondary] : _secondaryWindows) {
|
||||
if (secondary->widget() == window) {
|
||||
return secondary.get();
|
||||
for (const auto &[id, controller] : _windows) {
|
||||
if (controller->widget() == window) {
|
||||
return controller.get();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -1392,10 +1419,11 @@ Window::Controller *Application::activeWindow() const {
|
||||
|
||||
bool Application::closeNonLastAsync(not_null<Window::Controller*> window) {
|
||||
const auto hasOther = [&] {
|
||||
for (const auto &[account, primary] : _primaryWindows) {
|
||||
if (!_closingAsyncWindows.contains(primary.get())
|
||||
&& primary.get() != window
|
||||
&& primary->maybeSession()) {
|
||||
for (const auto &[id, controller] : _windows) {
|
||||
if (id.primary()
|
||||
&& !_closingAsyncWindows.contains(controller.get())
|
||||
&& controller.get() != window
|
||||
&& controller->maybeSession()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1457,10 +1485,10 @@ void Application::closeWindow(not_null<Window::Controller*> window) {
|
||||
: nullptr;
|
||||
const auto next = nextFromStack
|
||||
? nextFromStack
|
||||
: (_primaryWindows.front().second.get() != window)
|
||||
? _primaryWindows.front().second.get()
|
||||
: (_primaryWindows.back().second.get() != window)
|
||||
? _primaryWindows.back().second.get()
|
||||
: (_windows.front().second.get() != window)
|
||||
? _windows.front().second.get()
|
||||
: (_windows.back().second.get() != window)
|
||||
? _windows.back().second.get()
|
||||
: nullptr;
|
||||
Assert(next != window);
|
||||
|
||||
@@ -1481,20 +1509,12 @@ void Application::closeWindow(not_null<Window::Controller*> window) {
|
||||
}
|
||||
}
|
||||
_closingAsyncWindows.remove(window);
|
||||
for (auto i = begin(_primaryWindows); i != end(_primaryWindows);) {
|
||||
for (auto i = begin(_windows); i != end(_windows);) {
|
||||
if (i->second.get() == window) {
|
||||
Assert(_lastActiveWindow != window);
|
||||
Assert(_lastActivePrimaryWindow != window);
|
||||
Assert(_windowInSettings != window);
|
||||
i = _primaryWindows.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
for (auto i = begin(_secondaryWindows); i != end(_secondaryWindows);) {
|
||||
if (i->second.get() == window) {
|
||||
Assert(_lastActiveWindow != window);
|
||||
i = _secondaryWindows.erase(i);
|
||||
i = _windows.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
@@ -1502,36 +1522,34 @@ void Application::closeWindow(not_null<Window::Controller*> window) {
|
||||
const auto account = domain().started()
|
||||
? &domain().active()
|
||||
: nullptr;
|
||||
if (account && !_primaryWindows.contains(account) && _lastActiveWindow) {
|
||||
if (account
|
||||
&& !_windows.contains(Window::SeparateId(account))
|
||||
&& _lastActiveWindow) {
|
||||
domain().activate(&_lastActiveWindow->account());
|
||||
}
|
||||
}
|
||||
|
||||
void Application::closeChatFromWindows(not_null<PeerData*> peer) {
|
||||
if (const auto window = windowFor(peer)
|
||||
; window && !window->isPrimary()) {
|
||||
closeWindow(window);
|
||||
}
|
||||
for (const auto &[history, window] : _secondaryWindows) {
|
||||
if (const auto session = window->sessionController()) {
|
||||
if (session->activeChatCurrent().peer() == peer) {
|
||||
session->showPeerHistory(
|
||||
window->singlePeer()->id,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto window = windowFor(&peer->account())) {
|
||||
if (const auto primary = window->sessionController()) {
|
||||
if (primary->activeChatCurrent().peer() == peer) {
|
||||
primary->clearSectionStack();
|
||||
}
|
||||
if (const auto forum = primary->shownForum().current()) {
|
||||
if (peer->forum() == forum) {
|
||||
primary->closeForum();
|
||||
const auto closeOne = [&] {
|
||||
for (const auto &[id, window] : _windows) {
|
||||
if (id.thread && id.thread->peer() == peer) {
|
||||
closeWindow(window.get());
|
||||
return true;
|
||||
} else if (const auto controller = window->sessionController()) {
|
||||
if (controller->activeChatCurrent().peer() == peer) {
|
||||
controller->showByInitialId();
|
||||
}
|
||||
if (const auto forum = controller->shownForum().current()) {
|
||||
if (peer->forum() == forum) {
|
||||
controller->closeForum();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
while (closeOne()) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1737,11 +1755,8 @@ void Application::quitPreventFinished() {
|
||||
}
|
||||
|
||||
void Application::quitDelayed() {
|
||||
for (const auto &[account, window] : _primaryWindows) {
|
||||
window->widget()->hide();
|
||||
}
|
||||
for (const auto &[history, window] : _secondaryWindows) {
|
||||
window->widget()->hide();
|
||||
for (const auto &[id, controller] : _windows) {
|
||||
controller->widget()->hide();
|
||||
}
|
||||
if (!_private->quitTimer.isActive()) {
|
||||
_private->quitTimer.setCallback([] { Sandbox::QuitWhenStarted(); });
|
||||
@@ -1796,11 +1811,13 @@ void Application::startShortcuts() {
|
||||
}
|
||||
|
||||
void Application::RegisterUrlScheme() {
|
||||
const auto arguments = Launcher::Instance().customWorkingDir()
|
||||
? u"-workdir \"%1\""_q.arg(cWorkingDir())
|
||||
: QString();
|
||||
|
||||
base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{
|
||||
.executable = Platform::ExecutablePathForShortcuts(),
|
||||
.arguments = Launcher::Instance().customWorkingDir()
|
||||
? u"-workdir \"%1\""_q.arg(cWorkingDir())
|
||||
: QString(),
|
||||
.arguments = arguments,
|
||||
.protocol = u"tg"_q,
|
||||
.protocolName = u"Telegram Link"_q,
|
||||
.shortAppName = u"tdesktop"_q,
|
||||
@@ -1808,6 +1825,17 @@ void Application::RegisterUrlScheme() {
|
||||
.displayAppName = AppName.utf16(),
|
||||
.displayAppDescription = AppName.utf16(),
|
||||
});
|
||||
|
||||
base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{
|
||||
.executable = Platform::ExecutablePathForShortcuts(),
|
||||
.arguments = arguments,
|
||||
.protocol = u"tonsite"_q,
|
||||
.protocolName = u"TonSite Link"_q,
|
||||
.shortAppName = u"tdesktop"_q,
|
||||
.longAppName = QCoreApplication::applicationName(),
|
||||
.displayAppName = AppName.utf16(),
|
||||
.displayAppDescription = AppName.utf16(),
|
||||
});
|
||||
}
|
||||
|
||||
bool IsAppLaunched() {
|
||||
|
||||
@@ -7,9 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "mtproto/mtproto_auth_key.h"
|
||||
#include "mtproto/mtproto_proxy_data.h"
|
||||
#include "base/timer.h"
|
||||
#include "window/window_separate_id.h"
|
||||
|
||||
class History;
|
||||
|
||||
@@ -29,11 +30,9 @@ namespace Window {
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace Window {
|
||||
namespace Notifications {
|
||||
namespace Window::Notifications {
|
||||
class System;
|
||||
} // namespace Notifications
|
||||
} // namespace Window
|
||||
} // namespace Window::Notifications
|
||||
|
||||
namespace ChatHelpers {
|
||||
class EmojiKeywords;
|
||||
@@ -127,6 +126,8 @@ enum class QuitReason {
|
||||
QtQuitEvent,
|
||||
};
|
||||
|
||||
extern const char kOptionSkipUrlSchemeRegister[];
|
||||
|
||||
class Application final : public QObject {
|
||||
public:
|
||||
struct ProxyChange {
|
||||
@@ -170,19 +171,17 @@ public:
|
||||
not_null<QWidget*> widget) const;
|
||||
[[nodiscard]] Window::Controller *activeWindow() const;
|
||||
[[nodiscard]] Window::Controller *activePrimaryWindow() const;
|
||||
[[nodiscard]] Window::Controller *separateWindowForAccount(
|
||||
not_null<Main::Account*> account) const;
|
||||
[[nodiscard]] Window::Controller *separateWindowForPeer(
|
||||
not_null<PeerData*> peer) const;
|
||||
Window::Controller *ensureSeparateWindowForPeer(
|
||||
not_null<PeerData*> peer,
|
||||
MsgId showAtMsgId);
|
||||
Window::Controller *ensureSeparateWindowForAccount(
|
||||
not_null<Main::Account*> account);
|
||||
[[nodiscard]] Window::Controller *separateWindowFor(
|
||||
Window::SeparateId id) const;
|
||||
Window::Controller *ensureSeparateWindowFor(
|
||||
Window::SeparateId id,
|
||||
MsgId showAtMsgId = 0);
|
||||
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
||||
Window::SeparateId id) const;
|
||||
[[nodiscard]] Window::Controller *windowForShowingHistory(
|
||||
not_null<PeerData*> peer) const;
|
||||
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
||||
not_null<Main::Account*> account) const;
|
||||
[[nodiscard]] Window::Controller *windowForShowingForum(
|
||||
not_null<Data::Forum*> forum) const;
|
||||
[[nodiscard]] bool closeNonLastAsync(
|
||||
not_null<Window::Controller*> window);
|
||||
void closeWindow(not_null<Window::Controller*> window);
|
||||
@@ -195,7 +194,7 @@ public:
|
||||
void checkSystemDarkMode();
|
||||
[[nodiscard]] bool isActiveForTrayMenu() const;
|
||||
void closeChatFromWindows(not_null<PeerData*> peer);
|
||||
void checkWindowAccount(not_null<Window::Controller*> window);
|
||||
void checkWindowId(not_null<Window::Controller*> window);
|
||||
void activate();
|
||||
|
||||
// Media view interface.
|
||||
@@ -352,6 +351,7 @@ private:
|
||||
friend bool IsAppLaunched();
|
||||
friend Application &App();
|
||||
|
||||
void autoRegisterUrlScheme();
|
||||
void clearEmojiSourceImages();
|
||||
[[nodiscard]] auto prepareEmojiSourceImages()
|
||||
-> std::shared_ptr<Ui::Emoji::UniversalImages>;
|
||||
@@ -378,6 +378,7 @@ private:
|
||||
|
||||
void showOpenGLCrashNotification();
|
||||
void clearPasscodeLock();
|
||||
void closeAdditionalWindows();
|
||||
|
||||
bool openCustomUrl(
|
||||
const QString &protocol,
|
||||
@@ -423,12 +424,9 @@ private:
|
||||
const std::unique_ptr<Calls::Instance> _calls;
|
||||
const std::unique_ptr<Iv::Instance> _iv;
|
||||
base::flat_map<
|
||||
Main::Account*,
|
||||
std::unique_ptr<Window::Controller>> _primaryWindows;
|
||||
Window::SeparateId,
|
||||
std::unique_ptr<Window::Controller>> _windows;
|
||||
base::flat_set<not_null<Window::Controller*>> _closingAsyncWindows;
|
||||
base::flat_map<
|
||||
not_null<History*>,
|
||||
std::unique_ptr<Window::Controller>> _secondaryWindows;
|
||||
std::vector<not_null<Window::Controller*>> _windowStack;
|
||||
Window::Controller *_lastActiveWindow = nullptr;
|
||||
Window::Controller *_lastActivePrimaryWindow = nullptr;
|
||||
|
||||
@@ -20,11 +20,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/history_item.h"
|
||||
#include "inline_bots/bot_attach_web_view.h"
|
||||
#include "data/data_game.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_session.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_session_controller_link_info.h"
|
||||
#include "styles/style_calls.h" // groupCallBoxLabel
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace {
|
||||
@@ -119,9 +122,14 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
|
||||
return result;
|
||||
}()));
|
||||
} else {
|
||||
const auto parsedUrl = QUrl::fromUserInput(url);
|
||||
const auto parsedUrl = url.startsWith(u"tonsite://"_q)
|
||||
? QUrl(url)
|
||||
: QUrl::fromUserInput(url);
|
||||
if (UrlRequiresConfirmation(parsedUrl) && !base::IsCtrlPressed()) {
|
||||
Core::App().hideMediaView();
|
||||
const auto my = context.value<ClickHandlerContext>();
|
||||
if (!my.show) {
|
||||
Core::App().hideMediaView();
|
||||
}
|
||||
const auto displayed = parsedUrl.isValid()
|
||||
? parsedUrl.toDisplayString()
|
||||
: url;
|
||||
@@ -130,7 +138,6 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
|
||||
: parsedUrl.isValid()
|
||||
? QString::fromUtf8(parsedUrl.toEncoded())
|
||||
: ShowEncoded(displayed);
|
||||
const auto my = context.value<ClickHandlerContext>();
|
||||
const auto controller = my.sessionWindow.get();
|
||||
const auto use = controller
|
||||
? &controller->window()
|
||||
@@ -140,8 +147,11 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
|
||||
.text = (tr::lng_open_this_link(tr::now)),
|
||||
.confirmed = [=](Fn<void()> hide) { hide(); open(); },
|
||||
.confirmText = tr::lng_open_link(),
|
||||
.labelStyle = my.dark ? &st::groupCallBoxLabel : nullptr,
|
||||
});
|
||||
const auto &st = st::boxLabel;
|
||||
const auto &st = my.dark
|
||||
? st::groupCallBoxLabel
|
||||
: st::boxLabel;
|
||||
box->addSkip(st.style.lineHeight - st::boxPadding.bottom());
|
||||
const auto url = box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(box, displayUrl, st));
|
||||
@@ -165,23 +175,42 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
|
||||
if (Core::InternalPassportLink(url)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto open = [=] {
|
||||
const auto openLink = [=] {
|
||||
UrlClickHandler::Open(url, context.other);
|
||||
};
|
||||
if (url.startsWith(u"tg://"_q, Qt::CaseInsensitive)) {
|
||||
open();
|
||||
} else if (!_bot
|
||||
|| _bot->isVerified()
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
const auto weakController = my.sessionWindow;
|
||||
const auto controller = weakController.get();
|
||||
const auto item = controller
|
||||
? controller->session().data().message(my.itemId)
|
||||
: nullptr;
|
||||
const auto media = item ? item->media() : nullptr;
|
||||
const auto game = media ? media->game() : nullptr;
|
||||
if (url.startsWith(u"tg://"_q, Qt::CaseInsensitive) || !_bot || !game) {
|
||||
openLink();
|
||||
}
|
||||
const auto bot = _bot;
|
||||
const auto title = game->title;
|
||||
const auto itemId = my.itemId;
|
||||
const auto openGame = [=] {
|
||||
bot->session().attachWebView().open({
|
||||
.bot = bot,
|
||||
.button = {.url = url.toUtf8() },
|
||||
.source = InlineBots::WebViewSourceGame{
|
||||
.messageId = itemId,
|
||||
.title = title,
|
||||
},
|
||||
});
|
||||
};
|
||||
if (_bot->isVerified()
|
||||
|| _bot->session().local().isBotTrustedOpenGame(_bot->id)) {
|
||||
open();
|
||||
openGame();
|
||||
} else {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto controller = my.sessionWindow.get()) {
|
||||
const auto callback = [=, bot = _bot](Fn<void()> close) {
|
||||
close();
|
||||
bot->session().local().markBotTrustedOpenGame(bot->id);
|
||||
open();
|
||||
openGame();
|
||||
};
|
||||
controller->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_allow_bot_pass(
|
||||
@@ -190,6 +219,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
|
||||
_bot->name()),
|
||||
.confirmed = callback,
|
||||
.confirmText = tr::lng_allow_bot(),
|
||||
.labelStyle = my.dark ? &st::groupCallBoxLabel : nullptr,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace Ui {
|
||||
class Show;
|
||||
} // namespace Ui
|
||||
|
||||
namespace InlineBots {
|
||||
struct WebViewContext;
|
||||
} // namespace InlineBots
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
@@ -38,15 +42,16 @@ class SessionController;
|
||||
class PeerData;
|
||||
struct ClickHandlerContext {
|
||||
FullMsgId itemId;
|
||||
QString attachBotWebviewUrl;
|
||||
// Is filled from sections.
|
||||
Fn<HistoryView::ElementDelegate*()> elementDelegate;
|
||||
base::weak_ptr<Window::SessionController> sessionWindow;
|
||||
std::shared_ptr<InlineBots::WebViewContext> botWebviewContext;
|
||||
std::shared_ptr<Ui::Show> show;
|
||||
bool mayShowConfirmation = false;
|
||||
bool skipBotAutoLogin = false;
|
||||
bool botStartAutoSubmit = false;
|
||||
bool ignoreIv = false;
|
||||
bool dark = false;
|
||||
// Is filled from peer info.
|
||||
PeerData *peer = nullptr;
|
||||
};
|
||||
|
||||