diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 540809a09..8b6ee2b29 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -390,7 +390,7 @@ jobs:
run: |
cd $LibrariesPath
- git clone -b 1.16 https://gitlab.freedesktop.org/wayland/wayland
+ git clone -b 1.18.0 https://gitlab.freedesktop.org/wayland/wayland
cd wayland
./autogen.sh \
--enable-static \
diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml
index ec5d33619..d96ae3e77 100644
--- a/.github/workflows/mac.yml
+++ b/.github/workflows/mac.yml
@@ -411,7 +411,7 @@ jobs:
uses: actions/cache@v1
with:
path: ${{ env.LibrariesPath }}/qt-cache
- key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8.diff') }}
+ key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }}
- name: Use cached Qt 5.12.8.
if: steps.cache-qt.outputs.cache-hit == 'true'
run: |
diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml
index 8b4cf758c..fd9192cb8 100644
--- a/.github/workflows/snap.yml
+++ b/.github/workflows/snap.yml
@@ -13,7 +13,6 @@ on:
- '!.github/workflows/snap.yml'
- 'Telegram/build/**'
- 'Telegram/Patches/**'
- - '!Telegram/Patches/ffmpeg.diff'
- 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**'
@@ -33,7 +32,6 @@ on:
- '!.github/workflows/snap.yml'
- 'Telegram/build/**'
- 'Telegram/Patches/**'
- - '!Telegram/Patches/ffmpeg.diff'
- 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**'
@@ -45,13 +43,13 @@ on:
jobs:
linux:
- name: Ubuntu 18.04
+ name: Ubuntu 20.04
if: >
!(github.event_name == 'push'
&& contains(github.event.head_commit.message, '[skip ci]'))
&& !(github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
env:
UPLOAD_ARTIFACT: "false"
diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml
index 898c38880..b229199d4 100644
--- a/.github/workflows/win.yml
+++ b/.github/workflows/win.yml
@@ -301,7 +301,7 @@ jobs:
uses: actions/cache@v1
with:
path: ${{ env.LibrariesPath }}/Qt-5.12.8
- key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8.diff') }}
+ key: ${{ runner.OS }}-qt-${{ env.CACHE_KEY }}-${{ hashFiles('**/qtbase_5_12_8/*') }}
- name: Configure Qt 5.12.8.
if: steps.cache-qt.outputs.cache-hit != 'true'
shell: cmd
@@ -397,7 +397,7 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true'
shell: cmd
run: |
- cd %REPO_NAME%\build\bin
+ cd %REPO_NAME%\out\Debug
mkdir artifact
move Kotatogram.exe artifact/
move Updater.exe artifact/
@@ -406,4 +406,4 @@ jobs:
if: env.UPLOAD_ARTIFACT == 'true'
with:
name: ${{ env.ARTIFACT_NAME }}
- path: ${{ env.REPO_NAME }}\build\bin\artifact\
+ path: ${{ env.REPO_NAME }}\out\Debug\artifact\
diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt
index dd05ac060..461f675c7 100644
--- a/Telegram/CMakeLists.txt
+++ b/Telegram/CMakeLists.txt
@@ -1224,7 +1224,7 @@ endif()
set_target_properties(Telegram PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
-if ((NOT DESKTOP_APP_DISABLE_AUTOUPDATE OR NOT LINUX) AND NOT build_macstore AND NOT build_winstore)
+if ((NOT DESKTOP_APP_DISABLE_AUTOUPDATE OR APPLE) AND NOT build_macstore AND NOT build_winstore)
add_executable(Updater WIN32)
init_target(Updater)
diff --git a/Telegram/Patches/ffmpeg.diff b/Telegram/Patches/ffmpeg.diff
deleted file mode 100644
index b5ab619fe..000000000
--- a/Telegram/Patches/ffmpeg.diff
+++ /dev/null
@@ -1,225 +0,0 @@
-diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
-index 00f93bf59f..52da7036f3 100644
---- a/libavcodec/aarch64/Makefile
-+++ b/libavcodec/aarch64/Makefile
-@@ -6,6 +6,7 @@ OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o
- OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_init.o
- OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.o
- OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o
-+OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o
- OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
- OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o
- OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
-@@ -21,6 +22,7 @@ OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_init_aarch64.o
- OBJS-$(CONFIG_VORBIS_DECODER) += aarch64/vorbisdsp_init.o
- OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9dsp_init_10bpp_aarch64.o \
- aarch64/vp9dsp_init_12bpp_aarch64.o \
-+ aarch64/vp9mc_aarch64.o \
- aarch64/vp9dsp_init_aarch64.o
-
- # ARMv8 optimizations
-@@ -41,8 +43,7 @@ NEON-OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_neon.o
- NEON-OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_neon.o \
- aarch64/hpeldsp_neon.o
- NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
--NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o \
-- aarch64/simple_idct_neon.o
-+NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/simple_idct_neon.o
- NEON-OBJS-$(CONFIG_MDCT) += aarch64/mdct_neon.o
- NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o
- NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o
-diff --git a/libavcodec/aarch64/idctdsp_init_aarch64.c b/libavcodec/aarch64/idctdsp_init_aarch64.c
-index 0406e60830..742a3372e3 100644
---- a/libavcodec/aarch64/idctdsp_init_aarch64.c
-+++ b/libavcodec/aarch64/idctdsp_init_aarch64.c
-@@ -21,6 +21,8 @@
- */
-
- #include "libavutil/attributes.h"
-+#include "libavutil/cpu.h"
-+#include "libavutil/arm/cpu.h"
- #include "libavcodec/avcodec.h"
- #include "libavcodec/idctdsp.h"
- #include "idct.h"
-@@ -28,7 +30,9 @@
- av_cold void ff_idctdsp_init_aarch64(IDCTDSPContext *c, AVCodecContext *avctx,
- unsigned high_bit_depth)
- {
-- if (!avctx->lowres && !high_bit_depth) {
-+ int cpu_flags = av_get_cpu_flags();
-+
-+ if (have_neon(cpu_flags) && !avctx->lowres && !high_bit_depth) {
- if (avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLENEON) {
-diff --git a/libavcodec/aarch64/vp9mc_16bpp_neon.S b/libavcodec/aarch64/vp9mc_16bpp_neon.S
-index cac6428709..53b372c262 100644
---- a/libavcodec/aarch64/vp9mc_16bpp_neon.S
-+++ b/libavcodec/aarch64/vp9mc_16bpp_neon.S
-@@ -25,31 +25,6 @@
- // const uint8_t *ref, ptrdiff_t ref_stride,
- // int h, int mx, int my);
-
--function ff_vp9_copy128_aarch64, export=1
--1:
-- ldp x5, x6, [x2]
-- ldp x7, x8, [x2, #16]
-- stp x5, x6, [x0]
-- ldp x9, x10, [x2, #32]
-- stp x7, x8, [x0, #16]
-- subs w4, w4, #1
-- ldp x11, x12, [x2, #48]
-- stp x9, x10, [x0, #32]
-- stp x11, x12, [x0, #48]
-- ldp x5, x6, [x2, #64]
-- ldp x7, x8, [x2, #80]
-- stp x5, x6, [x0, #64]
-- ldp x9, x10, [x2, #96]
-- stp x7, x8, [x0, #80]
-- ldp x11, x12, [x2, #112]
-- stp x9, x10, [x0, #96]
-- stp x11, x12, [x0, #112]
-- add x2, x2, x3
-- add x0, x0, x1
-- b.ne 1b
-- ret
--endfunc
--
- function ff_vp9_avg64_16_neon, export=1
- mov x5, x0
- sub x1, x1, #64
-diff --git a/libavcodec/aarch64/vp9mc_aarch64.S b/libavcodec/aarch64/vp9mc_aarch64.S
-new file mode 100644
-index 0000000000..f17a8cf04a
---- /dev/null
-+++ b/libavcodec/aarch64/vp9mc_aarch64.S
-@@ -0,0 +1,81 @@
-+/*
-+ * Copyright (c) 2016 Google Inc.
-+ *
-+ * This file is part of FFmpeg.
-+ *
-+ * FFmpeg is free software; you can redistribute it and/or
-+ * modify it under the terms of the GNU Lesser General Public
-+ * License as published by the Free Software Foundation; either
-+ * version 2.1 of the License, or (at your option) any later version.
-+ *
-+ * FFmpeg is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ * Lesser General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU Lesser General Public
-+ * License along with FFmpeg; if not, write to the Free Software
-+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-+ */
-+
-+#include "libavutil/aarch64/asm.S"
-+
-+// All public functions in this file have the following signature:
-+// typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
-+// const uint8_t *ref, ptrdiff_t ref_stride,
-+// int h, int mx, int my);
-+
-+function ff_vp9_copy128_aarch64, export=1
-+1:
-+ ldp x5, x6, [x2]
-+ ldp x7, x8, [x2, #16]
-+ stp x5, x6, [x0]
-+ ldp x9, x10, [x2, #32]
-+ stp x7, x8, [x0, #16]
-+ subs w4, w4, #1
-+ ldp x11, x12, [x2, #48]
-+ stp x9, x10, [x0, #32]
-+ stp x11, x12, [x0, #48]
-+ ldp x5, x6, [x2, #64]
-+ ldp x7, x8, [x2, #80]
-+ stp x5, x6, [x0, #64]
-+ ldp x9, x10, [x2, #96]
-+ stp x7, x8, [x0, #80]
-+ ldp x11, x12, [x2, #112]
-+ stp x9, x10, [x0, #96]
-+ stp x11, x12, [x0, #112]
-+ add x2, x2, x3
-+ add x0, x0, x1
-+ b.ne 1b
-+ ret
-+endfunc
-+
-+function ff_vp9_copy64_aarch64, export=1
-+1:
-+ ldp x5, x6, [x2]
-+ ldp x7, x8, [x2, #16]
-+ stp x5, x6, [x0]
-+ ldp x9, x10, [x2, #32]
-+ stp x7, x8, [x0, #16]
-+ subs w4, w4, #1
-+ ldp x11, x12, [x2, #48]
-+ stp x9, x10, [x0, #32]
-+ stp x11, x12, [x0, #48]
-+ add x2, x2, x3
-+ add x0, x0, x1
-+ b.ne 1b
-+ ret
-+endfunc
-+
-+function ff_vp9_copy32_aarch64, export=1
-+1:
-+ ldp x5, x6, [x2]
-+ ldp x7, x8, [x2, #16]
-+ stp x5, x6, [x0]
-+ subs w4, w4, #1
-+ stp x7, x8, [x0, #16]
-+ add x2, x2, x3
-+ add x0, x0, x1
-+ b.ne 1b
-+ ret
-+endfunc
-diff --git a/libavcodec/aarch64/vp9mc_neon.S b/libavcodec/aarch64/vp9mc_neon.S
-index f67624ca04..abf2bae9db 100644
---- a/libavcodec/aarch64/vp9mc_neon.S
-+++ b/libavcodec/aarch64/vp9mc_neon.S
-@@ -25,23 +25,6 @@
- // const uint8_t *ref, ptrdiff_t ref_stride,
- // int h, int mx, int my);
-
--function ff_vp9_copy64_aarch64, export=1
--1:
-- ldp x5, x6, [x2]
-- ldp x7, x8, [x2, #16]
-- stp x5, x6, [x0]
-- ldp x9, x10, [x2, #32]
-- stp x7, x8, [x0, #16]
-- subs w4, w4, #1
-- ldp x11, x12, [x2, #48]
-- stp x9, x10, [x0, #32]
-- stp x11, x12, [x0, #48]
-- add x2, x2, x3
-- add x0, x0, x1
-- b.ne 1b
-- ret
--endfunc
--
- function ff_vp9_avg64_neon, export=1
- mov x5, x0
- 1:
-@@ -64,19 +47,6 @@ function ff_vp9_avg64_neon, export=1
- ret
- endfunc
-
--function ff_vp9_copy32_aarch64, export=1
--1:
-- ldp x5, x6, [x2]
-- ldp x7, x8, [x2, #16]
-- stp x5, x6, [x0]
-- subs w4, w4, #1
-- stp x7, x8, [x0, #16]
-- add x2, x2, x3
-- add x0, x0, x1
-- b.ne 1b
-- ret
--endfunc
--
- function ff_vp9_avg32_neon, export=1
- 1:
- ld1 {v2.16b, v3.16b}, [x2], x3
diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml
index 10caa4f8b..a3310c7f1 100644
--- a/Telegram/Resources/uwp/AppX/AppxManifest.xml
+++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml
@@ -9,7 +9,7 @@
+ Version="2.1.13.0" />
Telegram Desktop
Telegram FZ-LLC
diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc
index 269096c02..9b5d5dfc4 100644
--- a/Telegram/Resources/winrc/Telegram.rc
+++ b/Telegram/Resources/winrc/Telegram.rc
@@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,1,10,0
- PRODUCTVERSION 2,1,10,0
+ FILEVERSION 2,1,13,0
+ PRODUCTVERSION 2,1,13,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -62,10 +62,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop"
- VALUE "FileVersion", "2.1.10.0"
+ VALUE "FileVersion", "2.1.13.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
VALUE "ProductName", "Telegram Desktop"
- VALUE "ProductVersion", "2.1.10.0"
+ VALUE "ProductVersion", "2.1.13.0"
END
END
BLOCK "VarFileInfo"
diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc
index d371e8728..b8ed82512 100644
--- a/Telegram/Resources/winrc/Updater.rc
+++ b/Telegram/Resources/winrc/Updater.rc
@@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,1,10,0
- PRODUCTVERSION 2,1,10,0
+ FILEVERSION 2,1,13,0
+ PRODUCTVERSION 2,1,13,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -53,10 +53,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "Telegram FZ-LLC"
VALUE "FileDescription", "Telegram Desktop Updater"
- VALUE "FileVersion", "2.1.10.0"
+ VALUE "FileVersion", "2.1.13.0"
VALUE "LegalCopyright", "Copyright (C) 2014-2020"
VALUE "ProductName", "Telegram Desktop"
- VALUE "ProductVersion", "2.1.10.0"
+ VALUE "ProductVersion", "2.1.13.0"
END
END
BLOCK "VarFileInfo"
diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp
index 79d0d5a8e..9987deda9 100644
--- a/Telegram/SourceFiles/_other/packer.cpp
+++ b/Telegram/SourceFiles/_other/packer.cpp
@@ -254,7 +254,7 @@ int main(int argc, char *argv[])
}
QByteArray inner = f.readAll();
stream << name << quint32(inner.size()) << inner;
-#if defined Q_OS_MAC || defined Q_OS_LINUX
+#ifdef Q_OS_UNIX
stream << (QFileInfo(fullName).isExecutable() ? true : false);
#endif
}
@@ -467,10 +467,12 @@ int main(int argc, char *argv[])
QString outName(QString("tupdate%1").arg(AlphaVersion ? AlphaVersion : version));
#elif defined Q_OS_MAC
QString outName((targetosx ? QString("tosxupd%1") : QString("tmacupd%1")).arg(AlphaVersion ? AlphaVersion : version));
-#elif defined Q_OS_LINUX32
+#elif defined Q_OS_UNIX
+#ifndef _LP64
QString outName(QString("tlinux32upd%1").arg(AlphaVersion ? AlphaVersion : version));
-#elif defined Q_OS_LINUX64
+#else
QString outName(QString("tlinuxupd%1").arg(AlphaVersion ? AlphaVersion : version));
+#endif
#else
#error Unknown platform!
#endif
diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp
index 1e8627445..b0b8b4cc9 100644
--- a/Telegram/SourceFiles/api/api_sending.cpp
+++ b/Telegram/SourceFiles/api/api_sending.cpp
@@ -93,6 +93,7 @@ void SendExistingMedia(
};
TextUtilities::Trim(caption);
auto sentEntities = EntitiesToMTP(
+ session,
caption.entities,
ConvertOption::SkipLocal);
if (!sentEntities.v.isEmpty()) {
diff --git a/Telegram/SourceFiles/api/api_text_entities.cpp b/Telegram/SourceFiles/api/api_text_entities.cpp
index 919a18c63..18acbe2f1 100644
--- a/Telegram/SourceFiles/api/api_text_entities.cpp
+++ b/Telegram/SourceFiles/api/api_text_entities.cpp
@@ -18,11 +18,13 @@ using namespace TextUtilities;
} // namespace
-EntitiesInText EntitiesFromMTP(const QVector &entities) {
+EntitiesInText EntitiesFromMTP(
+ Main::Session *session,
+ const QVector &entities) {
auto result = EntitiesInText();
if (!entities.isEmpty()) {
result.reserve(entities.size());
- for_const (auto &entity, entities) {
+ 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, Clean(qs(d.vurl())) }); } break;
@@ -32,28 +34,30 @@ EntitiesInText EntitiesFromMTP(const QVector &entities) {
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: {
- auto &d = entity.c_messageEntityMentionName();
- auto data = [&d] {
- if (auto user = Auth().data().userLoaded(d.vuser_id().v)) {
- return MentionNameDataFromFields({
- d.vuser_id().v,
- user->accessHash() });
+ const auto &d = entity.c_messageEntityMentionName();
+ const auto data = [&] {
+ if (session) {
+ if (const auto user = session->data().userLoaded(d.vuser_id().v)) {
+ return MentionNameDataFromFields({
+ d.vuser_id().v,
+ user->accessHash() });
+ }
}
return MentionNameDataFromFields(d.vuser_id().v);
- };
- result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data() });
+ }();
+ result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data });
} break;
case mtpc_inputMessageEntityMentionName: {
- auto &d = entity.c_inputMessageEntityMentionName();
- auto data = ([&d]() -> QString {
- if (d.vuser_id().type() == mtpc_inputUserSelf) {
- return MentionNameDataFromFields(Auth().userId());
+ const auto &d = entity.c_inputMessageEntityMentionName();
+ const auto data = [&] {
+ if (session && d.vuser_id().type() == mtpc_inputUserSelf) {
+ return MentionNameDataFromFields(session->userId());
} else if (d.vuser_id().type() == mtpc_inputUser) {
auto &user = d.vuser_id().c_inputUser();
return MentionNameDataFromFields({ user.vuser_id().v, user.vaccess_hash().v });
}
return QString();
- })();
+ }();
if (!data.isEmpty()) {
result.push_back({ EntityType::MentionName, d.voffset().v, d.vlength().v, data });
}
@@ -74,11 +78,12 @@ EntitiesInText EntitiesFromMTP(const QVector &entities) {
}
MTPVector EntitiesToMTP(
+ not_null session,
const EntitiesInText &entities,
ConvertOption option) {
auto v = QVector();
v.reserve(entities.size());
- for_const (auto &entity, entities) {
+ for (const auto &entity : entities) {
if (entity.length() <= 0) continue;
if (option == ConvertOption::SkipLocal
&& entity.type() != EntityType::Bold
@@ -103,15 +108,15 @@ MTPVector EntitiesToMTP(
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: {
- auto inputUser = ([](const QString &data) -> MTPInputUser {
+ auto inputUser = [&](const QString &data) -> MTPInputUser {
auto fields = MentionNameDataToFields(data);
- if (fields.userId == Auth().userId()) {
+ if (session && fields.userId == session->userId()) {
return MTP_inputUserSelf();
} else if (fields.userId) {
return MTP_inputUser(MTP_int(fields.userId), MTP_long(fields.accessHash));
}
return MTP_inputUserEmpty();
- })(entity.data());
+ }(entity.data());
if (inputUser.type() != mtpc_inputUserEmpty) {
v.push_back(MTP_inputMessageEntityMentionName(offset, length, inputUser));
}
diff --git a/Telegram/SourceFiles/api/api_text_entities.h b/Telegram/SourceFiles/api/api_text_entities.h
index 836a3d77a..95348d616 100644
--- a/Telegram/SourceFiles/api/api_text_entities.h
+++ b/Telegram/SourceFiles/api/api_text_entities.h
@@ -9,14 +9,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_entity.h"
+namespace Main {
+class Session;
+} // namespace Main
+
namespace Api {
-EntitiesInText EntitiesFromMTP(const QVector &entities);
enum class ConvertOption {
WithLocal,
SkipLocal,
};
-MTPVector EntitiesToMTP(
+
+[[nodiscard]] EntitiesInText EntitiesFromMTP(
+ Main::Session *session,
+ const QVector &entities);
+
+[[nodiscard]] MTPVector EntitiesToMTP(
+ not_null session,
const EntitiesInText &entities,
ConvertOption option = ConvertOption::WithLocal);
diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp
index 24fb0ea18..92c4507be 100644
--- a/Telegram/SourceFiles/apiwrap.cpp
+++ b/Telegram/SourceFiles/apiwrap.cpp
@@ -411,7 +411,7 @@ void ApiWrap::requestTermsUpdate() {
const auto &terms = data.vterms_of_service();
const auto &fields = terms.c_help_termsOfService();
Core::App().lockByTerms(
- Window::TermsLock::FromMTP(fields));
+ Window::TermsLock::FromMTP(&session(), fields));
requestNext(data);
} break;
default: Unexpected("Type in requestTermsUpdate().");
@@ -2442,6 +2442,7 @@ void ApiWrap::saveDraftsToCloud() {
flags |= MTPmessages_SaveDraft::Flag::f_entities;
}
auto entities = Api::EntitiesToMTP(
+ &session(),
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags),
Api::ConvertOption::SkipLocal);
@@ -4674,6 +4675,7 @@ void ApiWrap::editUploadedFile(
}
auto sentEntities = Api::EntitiesToMTP(
+ &session(),
item->originalText().entities,
Api::ConvertOption::SkipLocal);
@@ -4826,8 +4828,11 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
if (silentPost) {
sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
}
- auto localEntities = Api::EntitiesToMTP(sending.entities);
+ auto localEntities = Api::EntitiesToMTP(
+ &session(),
+ sending.entities);
auto sentEntities = Api::EntitiesToMTP(
+ &session(),
sending.entities,
Api::ConvertOption::SkipLocal);
if (!sentEntities.v.isEmpty()) {
@@ -5118,6 +5123,7 @@ void ApiWrap::sendMediaWithRandomId(
auto caption = item->originalText();
TextUtilities::Trim(caption);
auto sentEntities = Api::EntitiesToMTP(
+ &session(),
caption.entities,
Api::ConvertOption::SkipLocal);
@@ -5794,6 +5800,7 @@ void ApiWrap::rescheduleMessage(
Api::SendOptions options) {
const auto text = item->originalText().text;
const auto sentEntities = Api::EntitiesToMTP(
+ &session(),
item->originalText().entities,
Api::ConvertOption::SkipLocal);
const auto media = item->media();
diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp
index 78057584c..f07b4e577 100644
--- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp
+++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp
@@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document_media.h"
#include "history/history.h"
#include "history/history_item.h"
+#include "platform/platform_specific.h"
#include "lang/lang_keys.h"
#include "layout.h"
#include "media/streaming/media_streaming_instance.h"
@@ -327,10 +328,6 @@ EditCaptionBox::EditCaptionBox(
) | rpl::start_with_next([&](bool checked) {
_asFile = checked;
}, _wayWrap->lifetime());
-
- if (_animated) {
- prepareStreamedPreview();
- }
}
EditCaptionBox::~EditCaptionBox() = default;
@@ -590,6 +587,10 @@ void EditCaptionBox::createEditMediaButton() {
}
void EditCaptionBox::prepare() {
+ if (_animated) {
+ prepareStreamedPreview();
+ }
+
addButton(tr::lng_settings_save(), [this] { save(); });
if (_isAllowedEditMedia) {
createEditMediaButton();
@@ -656,7 +657,10 @@ bool EditCaptionBox::fileFromClipboard(not_null data) {
if (result.error == Error::None) {
return result;
} else if (data->hasImage()) {
- auto image = qvariant_cast(data->imageData());
+ auto image = Platform::GetImageFromClipboard();
+ if (image.isNull()) {
+ image = qvariant_cast(data->imageData());
+ }
if (!image.isNull()) {
_isImage = true;
_photo = true;
@@ -934,6 +938,7 @@ void EditCaptionBox::save() {
TextUtilities::Trim(sending);
const auto sentEntities = Api::EntitiesToMTP(
+ &item->history()->session(),
sending.entities,
Api::ConvertOption::SkipLocal);
if (!sentEntities.v.isEmpty()) {
diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp
index 2f1df25c7..3fc3a6df2 100644
--- a/Telegram/SourceFiles/boxes/send_files_box.cpp
+++ b/Telegram/SourceFiles/boxes/send_files_box.cpp
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/send_files_box.h"
+#include "platform/platform_specific.h"
#include "lang/lang_keys.h"
#include "storage/localstorage.h"
#include "storage/storage_media_prepare.h"
@@ -2168,7 +2169,10 @@ bool SendFilesBox::addFiles(not_null data) {
if (result.error == Storage::PreparedList::Error::None) {
return result;
} else if (data->hasImage()) {
- auto image = qvariant_cast(data->imageData());
+ auto image = Platform::GetImageFromClipboard();
+ if (image.isNull()) {
+ image = qvariant_cast(data->imageData());
+ }
if (!image.isNull()) {
return Storage::PrepareMediaFromImage(
std::move(image),
diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp
index 9e28c43d5..8e21da0d1 100644
--- a/Telegram/SourceFiles/boxes/stickers_box.cpp
+++ b/Telegram/SourceFiles/boxes/stickers_box.cpp
@@ -326,7 +326,9 @@ void StickersBox::prepare() {
_session->api().updateStickers();
if (_installed.widget()) {
- connect(_installed.widget(), SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int)));
+ connect(_installed.widget(), &Inner::draggingScrollDelta, [=](int delta) {
+ scrollByDraggingDelta(delta);
+ });
if (!_megagroupSet) {
boxClosing() | rpl::start_with_next([=] {
saveChanges();
diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp
index 0ac1a04c8..945ad2f1a 100644
--- a/Telegram/SourceFiles/core/application.cpp
+++ b/Telegram/SourceFiles/core/application.cpp
@@ -798,13 +798,9 @@ void Application::notifyFileDialogShown(bool shown) {
}
QWidget *Application::getModalParent() {
-#ifdef Q_OS_LINUX
return Platform::IsWayland()
? App::wnd()
: nullptr;
-#endif // Q_OS_LINUX
-
- return nullptr;
}
diff --git a/Telegram/SourceFiles/core/crash_reports.cpp b/Telegram/SourceFiles/core/crash_reports.cpp
index cc02f7cb6..8b3a8932f 100644
--- a/Telegram/SourceFiles/core/crash_reports.cpp
+++ b/Telegram/SourceFiles/core/crash_reports.cpp
@@ -39,7 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "client/crashpad_client.h"
#endif // else for MAC_USE_BREAKPAD
-#elif defined Q_OS_LINUX64 || defined Q_OS_LINUX32 // Q_OS_MAC
+#elif defined Q_OS_UNIX // Q_OS_MAC
#include
#include
@@ -47,7 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "client/linux/handler/exception_handler.h"
-#endif // Q_OS_LINUX64 || Q_OS_LINUX32
+#endif // Q_OS_UNIX
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
@@ -140,7 +140,7 @@ QMutex ReportingMutex;
const char *BreakpadDumpPath = nullptr;
const wchar_t *BreakpadDumpPathW = nullptr;
-#if defined Q_OS_MAC || defined Q_OS_LINUX32 || defined Q_OS_LINUX64
+#ifdef Q_OS_UNIX
struct sigaction SIG_def[32];
void SignalHandler(int signum, siginfo_t *info, void *ucontext) {
@@ -148,9 +148,9 @@ void SignalHandler(int signum, siginfo_t *info, void *ucontext) {
sigaction(signum, &SIG_def[signum], 0);
}
-#else // Q_OS_MAC || Q_OS_LINUX32 || Q_OS_LINUX64
+#else // Q_OS_UNIX
void SignalHandler(int signum) {
-#endif // else for Q_OS_MAC || Q_OS_LINUX || Q_OS_LINUX64
+#endif // else for Q_OS_UNIX
const char* name = 0;
switch (signum) {
@@ -212,7 +212,7 @@ void SignalHandler(int signum) {
}
// see https://github.com/benbjohnson/bandicoot
-#if defined Q_OS_MAC || defined Q_OS_LINUX32 || defined Q_OS_LINUX64
+#ifdef Q_OS_UNIX
ucontext_t *uc = (ucontext_t*)ucontext;
void *caller = 0;
@@ -276,9 +276,9 @@ void SignalHandler(int signum) {
backtrace_symbols_fd(addresses, size, ReportFileNo);
-#else // Q_OS_MAC || Q_OS_LINUX32 || Q_OS_LINUX64
+#else // Q_OS_UNIX
dump() << "\nBacktrace omitted.\n";
-#endif // else for Q_OS_MAC || Q_OS_LINUX32 || Q_OS_LINUX64
+#endif // else for Q_OS_UNIX
dump() << "\n";
@@ -294,9 +294,9 @@ google_breakpad::ExceptionHandler* BreakpadExceptionHandler = 0;
bool DumpCallback(const wchar_t* _dump_dir, const wchar_t* _minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool success)
#elif defined Q_OS_MAC // Q_OS_WIN
bool DumpCallback(const char* _dump_dir, const char* _minidump_id, void *context, bool success)
-#elif defined Q_OS_LINUX64 || defined Q_OS_LINUX32 // Q_OS_MAC
+#elif defined Q_OS_UNIX // Q_OS_MAC
bool DumpCallback(const google_breakpad::MinidumpDescriptor &md, void *context, bool success)
-#endif // Q_OS_LINUX64 || Q_OS_LINUX32
+#endif // Q_OS_UNIX
{
if (CrashLogged) return success;
CrashLogged = true;
@@ -392,7 +392,7 @@ void StartCatching(not_null launcher) {
crashpad_client.UseHandler();
}
#endif // else for MAC_USE_BREAKPAD
-#elif defined Q_OS_LINUX64 || defined Q_OS_LINUX32
+#elif defined Q_OS_UNIX
BreakpadExceptionHandler = new google_breakpad::ExceptionHandler(
google_breakpad::MinidumpDescriptor(QFile::encodeName(dumpspath).toStdString()),
/*FilterCallback*/ 0,
@@ -401,7 +401,7 @@ void StartCatching(not_null launcher) {
true,
-1
);
-#endif // Q_OS_LINUX64 || Q_OS_LINUX32
+#endif // Q_OS_UNIX
#endif // !DESKTOP_APP_DISABLE_CRASH_REPORTS
}
diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp
index 284fe2609..275597523 100644
--- a/Telegram/SourceFiles/core/launcher.cpp
+++ b/Telegram/SourceFiles/core/launcher.cpp
@@ -291,7 +291,7 @@ void Launcher::init() {
QApplication::setApplicationName(qsl("KotatogramDesktop"));
-#if defined(Q_OS_LINUX) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
+#if defined Q_OS_UNIX && !defined Q_OS_MAC && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QApplication::setDesktopFileName(Platform::GetLauncherFilename());
#endif
diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp
index 22659ec1d..bd80fd2dc 100644
--- a/Telegram/SourceFiles/core/local_url_handlers.cpp
+++ b/Telegram/SourceFiles/core/local_url_handlers.cpp
@@ -392,7 +392,9 @@ bool HandleUnknown(
const auto callback = [=](const MTPDhelp_deepLinkInfo &result) {
const auto text = TextWithEntities{
qs(result.vmessage()),
- Api::EntitiesFromMTP(result.ventities().value_or_empty())
+ Api::EntitiesFromMTP(
+ session,
+ result.ventities().value_or_empty())
};
if (result.is_update_app()) {
const auto box = std::make_shared>();
diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp
index da33fa951..84ad8a668 100644
--- a/Telegram/SourceFiles/core/sandbox.cpp
+++ b/Telegram/SourceFiles/core/sandbox.cpp
@@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "facades.h"
#include "app.h"
+#include
#include
namespace Core {
@@ -84,9 +85,9 @@ Sandbox::Sandbox(
: QApplication(argc, argv)
, _mainThreadId(QThread::currentThreadId())
, _handleObservables([=] {
- Expects(_application != nullptr);
-
- _application->call_handleObservables();
+ if (_application) {
+ _application->call_handleObservables();
+ }
})
, _launcher(launcher) {
}
@@ -132,6 +133,19 @@ int Sandbox::start() {
});
});
+ // https://github.com/telegramdesktop/tdesktop/issues/948
+ // and https://github.com/telegramdesktop/tdesktop/issues/5022
+ const auto restartHint = [](QSessionManager &manager) {
+ manager.setRestartHint(QSessionManager::RestartNever);
+ };
+
+ connect(
+ this,
+ &QGuiApplication::saveStateRequest,
+ this,
+ restartHint,
+ Qt::DirectConnection);
+
if (cManyInstance()) {
LOG(("Many instance allowed, starting..."));
singleInstanceChecked();
diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp
index e330885a3..3596beb9d 100644
--- a/Telegram/SourceFiles/core/ui_integration.cpp
+++ b/Telegram/SourceFiles/core/ui_integration.cpp
@@ -79,68 +79,68 @@ void UiIntegration::startFontsEnd() {
}
std::shared_ptr UiIntegration::createLinkHandler(
- EntityType type,
- const QString &text,
- const QString &data,
- const TextParseOptions &options) {
- switch (type) {
+ const EntityLinkData &data,
+ const std::any &context) {
+ const auto my = std::any_cast(&context);
+ switch (data.type) {
case EntityType::Url:
- return (!data.isEmpty() && UrlClickHandler::IsSuspicious(data))
- ? std::make_shared(data)
- : nullptr;
+ return (!data.data.isEmpty()
+ && UrlClickHandler::IsSuspicious(data.data))
+ ? std::make_shared(data.data)
+ : Integration::createLinkHandler(data, context);
case EntityType::CustomUrl:
- return !data.isEmpty()
- ? std::make_shared(data)
- : nullptr;
+ return !data.data.isEmpty()
+ ? std::make_shared(data.data)
+ : Integration::createLinkHandler(data, context);
case EntityType::BotCommand:
- return std::make_shared(data);
+ return std::make_shared(data.data);
case EntityType::Hashtag:
- if (options.flags & TextTwitterMentions) {
+ if (my && my->type == HashtagMentionType::Twitter) {
return std::make_shared(
(qsl("https://twitter.com/hashtag/")
- + data.mid(1)
+ + data.data.mid(1)
+ qsl("?src=hash")),
true);
- } else if (options.flags & TextInstagramMentions) {
+ } else if (my && my->type == HashtagMentionType::Instagram) {
return std::make_shared(
(qsl("https://instagram.com/explore/tags/")
- + data.mid(1)
+ + data.data.mid(1)
+ '/'),
true);
}
- return std::make_shared(data);
+ return std::make_shared(data.data);
case EntityType::Cashtag:
- return std::make_shared(data);
+ return std::make_shared(data.data);
case EntityType::Mention:
- if (options.flags & TextTwitterMentions) {
+ if (my && my->type == HashtagMentionType::Twitter) {
return std::make_shared(
- qsl("https://twitter.com/") + data.mid(1),
+ qsl("https://twitter.com/") + data.data.mid(1),
true);
- } else if (options.flags & TextInstagramMentions) {
+ } else if (my && my->type == HashtagMentionType::Instagram) {
return std::make_shared(
- qsl("https://instagram.com/") + data.mid(1) + '/',
+ qsl("https://instagram.com/") + data.data.mid(1) + '/',
true);
}
- return std::make_shared(data);
+ return std::make_shared(data.data);
case EntityType::MentionName: {
- auto fields = TextUtilities::MentionNameDataToFields(data);
+ auto fields = TextUtilities::MentionNameDataToFields(data.data);
if (fields.userId) {
return std::make_shared(
- text,
+ data.text,
fields.userId,
fields.accessHash);
} else {
- LOG(("Bad mention name: %1").arg(data));
+ LOG(("Bad mention name: %1").arg(data.data));
}
} break;
}
- return nullptr;
+ return Integration::createLinkHandler(data, context);
}
bool UiIntegration::handleUrlClick(
diff --git a/Telegram/SourceFiles/core/ui_integration.h b/Telegram/SourceFiles/core/ui_integration.h
index 3cb3e191c..f5e9ff1d9 100644
--- a/Telegram/SourceFiles/core/ui_integration.h
+++ b/Telegram/SourceFiles/core/ui_integration.h
@@ -13,6 +13,15 @@ namespace Core {
class UiIntegration : public Ui::Integration {
public:
+ enum class HashtagMentionType : uchar {
+ Telegram,
+ Twitter,
+ Instagram,
+ };
+ struct Context {
+ HashtagMentionType type = HashtagMentionType::Telegram;
+ };
+
void postponeCall(FnMut &&callable) override;
void registerLeaveSubscription(not_null widget) override;
void unregisterLeaveSubscription(not_null widget) override;
@@ -27,10 +36,8 @@ public:
void startFontsEnd() override;
std::shared_ptr createLinkHandler(
- EntityType type,
- const QString &text,
- const QString &data,
- const TextParseOptions &options) override;
+ const EntityLinkData &data,
+ const std::any &context) override;
bool handleUrlClick(
const QString &url,
const QVariant &context) override;
diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp
index ce9eda022..410e52b6c 100644
--- a/Telegram/SourceFiles/core/update_checker.cpp
+++ b/Telegram/SourceFiles/core/update_checker.cpp
@@ -409,9 +409,9 @@ bool UnpackUpdate(const QString &filepath) {
bool executable = false;
stream >> relativeName >> fileSize >> fileInnerData;
-#if defined Q_OS_MAC || defined Q_OS_LINUX
+#ifdef Q_OS_UNIX
stream >> executable;
-#endif // Q_OS_MAC || Q_OS_LINUX
+#endif // Q_OS_UNIX
if (stream.status() != QDataStream::Ok) {
LOG(("Update Error: cant read file from downloaded stream, status: %1").arg(stream.status()));
return false;
@@ -1511,10 +1511,10 @@ bool checkReadyUpdate() {
#elif defined Q_OS_MAC // Q_OS_WIN
QString curUpdater = (cExeDir() + cExeName() + qsl("/Contents/Frameworks/Updater"));
QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Kotatogram.app/Contents/Frameworks/Updater"));
-#elif defined Q_OS_LINUX // Q_OS_MAC
+#elif defined Q_OS_UNIX // Q_OS_MAC
QString curUpdater = (cExeDir() + qsl("Updater"));
QFileInfo updater(cWorkingDir() + qsl("tupdates/temp/Updater"));
-#endif // Q_OS_LINUX
+#endif // Q_OS_UNIX
if (!updater.exists()) {
QFileInfo current(curUpdater);
if (!current.exists()) {
@@ -1548,12 +1548,12 @@ bool checkReadyUpdate() {
ClearAll();
return false;
}
-#elif defined Q_OS_LINUX // Q_OS_MAC
+#elif defined Q_OS_UNIX // Q_OS_MAC
if (!linuxMoveFile(QFile::encodeName(updater.absoluteFilePath()).constData(), QFile::encodeName(curUpdater).constData())) {
ClearAll();
return false;
}
-#endif // Q_OS_LINUX
+#endif // Q_OS_UNIX
#ifdef Q_OS_MAC
Platform::RemoveQuarantine(QFileInfo(curUpdater).absolutePath());
diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h
index 80ab34408..4dbd25fcd 100644
--- a/Telegram/SourceFiles/core/version.h
+++ b/Telegram/SourceFiles/core/version.h
@@ -23,7 +23,7 @@ constexpr auto AppId = "{C4A4AE8F-B9F7-4CC7-8A6C-BF7EEE87ACA5}"_cs;
constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs;
constexpr auto AppName = "Kotatogram Desktop"_cs;
constexpr auto AppFile = "Kotatogram"_cs;
-constexpr auto AppVersion = 2001010;
-constexpr auto AppVersionStr = "2.1.10";
+constexpr auto AppVersion = 2001013;
+constexpr auto AppVersionStr = "2.1.13";
constexpr auto AppBetaVersion = true;
constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION;
diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp
index c7efb41c1..76d270c19 100644
--- a/Telegram/SourceFiles/data/data_document.cpp
+++ b/Telegram/SourceFiles/data/data_document.cpp
@@ -797,7 +797,9 @@ bool DocumentData::saveToCache() const {
|| isAnimation()
|| isVoiceMessage()
|| (type == WallPaperDocument)
- || isTheme());
+ || isTheme()
+ || (mimeString() == qstr("image/png")
+ && _filename.startsWith("image_")));
}
void DocumentData::automaticLoadSettingsChanged() {
@@ -1615,10 +1617,10 @@ bool IsExecutableName(const QString &filepath) {
qsl("\
applescript action app bin command csh osx workflow terminal url caction \
mpkg pkg scpt scptd xhtm webarchive");
-#elif defined Q_OS_LINUX // Q_OS_MAC
+#elif defined Q_OS_UNIX // Q_OS_MAC
qsl("bin csh deb desktop ksh out pet pkg pup rpm run sh shar \
slp zsh");
-#else // Q_OS_MAC || Q_OS_LINUX
+#else // Q_OS_MAC || Q_OS_UNIX
qsl("\
ad ade adp app application appref-ms asp asx bas bat bin cdxml cer cfg chi \
chm cmd cnt com cpl crt csh der diagcab dll drv eml exe fon fxp gadget grp \
@@ -1631,7 +1633,7 @@ psm1 pssc pst py py3 pyc pyd pyi pyo pyw pywz pyz rb reg rgs scf scr sct \
search-ms settingcontent-ms shb shs slk sys t tmp u3p url vb vbe vbp vbs \
vbscript vdx vsmacros vsd vsdm vsdx vss vssm vssx vst vstm vstx vsw vsx vtx \
website ws wsc wsf wsh xbap xll xnk xs");
-#endif // !Q_OS_MAC && !Q_OS_LINUX
+#endif // !Q_OS_MAC && !Q_OS_UNIX
const auto list = joined.split(' ');
return base::flat_set(list.begin(), list.end());
}();
diff --git a/Telegram/SourceFiles/data/data_drafts.cpp b/Telegram/SourceFiles/data/data_drafts.cpp
index 3e11daf77..af02fd8d5 100644
--- a/Telegram/SourceFiles/data/data_drafts.cpp
+++ b/Telegram/SourceFiles/data/data_drafts.cpp
@@ -45,14 +45,19 @@ Draft::Draft(
, previewCancelled(previewCancelled) {
}
-void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
- const auto history = Auth().data().history(peerId);
+void ApplyPeerCloudDraft(
+ not_null session,
+ PeerId peerId,
+ const MTPDdraftMessage &draft) {
+ const auto history = session->data().history(peerId);
const auto textWithTags = TextWithTags {
qs(draft.vmessage()),
TextUtilities::ConvertEntitiesToTextTags(
- Api::EntitiesFromMTP(draft.ventities().value_or_empty()))
+ Api::EntitiesFromMTP(
+ session,
+ draft.ventities().value_or_empty()))
};
- auto replyTo = draft.vreply_to_msg_id().value_or_empty();
+ const auto replyTo = draft.vreply_to_msg_id().value_or_empty();
if (history->skipCloudDraft(textWithTags.text, replyTo, draft.vdate().v)) {
return;
}
@@ -67,8 +72,11 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
history->applyCloudDraft();
}
-void clearPeerCloudDraft(PeerId peerId, TimeId date) {
- const auto history = Auth().data().history(peerId);
+void ClearPeerCloudDraft(
+ not_null session,
+ PeerId peerId,
+ TimeId date) {
+ const auto history = session->data().history(peerId);
if (history->skipCloudDraft(QString(), MsgId(0), date)) {
return;
}
diff --git a/Telegram/SourceFiles/data/data_drafts.h b/Telegram/SourceFiles/data/data_drafts.h
index c3ccdc3f8..57428e62e 100644
--- a/Telegram/SourceFiles/data/data_drafts.h
+++ b/Telegram/SourceFiles/data/data_drafts.h
@@ -11,10 +11,20 @@ namespace Ui {
class InputField;
} // namespace Ui
+namespace Main {
+class Session;
+} // namespace Main
+
namespace Data {
-void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft);
-void clearPeerCloudDraft(PeerId peerId, TimeId date);
+void ApplyPeerCloudDraft(
+ not_null session,
+ PeerId peerId,
+ const MTPDdraftMessage &draft);
+void ClearPeerCloudDraft(
+ not_null session,
+ PeerId peerId,
+ TimeId date);
struct Draft {
Draft() = default;
diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp
index 1b47c63dd..134447224 100644
--- a/Telegram/SourceFiles/data/data_media_types.cpp
+++ b/Telegram/SourceFiles/data/data_media_types.cpp
@@ -244,8 +244,9 @@ TextWithEntities Media::consumedMessageText() const {
}
std::unique_ptr Media::createView(
- not_null message) {
- return createView(message, message->data());
+ not_null message,
+ HistoryView::Element *replacing) {
+ return createView(message, message->data(), replacing);
}
MediaPhoto::MediaPhoto(
@@ -386,7 +387,8 @@ bool MediaPhoto::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaPhoto::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
if (_chat) {
return std::make_unique(
message,
@@ -663,11 +665,15 @@ bool MediaFile::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaFile::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
if (_document->sticker()) {
return std::make_unique(
message,
- std::make_unique(message, _document));
+ std::make_unique(
+ message,
+ _document,
+ replacing));
} else if (_document->isAnimation() || _document->isVideoFile()) {
return std::make_unique(
message,
@@ -760,7 +766,8 @@ bool MediaContact::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaContact::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(
message,
_contact.userId,
@@ -840,7 +847,8 @@ bool MediaLocation::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaLocation::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(
message,
_location,
@@ -900,7 +908,8 @@ bool MediaCall::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaCall::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(message, &_call);
}
@@ -995,7 +1004,8 @@ bool MediaWebPage::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaWebPage::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(message, _page);
}
@@ -1086,7 +1096,8 @@ bool MediaGame::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaGame::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(
message,
_game,
@@ -1151,7 +1162,8 @@ bool MediaInvoice::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaInvoice::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(message, &_invoice);
}
@@ -1217,7 +1229,8 @@ bool MediaPoll::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaPoll::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(message, _poll);
}
@@ -1274,7 +1287,8 @@ bool MediaDice::updateSentMedia(const MTPMessageMedia &media) {
std::unique_ptr MediaDice::createView(
not_null message,
- not_null realParent) {
+ not_null realParent,
+ HistoryView::Element *replacing) {
return std::make_unique(
message,
std::make_unique(message, this));
diff --git a/Telegram/SourceFiles/data/data_media_types.h b/Telegram/SourceFiles/data/data_media_types.h
index ab09b28f4..dfae6ce8c 100644
--- a/Telegram/SourceFiles/data/data_media_types.h
+++ b/Telegram/SourceFiles/data/data_media_types.h
@@ -111,9 +111,11 @@ public:
virtual bool updateSentMedia(const MTPMessageMedia &media) = 0;
virtual std::unique_ptr createView(
not_null message,
- not_null realParent) = 0;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) = 0;
std::unique_ptr createView(
- not_null message);
+ not_null message,
+ HistoryView::Element *replacing = nullptr);
private:
const not_null _parent;
@@ -152,7 +154,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
not_null _photo;
@@ -189,7 +192,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
not_null _document;
@@ -218,7 +222,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
SharedContact _contact;
@@ -248,7 +253,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
LocationPoint _point;
@@ -276,7 +282,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
static QString Text(
not_null item,
@@ -312,7 +319,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
not_null _page;
@@ -343,7 +351,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
not_null _game;
@@ -374,7 +383,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
Invoice _invoice;
@@ -401,7 +411,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
not_null _poll;
@@ -425,7 +436,8 @@ public:
bool updateSentMedia(const MTPMessageMedia &media) override;
std::unique_ptr createView(
not_null message,
- not_null realParent) override;
+ not_null realParent,
+ HistoryView::Element *replacing = nullptr) override;
private:
QString _emoji;
diff --git a/Telegram/SourceFiles/data/data_poll.cpp b/Telegram/SourceFiles/data/data_poll.cpp
index 3bb520a7d..e31c2145d 100644
--- a/Telegram/SourceFiles/data/data_poll.cpp
+++ b/Telegram/SourceFiles/data/data_poll.cpp
@@ -45,6 +45,14 @@ PollData::PollData(not_null owner, PollId id)
, _owner(owner) {
}
+Data::Session &PollData::owner() const {
+ return *_owner;
+}
+
+Main::Session &PollData::session() const {
+ return _owner->session();
+}
+
bool PollData::closeByTimer() {
if (closed()) {
return false;
@@ -151,6 +159,7 @@ bool PollData::applyResults(const MTPPollResults &results) {
auto newSolution = TextWithEntities{
results.vsolution().value_or_empty(),
Api::EntitiesFromMTP(
+ &_owner->session(),
results.vsolution_entities().value_or_empty())
};
if (solution != newSolution) {
@@ -293,6 +302,7 @@ MTPInputMedia PollDataToInputMedia(
TextUtilities::PrepareForSending(solution, prepareFlags);
TextUtilities::Trim(solution);
const auto sentEntities = Api::EntitiesToMTP(
+ &poll->session(),
solution.entities,
Api::ConvertOption::SkipLocal);
if (!solution.text.isEmpty()) {
diff --git a/Telegram/SourceFiles/data/data_poll.h b/Telegram/SourceFiles/data/data_poll.h
index 19c4e59e4..9a0229983 100644
--- a/Telegram/SourceFiles/data/data_poll.h
+++ b/Telegram/SourceFiles/data/data_poll.h
@@ -11,6 +11,10 @@ namespace Data {
class Session;
} // namespace Data
+namespace Main {
+class Session;
+} // namespace Main
+
struct PollAnswer {
QString text;
QByteArray option;
@@ -31,6 +35,9 @@ inline bool operator!=(const PollAnswer &a, const PollAnswer &b) {
struct PollData {
PollData(not_null owner, PollId id);
+ [[nodiscard]] Data::Session &owner() const;
+ [[nodiscard]] Main::Session &session() const;
+
enum class Flag {
Closed = 0x01,
PublicVotes = 0x02,
diff --git a/Telegram/SourceFiles/data/data_scheduled_messages.cpp b/Telegram/SourceFiles/data/data_scheduled_messages.cpp
index 75b725b3e..3e49bf176 100644
--- a/Telegram/SourceFiles/data/data_scheduled_messages.cpp
+++ b/Telegram/SourceFiles/data/data_scheduled_messages.cpp
@@ -152,7 +152,7 @@ void ScheduledMessages::sendNowSimpleMessage(
// we know for sure that a message can't have fields such as the author,
// views count, etc.
- const auto &history = local->history();
+ const auto history = local->history();
auto flags = NewMessageFlags(history->peer)
| MTPDmessage::Flag::f_entities
| MTPDmessage::Flag::f_from_id
@@ -175,7 +175,9 @@ void ScheduledMessages::sendNowSimpleMessage(
MTP_string(local->originalText().text),
MTP_messageMediaEmpty(),
MTPReplyMarkup(),
- Api::EntitiesToMTP(local->originalText().entities),
+ Api::EntitiesToMTP(
+ &history->session(),
+ local->originalText().entities),
MTP_int(1),
MTPint(),
MTP_string(),
@@ -234,7 +236,7 @@ void ScheduledMessages::checkEntitiesAndUpdate(const MTPDmessage &data) {
Assert(existing->date() == kScheduledUntilOnlineTimestamp);
existing->updateSentContent({
qs(data.vmessage()),
- Api::EntitiesFromMTP(data.ventities().value_or_empty())
+ Api::EntitiesFromMTP(_session, data.ventities().value_or_empty())
}, data.vmedia());
existing->updateReplyMarkup(data.vreply_markup());
existing->updateForwardedInfo(data.vfwd_from());
@@ -410,7 +412,9 @@ HistoryItem *ScheduledMessages::append(
message.match([&](const MTPDmessage &data) {
existing->updateSentContent({
qs(data.vmessage()),
- Api::EntitiesFromMTP(data.ventities().value_or_empty())
+ Api::EntitiesFromMTP(
+ _session,
+ data.ventities().value_or_empty())
}, data.vmedia());
existing->updateReplyMarkup(data.vreply_markup());
existing->updateForwardedInfo(data.vfwd_from());
diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp
index 64fddfbe5..2d0af620e 100644
--- a/Telegram/SourceFiles/data/data_session.cpp
+++ b/Telegram/SourceFiles/data/data_session.cpp
@@ -1703,7 +1703,9 @@ bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
if (const auto existing = message(peerToChannel(peer), data.vid().v)) {
existing->updateSentContent({
qs(data.vmessage()),
- Api::EntitiesFromMTP(data.ventities().value_or_empty())
+ Api::EntitiesFromMTP(
+ &session(),
+ data.ventities().value_or_empty())
}, data.vmedia());
existing->updateReplyMarkup(data.vreply_markup());
existing->updateForwardedInfo(data.vfwd_from());
@@ -3725,7 +3727,7 @@ void Session::insertCheckedServiceNotification(
MTP_string(sending.text),
media,
MTPReplyMarkup(),
- Api::EntitiesToMTP(sending.entities),
+ Api::EntitiesToMTP(&session(), sending.entities),
MTPint(),
MTPint(),
MTPstring(),
diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp
index 87de0e09c..cf0d6edc6 100644
--- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp
+++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp
@@ -538,13 +538,15 @@ HistoryView::Context InnerWidget::elementContext() {
}
std::unique_ptr InnerWidget::elementCreate(
- not_null message) {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing) {
+ return std::make_unique(this, message, replacing);
}
std::unique_ptr InnerWidget::elementCreate(
- not_null message) {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing) {
+ return std::make_unique(this, message, replacing);
}
bool InnerWidget::elementUnderCursor(
@@ -1535,13 +1537,13 @@ void InnerWidget::mouseActionFinish(const QPoint &screenPos, Qt::MouseButton but
_mouseSelectType = TextSelectType::Letters;
//_widget->noSelectingScroll(); // TODO
-#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
+#if defined Q_OS_UNIX && !defined Q_OS_MAC
if (_selectedItem && _selectedText.from != _selectedText.to) {
TextUtilities::SetClipboardText(
_selectedItem->selectedText(_selectedText),
QClipboard::Selection);
}
-#endif // Q_OS_LINUX32 || Q_OS_LINUX64
+#endif // Q_OS_UNIX && !Q_OS_MAC
}
void InnerWidget::updateSelected() {
diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h
index 3d2d228e4..9ed7773b5 100644
--- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h
+++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h
@@ -89,9 +89,11 @@ public:
// HistoryView::ElementDelegate interface.
HistoryView::Context elementContext() override;
std::unique_ptr elementCreate(
- not_null message) override;
+ not_null message,
+ HistoryView::Element *replacing = nullptr) override;
std::unique_ptr elementCreate(
- not_null message) override;
+ not_null message,
+ HistoryView::Element *replacing = nullptr) override;
bool elementUnderCursor(
not_null view) override;
void elementAnimationAutoplayAsync(
diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp
index eef73cdf3..8b73e684d 100644
--- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp
+++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp
@@ -111,14 +111,16 @@ bool MediaCanHaveCaption(const MTPMessage &message) {
return (mediaType == mtpc_messageMediaDocument || mediaType == mtpc_messageMediaPhoto);
}
-TextWithEntities ExtractEditedText(const MTPMessage &message) {
+TextWithEntities ExtractEditedText(
+ not_null session,
+ const MTPMessage &message) {
if (message.type() != mtpc_message) {
return TextWithEntities();
}
const auto &data = message.c_message();
return {
TextUtilities::Clean(qs(data.vmessage())),
- Api::EntitiesFromMTP(data.ventities().value_or_empty())
+ Api::EntitiesFromMTP(session, data.ventities().value_or_empty())
};
}
@@ -376,19 +378,20 @@ void GenerateItems(
Fn callback) {
Expects(history->peer->isChannel());
- auto id = event.vid().v;
- auto from = Auth().data().user(event.vuser_id().v);
- auto channel = history->peer->asChannel();
- auto &action = event.vaction();
- auto date = event.vdate().v;
- auto addPart = [&](not_null item) {
+ const auto session = &history->session();
+ const auto id = event.vid().v;
+ const auto from = Auth().data().user(event.vuser_id().v);
+ const auto channel = history->peer->asChannel();
+ const auto &action = event.vaction();
+ const auto date = event.vdate().v;
+ const auto addPart = [&](not_null item) {
return callback(OwnedItem(delegate, item));
};
using Flag = MTPDmessage::Flag;
- auto fromName = from->name;
- auto fromLink = from->createOpenLink();
- auto fromLinkText = textcmdLink(1, fromName);
+ const auto fromName = from->name;
+ const auto fromLink = from->createOpenLink();
+ const auto fromLinkText = textcmdLink(1, fromName);
auto addSimpleServiceMessage = [&](const QString &text, PhotoData *photo = nullptr) {
auto message = HistoryService::PreparedText { text };
@@ -542,7 +545,7 @@ void GenerateItems(
};
auto createEditMessage = [&](const MTPDchannelAdminLogEventActionEditMessage &action) {
- auto newValue = ExtractEditedText(action.vnew_message());
+ auto newValue = ExtractEditedText(session, action.vnew_message());
auto canHaveCaption = MediaCanHaveCaption(action.vnew_message());
auto text = (!canHaveCaption
? tr::lng_admin_log_edited_message
@@ -554,7 +557,7 @@ void GenerateItems(
fromLinkText);
addSimpleServiceMessage(text);
- auto oldValue = ExtractEditedText(action.vprev_message());
+ auto oldValue = ExtractEditedText(session, action.vprev_message());
auto detachExistingItem = false;
auto body = history->createItem(
PrepareLogMessage(
diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp
index e8fee9386..96b1f786e 100644
--- a/Telegram/SourceFiles/history/history.cpp
+++ b/Telegram/SourceFiles/history/history.cpp
@@ -2700,7 +2700,10 @@ void History::applyDialog(
const auto draft = data.vdraft();
if (draft && draft->type() == mtpc_draftMessage) {
- Data::applyPeerCloudDraft(peer->id, draft->c_draftMessage());
+ Data::ApplyPeerCloudDraft(
+ &session(),
+ peer->id,
+ draft->c_draftMessage());
}
owner().histories().dialogEntryApplied(this);
}
@@ -3361,7 +3364,9 @@ void HistoryBlock::refreshView(not_null view) {
Expects(view->block() == this);
const auto item = view->data();
- auto refreshed = item->createView(HistoryInner::ElementDelegate());
+ auto refreshed = item->createView(
+ HistoryInner::ElementDelegate(),
+ view);
auto blockIndex = indexInHistory();
auto itemIndex = view->indexInBlock();
diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp
index d3bc4ccbb..a4c1fc707 100644
--- a/Telegram/SourceFiles/history/history_inner_widget.cpp
+++ b/Telegram/SourceFiles/history/history_inner_widget.cpp
@@ -1427,7 +1427,7 @@ void HistoryInner::mouseActionFinish(
_widget->noSelectingScroll();
_widget->updateTopBarSelection();
-#if defined Q_OS_LINUX32 || defined Q_OS_LINUX64
+#if defined Q_OS_UNIX && !defined Q_OS_MAC
if (!_selected.empty() && _selected.cbegin()->second != FullSelection) {
const auto [item, selection] = *_selected.cbegin();
if (const auto view = item->mainView()) {
@@ -1436,7 +1436,7 @@ void HistoryInner::mouseActionFinish(
QClipboard::Selection);
}
}
-#endif // Q_OS_LINUX32 || Q_OS_LINUX64
+#endif // Q_OS_UNIX && !Q_OS_MAC
}
void HistoryInner::mouseReleaseEvent(QMouseEvent *e) {
@@ -2373,7 +2373,7 @@ HistoryInner::~HistoryInner() {
for (const auto &item : _animatedStickersPlayed) {
if (const auto view = item->mainView()) {
if (const auto media = view->media()) {
- media->clearStickerLoopPlayed();
+ media->stickerClearLoopPlayed();
}
}
}
@@ -3323,12 +3323,20 @@ not_null HistoryInner::ElementDelegate() {
return HistoryView::Context::History;
}
std::unique_ptr elementCreate(
- not_null message) override {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing = nullptr) override {
+ return std::make_unique(
+ this,
+ message,
+ replacing);
}
std::unique_ptr elementCreate(
- not_null message) override {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing = nullptr) override {
+ return std::make_unique(
+ this,
+ message,
+ replacing);
}
bool elementUnderCursor(
not_null view) override {
diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h
index 20ec30e1e..1310c283c 100644
--- a/Telegram/SourceFiles/history/history_item.h
+++ b/Telegram/SourceFiles/history/history_item.h
@@ -326,7 +326,8 @@ public:
[[nodiscard]] PeerData *displayFrom() const;
[[nodiscard]] virtual std::unique_ptr createView(
- not_null delegate) = 0;
+ not_null delegate,
+ HistoryView::Element *replacing = nullptr) = 0;
void updateDate(TimeId newDate);
[[nodiscard]] bool canUpdateDate() const;
diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp
index 6a2232b7c..595f287ed 100644
--- a/Telegram/SourceFiles/history/history_message.cpp
+++ b/Telegram/SourceFiles/history/history_message.cpp
@@ -458,7 +458,9 @@ HistoryMessage::HistoryMessage(
}
const auto textWithEntities = TextWithEntities{
TextUtilities::Clean(qs(data.vmessage())),
- Api::EntitiesFromMTP(data.ventities().value_or_empty())
+ Api::EntitiesFromMTP(
+ &history->session(),
+ data.ventities().value_or_empty())
};
setText(_media ? textWithEntities : EnsureNonEmpty(textWithEntities));
if (const auto groupedId = data.vgrouped_id()) {
@@ -1072,7 +1074,9 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) {
const auto textWithEntities = TextWithEntities{
qs(message.vmessage()),
- Api::EntitiesFromMTP(message.ventities().value_or_empty())
+ Api::EntitiesFromMTP(
+ &history()->session(),
+ message.ventities().value_or_empty())
};
setReplyMarkup(message.vreply_markup());
if (!isLocalUpdateMedia()) {
@@ -1383,8 +1387,9 @@ QString HistoryMessage::notificationHeader() const {
}
std::unique_ptr HistoryMessage::createView(
- not_null delegate) {
- return delegate->elementCreate(this);
+ not_null delegate,
+ HistoryView::Element *replacing) {
+ return delegate->elementCreate(this, replacing);
}
HistoryMessage::~HistoryMessage() {
diff --git a/Telegram/SourceFiles/history/history_message.h b/Telegram/SourceFiles/history/history_message.h
index 8b783edf9..52718a245 100644
--- a/Telegram/SourceFiles/history/history_message.h
+++ b/Telegram/SourceFiles/history/history_message.h
@@ -168,7 +168,8 @@ public:
}
[[nodiscard]] std::unique_ptr createView(
- not_null delegate) override;
+ not_null delegate,
+ HistoryView::Element *replacing = nullptr) override;
~HistoryMessage();
diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp
index 7c45e1691..4109aa92f 100644
--- a/Telegram/SourceFiles/history/history_service.cpp
+++ b/Telegram/SourceFiles/history/history_service.cpp
@@ -570,8 +570,9 @@ QString HistoryService::inReplyText() const {
}
std::unique_ptr HistoryService::createView(
- not_null delegate) {
- return delegate->elementCreate(this);
+ not_null delegate,
+ HistoryView::Element *replacing) {
+ return delegate->elementCreate(this, replacing);
}
QString HistoryService::fromLinkText() const {
diff --git a/Telegram/SourceFiles/history/history_service.h b/Telegram/SourceFiles/history/history_service.h
index fe06d26ad..0b68c1842 100644
--- a/Telegram/SourceFiles/history/history_service.h
+++ b/Telegram/SourceFiles/history/history_service.h
@@ -105,7 +105,8 @@ public:
QString inReplyText() const override;
std::unique_ptr createView(
- not_null delegate) override;
+ not_null delegate,
+ HistoryView::Element *replacing = nullptr) override;
~HistoryService();
diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp
index c042f2ed7..3589304b6 100644
--- a/Telegram/SourceFiles/history/history_widget.cpp
+++ b/Telegram/SourceFiles/history/history_widget.cpp
@@ -65,6 +65,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/tabbed_section.h"
#include "chat_helpers/bot_keyboard.h"
#include "chat_helpers/message_field.h"
+#include "platform/platform_specific.h"
#include "lang/lang_keys.h"
#include "mainwidget.h"
#include "mainwindow.h"
@@ -2102,6 +2103,7 @@ void HistoryWidget::refreshScheduledToggle() {
controller()->showSection(
HistoryView::ScheduledMemento(_history));
});
+ orderWidgets(); // Raise drag areas to the top.
}
}
}
@@ -3068,8 +3070,9 @@ void HistoryWidget::saveEditMsg() {
if (webPageId == CancelledWebPageId) {
sendFlags |= MTPmessages_EditMessage::Flag::f_no_webpage;
}
- auto localEntities = Api::EntitiesToMTP(sending.entities);
+ auto localEntities = Api::EntitiesToMTP(&session(), sending.entities);
auto sentEntities = Api::EntitiesToMTP(
+ &session(),
sending.entities,
Api::ConvertOption::SkipLocal);
if (!sentEntities.v.isEmpty()) {
@@ -4605,7 +4608,10 @@ bool HistoryWidget::confirmSendingFiles(
}
if (hasImage) {
- auto image = qvariant_cast(data->imageData());
+ auto image = Platform::GetImageFromClipboard();
+ if (image.isNull()) {
+ image = qvariant_cast(data->imageData());
+ }
if (!image.isNull()) {
confirmSendingFiles(
std::move(image),
@@ -4755,7 +4761,7 @@ void HistoryWidget::sendFileConfirmed(
session().user()).flags;
TextUtilities::PrepareForSending(caption, prepareFlags);
TextUtilities::Trim(caption);
- auto localEntities = Api::EntitiesToMTP(caption.entities);
+ auto localEntities = Api::EntitiesToMTP(&session(), caption.entities);
if (itemToEdit) {
if (const auto id = itemToEdit->groupId()) {
diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp
index a443315f0..b8ec2414a 100644
--- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp
@@ -430,12 +430,17 @@ bool AddRescheduleMessageAction(
? SendMenuType::ScheduledToUser
: SendMenuType::Scheduled;
+ using S = Data::ScheduledMessages;
+ const auto date = (item->date() == S::kScheduledUntilOnlineTimestamp)
+ ? HistoryView::DefaultScheduleTime()
+ : item->date() + 600;
+
Ui::show(
HistoryView::PrepareScheduleBox(
&request.navigation->session(),
sendMenuType,
callback,
- item->date() + 600),
+ date),
Ui::LayerOption::KeepOther);
});
return true;
diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp
index a9c03aa94..340913111 100644
--- a/Telegram/SourceFiles/history/view/history_view_element.cpp
+++ b/Telegram/SourceFiles/history/view/history_view_element.cpp
@@ -56,13 +56,15 @@ bool IsAttachedToPreviousInSavedMessages(
std::unique_ptr SimpleElementDelegate::elementCreate(
- not_null message) {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing) {
+ return std::make_unique(this, message, replacing);
}
std::unique_ptr SimpleElementDelegate::elementCreate(
- not_null message) {
- return std::make_unique(this, message);
+ not_null message,
+ Element *replacing) {
+ return std::make_unique(this, message, replacing);
}
bool SimpleElementDelegate::elementUnderCursor(
@@ -203,14 +205,15 @@ void DateBadge::paint(Painter &p, int y, int w) const {
Element::Element(
not_null delegate,
- not_null data)
+ not_null data,
+ Element *replacing)
: _delegate(delegate)
, _data(data)
, _isScheduledUntilOnline(IsItemScheduledUntilOnline(data))
, _dateTime(_isScheduledUntilOnline ? QDateTime() : ItemDateTime(data))
, _context(delegate->elementContext()) {
history()->owner().registerItemView(this);
- refreshMedia();
+ refreshMedia(replacing);
if (_context == Context::History) {
history()->setHasPendingResizedItems();
}
@@ -342,7 +345,7 @@ bool Element::isHidden() const {
return isHiddenByGroup();
}
-void Element::refreshMedia() {
+void Element::refreshMedia(Element *replacing) {
_flags &= ~Flag::HiddenByGroup;
const auto item = data();
@@ -365,7 +368,7 @@ void Element::refreshMedia() {
}
const auto session = &history()->session();
if (const auto media = _data->media()) {
- _media = media->createView(this);
+ _media = media->createView(this, replacing);
} else if (_data->isIsolatedEmoji()
&& session->settings().largeEmoji()) {
const auto emoji = _data->isolatedEmoji();
@@ -376,6 +379,7 @@ void Element::refreshMedia() {
std::make_unique(
this,
sticker.document,
+ replacing,
sticker.replacements));
} else {
_media = std::make_unique(
diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h
index c14a6347c..e28215c07 100644
--- a/Telegram/SourceFiles/history/view/history_view_element.h
+++ b/Telegram/SourceFiles/history/view/history_view_element.h
@@ -37,9 +37,11 @@ class ElementDelegate {
public:
virtual Context elementContext() = 0;
virtual std::unique_ptr elementCreate(
- not_null message) = 0;
+ not_null message,
+ Element *replacing = nullptr) = 0;
virtual std::unique_ptr elementCreate(
- not_null message) = 0;
+ not_null message,
+ Element *replacing = nullptr) = 0;
virtual bool elementUnderCursor(not_null view) = 0;
virtual void elementAnimationAutoplayAsync(
not_null element) = 0;
@@ -63,9 +65,11 @@ public:
class SimpleElementDelegate : public ElementDelegate {
public:
std::unique_ptr elementCreate(
- not_null message) override;
+ not_null message,
+ Element *replacing = nullptr) override;
std::unique_ptr elementCreate(
- not_null message) override;
+ not_null message,
+ Element *replacing = nullptr) override;
bool elementUnderCursor(not_null view) override;
void elementAnimationAutoplayAsync(
not_null element) override;
@@ -134,7 +138,8 @@ class Element
public:
Element(
not_null delegate,
- not_null data);
+ not_null data,
+ Element *replacing);
enum class Flag : uchar {
NeedsResize = 0x01,
@@ -305,7 +310,7 @@ private:
virtual QSize performCountOptimalSize() = 0;
virtual QSize performCountCurrentSize(int newWidth) = 0;
- void refreshMedia();
+ void refreshMedia(Element *replacing);
const not_null _delegate;
const not_null