From 7ff5f81b8863506947161fee8b603bbe0f62495c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 6 May 2024 08:44:18 +0400 Subject: [PATCH 01/67] Try automatic actions update --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..5ace4600a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From 046bc0303705780f2033f2e73e9066211d4f7e89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 05:47:20 +0000 Subject: [PATCH 02/67] Bump actions/checkout from 3.1.0 to 4.1.4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 4.1.4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.1.0...v4.1.4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- .github/workflows/linux.yml | 2 +- .github/workflows/mac.yml | 2 +- .github/workflows/mac_packaged.yml | 2 +- .github/workflows/master_updater.yml | 2 +- .github/workflows/snap.yml | 2 +- .github/workflows/win.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7a65b483f..e70226345 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: submodules: recursive diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 8020e46c5..0d772b8d7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -58,7 +58,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: submodules: recursive path: ${{ env.REPO_NAME }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 8271664c0..c96a45689 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -56,7 +56,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: submodules: recursive path: ${{ env.REPO_NAME }} diff --git a/.github/workflows/mac_packaged.yml b/.github/workflows/mac_packaged.yml index d04b284de..fc0d5e514 100644 --- a/.github/workflows/mac_packaged.yml +++ b/.github/workflows/mac_packaged.yml @@ -60,7 +60,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: submodules: recursive path: ${{ env.REPO_NAME }} diff --git a/.github/workflows/master_updater.yml b/.github/workflows/master_updater.yml index 284bb844e..a4e50c124 100644 --- a/.github/workflows/master_updater.yml +++ b/.github/workflows/master_updater.yml @@ -11,7 +11,7 @@ jobs: SKIP: "0" to_branch: "master" steps: - - uses: actions/checkout@v4.1.0 + - uses: actions/checkout@v4.1.4 with: fetch-depth: 0 if: env.SKIP == '0' diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml index badcf6cc9..ae4371f0d 100644 --- a/.github/workflows/snap.yml +++ b/.github/workflows/snap.yml @@ -47,7 +47,7 @@ jobs: steps: - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: fetch-depth: 0 submodules: recursive diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index f8332c36f..d4b8ce7a8 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -75,7 +75,7 @@ jobs: arch: ${{ matrix.arch }} - name: Clone. - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.4 with: submodules: recursive path: ${{ env.TBUILD }}\${{ env.REPO_NAME }} From 3847b97f80ede5efd8ac2bac7fda2c312b5c7ae1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 05:47:12 +0000 Subject: [PATCH 03/67] Bump actions/cache from 3.0.11 to 4.0.2 Bumps [actions/cache](https://github.com/actions/cache) from 3.0.11 to 4.0.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.11...v4.0.2) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/mac.yml | 4 ++-- .github/workflows/mac_packaged.yml | 2 +- .github/workflows/win.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index c96a45689..0bd06cb1f 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -76,7 +76,7 @@ jobs: - name: ThirdParty cache. id: cache-third-party - uses: actions/cache@v3.0.11 + uses: actions/cache@v4.0.2 with: path: ThirdParty key: ${{ runner.OS }}-third-party-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} @@ -84,7 +84,7 @@ jobs: - name: Libraries cache. id: cache-libs - uses: actions/cache@v3.0.11 + uses: actions/cache@v4.0.2 with: path: Libraries key: ${{ runner.OS }}-libs-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} diff --git a/.github/workflows/mac_packaged.yml b/.github/workflows/mac_packaged.yml index fc0d5e514..7f0daf22d 100644 --- a/.github/workflows/mac_packaged.yml +++ b/.github/workflows/mac_packaged.yml @@ -99,7 +99,7 @@ jobs: - name: WebRTC cache. id: cache-webrtc - uses: actions/cache@v3.0.11 + uses: actions/cache@v4.0.2 with: path: ${{ env.LibrariesPath }}/tg_owt key: ${{ runner.OS }}-webrtc-${{ env.CACHE_KEY }}-${{ hashFiles('**/tg_owt-version.json') }} diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index d4b8ce7a8..669ef15d4 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -96,7 +96,7 @@ jobs: - name: Libraries cache. id: cache-libs - uses: actions/cache@v3.0.11 + uses: actions/cache@v4.0.2 with: path: ${{ env.TBUILD }}\Libraries key: ${{ runner.OS }}-${{ matrix.arch }}-libs-${{ env.CACHE_KEY }} From ddf6514a90005c2600738f8c22149fab64bc0dc1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 05:47:14 +0000 Subject: [PATCH 04/67] Bump actions/stale from 5 to 9 Bumps [actions/stale](https://github.com/actions/stale) from 5 to 9. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v5...v9) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 219f95a82..4148917e7 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v5 + - uses: actions/stale@v9 with: stale-issue-message: | Hey there! From 78a05768d83f5537c9d3e059ae766004e8284b58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 05:47:08 +0000 Subject: [PATCH 05/67] Bump dessant/lock-threads from 3 to 5 Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 3 to 5. - [Release notes](https://github.com/dessant/lock-threads/releases) - [Changelog](https://github.com/dessant/lock-threads/blob/main/CHANGELOG.md) - [Commits](https://github.com/dessant/lock-threads/compare/v3...v5) --- updated-dependencies: - dependency-name: dessant/lock-threads dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/lock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 562159d0d..cf3c46989 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -8,7 +8,7 @@ jobs: lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v3 + - uses: dessant/lock-threads@v5 with: github-token: ${{ github.token }} issue-inactive-days: 45 From 7e253314ecb560954d23e2e0f6c2e575e78bbb40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 16:42:41 +0000 Subject: [PATCH 06/67] Bump jinja2 from 3.1.3 to 3.1.4 in /Telegram/build/docker/centos_env Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.3 to 3.1.4. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.3...3.1.4) --- updated-dependencies: - dependency-name: jinja2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Telegram/build/docker/centos_env/poetry.lock | 10 +++++----- Telegram/build/docker/centos_env/pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Telegram/build/docker/centos_env/poetry.lock b/Telegram/build/docker/centos_env/poetry.lock index 08526811d..5ad561c71 100644 --- a/Telegram/build/docker/centos_env/poetry.lock +++ b/Telegram/build/docker/centos_env/poetry.lock @@ -1,14 +1,14 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "jinja2" -version = "3.1.3" +version = "3.1.4" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, - {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, + {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, + {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, ] [package.dependencies] @@ -69,4 +69,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "bac9a23a86839c72127e75f2cf181e331f59d96f723403d529e7ea19774ff9c4" +content-hash = "dcdc36798334f1f85051cf78d7f8a7242a480509eb34135934d9f092d2da5c33" diff --git a/Telegram/build/docker/centos_env/pyproject.toml b/Telegram/build/docker/centos_env/pyproject.toml index bba5c212f..d20d3d1d4 100644 --- a/Telegram/build/docker/centos_env/pyproject.toml +++ b/Telegram/build/docker/centos_env/pyproject.toml @@ -6,7 +6,7 @@ authors = [] [tool.poetry.dependencies] python = "^3.7" -Jinja2 = "^3.1.3" +Jinja2 = "^3.1.4" [tool.poetry.dev-dependencies] From 5d622b906e63a18155f7e812609d99a1e7b877af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 05:47:17 +0000 Subject: [PATCH 07/67] Bump ilammy/msvc-dev-cmd from 1.12.0 to 1.13.0 Bumps [ilammy/msvc-dev-cmd](https://github.com/ilammy/msvc-dev-cmd) from 1.12.0 to 1.13.0. - [Release notes](https://github.com/ilammy/msvc-dev-cmd/releases) - [Commits](https://github.com/ilammy/msvc-dev-cmd/compare/v1.12.0...v1.13.0) --- updated-dependencies: - dependency-name: ilammy/msvc-dev-cmd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/win.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 669ef15d4..222366c6c 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -69,7 +69,7 @@ jobs: shell: bash run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - - uses: ilammy/msvc-dev-cmd@v1.12.0 + - uses: ilammy/msvc-dev-cmd@v1.13.0 name: Native Tools Command Prompt. with: arch: ${{ matrix.arch }} From 593e76479ccb6fa7299a5638b28a6e8c1f2376b1 Mon Sep 17 00:00:00 2001 From: GkvJwa Date: Sat, 4 May 2024 18:56:28 +0800 Subject: [PATCH 08/67] Use jom build openssl on windows --- Telegram/build/prepare/prepare.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index ce00e278e..ce6c87b9b 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -593,25 +593,25 @@ stage('openssl3', """ git clone -b openssl-3.2.1 https://github.com/openssl/openssl openssl3 cd openssl3 win32: - perl Configure no-shared no-tests debug-VC-WIN32 + perl Configure no-shared no-tests debug-VC-WIN32 /FS win64: - perl Configure no-shared no-tests debug-VC-WIN64A + perl Configure no-shared no-tests debug-VC-WIN64A /FS win: - nmake + jom -j%NUMBER_OF_PROCESSORS% mkdir out.dbg move libcrypto.lib out.dbg move libssl.lib out.dbg move ossl_static.pdb out.dbg release: move out.dbg\\ossl_static.pdb out.dbg\\ossl_static - nmake clean + jom clean move out.dbg\\ossl_static out.dbg\\ossl_static.pdb win32: - perl Configure no-shared no-tests VC-WIN32 + perl Configure no-shared no-tests VC-WIN32 /FS win64: - perl Configure no-shared no-tests VC-WIN64A + perl Configure no-shared no-tests VC-WIN64A /FS win: - nmake + jom -j%NUMBER_OF_PROCESSORS% mkdir out move libcrypto.lib out move libssl.lib out From c1a01728226d249384a52c590fd7508ca013ed12 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 May 2024 17:07:02 +0400 Subject: [PATCH 09/67] De-focus empty search by backspace. --- Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 6d8a226b4..bfa3771a6 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -3244,6 +3244,10 @@ void Widget::keyPressEvent(QKeyEvent *e) { //} else { // e->ignore(); //} + } else if (e->key() == Qt::Key_Backspace + && _searchHasFocus + && !_searchInChat) { + escape(); } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { submit(); } else if (_suggestions From 1f3a3ec04b54f0cc15ef8b3e8bb5b0827aa30ee7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 May 2024 20:45:55 +0400 Subject: [PATCH 10/67] Don't focus search when forum is opened. --- Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index bfa3771a6..2f1763964 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1001,7 +1001,9 @@ void Widget::setupShortcuts() { const auto history = forum->history(); controller()->searchInChat(history); return true; - } else if (!_openedFolder && _search->isVisible()) { + } else if (!_openedFolder + && !_childList + && _search->isVisible()) { _search->setFocus(); return true; } @@ -3291,6 +3293,7 @@ void Widget::keyPressEvent(QKeyEvent *e) { bool Widget::redirectKeyToSearch(QKeyEvent *e) const { if (_openedFolder || _openedForum + || _childList || !_search->isVisible() || _search->hasFocus()) { return false; From 2cb0651b046438cc444c9947a8cee95982e1e22f Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 7 May 2024 13:18:58 +0400 Subject: [PATCH 11/67] Redirect IME to search on Windows. --- .../SourceFiles/dialogs/dialogs_widget.cpp | 27 +++++++++++++++---- Telegram/SourceFiles/dialogs/dialogs_widget.h | 2 ++ .../platform/win/main_window_win.cpp | 15 +++++++++++ .../platform/win/main_window_win.h | 5 ++++ Telegram/SourceFiles/window/main_window.cpp | 8 ++++++ Telegram/SourceFiles/window/main_window.h | 5 +++- 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 2f1763964..575516ffa 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -356,6 +356,14 @@ Widget::Widget( Ui::PostponeCall(this, [=] { listScrollUpdated(); }); }, lifetime()); + setAttribute(Qt::WA_InputMethodEnabled); + controller->widget()->imeCompositionStarts( + ) | rpl::filter([=] { + return redirectImeToSearch(); + }) | rpl::start_with_next([=] { + _search->setFocusFast(); + }, lifetime()); + _search->changes( ) | rpl::start_with_next([=] { applySearchUpdate(); @@ -3290,12 +3298,17 @@ void Widget::keyPressEvent(QKeyEvent *e) { } } +bool Widget::redirectToSearchPossible() const { + return !_openedFolder + && !_openedForum + && !_childList + && _search->isVisible() + && !_search->hasFocus() + && hasFocus(); +} + bool Widget::redirectKeyToSearch(QKeyEvent *e) const { - if (_openedFolder - || _openedForum - || _childList - || !_search->isVisible() - || _search->hasFocus()) { + if (!redirectToSearchPossible()) { return false; } const auto character = !(e->modifiers() & ~Qt::ShiftModifier) @@ -3316,6 +3329,10 @@ bool Widget::redirectKeyToSearch(QKeyEvent *e) const { return data && data->hasText(); } +bool Widget::redirectImeToSearch() const { + return redirectToSearchPossible(); +} + void Widget::paintEvent(QPaintEvent *e) { if (controller()->contentOverlapped(this, e)) { return; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index ecd2f3608..5ff9828d5 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -250,7 +250,9 @@ private: void updateSuggestions(anim::type animated); void processSearchFocusChange(); + [[nodiscard]] bool redirectToSearchPossible() const; [[nodiscard]] bool redirectKeyToSearch(QKeyEvent *e) const; + [[nodiscard]] bool redirectImeToSearch() const; MTP::Sender _api; diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 8c852b837..dd2f3dafe 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -480,6 +480,21 @@ bool MainWindow::initGeometryFromSystem() { return true; } +bool MainWindow::nativeEvent( + const QByteArray &eventType, + void *message, + long *result) { + if (message) { + const auto msg = static_cast(message); + if (msg->message == WM_IME_STARTCOMPOSITION) { + Core::Sandbox::Instance().customEnterFromEventLoop([&] { + imeCompositionStartReceived(); + }); + } + } + return false; +} + void MainWindow::updateWindowIcon() { updateTaskbarAndIconCounters(); } diff --git a/Telegram/SourceFiles/platform/win/main_window_win.h b/Telegram/SourceFiles/platform/win/main_window_win.h index 856bee773..63dc6ba17 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.h +++ b/Telegram/SourceFiles/platform/win/main_window_win.h @@ -48,6 +48,11 @@ protected: bool initGeometryFromSystem() override; + bool nativeEvent( + const QByteArray &eventType, + void *message, + long *result) override; + private: struct Private; diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 3f8c9b5ba..1c5de5967 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -795,10 +795,18 @@ void MainWindow::setPositionInited() { _positionInited = true; } +void MainWindow::imeCompositionStartReceived() { + _imeCompositionStartReceived.fire({}); +} + rpl::producer<> MainWindow::leaveEvents() const { return _leaveEvents.events(); } +rpl::producer<> MainWindow::imeCompositionStarts() const { + return _imeCompositionStartReceived.events(); +} + void MainWindow::leaveEventHook(QEvent *e) { _leaveEvents.fire({}); } diff --git a/Telegram/SourceFiles/window/main_window.h b/Telegram/SourceFiles/window/main_window.h index 8feb329a9..79dc3c6fe 100644 --- a/Telegram/SourceFiles/window/main_window.h +++ b/Telegram/SourceFiles/window/main_window.h @@ -119,7 +119,8 @@ public: void launchDrag(std::unique_ptr data, Fn &&callback); - rpl::producer<> leaveEvents() const; + [[nodiscard]] rpl::producer<> leaveEvents() const; + [[nodiscard]] rpl::producer<> imeCompositionStarts() const; virtual void updateWindowIcon() = 0; void updateTitle(); @@ -185,6 +186,7 @@ protected: return false; } + void imeCompositionStartReceived(); void setPositionInited(); virtual QRect computeDesktopRect() const; @@ -214,6 +216,7 @@ private: bool _isActive = false; rpl::event_stream<> _leaveEvents; + rpl::event_stream<> _imeCompositionStartReceived; bool _maximizedBeforeHide = false; From 15697f4f2b81b9fbab920067919671a8361a8de7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 8 May 2024 10:29:17 +0400 Subject: [PATCH 12/67] Fix libpng package name in snap --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 7b7761769..79148548e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -331,7 +331,7 @@ parts: - liblcms2-2 - libopengl0 - libpcre2-16-0 - - libpng16-16 + - libpng16-16t64 - libsm6 - libssl3 - libvulkan1 From 6ebbca58e87d80140c5ee42b60496d42b6e53f93 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 13 May 2024 19:46:18 +0400 Subject: [PATCH 13/67] Track major version for official GitHub helpers in actions --- .github/workflows/docker.yml | 2 +- .github/workflows/linux.yml | 4 ++-- .github/workflows/mac.yml | 8 ++++---- .github/workflows/mac_packaged.yml | 6 +++--- .github/workflows/master_updater.yml | 2 +- .github/workflows/snap.yml | 4 ++-- .github/workflows/win.yml | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e70226345..bf2008732 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0d772b8d7..e8d8f5901 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -58,7 +58,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: submodules: recursive path: ${{ env.REPO_NAME }} @@ -116,7 +116,7 @@ jobs: cd $REPO_NAME/out/Debug sudo mkdir artifact sudo mv {Telegram,Updater} artifact/ - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v2 if: env.UPLOAD_ARTIFACT == 'true' name: Upload artifact. with: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 0bd06cb1f..8a83d62dd 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -56,7 +56,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: submodules: recursive path: ${{ env.REPO_NAME }} @@ -76,7 +76,7 @@ jobs: - name: ThirdParty cache. id: cache-third-party - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: path: ThirdParty key: ${{ runner.OS }}-third-party-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} @@ -84,7 +84,7 @@ jobs: - name: Libraries cache. id: cache-libs - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: path: Libraries key: ${{ runner.OS }}-libs-${{ hashFiles(format('{0}/{1}', env.REPO_NAME, env.PREPARE_PATH)) }} @@ -134,7 +134,7 @@ jobs: mkdir artifact mv Telegram.app artifact/ mv Updater artifact/ - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v2 if: env.UPLOAD_ARTIFACT == 'true' name: Upload artifact. with: diff --git a/.github/workflows/mac_packaged.yml b/.github/workflows/mac_packaged.yml index 7f0daf22d..9b40c249e 100644 --- a/.github/workflows/mac_packaged.yml +++ b/.github/workflows/mac_packaged.yml @@ -60,7 +60,7 @@ jobs: run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: submodules: recursive path: ${{ env.REPO_NAME }} @@ -99,7 +99,7 @@ jobs: - name: WebRTC cache. id: cache-webrtc - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: path: ${{ env.LibrariesPath }}/tg_owt key: ${{ runner.OS }}-webrtc-${{ env.CACHE_KEY }}-${{ hashFiles('**/tg_owt-version.json') }} @@ -153,7 +153,7 @@ jobs: cd $REPO_NAME/build mkdir artifact mv Telegram.dmg artifact/ - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v2 if: env.UPLOAD_ARTIFACT == 'true' name: Upload artifact. with: diff --git a/.github/workflows/master_updater.yml b/.github/workflows/master_updater.yml index a4e50c124..c59f62e29 100644 --- a/.github/workflows/master_updater.yml +++ b/.github/workflows/master_updater.yml @@ -11,7 +11,7 @@ jobs: SKIP: "0" to_branch: "master" steps: - - uses: actions/checkout@v4.1.4 + - uses: actions/checkout@v4 with: fetch-depth: 0 if: env.SKIP == '0' diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml index ae4371f0d..3d01478e6 100644 --- a/.github/workflows/snap.yml +++ b/.github/workflows/snap.yml @@ -47,7 +47,7 @@ jobs: steps: - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive @@ -75,7 +75,7 @@ jobs: mkdir artifact mv $artifact_name artifact - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v2 if: env.UPLOAD_ARTIFACT == 'true' name: Upload artifact. with: diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index 222366c6c..1200e1de0 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -75,7 +75,7 @@ jobs: arch: ${{ matrix.arch }} - name: Clone. - uses: actions/checkout@v4.1.4 + uses: actions/checkout@v4 with: submodules: recursive path: ${{ env.TBUILD }}\${{ env.REPO_NAME }} @@ -96,7 +96,7 @@ jobs: - name: Libraries cache. id: cache-libs - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: path: ${{ env.TBUILD }}\Libraries key: ${{ runner.OS }}-${{ matrix.arch }}-libs-${{ env.CACHE_KEY }} @@ -183,7 +183,7 @@ jobs: mkdir artifact move %OUT%\Telegram.exe artifact/ move %OUT%\Updater.exe artifact/ - - uses: actions/upload-artifact@master + - uses: actions/upload-artifact@v2 name: Upload artifact. if: (env.UPLOAD_ARTIFACT == 'true') || (github.ref == 'refs/heads/nightly') with: From d28b9f10b469ebee69b76dfbb1b24a59e089ef41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 13:06:59 +0000 Subject: [PATCH 14/67] Bump jlumbroso/free-disk-space from 1.3.0 to 1.3.1 Bumps [jlumbroso/free-disk-space](https://github.com/jlumbroso/free-disk-space) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/jlumbroso/free-disk-space/releases) - [Commits](https://github.com/jlumbroso/free-disk-space/compare/f68fdb76e2ea636224182cfb7377ff9a1708f9b8...54081f138730dfa15788a46383842cd2f914a1be) --- updated-dependencies: - dependency-name: jlumbroso/free-disk-space dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- .github/workflows/snap.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bf2008732..ac40f3a33 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,7 +31,7 @@ jobs: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - name: Free up some disk space. - uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8 + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be - name: Docker image build. run: | diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml index 3d01478e6..c2ee6773a 100644 --- a/.github/workflows/snap.yml +++ b/.github/workflows/snap.yml @@ -61,7 +61,7 @@ jobs: sudo snap run lxd waitready - name: Free up some disk space. - uses: jlumbroso/free-disk-space@f68fdb76e2ea636224182cfb7377ff9a1708f9b8 + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be - name: Telegram Desktop snap build. run: sg lxd -c 'snap run snapcraft --verbosity=debug' From 3358673ba423b539611be2fbf9ff23de680afeaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= Date: Fri, 10 May 2024 18:05:08 +0200 Subject: [PATCH 15/67] Add compatibility with FFMPEG 7.0 avio: Constify data pointees of write callbacks avutil: remove deprecated FF_API_PKT_DURATION Ref: https://github.com/FFmpeg/FFmpeg/commit/2a68d945cd74265bb71c3d38b7a2e7f7d7e87be5 https://github.com/FFmpeg/FFmpeg/commit/02aea61d69d8f81bc285e2131bf25f96a3e27feb https://github.com/FFmpeg/FFmpeg/commit/b8fef7e9c520b3923b32813b6a82c154c74402dc --- .../ffmpeg/ffmpeg_frame_generator.cpp | 4 ++++ Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp | 8 ++++++++ Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h | 18 ++++++++++++++++-- .../media/audio/media_audio_capture.cpp | 4 ++++ .../media/clip/media_clip_ffmpeg.cpp | 4 ++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_frame_generator.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_frame_generator.cpp index 116d998a2..de478b784 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_frame_generator.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_frame_generator.cpp @@ -291,7 +291,11 @@ void FrameGenerator::Impl::jumpToStart() { void FrameGenerator::Impl::resolveNextFrameTiming() { const auto base = _format->streams[_streamId]->time_base; +#if DA_FFMPEG_HAVE_DURATION + const auto duration = _next.frame->duration; +#else const auto duration = _next.frame->pkt_duration; +#endif const auto framePts = _next.frame->pts; auto framePosition = (framePts * 1000LL * base.num) / base.den; _currentFrameDelay = _nextFrameDelay; diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index 2a42d0034..0f7083df3 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -230,7 +230,11 @@ enum AVPixelFormat GetFormatImplementation( IOPointer MakeIOPointer( void *opaque, int(*read)(void *opaque, uint8_t *buffer, int bufferSize), +#if DA_FFMPEG_CONST_WRITE_CALLBACK + int(*write)(void *opaque, const uint8_t *buffer, int bufferSize), +#else int(*write)(void *opaque, uint8_t *buffer, int bufferSize), +#endif int64_t(*seek)(void *opaque, int64_t offset, int whence)) { auto buffer = reinterpret_cast(av_malloc(kAvioBlockSize)); if (!buffer) { @@ -263,7 +267,11 @@ void IODeleter::operator()(AVIOContext *value) { FormatPointer MakeFormatPointer( void *opaque, int(*read)(void *opaque, uint8_t *buffer, int bufferSize), +#if DA_FFMPEG_CONST_WRITE_CALLBACK + int(*write)(void *opaque, const uint8_t *buffer, int bufferSize), +#else int(*write)(void *opaque, uint8_t *buffer, int bufferSize), +#endif int64_t(*seek)(void *opaque, int64_t offset, int whence)) { auto io = MakeIOPointer(opaque, read, write, seek); if (!io) { diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h index bc9c8764b..d96daa9c7 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.h @@ -22,8 +22,14 @@ extern "C" { #include } // extern "C" -#define DA_FFMPEG_NEW_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR > 57 \ - || (LIBAVUTIL_VERSION_MAJOR == 57 && LIBAVUTIL_VERSION_MINOR >= 28)) +#define DA_FFMPEG_NEW_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_INT >= \ + AV_VERSION_INT(57, 28, 100)) + +#define DA_FFMPEG_CONST_WRITE_CALLBACK (LIBAVFORMAT_VERSION_INT >= \ + AV_VERSION_INT(61, 01, 100)) + +#define DA_FFMPEG_HAVE_DURATION (LIBAVUTIL_VERSION_INT >= \ + AV_VERSION_INT(58, 02, 100)) class QImage; @@ -112,7 +118,11 @@ using IOPointer = std::unique_ptr; [[nodiscard]] IOPointer MakeIOPointer( void *opaque, int(*read)(void *opaque, uint8_t *buffer, int bufferSize), +#if DA_FFMPEG_CONST_WRITE_CALLBACK + int(*write)(void *opaque, const uint8_t *buffer, int bufferSize), +#else int(*write)(void *opaque, uint8_t *buffer, int bufferSize), +#endif int64_t(*seek)(void *opaque, int64_t offset, int whence)); struct FormatDeleter { @@ -122,7 +132,11 @@ using FormatPointer = std::unique_ptr; [[nodiscard]] FormatPointer MakeFormatPointer( void *opaque, int(*read)(void *opaque, uint8_t *buffer, int bufferSize), +#if DA_FFMPEG_CONST_WRITE_CALLBACK + int(*write)(void *opaque, const uint8_t *buffer, int bufferSize), +#else int(*write)(void *opaque, uint8_t *buffer, int bufferSize), +#endif int64_t(*seek)(void *opaque, int64_t offset, int whence)); struct CodecDeleter { diff --git a/Telegram/SourceFiles/media/audio/media_audio_capture.cpp b/Telegram/SourceFiles/media/audio/media_audio_capture.cpp index b9151db2a..1bbf9b10c 100644 --- a/Telegram/SourceFiles/media/audio/media_audio_capture.cpp +++ b/Telegram/SourceFiles/media/audio/media_audio_capture.cpp @@ -249,7 +249,11 @@ struct Instance::Inner::Private { return nbytes; } +#if DA_FFMPEG_CONST_WRITE_CALLBACK + static int WriteData(void *opaque, const uint8_t *buf, int buf_size) { +#else static int WriteData(void *opaque, uint8_t *buf, int buf_size) { +#endif auto l = reinterpret_cast(opaque); if (buf_size <= 0) return 0; diff --git a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp index 9f1c7b234..1188f0232 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp @@ -144,7 +144,11 @@ ReaderImplementation::ReadResult FFMpegReaderImplementation::readNextFrame() { } void FFMpegReaderImplementation::processReadFrame() { +#if DA_FFMPEG_HAVE_DURATION + int64 duration = _frame->duration; +#else int64 duration = _frame->pkt_duration; +#endif int64 framePts = _frame->pts; crl::time frameMs = (framePts * 1000LL * _fmtContext->streams[_streamId]->time_base.num) / _fmtContext->streams[_streamId]->time_base.den; _currentFrameDelay = _nextFrameDelay; From 923e3ee8080b3d91a0aa643408127c95aa2375e9 Mon Sep 17 00:00:00 2001 From: GoodDok Date: Sat, 4 May 2024 02:56:13 +0300 Subject: [PATCH 16/67] Fix 25202: surrounding $PWD with double quotes Added double quotes to work correctly with spaces in current directory's name --- docs/building-linux.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/building-linux.md b/docs/building-linux.md index 393bd854a..e8a0b050b 100644 --- a/docs/building-linux.md +++ b/docs/building-linux.md @@ -20,7 +20,7 @@ Install [poetry](https://python-poetry.org), go to ***BuildPath*** and run Go to ***BuildPath*/tdesktop** and run (using [your **api_id** and **api_hash**](#obtain-your-api-credentials)) docker run --rm -it \ - -v $PWD:/usr/src/tdesktop \ + -v "$PWD:/usr/src/tdesktop" \ tdesktop:centos_env \ /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ -D TDESKTOP_API_ID=YOUR_API_ID \ @@ -29,7 +29,7 @@ Go to ***BuildPath*/tdesktop** and run (using [your **api_id** and **api_hash**] Or, to create a debug build, run (also using [your **api_id** and **api_hash**](#obtain-your-api-credentials)) docker run --rm -it \ - -v $PWD:/usr/src/tdesktop \ + -v "$PWD:/usr/src/tdesktop" \ -e CONFIG=Debug \ tdesktop:centos_env \ /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ From 334fd4e951029ae15caeae917d5a4c382793a472 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 7 May 2024 17:47:52 +0300 Subject: [PATCH 17/67] Added ability to edit media with spoiled one without resending. --- Telegram/CMakeLists.txt | 2 + Telegram/SourceFiles/api/api_editing.cpp | 39 ++++++++- Telegram/SourceFiles/api/api_editing.h | 3 +- .../SourceFiles/history/history_widget.cpp | 23 ++++- Telegram/SourceFiles/history/history_widget.h | 3 + .../view/controls/compose_controls_common.h | 1 + .../history_view_compose_controls.cpp | 67 ++++++++++++++- .../controls/history_view_compose_controls.h | 11 +++ ...istory_view_compose_media_edit_manager.cpp | 83 +++++++++++++++++++ .../history_view_compose_media_edit_manager.h | 39 +++++++++ .../view/history_view_replies_section.cpp | 9 +- .../view/history_view_replies_section.h | 3 +- .../view/history_view_scheduled_section.cpp | 9 +- .../view/history_view_scheduled_section.h | 3 +- .../business/settings_shortcut_messages.cpp | 12 ++- 15 files changed, 285 insertions(+), 22 deletions(-) create mode 100644 Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.cpp create mode 100644 Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 2f42270ee..88d42a190 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -688,6 +688,8 @@ PRIVATE history/view/controls/compose_controls_common.h history/view/controls/history_view_compose_controls.cpp history/view/controls/history_view_compose_controls.h + history/view/controls/history_view_compose_media_edit_manager.cpp + history/view/controls/history_view_compose_media_edit_manager.h history/view/controls/history_view_compose_search.cpp history/view/controls/history_view_compose_search.h history/view/controls/history_view_draft_options.cpp diff --git a/Telegram/SourceFiles/api/api_editing.cpp b/Telegram/SourceFiles/api/api_editing.cpp index f91a73579..5705d267e 100644 --- a/Telegram/SourceFiles/api/api_editing.cpp +++ b/Telegram/SourceFiles/api/api_editing.cpp @@ -252,12 +252,47 @@ mtpRequestId EditTextMessage( Data::WebPageDraft webpage, SendOptions options, Fn done, - Fn fail) { + Fn fail, + std::optional spoilerMediaOverride) { const auto callback = [=](Fn applyUpdates, mtpRequestId id) { applyUpdates(); done(id); }; - return EditMessage(item, caption, webpage, options, callback, fail); + auto inputMedia = std::optional(); + if (spoilerMediaOverride) { + const auto spoiler = *spoilerMediaOverride; + if (const auto media = item->media()) { + if (const auto photo = media->photo()) { + using Flag = MTPDinputMediaPhoto::Flag; + const auto flags = Flag() + | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag()) + | (spoiler ? Flag::f_spoiler : Flag()); + inputMedia = MTP_inputMediaPhoto( + MTP_flags(flags), + photo->mtpInput(), + MTP_int(media->ttlSeconds())); + } else if (const auto document = media->document()) { + using Flag = MTPDinputMediaDocument::Flag; + const auto flags = Flag() + | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag()) + | (spoiler ? Flag::f_spoiler : Flag()); + inputMedia = MTP_inputMediaDocument( + MTP_flags(flags), + document->mtpInput(), + MTP_int(media->ttlSeconds()), + MTPstring()); // query + } + } + } + + return EditMessage( + item, + caption, + webpage, + options, + callback, + fail, + inputMedia); } } // namespace Api diff --git a/Telegram/SourceFiles/api/api_editing.h b/Telegram/SourceFiles/api/api_editing.h index 86f106f45..c8d0f6c50 100644 --- a/Telegram/SourceFiles/api/api_editing.h +++ b/Telegram/SourceFiles/api/api_editing.h @@ -55,6 +55,7 @@ mtpRequestId EditTextMessage( Data::WebPageDraft webpage, SendOptions options, Fn done, - Fn fail); + Fn fail, + std::optional spoilerMediaOverride); } // namespace Api diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index fdd4935a0..5e8da7f99 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2656,6 +2656,7 @@ void HistoryWidget::setEditMsgId(MsgId msgId) { unregisterDraftSources(); _editMsgId = msgId; if (!msgId) { + _mediaEditSpoiler.setSpoilerOverride(std::nullopt); _canReplaceMedia = false; if (_preview) { _preview->setDisabled(false); @@ -4043,7 +4044,8 @@ void HistoryWidget::saveEditMsg() { webPageDraft, options, done, - fail); + fail, + _mediaEditSpoiler.spoilerOverride()); } void HistoryWidget::hideChildWidgets() { @@ -6562,7 +6564,14 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) { return; } const auto isReadyToForward = readyToForward(); - if (_inPhotoEdit && _photoEditMedia) { + if (_editMsgId + && (_inDetails || _inPhotoEdit) + && (e->button() == Qt::RightButton)) { + _mediaEditSpoiler.showMenu( + _list, + session().data().message(_history->peer, _editMsgId), + [=](bool) { mouseMoveEvent(nullptr); }); + } else if (_inPhotoEdit && _photoEditMedia) { EditCaptionBox::StartPhotoEdit( controller(), _photoEditMedia, @@ -8235,8 +8244,14 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) { ? drawMsgText->media() : nullptr; const auto hasPreview = media && media->hasReplyPreview(); - const auto preview = hasPreview ? media->replyPreview() : nullptr; - const auto spoilered = preview && media->hasSpoiler(); + const auto preview = _mediaEditSpoiler.spoilerOverride() + ? _mediaEditSpoiler.mediaPreview(drawMsgText) + : hasPreview + ? media->replyPreview() + : nullptr; + const auto spoilered = _mediaEditSpoiler.spoilerOverride() + ? (*_mediaEditSpoiler.spoilerOverride()) + : (preview && media->hasSpoiler()); if (!spoilered) { _replySpoiler = nullptr; } else if (!_replySpoiler) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index b4d8bb49c..b731507b2 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "history/view/controls/history_view_compose_media_edit_manager.h" #include "history/view/history_view_corner_buttons.h" #include "history/history_drag_area.h" #include "history/history_view_highlight_manager.h" @@ -103,6 +104,7 @@ class ForwardPanel; class TTLButton; class WebpageProcessor; class CharactersLimitLabel; +class PhotoEditSpoilerManager; } // namespace HistoryView::Controls class BotKeyboard; @@ -660,6 +662,7 @@ private: MsgId _editMsgId = 0; std::shared_ptr _photoEditMedia; bool _canReplaceMedia = false; + HistoryView::MediaEditSpoilerManager _mediaEditSpoiler; HistoryItem *_replyEditMsg = nullptr; Ui::Text::String _replyEditMsgText; diff --git a/Telegram/SourceFiles/history/view/controls/compose_controls_common.h b/Telegram/SourceFiles/history/view/controls/compose_controls_common.h index e707523ec..01237072b 100644 --- a/Telegram/SourceFiles/history/view/controls/compose_controls_common.h +++ b/Telegram/SourceFiles/history/view/controls/compose_controls_common.h @@ -21,6 +21,7 @@ struct MessageToEdit { FullMsgId fullId; Api::SendOptions options; TextWithTags textWithTags; + std::optional spoilerMediaOverride; }; struct VoiceToSend { QByteArray bytes; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index dff29122c..9154d846e 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "history/view/controls/history_view_characters_limit.h" +#include "history/view/controls/history_view_compose_media_edit_manager.h" #include "history/view/controls/history_view_forward_panel.h" #include "history/view/controls/history_view_draft_options.h" #include "history/view/controls/history_view_voice_record_bar.h" @@ -72,6 +73,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/ui_utility.h" #include "ui/widgets/fields/input_field.h" #include "ui/widgets/dropdown_menu.h" +#include "ui/widgets/popup_menu.h" #include "ui/text/format_values.h" #include "ui/controls/emoji_button.h" #include "ui/controls/send_button.h" @@ -84,6 +86,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwindow.h" #include "styles/style_chat.h" #include "styles/style_chat_helpers.h" +#include "styles/style_menu_icons.h" namespace HistoryView { namespace { @@ -210,6 +213,8 @@ private: bool _repaintScheduled : 1 = false; bool _inClickable : 1 = false; + HistoryView::MediaEditSpoilerManager _mediaEditSpoiler; + const not_null _data; const not_null _cancel; @@ -398,7 +403,12 @@ void FieldHeader::init() { _editOptionsRequests.fire({}); } } else if (!isLeftButton) { - if (const auto reply = replyingToMessage()) { + if (inPreviewRect && isEditingMessage()) { + _mediaEditSpoiler.showMenu( + this, + _data->message(_editMsgId.current()), + [=](bool) { update(); }); + } else if (const auto reply = replyingToMessage()) { _jumpToItemRequests.fire_copy(reply); } } @@ -572,10 +582,14 @@ void FieldHeader::paintEditOrReplyToMessage(Painter &p) { const auto media = _shownMessage->media(); _shownMessageHasPreview = media && media->hasReplyPreview(); - const auto preview = _shownMessageHasPreview + const auto preview = _mediaEditSpoiler.spoilerOverride() + ? _mediaEditSpoiler.mediaPreview(_shownMessage) + : _shownMessageHasPreview ? media->replyPreview() : nullptr; - const auto spoilered = preview && media->hasSpoiler(); + const auto spoilered = _mediaEditSpoiler.spoilerOverride() + ? (*_mediaEditSpoiler.spoilerOverride()) + : (preview && media->hasSpoiler()); if (!spoilered) { _shownPreviewSpoiler = nullptr; } else if (!_shownPreviewSpoiler) { @@ -720,6 +734,7 @@ void FieldHeader::editMessage(FullMsgId id, bool photoEditAllowed) { _photoEditAllowed = photoEditAllowed; _editMsgId = id; if (!photoEditAllowed) { + _mediaEditSpoiler.setSpoilerOverride(std::nullopt); _inPhotoEdit = false; _inPhotoEditOver.stop(); } @@ -767,6 +782,7 @@ MessageToEdit FieldHeader::queryToEdit() { .scheduled = item->isScheduled() ? item->date() : 0, .shortcutId = item->shortcutId(), }, + .spoilerMediaOverride = _mediaEditSpoiler.spoilerOverride(), }; } @@ -3440,4 +3456,49 @@ rpl::producer SendDisabledBySlowmode(not_null peer) { _1 && _2); } +void ShowPhotoEditSpoilerMenu( + not_null parent, + not_null item, + const std::optional &override, + Fn callback) { + const auto media = item->media(); + const auto hasPreview = media && media->hasReplyPreview(); + const auto preview = hasPreview ? media->replyPreview() : nullptr; + if (!preview) { + return; + } + const auto spoilered = override + ? (*override) + : (preview && media->hasSpoiler()); + const auto menu = Ui::CreateChild( + parent, + st::popupMenuWithIcons); + menu->addAction( + spoilered + ? tr::lng_context_disable_spoiler(tr::now) + : tr::lng_context_spoiler_effect(tr::now), + [=] { callback(!spoilered); }, + spoilered ? &st::menuIconSpoilerOff : &st::menuIconSpoiler); + menu->popup(QCursor::pos()); +} + +Image *MediaPreviewWithOverriddenSpoiler( + not_null item, + bool spoiler) { + if (const auto media = item->media()) { + if (const auto photo = media->photo()) { + return photo->getReplyPreview( + item->fullId(), + item->history()->peer, + spoiler); + } else if (const auto document = media->document()) { + return document->getReplyPreview( + item->fullId(), + item->history()->peer, + spoiler); + } + } + return nullptr; +} + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index b24e0213a..f6c915968 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL class History; class DocumentData; class FieldAutocomplete; +class Image; namespace style { struct ComposeControls; @@ -451,4 +452,14 @@ private: [[nodiscard]] rpl::producer SendDisabledBySlowmode( not_null peer); +void ShowPhotoEditSpoilerMenu( + not_null parent, + not_null item, + const std::optional &override, + Fn callback); + +[[nodiscard]] Image *MediaPreviewWithOverriddenSpoiler( + not_null item, + bool spoiler); + } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.cpp new file mode 100644 index 000000000..940ff7ff2 --- /dev/null +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.cpp @@ -0,0 +1,83 @@ +/* +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 "history/view/controls/history_view_compose_media_edit_manager.h" + +#include "data/data_document.h" +#include "data/data_file_origin.h" +#include "data/data_photo.h" +#include "history/history.h" +#include "history/history_item.h" +#include "lang/lang_keys.h" +#include "ui/widgets/popup_menu.h" +#include "styles/style_menu_icons.h" + +namespace HistoryView { + +MediaEditSpoilerManager::MediaEditSpoilerManager() = default; + +void MediaEditSpoilerManager::showMenu( + not_null parent, + not_null item, + Fn callback) { + const auto media = item->media(); + const auto hasPreview = media && media->hasReplyPreview(); + const auto preview = hasPreview ? media->replyPreview() : nullptr; + if (!preview) { + return; + } + const auto spoilered = _spoilerOverride + ? (*_spoilerOverride) + : (preview && media->hasSpoiler()); + const auto menu = Ui::CreateChild( + parent, + st::popupMenuWithIcons); + menu->addAction( + spoilered + ? tr::lng_context_disable_spoiler(tr::now) + : tr::lng_context_spoiler_effect(tr::now), + [=] { + _spoilerOverride = (!spoilered); + if (callback) { + callback(!spoilered); + } + }, + spoilered ? &st::menuIconSpoilerOff : &st::menuIconSpoiler); + menu->popup(QCursor::pos()); +} + +[[nodiscard]] Image *MediaEditSpoilerManager::mediaPreview( + not_null item) { + if (!_spoilerOverride) { + return nullptr; + } + if (const auto media = item->media()) { + if (const auto photo = media->photo()) { + return photo->getReplyPreview( + item->fullId(), + item->history()->peer, + *_spoilerOverride); + } else if (const auto document = media->document()) { + return document->getReplyPreview( + item->fullId(), + item->history()->peer, + *_spoilerOverride); + } + } + return nullptr; +} + +void MediaEditSpoilerManager::setSpoilerOverride( + std::optional spoilerOverride) { + _spoilerOverride = spoilerOverride; +} + +std::optional MediaEditSpoilerManager::spoilerOverride() const { + return _spoilerOverride; +} + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.h new file mode 100644 index 000000000..8bc34b7c4 --- /dev/null +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_media_edit_manager.h @@ -0,0 +1,39 @@ +/* +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 Ui { +class RpWidget; +} // namespace Ui + +class Image; +class HistoryItem; + +namespace HistoryView { + +class MediaEditSpoilerManager final { +public: + MediaEditSpoilerManager(); + + void showMenu( + not_null parent, + not_null item, + Fn callback); + + [[nodiscard]] Image *mediaPreview(not_null item); + + void setSpoilerOverride(std::optional spoilerOverride); + + std::optional spoilerOverride() const; + +private: + std::optional _spoilerOverride; + +}; + +} // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index afd77d665..1974cce2b 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -736,7 +736,8 @@ void RepliesWidget::setupComposeControls() { _composeControls->editRequests( ) | rpl::start_with_next([=](auto data) { if (const auto item = session().data().message(data.fullId)) { - edit(item, data.options, saveEditMsgRequestId); + const auto spoiler = data.spoilerMediaOverride; + edit(item, data.options, saveEditMsgRequestId, spoiler); } }, lifetime()); @@ -1207,7 +1208,8 @@ void RepliesWidget::send(Api::SendOptions options) { void RepliesWidget::edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId) { + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride) { if (*saveEditMsgRequestId) { return; } @@ -1275,7 +1277,8 @@ void RepliesWidget::edit( webpage, options, crl::guard(this, done), - crl::guard(this, fail)); + crl::guard(this, fail), + spoilerMediaOverride); _composeControls->hidePanelsAnimated(); doSetInnerFocus(); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 3da1c44f0..33b7859b4 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -246,7 +246,8 @@ private: void edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId); + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride); void chooseAttach(std::optional overrideSendImagesAsPhotos); [[nodiscard]] SendMenu::Type sendMenuType() const; [[nodiscard]] FullReplyTo replyTo() const; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 667347423..887d16e09 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -318,7 +318,8 @@ void ScheduledWidget::setupComposeControls() { ) | rpl::start_with_next([=](auto data) { if (const auto item = session().data().message(data.fullId)) { if (item->isScheduled()) { - edit(item, data.options, saveEditMsgRequestId); + const auto spoiler = data.spoilerMediaOverride; + edit(item, data.options, saveEditMsgRequestId, spoiler); } } }, lifetime()); @@ -726,7 +727,8 @@ void ScheduledWidget::sendVoice( void ScheduledWidget::edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId) { + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride) { if (*saveEditMsgRequestId) { return; } @@ -794,7 +796,8 @@ void ScheduledWidget::edit( webpage, options, crl::guard(this, done), - crl::guard(this, fail)); + crl::guard(this, fail), + spoilerMediaOverride); _composeControls->hidePanelsAnimated(); _composeControls->focus(); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h index 43702688f..6685c113a 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h @@ -213,7 +213,8 @@ private: void edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId); + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride); void highlightSingleNewMessage(const Data::MessagesSlice &slice); void chooseAttach(); [[nodiscard]] SendMenu::Type sendMenuType() const; diff --git a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp index efeffaac9..ca82da329 100644 --- a/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp +++ b/Telegram/SourceFiles/settings/business/settings_shortcut_messages.cpp @@ -238,7 +238,8 @@ private: void edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId); + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride); void chooseAttach(std::optional overrideSendImagesAsPhotos); [[nodiscard]] SendMenu::Type sendMenuType() const; [[nodiscard]] FullReplyTo replyTo() const; @@ -673,7 +674,8 @@ void ShortcutMessages::setupComposeControls() { ) | rpl::start_with_next([=](auto data) { if (const auto item = _session->data().message(data.fullId)) { if (item->isBusinessShortcut()) { - edit(item, data.options, saveEditMsgRequestId); + const auto spoiler = data.spoilerMediaOverride; + edit(item, data.options, saveEditMsgRequestId, spoiler); } } }, lifetime()); @@ -1213,7 +1215,8 @@ void ShortcutMessages::send(Api::SendOptions options) { void ShortcutMessages::edit( not_null item, Api::SendOptions options, - mtpRequestId *const saveEditMsgRequestId) { + mtpRequestId *const saveEditMsgRequestId, + std::optional spoilerMediaOverride) { if (*saveEditMsgRequestId) { return; } @@ -1281,7 +1284,8 @@ void ShortcutMessages::edit( webpage, options, crl::guard(this, done), - crl::guard(this, fail)); + crl::guard(this, fail), + spoilerMediaOverride); _composeControls->hidePanelsAnimated(); doSetInnerFocus(); From 7a95b38d3c9239b4ad4cb1ff4a5adc880ef318be Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 13 May 2024 22:05:09 +0300 Subject: [PATCH 18/67] Fixed refreshing of file reference in api media spoiler editing module. --- Telegram/SourceFiles/api/api_editing.cpp | 84 +++++++++++++++++++----- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/Telegram/SourceFiles/api/api_editing.cpp b/Telegram/SourceFiles/api/api_editing.cpp index 5705d267e..7dcd768cb 100644 --- a/Telegram/SourceFiles/api/api_editing.cpp +++ b/Telegram/SourceFiles/api/api_editing.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "data/business/data_shortcut_messages.h" #include "data/components/scheduled_messages.h" +#include "data/data_file_origin.h" #include "data/data_histories.h" #include "data/data_session.h" #include "data/data_web_page.h" @@ -254,37 +255,90 @@ mtpRequestId EditTextMessage( Fn done, Fn fail, std::optional spoilerMediaOverride) { - const auto callback = [=](Fn applyUpdates, mtpRequestId id) { - applyUpdates(); - done(id); - }; - auto inputMedia = std::optional(); if (spoilerMediaOverride) { const auto spoiler = *spoilerMediaOverride; if (const auto media = item->media()) { + auto takeInputMedia = Fn()>(nullptr); + auto takeFileReference = Fn(nullptr); if (const auto photo = media->photo()) { using Flag = MTPDinputMediaPhoto::Flag; const auto flags = Flag() | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag()) | (spoiler ? Flag::f_spoiler : Flag()); - inputMedia = MTP_inputMediaPhoto( - MTP_flags(flags), - photo->mtpInput(), - MTP_int(media->ttlSeconds())); + takeInputMedia = [=] { + return MTP_inputMediaPhoto( + MTP_flags(flags), + photo->mtpInput(), + MTP_int(media->ttlSeconds())); + }; + takeFileReference = [=] { return photo->fileReference(); }; } else if (const auto document = media->document()) { using Flag = MTPDinputMediaDocument::Flag; const auto flags = Flag() | (media->ttlSeconds() ? Flag::f_ttl_seconds : Flag()) | (spoiler ? Flag::f_spoiler : Flag()); - inputMedia = MTP_inputMediaDocument( - MTP_flags(flags), - document->mtpInput(), - MTP_int(media->ttlSeconds()), - MTPstring()); // query + takeInputMedia = [=] { + return MTP_inputMediaDocument( + MTP_flags(flags), + document->mtpInput(), + MTP_int(media->ttlSeconds()), + MTPstring()); // query + }; + takeFileReference = [=] { return document->fileReference(); }; } + + const auto usedFileReference = takeFileReference + ? takeFileReference() + : QByteArray(); + const auto origin = item->fullId(); + const auto api = &item->history()->session().api(); + const auto performRequest = [=]( + const auto &repeatRequest, + mtpRequestId originalRequestId) -> mtpRequestId { + const auto handleReference = [=]( + const QString &error, + mtpRequestId requestId) { + if (error.startsWith(u"FILE_REFERENCE_"_q)) { + api->refreshFileReference(origin, [=](const auto &) { + if (takeFileReference && + (takeFileReference() != usedFileReference)) { + repeatRequest( + repeatRequest, + originalRequestId + ? originalRequestId + : requestId); + } else { + fail(error, requestId); + } + }); + } else { + fail(error, requestId); + } + }; + const auto callback = [=]( + Fn applyUpdates, + mtpRequestId requestId) { + applyUpdates(); + done(originalRequestId ? originalRequestId : requestId); + }; + const auto requestId = EditMessage( + item, + caption, + webpage, + options, + callback, + handleReference, + takeInputMedia ? takeInputMedia() : std::nullopt); + return originalRequestId ? originalRequestId : requestId; + }; + return performRequest(performRequest, 0); } } + const auto callback = [=](Fn applyUpdates, mtpRequestId id) { + applyUpdates(); + done(id); + }; return EditMessage( item, caption, @@ -292,7 +346,7 @@ mtpRequestId EditTextMessage( options, callback, fail, - inputMedia); + std::nullopt); } } // namespace Api From bc11c667770471b83d4f1d27027b1995816e3f3f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 00:44:52 +0300 Subject: [PATCH 19/67] Added ability to hide single sponsored message to premium users. --- .../data/components/sponsored_messages.cpp | 25 +++++++++++++------ Telegram/SourceFiles/menu/menu_sponsored.cpp | 12 ++++++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/data/components/sponsored_messages.cpp b/Telegram/SourceFiles/data/components/sponsored_messages.cpp index 4cb54fc7e..c20ec967e 100644 --- a/Telegram/SourceFiles/data/components/sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/components/sponsored_messages.cpp @@ -443,6 +443,22 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId) return; } + const auto erase = [=] { + const auto it = _data.find(history); + if (it != end(_data)) { + auto &list = it->second.entries; + const auto proj = [&](const Entry &e) { + return e.itemFullId == fullId; + }; + list.erase(ranges::remove_if(list, proj), end(list)); + } + }; + + if (optionId == Result::Id("-1")) { + erase(); + return; + } + state->requestId = _session->api().request( MTPchannels_ReportSponsoredMessage( channel->inputChannel, @@ -469,14 +485,7 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId) }, [](const TLAdsHidden &data) -> Result { return { .result = Result::FinalStep::Hidden }; }, [&](const TLReported &data) -> Result { - const auto it = _data.find(history); - if (it != end(_data)) { - auto &list = it->second.entries; - const auto proj = [&](const Entry &e) { - return e.itemFullId == fullId; - }; - list.erase(ranges::remove_if(list, proj), end(list)); - } + erase(); if (optionId == Result::Id("1")) { // I don't like it. return { .result = Result::FinalStep::Silence }; } diff --git a/Telegram/SourceFiles/menu/menu_sponsored.cpp b/Telegram/SourceFiles/menu/menu_sponsored.cpp index e917c3f07..f836106d0 100644 --- a/Telegram/SourceFiles/menu/menu_sponsored.cpp +++ b/Telegram/SourceFiles/menu/menu_sponsored.cpp @@ -332,9 +332,7 @@ void ShowSponsored( not_null item) { Expects(item->isSponsored()); - struct State final { - }; - const auto state = std::make_shared(); + const auto session = &item->history()->session(); const auto menu = Ui::CreateChild( parent.get(), @@ -351,7 +349,13 @@ void ShowSponsored( menu->addSeparator(&st::expandedMenuSeparator); menu->addAction(tr::lng_sponsored_hide_ads(tr::now), [=] { - ShowPremiumPreviewBox(show, PremiumFeature::NoAds); + if (session->premium()) { + using Result = Data::SponsoredReportResult; + session->sponsoredMessages().createReportCallback( + item->fullId())(Result::Id("-1"), [](const auto &) {}); + } else { + ShowPremiumPreviewBox(show, PremiumFeature::NoAds); + } }, &st::menuIconCancel); menu->popup(QCursor::pos()); From 3e7d4af4a03cf2987b94376159d1c43e08854276 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 01:01:01 +0300 Subject: [PATCH 20/67] Fixed reply bubble width for short quotes. --- Telegram/SourceFiles/history/view/history_view_reply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index 1b9df5db6..d2043b027 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -583,7 +583,7 @@ QSize Reply::countMultilineOptimalSize( textGeometry(max, previewSkip, &elided)); _minHeightExpandable = elided ? 1 : 0; return { - result.width, + result.width + st::historyReplyPadding.right(), std::max(result.height, st::normalFont->height), }; } From 2afb69e7878cb71085748a755aeab0415068746c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 01:28:46 +0300 Subject: [PATCH 21/67] Fixed text state of reply bubble for messages with unwrapped media. --- .../history/view/media/history_view_media_unwrapped.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index b0dba7ecb..4c9e3277c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -441,7 +441,7 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const { } if (recth) { int rectx = _additionalOnTop - ? (rightAligned ? (inner.width() + st::msgReplyPadding.left() - rectw) : 0) + ? (rightAligned ? (inner.x() + inner.width() - rectw) : 0) : (rightAligned ? 0 : (inner.width() + st::msgReplyPadding.left())); int recty = surrounding.height - recth; if (rtl()) rectx = width() - rectx - rectw; From 41e414af37fe09e35686c57a205cb144fc9631e6 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 02:52:18 +0300 Subject: [PATCH 22/67] Removed transcribe buttons from scheduled messages. --- .../SourceFiles/history/view/media/history_view_document.cpp | 1 + Telegram/SourceFiles/history/view/media/history_view_gif.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index b7714d579..bb64302c7 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -440,6 +440,7 @@ QSize Document::countOptimalSize() { const auto session = &history->session(); const auto transcribes = &session->api().transcribes(); if (_parent->data()->media()->ttlSeconds() + || _realParent->isScheduled() || (!session->premium() && !transcribes->freeFor(_realParent) && !transcribes->trialsSupport())) { diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index bda09fe8d..2097ca1b5 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -2063,6 +2063,7 @@ bool Gif::needCornerStatusDisplay() const { void Gif::ensureTranscribeButton() const { if (_data->isVideoMessage() && !_parent->data()->media()->ttlSeconds() + && !_parent->data()->isScheduled() && (_data->session().premium() || _data->session().api().transcribes().trialsSupport())) { if (!_transcribe) { From c1c49e8ddccd85b6a67162d7d61c515eaf3ca5f8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 03:45:49 +0300 Subject: [PATCH 23/67] Added captions to voice messages in overview layout. --- .../SourceFiles/overview/overview_layout.cpp | 26 +++++++++++++++++++ .../SourceFiles/overview/overview_layout.h | 4 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index e75af1464..6bbacb1d8 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "overview/overview_layout.h" #include "overview/overview_layout_delegate.h" +#include "core/ui_integration.h" // Core::MarkedTextContext. #include "data/data_document.h" #include "data/data_document_resolver.h" #include "data/data_session.h" @@ -867,6 +868,7 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const p.drawTextLeft(nameleft, statustop, _width, _status.text(), statusw); unreadx += statusw; } + auto captionLeft = unreadx + st::mediaUnreadSkip; if (parent()->hasUnreadMediaFlag() && unreadx + st::mediaUnreadSkip + st::mediaUnreadSize <= _width) { p.setPen(Qt::NoPen); p.setBrush(selected ? st::msgFileInBgSelected : st::msgFileInBg); @@ -875,6 +877,22 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const PainterHighQualityEnabler hq(p); p.drawEllipse(style::rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); } + captionLeft += st::mediaUnreadSkip + st::mediaUnreadSize; + } + if (!_caption.isEmpty()) { + p.setPen(st::historyFileNameInFg); + const auto w = _width - captionLeft - st::defaultScrollArea.width; + _caption.draw(p, Ui::Text::PaintContext{ + .position = QPoint(captionLeft, statustop), + .availableWidth = w, + .spoiler = Ui::Text::DefaultSpoilerCache(), + .paused = context + ? context->paused + : On(PowerSaving::kEmojiChat), + .pausedEmoji = On(PowerSaving::kEmojiChat), + .pausedSpoiler = On(PowerSaving::kChatSpoiler), + .elisionLines = 1, + }); } } @@ -1005,6 +1023,14 @@ void Voice::updateName() { Ui::NameTextOptions()); } _nameVersion = parent()->fromOriginal()->nameVersion(); + _caption.setMarkedText( + st::defaultTextStyle, + parent()->originalText(), + Ui::DialogTextOptions(), + Core::MarkedTextContext{ + .session = &parent()->history()->session(), + .customEmojiRepaint = [=] { delegate()->repaintItem(this); }, + }); } bool Voice::updateStatusText() { diff --git a/Telegram/SourceFiles/overview/overview_layout.h b/Telegram/SourceFiles/overview/overview_layout.h index 3526b5e57..936379e36 100644 --- a/Telegram/SourceFiles/overview/overview_layout.h +++ b/Telegram/SourceFiles/overview/overview_layout.h @@ -362,7 +362,9 @@ private: const style::OverviewFileLayout &_st; - Ui::Text::String _name, _details; + Ui::Text::String _name; + Ui::Text::String _details; + Ui::Text::String _caption; int _nameVersion = 0; void updateName(); From b406e2b99b98e5828069e6ecfaef2bcfb0ad3fb5 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 04:04:07 +0300 Subject: [PATCH 24/67] Fixed sender name for voices in overview layout when sender is hidden. --- .../history/view/history_view_message.cpp | 2 +- .../SourceFiles/overview/overview_layout.cpp | 33 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 67f10c033..4eddd3b49 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -3826,7 +3826,7 @@ void Message::fromNameUpdated(int width) const { const auto nameText = [&]() -> const Ui::Text::String * { if (from) { return &_fromName; - } else if (const auto info= item->originalHiddenSenderInfo()) { + } else if (const auto info = item->originalHiddenSenderInfo()) { return &info->nameText(); } else { Unexpected("Corrupted forwarded information in message."); diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 6bbacb1d8..c56582bc4 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_document_resolver.h" #include "data/data_session.h" #include "data/data_web_page.h" -#include "data/data_media_types.h" #include "data/data_peer.h" #include "data/data_photo_media.h" #include "data/data_document_media.h" @@ -21,9 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "lang/lang_keys.h" #include "layout/layout_selection.h" -#include "mainwidget.h" #include "storage/file_upload.h" -#include "mainwindow.h" #include "main/main_session.h" #include "media/audio/media_audio.h" #include "media/player/media_player_instance.h" @@ -999,23 +996,19 @@ const style::RoundCheckbox &Voice::checkboxStyle() const { void Voice::updateName() { if (const auto forwarded = parent()->Get()) { - if (parent()->fromOriginal()->isChannel()) { - _name.setText( - st::semiboldTextStyle, - tr::lng_forwarded_channel( - tr::now, - lt_channel, - parent()->fromOriginal()->name()), - Ui::NameTextOptions()); - } else { - _name.setText( - st::semiboldTextStyle, - tr::lng_forwarded( - tr::now, - lt_user, - parent()->fromOriginal()->name()), - Ui::NameTextOptions()); - } + const auto info = parent()->originalHiddenSenderInfo(); + const auto name = info + ? tr::lng_forwarded(tr::now, lt_user, info->nameText().toString()) + : parent()->fromOriginal()->isChannel() + ? tr::lng_forwarded_channel( + tr::now, + lt_channel, + parent()->fromOriginal()->name()) + : tr::lng_forwarded( + tr::now, + lt_user, + parent()->fromOriginal()->name()); + _name.setText(st::semiboldTextStyle, name, Ui::NameTextOptions()); } else { _name.setText( st::semiboldTextStyle, From e4323ecd26f9bcabae3181f957a13b524766d5af Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 07:07:59 +0300 Subject: [PATCH 25/67] Slightly improved code style in processing of api text entities. --- .../SourceFiles/api/api_text_entities.cpp | 308 +++++++++++++----- 1 file changed, 227 insertions(+), 81 deletions(-) diff --git a/Telegram/SourceFiles/api/api_text_entities.cpp b/Telegram/SourceFiles/api/api_text_entities.cpp index 6c434bc9b..44a689ff4 100644 --- a/Telegram/SourceFiles/api/api_text_entities.cpp +++ b/Telegram/SourceFiles/api/api_text_entities.cpp @@ -7,12 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "api/api_text_entities.h" -#include "main/main_session.h" +#include "data/data_document.h" +#include "data/data_session.h" +#include "data/data_user.h" #include "data/stickers/data_custom_emoji.h" #include "data/stickers/data_stickers_set.h" -#include "data/data_session.h" -#include "data/data_document.h" -#include "data/data_user.h" +#include "main/main_session.h" namespace Api { namespace { @@ -62,67 +62,163 @@ using namespace TextUtilities; EntitiesInText EntitiesFromMTP( Main::Session *session, const QVector &entities) { + if (entities.isEmpty()) { + return {}; + } auto result = EntitiesInText(); - if (!entities.isEmpty()) { - result.reserve(entities.size()); - for (const auto &entity : entities) { - switch (entity.type()) { - case mtpc_messageEntityUrl: { auto &d = entity.c_messageEntityUrl(); result.push_back({ EntityType::Url, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityTextUrl: { auto &d = entity.c_messageEntityTextUrl(); result.push_back({ EntityType::CustomUrl, d.voffset().v, d.vlength().v, qs(d.vurl()) }); } break; - case mtpc_messageEntityEmail: { auto &d = entity.c_messageEntityEmail(); result.push_back({ EntityType::Email, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityHashtag: { auto &d = entity.c_messageEntityHashtag(); result.push_back({ EntityType::Hashtag, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityCashtag: { auto &d = entity.c_messageEntityCashtag(); result.push_back({ EntityType::Cashtag, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityPhone: break; // Skipping phones. - case mtpc_messageEntityMention: { auto &d = entity.c_messageEntityMention(); result.push_back({ EntityType::Mention, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityMentionName: if (session) { - const auto &d = entity.c_messageEntityMentionName(); - const auto userId = UserId(d.vuser_id()); - const auto user = session->data().userLoaded(userId); - const auto data = MentionNameDataFromFields({ - .selfId = session->userId().bare, - .userId = userId.bare, - .accessHash = user ? user->accessHash() : 0, - }); - result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data }); - } break; - case mtpc_inputMessageEntityMentionName: if (session) { - const auto &d = entity.c_inputMessageEntityMentionName(); - const auto data = d.vuser_id().match([&]( - const MTPDinputUserSelf &) { - return MentionNameDataFromFields({ - .selfId = session->userId().bare, - .userId = session->userId().bare, - .accessHash = session->user()->accessHash(), - }); - }, [&](const MTPDinputUser &data) { - return MentionNameDataFromFields({ - .selfId = session->userId().bare, - .userId = UserId(data.vuser_id()).bare, - .accessHash = data.vaccess_hash().v, - }); - }, [&](const auto &) { - return QString(); - }); - if (!data.isEmpty()) { - result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data }); - } - } break; - case mtpc_messageEntityBotCommand: { auto &d = entity.c_messageEntityBotCommand(); result.push_back({ EntityType::BotCommand, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityBold: { auto &d = entity.c_messageEntityBold(); result.push_back({ EntityType::Bold, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityItalic: { auto &d = entity.c_messageEntityItalic(); result.push_back({ EntityType::Italic, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityUnderline: { auto &d = entity.c_messageEntityUnderline(); result.push_back({ EntityType::Underline, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityStrike: { auto &d = entity.c_messageEntityStrike(); result.push_back({ EntityType::StrikeOut, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityCode: { auto &d = entity.c_messageEntityCode(); result.push_back({ EntityType::Code, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityPre: { auto &d = entity.c_messageEntityPre(); result.push_back({ EntityType::Pre, d.voffset().v, d.vlength().v, qs(d.vlanguage()) }); } break; - case mtpc_messageEntityBlockquote: { auto &d = entity.c_messageEntityBlockquote(); result.push_back({ EntityType::Blockquote, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityBankCard: break; // Skipping cards. // #TODO entities - case mtpc_messageEntitySpoiler: { auto &d = entity.c_messageEntitySpoiler(); result.push_back({ EntityType::Spoiler, d.voffset().v, d.vlength().v }); } break; - case mtpc_messageEntityCustomEmoji: { - const auto &d = entity.c_messageEntityCustomEmoji(); - result.push_back({ EntityType::CustomEmoji, d.voffset().v, d.vlength().v, CustomEmojiEntityData(d) }); - } break; + result.reserve(entities.size()); + + for (const auto &entity : entities) { + entity.match([&](const MTPDmessageEntityUnknown &d) { + }, [&](const MTPDmessageEntityMention &d) { + result.push_back({ + EntityType::Mention, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityHashtag &d) { + result.push_back({ + EntityType::Hashtag, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityBotCommand &d) { + result.push_back({ + EntityType::BotCommand, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityUrl &d) { + result.push_back({ + EntityType::Url, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityEmail &d) { + result.push_back({ + EntityType::Email, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityBold &d) { + result.push_back({ + EntityType::Bold, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityItalic &d) { + result.push_back({ + EntityType::Italic, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityCode &d) { + result.push_back({ + EntityType::Code, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityPre &d) { + result.push_back({ + EntityType::Pre, + d.voffset().v, + d.vlength().v, + qs(d.vlanguage()), + }); + }, [&](const MTPDmessageEntityTextUrl &d) { + result.push_back({ + EntityType::CustomUrl, + d.voffset().v, + d.vlength().v, + qs(d.vurl()), + }); + }, [&](const MTPDmessageEntityMentionName &d) { + if (!session) { + return; } - } + const auto userId = UserId(d.vuser_id()); + const auto user = session->data().userLoaded(userId); + const auto data = MentionNameDataFromFields({ + .selfId = session->userId().bare, + .userId = userId.bare, + .accessHash = user ? user->accessHash() : 0, + }); + result.push_back({ + EntityType::MentionName, + d.voffset().v, + d.vlength().v, + data, + }); + }, [&](const MTPDinputMessageEntityMentionName &d) { + if (!session) { + return; + } + const auto data = d.vuser_id().match([&]( + const MTPDinputUserSelf &) { + return MentionNameDataFromFields({ + .selfId = session->userId().bare, + .userId = session->userId().bare, + .accessHash = session->user()->accessHash(), + }); + }, [&](const MTPDinputUser &data) { + return MentionNameDataFromFields({ + .selfId = session->userId().bare, + .userId = UserId(data.vuser_id()).bare, + .accessHash = data.vaccess_hash().v, + }); + }, [](const auto &) { + return QString(); + }); + if (!data.isEmpty()) { + result.push_back({ + EntityType::MentionName, + d.voffset().v, + d.vlength().v, + data, + }); + } + }, [&](const MTPDmessageEntityPhone &d) { + // Skipping phones. + }, [&](const MTPDmessageEntityCashtag &d) { + result.push_back({ + EntityType::Cashtag, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityUnderline &d) { + result.push_back({ + EntityType::Underline, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityStrike &d) { + result.push_back({ + EntityType::StrikeOut, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityBankCard &d) { + // Skipping cards. // #TODO entities + }, [&](const MTPDmessageEntitySpoiler &d) { + result.push_back({ + EntityType::Spoiler, + d.voffset().v, + d.vlength().v, + }); + }, [&](const MTPDmessageEntityCustomEmoji &d) { + result.push_back({ + EntityType::CustomEmoji, + d.voffset().v, + d.vlength().v, + CustomEmojiEntityData(d), + }); + }, [&](const MTPDmessageEntityBlockquote &d) { + result.push_back({ + EntityType::Blockquote, + d.voffset().v, + d.vlength().v, + }); + }); } return result; } @@ -134,7 +230,9 @@ MTPVector EntitiesToMTP( auto v = QVector(); v.reserve(entities.size()); for (const auto &entity : entities) { - if (entity.length() <= 0) continue; + if (entity.length() <= 0) { + continue; + } if (option == ConvertOption::SkipLocal && entity.type() != EntityType::Bold //&& entity.type() != EntityType::Semibold // Not in API. @@ -154,28 +252,76 @@ MTPVector EntitiesToMTP( auto offset = MTP_int(entity.offset()); auto length = MTP_int(entity.length()); switch (entity.type()) { - case EntityType::Url: v.push_back(MTP_messageEntityUrl(offset, length)); break; - case EntityType::CustomUrl: v.push_back(MTP_messageEntityTextUrl(offset, length, MTP_string(entity.data()))); break; - case EntityType::Email: v.push_back(MTP_messageEntityEmail(offset, length)); break; - case EntityType::Hashtag: v.push_back(MTP_messageEntityHashtag(offset, length)); break; - case EntityType::Cashtag: v.push_back(MTP_messageEntityCashtag(offset, length)); break; - case EntityType::Mention: v.push_back(MTP_messageEntityMention(offset, length)); break; + case EntityType::Url: { + v.push_back(MTP_messageEntityUrl(offset, length)); + } break; + case EntityType::CustomUrl: { + v.push_back( + MTP_messageEntityTextUrl( + offset, + length, + MTP_string(entity.data()))); + } break; + case EntityType::Email: { + v.push_back(MTP_messageEntityEmail(offset, length)); + } break; + case EntityType::Hashtag: { + v.push_back(MTP_messageEntityHashtag(offset, length)); + } break; + case EntityType::Cashtag: { + v.push_back(MTP_messageEntityCashtag(offset, length)); + } break; + case EntityType::Mention: { + v.push_back(MTP_messageEntityMention(offset, length)); + } break; case EntityType::MentionName: { - if (const auto valid = MentionNameEntity(session, offset, length, entity.data())) { + const auto valid = MentionNameEntity( + session, + offset, + length, + entity.data()); + if (valid) { v.push_back(*valid); } } break; - case EntityType::BotCommand: v.push_back(MTP_messageEntityBotCommand(offset, length)); break; - case EntityType::Bold: v.push_back(MTP_messageEntityBold(offset, length)); break; - case EntityType::Italic: v.push_back(MTP_messageEntityItalic(offset, length)); break; - case EntityType::Underline: v.push_back(MTP_messageEntityUnderline(offset, length)); break; - case EntityType::StrikeOut: v.push_back(MTP_messageEntityStrike(offset, length)); break; - case EntityType::Code: v.push_back(MTP_messageEntityCode(offset, length)); break; // #TODO entities - case EntityType::Pre: v.push_back(MTP_messageEntityPre(offset, length, MTP_string(entity.data()))); break; - case EntityType::Blockquote: v.push_back(MTP_messageEntityBlockquote(offset, length)); break; - case EntityType::Spoiler: v.push_back(MTP_messageEntitySpoiler(offset, length)); break; + case EntityType::BotCommand: { + v.push_back(MTP_messageEntityBotCommand(offset, length)); + } break; + case EntityType::Bold: { + v.push_back(MTP_messageEntityBold(offset, length)); + } break; + case EntityType::Italic: { + v.push_back(MTP_messageEntityItalic(offset, length)); + } break; + case EntityType::Underline: { + v.push_back(MTP_messageEntityUnderline(offset, length)); + } break; + case EntityType::StrikeOut: { + v.push_back(MTP_messageEntityStrike(offset, length)); + } break; + case EntityType::Code: { + // #TODO entities. + v.push_back(MTP_messageEntityCode(offset, length)); + } break; + case EntityType::Pre: { + v.push_back( + MTP_messageEntityPre( + offset, + length, + MTP_string(entity.data()))); + } break; + case EntityType::Blockquote: { + v.push_back(MTP_messageEntityBlockquote(offset, length)); + } break; + case EntityType::Spoiler: { + v.push_back(MTP_messageEntitySpoiler(offset, length)); + } break; case EntityType::CustomEmoji: { - if (const auto valid = CustomEmojiEntity(offset, length, entity.data())) { + const auto valid = CustomEmojiEntity( + offset, + length, + entity.data()); + if (valid) { v.push_back(*valid); } } break; From 76137ca1cf622401cbf5dac0138d19d2c58b4b63 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 09:34:58 +0300 Subject: [PATCH 26/67] Fixed link to premium section in box about sponsored messages. --- Telegram/SourceFiles/menu/menu_sponsored.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/menu/menu_sponsored.cpp b/Telegram/SourceFiles/menu/menu_sponsored.cpp index f836106d0..495da6a85 100644 --- a/Telegram/SourceFiles/menu/menu_sponsored.cpp +++ b/Telegram/SourceFiles/menu/menu_sponsored.cpp @@ -37,11 +37,13 @@ namespace { void AboutBox( not_null box, - not_null session) { + std::shared_ptr show) { constexpr auto kUrl = "https://promote.telegram.org"_cs; box->setNoContentMargin(true); + const auto session = &show->session(); + const auto content = box->verticalLayout().get(); const auto levels = Data::LevelLimits(session) .channelRestrictSponsoredLevelMin(); @@ -101,7 +103,7 @@ void AboutBox( st::channelEarnSemiboldLabel), padding); Ui::AddSkip(content, st::channelEarnHistoryThreeSkip); - content->add( + const auto label = content->add( object_ptr( content, std::move(about), @@ -121,6 +123,7 @@ void AboutBox( (g.left() - left->width()) / 2, g.top() + st::channelEarnHistoryThreeSkip); }, left->lifetime()); + return label; }; addEntry( tr::lng_sponsored_revenued_info1_title(), @@ -144,10 +147,14 @@ void AboutBox( lt_link, tr::lng_settings_privacy_premium_link( ) | rpl::map([=](QString t) { - return Ui::Text::Link(t, kUrl.utf16()); + return Ui::Text::Link(std::move(t), u"internal:"_q); }), Ui::Text::RichLangValue), - st::sponsoredAboutRemoveIcon); + st::sponsoredAboutRemoveIcon)->setClickHandlerFilter([=]( + const auto &...) { + ShowPremiumPreviewBox(show, PremiumFeature::NoAds); + return true; + }); Ui::AddSkip(content); Ui::AddSkip(content); } @@ -339,7 +346,7 @@ void ShowSponsored( st::popupMenuWithIcons); menu->addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] { - show->show(Box(AboutBox, &item->history()->session())); + show->show(Box(AboutBox, show)); }, &st::menuIconInfo); menu->addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] { @@ -363,7 +370,7 @@ void ShowSponsored( void ShowSponsoredAbout(std::shared_ptr show) { show->showBox(Box([=](not_null box) { - AboutBox(box, &show->session()); + AboutBox(box, show); })); } From 264e35a6a86809be1854eea5e82634faa6c5fabb Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 14 May 2024 17:16:02 +0300 Subject: [PATCH 27/67] Fixed rare crash in photo editor when editing media in message. --- Telegram/SourceFiles/boxes/edit_caption_box.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 5ffdfb6f3..be4d4e7fa 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -206,6 +206,9 @@ void EditPhotoImage( Storage::UpdateImageDetails(file, previewWidth, sideLimit); done(std::move(list)); }; + if (!large) { + return; + } const auto fileImage = std::make_shared(*large); auto editor = base::make_unique_q( parent, From 213326a212ca4096b224c6db2e672f3622e965bf Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 14 May 2024 18:15:02 +0400 Subject: [PATCH 28/67] Update submodules. --- Telegram/lib_webrtc | 2 +- Telegram/lib_webview | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index 1cbf5fa7d..f701713cd 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit 1cbf5fa7d875074c40e76216a3047bd7c59996d7 +Subproject commit f701713cd798bd7d5f69d318fdefb125d101aa76 diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 2ccbfa5f3..6db384204 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 2ccbfa5f3443274e40deb761674b536e2e8eedae +Subproject commit 6db384204054d853b30ba887d448a5a3ea4077c0 From b5f5aed1197aae6bccdeaef958d663fd5af41904 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 8 May 2024 09:30:59 +0400 Subject: [PATCH 29/67] Fix search focus in a hidden window on launch. Fixes #27853. --- Telegram/build/docker/centos_env/Dockerfile | 2 +- Telegram/build/prepare/prepare.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 350c7a3fd..d48e99710 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -51,7 +51,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin 44f5103860dfa3f9b9675730231af6fbe28cde93 \ + && git fetch --depth=1 origin 1b3aa9303260613841745a71442c939b55c8aaf2 \ && git reset --hard FETCH_HEAD \ && rm -rf .git diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index ce6c87b9b..9a3d0587e 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -435,7 +435,7 @@ if customRunCommand: stage('patches', """ git clone https://github.com/desktop-app/patches.git cd patches - git checkout 5d64e21844 + git checkout 1b3aa93032 """) stage('msys64', """ From 1f31d8032f752c90800255dfcfe3f3137a3beb0d Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 8 May 2024 17:16:34 +0400 Subject: [PATCH 30/67] Bring chosen font to the top of the box. --- Telegram/SourceFiles/ui/boxes/choose_font_box.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp b/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp index 512e8a691..80168ca0f 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_font_box.cpp @@ -546,15 +546,25 @@ std::vector Selector::FullList(const QString &now) { result.push_back({ .id = family }); } } - if (!ranges::contains(result, now, &Entry::id)) { + auto nowIt = ranges::find(result, now, &Entry::id); + if (nowIt == end(result)) { result.push_back({ .id = now }); + nowIt = end(result) - 1; } for (auto i = begin(result) + 2; i != end(result); ++i) { i->key = TextUtilities::RemoveAccents(i->id).toLower(); i->text = i->id; i->keywords = TextUtilities::PrepareSearchWords(i->id); } - ranges::sort(begin(result) + 2, end(result), std::less<>(), &Entry::key); + auto skip = 2; + if (nowIt - begin(result) >= skip) { + std::swap(result[2], *nowIt); + ++skip; + } + ranges::sort( + begin(result) + skip, end(result), + std::less<>(), + &Entry::key); return result; } From 88ad1be4c303d02fa9e2a24d88b246b7b648e6e1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 9 May 2024 11:12:01 +0400 Subject: [PATCH 31/67] Try to fix custom fonts in the input field. --- Telegram/SourceFiles/chat_helpers/chat_helpers.style | 2 +- Telegram/build/docker/centos_env/Dockerfile | 2 +- Telegram/build/prepare/prepare.py | 2 +- Telegram/lib_ui | 2 +- snap/snapcraft.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index 67358e4c9..f8c8ad61b 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -983,7 +983,7 @@ historyComposeField: InputField(defaultInputField) { placeholderFg: placeholderFg; placeholderFgActive: placeholderFgActive; placeholderFgError: placeholderFgActive; - placeholderMargins: margins(7px, 5px, 7px, 5px); + placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderAlign: align(topleft); placeholderScale: 0.; placeholderFont: normalFont; diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index d48e99710..251123360 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -51,7 +51,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin 1b3aa9303260613841745a71442c939b55c8aaf2 \ + && git fetch --depth=1 origin 25f76cf4d58fae5742447d17d2574ab1fad196e5 \ && git reset --hard FETCH_HEAD \ && rm -rf .git diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 9a3d0587e..8384492e6 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -435,7 +435,7 @@ if customRunCommand: stage('patches', """ git clone https://github.com/desktop-app/patches.git cd patches - git checkout 1b3aa93032 + git checkout 25f76cf4d5 """) stage('msys64', """ diff --git a/Telegram/lib_ui b/Telegram/lib_ui index f76ddd841..41d1fe923 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit f76ddd841ca02ca35432f6de569f8c430a9713b1 +Subproject commit 41d1fe9232c1d09b1ada01a0cc552e5c66d74b89 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 79148548e..95f560866 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -167,7 +167,7 @@ parts: patches: source: https://github.com/desktop-app/patches.git source-depth: 1 - source-commit: 44f5103860dfa3f9b9675730231af6fbe28cde93 + source-commit: 25f76cf4d58fae5742447d17d2574ab1fad196e5 plugin: dump override-pull: | craftctl default From bd48e2fff2a4f83834d53f7651cfd6abc7355e7c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 16 May 2024 19:13:21 +0400 Subject: [PATCH 32/67] Fix more package names in snap --- snap/snapcraft.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 95f560866..531d3d14d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -115,13 +115,13 @@ parts: - libasound2 - libavif16 - libboost-regex1.83.0 - - libglib2.0-0 + - libglib2.0-0t64 - libheif1 - libopenal1 - libopus0 - - libprotobuf-lite32 + - libprotobuf-lite32t64 - libpulse0 - - libssl3 + - libssl3t64 - libwayland-client0 - libwebkitgtk-6.0-4 - libxcb1 @@ -322,7 +322,7 @@ parts: - libegl1 - libfontconfig1 - libfreetype6 - - libglib2.0-0 + - libglib2.0-0t64 - libglx0 - libgtk-3-0t64 - libharfbuzz0b @@ -333,7 +333,7 @@ parts: - libpcre2-16-0 - libpng16-16t64 - libsm6 - - libssl3 + - libssl3t64 - libvulkan1 - libwayland-client0 - libwayland-cursor0 @@ -465,10 +465,10 @@ parts: - libegl1 - libgbm1 - libgl1 - - libglib2.0-0 + - libglib2.0-0t64 - libopenh264-7 - libopus0 - - libssl3 + - libssl3t64 - libvpx9 - libx11-6 - libxcomposite1 From a753c1515bd9bd069cee9285a8a47b140c010d2f Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 16 May 2024 19:13:42 +0400 Subject: [PATCH 33/67] Remove unneeded wayland-client dependency from telegram part in snap --- snap/snapcraft.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 531d3d14d..b65e2e06d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -105,7 +105,6 @@ parts: - libprotobuf-dev - libpulse-dev - libssl-dev - - libwayland-dev - libxcb1-dev - libxcb-keysyms1-dev - libxcb-record0-dev @@ -122,7 +121,6 @@ parts: - libprotobuf-lite32t64 - libpulse0 - libssl3t64 - - libwayland-client0 - libwebkitgtk-6.0-4 - libxcb1 - libxcb-keysyms1 From ad13048cdc7f6ed64980634af83de07e7da5494b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 16 May 2024 19:15:56 +0400 Subject: [PATCH 34/67] Update submodules --- Telegram/lib_ui | 2 +- Telegram/lib_webview | 2 +- cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 41d1fe923..72a1c98fa 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 41d1fe9232c1d09b1ada01a0cc552e5c66d74b89 +Subproject commit 72a1c98fa6470f160d0d81cca9a1b123821e8e0f diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 6db384204..3cc1c1c16 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 6db384204054d853b30ba887d448a5a3ea4077c0 +Subproject commit 3cc1c1c1619a2c23bcc9500ddb2ca1231a5db5b5 diff --git a/cmake b/cmake index d9f958e0b..a7527c0e6 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit d9f958e0ba4eef6359b0c968ca4fc75923134f78 +Subproject commit a7527c0e6eba1c71cd0dfd7bd8de9c1e68cb529f From 98b58c1168a380dff4bf9192abdd420008c0daa1 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 18 May 2024 01:02:49 +0400 Subject: [PATCH 35/67] Add missing binds for OpenGL shaders and buffers --- Telegram/SourceFiles/calls/calls_video_incoming.cpp | 1 + .../SourceFiles/calls/group/calls_group_viewport_opengl.cpp | 2 ++ .../SourceFiles/media/view/media_view_overlay_opengl.cpp | 5 +++++ Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp | 3 +++ 4 files changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/calls/calls_video_incoming.cpp b/Telegram/SourceFiles/calls/calls_video_incoming.cpp index 9ab16d73d..e1a52ebe9 100644 --- a/Telegram/SourceFiles/calls/calls_video_incoming.cpp +++ b/Telegram/SourceFiles/calls/calls_video_incoming.cpp @@ -331,6 +331,7 @@ void Panel::Incoming::RendererGL::paint( shadow.texture.left(), shadow.texture.top(), }; + _contentBuffer->bind(); _contentBuffer->write(0, coords, sizeof(coords)); const auto bottomShadowArea = QRect( diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp index 63e5105fa..6f6b07620 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp @@ -783,6 +783,7 @@ void Viewport::RendererGL::paintTile( : &*_frameProgram.yuv420; const auto uniformViewport = QSizeF(_viewport) * _factor; + program->bind(); program->setUniformValue("viewport", uniformViewport); program->setUniformValue( "frameBg", @@ -1078,6 +1079,7 @@ void Viewport::RendererGL::drawDownscalePass( ? &*_downscaleProgram.argb32 : &*_downscaleProgram.yuv420; + program->bind(); FillTexturedRectangle(f, program); } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp index 31ea35237..99be5557f 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp @@ -544,6 +544,7 @@ void OverlayWidget::RendererGL::paintTransformedContent( 0.f, 0.f, }; + _contentBuffer->bind(); _contentBuffer->write(0, coords, sizeof(coords)); program->setUniformValue("viewport", _uniformViewport); @@ -712,6 +713,7 @@ void OverlayWidget::RendererGL::paintControl( }; _controlsProgram->bind(); _controlsProgram->setUniformValue("viewport", _uniformViewport); + _contentBuffer->bind(); if (!over.isEmpty() && overOpacity > 0) { _contentBuffer->write( offset * 4 * sizeof(GLfloat), @@ -915,6 +917,7 @@ void OverlayWidget::RendererGL::paintRoundedCorners(int radius) { const auto offset = kControlsOffset + (kControlsCount * kControlValues) / 4; const auto byteOffset = offset * 4 * sizeof(GLfloat); + _contentBuffer->bind(); _contentBuffer->write(byteOffset, coords, sizeof(coords)); _roundedCornersProgram->bind(); _roundedCornersProgram->setUniformValue("viewport", _uniformViewport); @@ -981,6 +984,7 @@ void OverlayWidget::RendererGL::paintStoriesSiblingPart( + (6 * 2 * 4) / 4 // rounding + (index * 4); const auto byteOffset = offset * 4 * sizeof(GLfloat); + _contentBuffer->bind(); _contentBuffer->write(byteOffset, coords, sizeof(coords)); _controlsProgram->bind(); @@ -1059,6 +1063,7 @@ void OverlayWidget::RendererGL::paintUsingRaster( geometry.left(), geometry.bottom(), textured.texture.left(), textured.texture.top(), }; + _contentBuffer->bind(); _contentBuffer->write( bufferOffset * 4 * sizeof(GLfloat), coords, diff --git a/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp b/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp index 8e4e8e7c2..f4be398c2 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip_opengl.cpp @@ -427,6 +427,7 @@ void Pip::RendererGL::paintTransformedContent( (geometry.outer.height() - geometry.inner.y()) * yscale, }; + _contentBuffer->bind(); _contentBuffer->write(0, coords, sizeof(coords)); const auto rgbaFrame = _chromaSize.isEmpty(); @@ -588,6 +589,7 @@ void Pip::RendererGL::paintButton( iconOverRect.texture.right(), iconOverRect.texture.top(), iconOverRect.texture.left(), iconOverRect.texture.top(), }; + _contentBuffer->bind(); _contentBuffer->write( offset * 4 * sizeof(GLfloat), coords, @@ -741,6 +743,7 @@ void Pip::RendererGL::paintUsingRaster( geometry.left(), geometry.bottom(), textured.texture.left(), textured.texture.top(), }; + _contentBuffer->bind(); _contentBuffer->write( bufferOffset * 4 * sizeof(GLfloat), coords, From 65b62485be4a7ce1f584b84231f69d829743b61c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 17 May 2024 03:24:20 +0400 Subject: [PATCH 36/67] Forward input method event from Dialogs::Widget to search field --- .../SourceFiles/dialogs/dialogs_widget.cpp | 28 +++++++++++++++++++ Telegram/SourceFiles/dialogs/dialogs_widget.h | 3 ++ 2 files changed, 31 insertions(+) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 575516ffa..6e5c30b7b 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -82,6 +82,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/qt/qt_common_adapters.h" #include +#include #include #include @@ -239,6 +240,8 @@ Widget::Widget( : nullptr) , _searchTimer([=] { searchMessages(); }) , _singleMessageSearch(&controller->session()) { + setAttribute(Qt::WA_InputMethodEnabled); + const auto makeChildListShown = [](PeerId peerId, float64 shown) { return InnerWidget::ChildListShown{ peerId, shown }; }; @@ -3298,6 +3301,31 @@ void Widget::keyPressEvent(QKeyEvent *e) { } } +void Widget::inputMethodEvent(QInputMethodEvent *e) { + const auto cursor = _search->rawTextEdit()->textCursor(); + bool isGettingInput = !e->commitString().isEmpty() + || e->preeditString() != cursor.block().layout()->preeditAreaText() + || e->replacementLength() > 0; + + if (!isGettingInput || _postponeProcessSearchFocusChange) { + Window::AbstractSectionWidget::inputMethodEvent(e); + return; + } + + // This delay in search focus processing allows us not to create + // _suggestions in case the event inserts some non-whitespace search + // query while still show _suggestions animated, if it is a space. + _postponeProcessSearchFocusChange = true; + _search->setFocusFast(); + QCoreApplication::sendEvent(_search->rawTextEdit(), e); + _postponeProcessSearchFocusChange = false; + processSearchFocusChange(); +} + +QVariant Widget::inputMethodQuery(Qt::InputMethodQuery query) const { + return _search->rawTextEdit()->inputMethodQuery(query); +} + bool Widget::redirectToSearchPossible() const { return !_openedFolder && !_openedForum diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 5ff9828d5..aa6dbdf93 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -135,6 +135,8 @@ public: bool cancelSearch(); bool cancelSearchByMouseBack(); + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; + ~Widget(); protected: @@ -144,6 +146,7 @@ protected: void dropEvent(QDropEvent *e) override; void resizeEvent(QResizeEvent *e) override; void keyPressEvent(QKeyEvent *e) override; + void inputMethodEvent(QInputMethodEvent *e) override; void paintEvent(QPaintEvent *e) override; private: From af4e0178d0d4efdb87898386c0aa56ad6bd8ffc7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 19 May 2024 15:29:31 +0400 Subject: [PATCH 37/67] Ensure window flags are set before calling SeparatePanel::setInnerSize Setting window flags may lead to native window being re-created --- Telegram/SourceFiles/payments/ui/payments_panel.cpp | 2 +- Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp | 2 +- Telegram/lib_webview | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index f509fdb70..7813a8244 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -70,8 +70,8 @@ Panel::Progress::Progress(QWidget *parent, Fn rect) Panel::Panel(not_null delegate) : _delegate(delegate) , _widget(std::make_unique()) { - _widget->setInnerSize(st::paymentsPanelSize); _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); + _widget->setInnerSize(st::paymentsPanelSize); _widget->closeRequests( ) | rpl::start_with_next([=] { diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index a18c86bf2..747c812e4 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -323,8 +323,8 @@ Panel::Panel( , _menuButtons(menuButtons) , _widget(std::make_unique()) , _allowClipboardRead(allowClipboardRead) { - _widget->setInnerSize(st::botWebViewPanelSize); _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); + _widget->setInnerSize(st::botWebViewPanelSize); _widget->closeRequests( ) | rpl::start_with_next([=] { diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 3cc1c1c16..ebaa206b1 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 3cc1c1c1619a2c23bcc9500ddb2ca1231a5db5b5 +Subproject commit ebaa206b1d2f1f24cff08f3c8a73054ee69274f0 From 6734f99ba8b46b716beab112f98ff1551f47c2e2 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 19 May 2024 20:14:15 +0400 Subject: [PATCH 38/67] Update lib_ui & patches on Linux --- Telegram/build/docker/centos_env/Dockerfile | 2 +- Telegram/lib_ui | 2 +- snap/snapcraft.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 251123360..1f623e190 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -51,7 +51,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin 25f76cf4d58fae5742447d17d2574ab1fad196e5 \ + && git fetch --depth=1 origin 931535985f75ca51313923d31d7924560719b3eb \ && git reset --hard FETCH_HEAD \ && rm -rf .git diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 72a1c98fa..037ceb272 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 72a1c98fa6470f160d0d81cca9a1b123821e8e0f +Subproject commit 037ceb272c4dd2eb456e18b61e374c1fa759d109 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b65e2e06d..7a6fc8ffa 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -165,7 +165,7 @@ parts: patches: source: https://github.com/desktop-app/patches.git source-depth: 1 - source-commit: 25f76cf4d58fae5742447d17d2574ab1fad196e5 + source-commit: 931535985f75ca51313923d31d7924560719b3eb plugin: dump override-pull: | craftctl default From 2bdc204c4761178ca502cbad02a42aee08955cda Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 20 May 2024 13:34:05 +0400 Subject: [PATCH 39/67] Fix geometry applying in webview windows. --- .../payments/ui/payments_panel.cpp | 21 +++++---- .../SourceFiles/payments/ui/payments_panel.h | 2 + .../ui/chat/attach/attach_bot_webview.cpp | 46 ++++++++++--------- .../ui/chat/attach/attach_bot_webview.h | 4 +- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index 7813a8244..d97628285 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -534,12 +534,15 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { const auto bottom = _webviewBottom.get(); bottom->show(); - bottom->heightValue( - ) | rpl::start_with_next([=](int height) { - const auto inner = _widget->innerGeometry(); + rpl::combine( + container->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), + bottom->heightValue() + ) | rpl::start_with_next([=](QRect inner, int height) { bottom->move(inner.x(), inner.y() + inner.height() - height); - container->resize(inner.width(), inner.height() - height); bottom->resizeToWidth(inner.width()); + _footerHeight = bottom->height(); }, bottom->lifetime()); container->show(); @@ -584,10 +587,12 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { }); }); - container->geometryValue( - ) | rpl::start_with_next([=](QRect geometry) { - if (raw->widget()) { - raw->widget()->setGeometry(geometry); + rpl::combine( + container->geometryValue(), + _footerHeight.value() + ) | rpl::start_with_next([=](QRect geometry, int footer) { + if (const auto view = raw->widget()) { + view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer })); } }, _webview->lifetime); diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.h b/Telegram/SourceFiles/payments/ui/payments_panel.h index b65def015..6c64c661f 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel.h @@ -115,11 +115,13 @@ private: [[nodiscard]] bool progressWithBackground() const; [[nodiscard]] QRect progressRect() const; void setupProgressGeometry(); + void updateFooterHeight(); const not_null _delegate; std::unique_ptr _widget; std::unique_ptr _webview; std::unique_ptr _webviewBottom; + rpl::variable _footerHeight; std::unique_ptr _progress; QPointer _saveWebviewInformation; QPointer _weakFormSummary; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 747c812e4..d419d7775 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -570,17 +570,15 @@ void Panel::createWebviewBottom() { label->show(); _webviewBottom->resize(_webviewBottom->width(), height); - bottom->heightValue( - ) | rpl::start_with_next([=](int height) { - const auto inner = _widget->innerGeometry(); - if (_mainButton && !_mainButton->isHidden()) { - height = _mainButton->height(); - } + rpl::combine( + _webviewParent->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), + bottom->heightValue() + ) | rpl::start_with_next([=](QRect inner, int height) { bottom->move(inner.x(), inner.y() + inner.height() - height); - if (const auto container = _webviewParent.data()) { - container->setFixedSize(inner.width(), inner.height() - height); - } bottom->resizeToWidth(inner.width()); + updateFooterHeight(); }, bottom->lifetime()); } @@ -636,10 +634,13 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { }); }); - container->geometryValue( - ) | rpl::start_with_next([=](QRect geometry) { - if (raw->widget()) { - raw->widget()->setGeometry(geometry); + updateFooterHeight(); + rpl::combine( + container->geometryValue(), + _footerHeight.value() + ) | rpl::start_with_next([=](QRect geometry, int footer) { + if (const auto view = raw->widget()) { + view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer })); } }, _webview->lifetime); @@ -1185,22 +1186,25 @@ void Panel::createMainButton() { button->hide(); rpl::combine( + _webviewParent->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), button->shownValue(), button->heightValue() - ) | rpl::start_with_next([=](bool shown, int height) { - const auto inner = _widget->innerGeometry(); - if (!shown) { - height = _webviewBottom->height(); - } + ) | rpl::start_with_next([=](QRect inner, bool shown, int height) { button->move(inner.x(), inner.y() + inner.height() - height); - if (const auto raw = _webviewParent.data()) { - raw->setFixedSize(inner.width(), inner.height() - height); - } button->resizeToWidth(inner.width()); _webviewBottom->setVisible(!shown); + updateFooterHeight(); }, button->lifetime()); } +void Panel::updateFooterHeight() { + _footerHeight = (_mainButton && !_mainButton->isHidden()) + ? _mainButton->height() + : _webviewBottom->height(); +} + void Panel::showBox(object_ptr box) { if (const auto widget = _webview ? _webview->window.widget() : nullptr) { const auto hideNow = !widget->isHidden(); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index ee1dae837..fb0231a01 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -143,6 +143,7 @@ private: [[nodiscard]] bool progressWithBackground() const; [[nodiscard]] QRect progressRect() const; void setupProgressGeometry(); + void updateFooterHeight(); Webview::StorageId _storageId; const not_null _delegate; @@ -153,9 +154,10 @@ private: std::unique_ptr _webview; std::unique_ptr _webviewBottom; rpl::variable _bottomText; - QPointer _webviewParent; + QPointer _webviewParent; std::unique_ptr