From 6c9d5e1499cc6fb1479371e6c0da1dae13917c93 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Apr 2024 19:04:09 +0400 Subject: [PATCH 01/38] Improve clipboard QR code image logo quality. --- Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index 7b80e2652..8f67b6ba4 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -227,9 +227,9 @@ QImage QrExact(const Qr::Data &data, int pixel, QColor color) { p.drawImage( skip, skip, - Intro::details::TelegramLogoImage().scaled( - logoSize * style::DevicePixelRatio(), - logoSize * style::DevicePixelRatio(), + Window::LogoNoMargin().scaled( + logoSize, + logoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } From fe06cd63ac0c07cc833abb20d5b63e3ffdd12d48 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Apr 2024 19:16:00 +0400 Subject: [PATCH 02/38] Lock event loop --- Telegram/SourceFiles/core/sandbox.cpp | 1 - Telegram/SourceFiles/core/sandbox.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp index 6feacdb5b..3daf91784 100644 --- a/Telegram/SourceFiles/core/sandbox.cpp +++ b/Telegram/SourceFiles/core/sandbox.cpp @@ -82,7 +82,6 @@ bool Sandbox::QuitOnStartRequested = false; Sandbox::Sandbox(int &argc, char **argv) : QApplication(argc, argv) , _mainThreadId(QThread::currentThreadId()) { - setQuitOnLastWindowClosed(false); } int Sandbox::start() { diff --git a/Telegram/SourceFiles/core/sandbox.h b/Telegram/SourceFiles/core/sandbox.h index 4c15c2828..dfb1fe4a6 100644 --- a/Telegram/SourceFiles/core/sandbox.h +++ b/Telegram/SourceFiles/core/sandbox.h @@ -107,6 +107,7 @@ private: void readClients(); void removeClients(); + QEventLoopLocker _eventLoopLocker; const Qt::HANDLE _mainThreadId = nullptr; int _eventNestingLevel = 0; int _loopNestingLevel = 0; From 11b57ff7d3b61684daf03b350d90e5f8d68c24b1 Mon Sep 17 00:00:00 2001 From: Nyan <93275906+el-garro@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:30:52 -0400 Subject: [PATCH 03/38] Update data_document_resolver.cpp The correct python zipapp extension on windows is pyzw, this typo could lead to executing code in the client device without proper warning --- Telegram/SourceFiles/data/data_document_resolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 8ab502564..b7dc51e2c 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -169,7 +169,7 @@ lnk local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf mda \ mdb mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml \ msh2xml mshxml msi msp mst ops osd paf pcd phar php php3 php4 php5 php7 phps \ php-s pht phtml pif pl plg pm pod prf prg ps1 ps2 ps1xml ps2xml psc1 psc2 \ -psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pywz pyz rb reg rgs scf scr \ +psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pyzw pyz rb reg rgs scf scr \ sct search-ms settingcontent-ms sh 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"_q; From 90405f3ebc981ebd789887a235bd311a62eb876a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Apr 2024 23:40:32 +0400 Subject: [PATCH 04/38] Install protobuf in Docker --- Telegram/build/docker/centos_env/Dockerfile | 9 +++++---- cmake | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 92cd7bf31..47164dc3e 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -90,10 +90,11 @@ RUN git clone -b v21.9 --depth=1 --recursive {{ GIT }}/protocolbuffers/protobuf. -Dprotobuf_BUILD_TESTS=OFF \ -Dprotobuf_BUILD_PROTOBUF_BINARIES=ON \ -Dprotobuf_BUILD_LIBPROTOC=ON \ - -Dprotobuf_WITH_ZLIB_DEFAULT=OFF \ - -Dprotobuf_DEBUG_POSTFIX="" \ + -Dprotobuf_WITH_ZLIB=OFF \ && cmake --build build --parallel \ - && rm -rf .git + && DESTDIR="{{ LibrariesPath }}/protobuf-cache" cmake --install build \ + && cd .. \ + && rm -rf protobuf FROM builder AS lcms2 RUN git clone -b lcms2.15 --depth=1 {{ GIT }}/mm2/Little-CMS.git \ @@ -800,7 +801,7 @@ RUN cmake --build out --config Debug --parallel \ FROM builder-base COPY --link --from=zlib {{ LibrariesPath }}/zlib-cache / COPY --link --from=xz {{ LibrariesPath }}/xz-cache / -COPY --link --from=protobuf {{ LibrariesPath }}/protobuf protobuf +COPY --link --from=protobuf {{ LibrariesPath }}/protobuf-cache / COPY --link --from=lcms2 {{ LibrariesPath }}/lcms2-cache / COPY --link --from=brotli {{ LibrariesPath }}/brotli-cache / COPY --link --from=highway {{ LibrariesPath }}/highway-cache / diff --git a/cmake b/cmake index f921cb6ab..bf157ab03 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit f921cb6aba9ada6099b3f9c8c237986ecda238f5 +Subproject commit bf157ab03f3d07c3822dcdd3e3f90a8e4ccb7d66 From 5e546d1198fd368019230496265714393bb03e68 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Apr 2024 04:14:07 +0400 Subject: [PATCH 05/38] Update libjxl in Docker & snap --- Telegram/build/docker/centos_env/Dockerfile | 2 +- snap/snapcraft.yaml | 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 47164dc3e..964684ab8 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -263,7 +263,7 @@ COPY --link --from=lcms2 {{ LibrariesPath }}/lcms2-cache / COPY --link --from=brotli {{ LibrariesPath }}/brotli-cache / COPY --link --from=highway {{ LibrariesPath }}/highway-cache / -RUN git clone -b v0.8.2 --depth=1 {{ GIT }}/libjxl/libjxl.git \ +RUN git clone -b v0.10.2 --depth=1 {{ GIT }}/libjxl/libjxl.git \ && cd libjxl \ && cmake -GNinja -B build . \ -DCMAKE_BUILD_TYPE=None \ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 574d3c996..8a122ab95 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -246,7 +246,7 @@ parts: libjxl: source: https://github.com/libjxl/libjxl.git source-depth: 1 - source-tag: v0.8.2 + source-tag: v0.10.2 plugin: cmake build-environment: - LDFLAGS: ${LDFLAGS:+$LDFLAGS} -s From a1e2e3d011ad32413833a665447b23b955c2495e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Apr 2024 23:41:01 +0400 Subject: [PATCH 06/38] Replace mozjpeg with jpegli in Docker --- Telegram/build/docker/centos_env/Dockerfile | 26 +++++++-------------- cmake | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 964684ab8..28d1095d5 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -132,19 +132,6 @@ RUN git clone -b 1.0.7 --depth=1 {{ GIT }}/google/highway.git \ && cd .. \ && rm -rf highway -FROM builder AS mozjpeg -RUN git clone -b v4.1.4 --depth=1 {{ GIT }}/mozilla/mozjpeg.git \ - && cd mozjpeg \ - && cmake -GNinja -B build . \ - -DCMAKE_BUILD_TYPE=None \ - -DCMAKE_INSTALL_PREFIX=/usr/local \ - -DWITH_JPEG8=ON \ - -DPNG_SUPPORTED=OFF \ - && cmake --build build --parallel \ - && DESTDIR="{{ LibrariesPath }}/mozjpeg-cache" cmake --install build \ - && cd .. \ - && rm -rf mozjpeg - FROM builder AS opus RUN git clone -b v1.4 --depth=1 {{ GIT }}/xiph/opus.git \ && cd opus \ @@ -265,13 +252,14 @@ COPY --link --from=highway {{ LibrariesPath }}/highway-cache / RUN git clone -b v0.10.2 --depth=1 {{ GIT }}/libjxl/libjxl.git \ && cd libjxl \ + && git submodule update --init --recursive --depth=1 third_party/libjpeg-turbo \ && cmake -GNinja -B build . \ -DCMAKE_BUILD_TYPE=None \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_TESTING=OFF \ -DJPEGXL_ENABLE_DEVTOOLS=OFF \ -DJPEGXL_ENABLE_TOOLS=OFF \ - -DJPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF \ + -DJPEGXL_INSTALL_JPEGLI_LIBJPEG=ON \ -DJPEGXL_ENABLE_DOXYGEN=OFF \ -DJPEGXL_ENABLE_MANPAGES=OFF \ -DJPEGXL_ENABLE_BENCHMARK=OFF \ @@ -281,7 +269,10 @@ RUN git clone -b v0.10.2 --depth=1 {{ GIT }}/libjxl/libjxl.git \ -DJPEGXL_ENABLE_OPENEXR=OFF \ -DJPEGXL_ENABLE_SKCMS=OFF \ && cmake --build build --parallel \ - && DESTDIR="{{ LibrariesPath }}/libjxl-cache" cmake --install build \ + && export DESTDIR="{{ LibrariesPath }}/libjxl-cache" \ + && cmake --install build \ + && cp build/lib/libjpegli-static.a $DESTDIR/usr/local/lib64/libjpeg.a \ + && ar rcs $DESTDIR/usr/local/lib64/libjpeg.a build/lib/CMakeFiles/jpegli-libjpeg-obj.dir/jpegli/libjpeg_wrapper.cc.o \ && cd .. \ && rm -rf libjxl @@ -704,7 +695,7 @@ RUN git clone -b 1.78.1 --depth=1 {{ GIT }}/GNOME/gobject-introspection.git \ FROM patches AS qt COPY --link --from=zlib {{ LibrariesPath }}/zlib-cache / COPY --link --from=lcms2 {{ LibrariesPath }}/lcms2-cache / -COPY --link --from=mozjpeg {{ LibrariesPath }}/mozjpeg-cache / +COPY --link --from=libjxl {{ LibrariesPath }}/libjxl-cache / COPY --link --from=xcb {{ LibrariesPath }}/xcb-cache / COPY --link --from=xcb-wm {{ LibrariesPath }}/xcb-wm-cache / COPY --link --from=xcb-util {{ LibrariesPath }}/xcb-util-cache / @@ -757,9 +748,9 @@ RUN git clone -b v2023.06.01 --depth=1 https://chromium.googlesource.com/breakpa && rm -rf breakpad FROM builder AS webrtc -COPY --link --from=mozjpeg {{ LibrariesPath }}/mozjpeg-cache / COPY --link --from=opus {{ LibrariesPath }}/opus-cache / COPY --link --from=libvpx {{ LibrariesPath }}/libvpx-cache / +COPY --link --from=libjxl {{ LibrariesPath }}/libjxl-cache / COPY --link --from=ffmpeg {{ LibrariesPath }}/ffmpeg-cache / COPY --link --from=openssl {{ LibrariesPath }}/openssl-cache / COPY --link --from=libXtst {{ LibrariesPath }}/libXtst-cache / @@ -805,7 +796,6 @@ COPY --link --from=protobuf {{ LibrariesPath }}/protobuf-cache / COPY --link --from=lcms2 {{ LibrariesPath }}/lcms2-cache / COPY --link --from=brotli {{ LibrariesPath }}/brotli-cache / COPY --link --from=highway {{ LibrariesPath }}/highway-cache / -COPY --link --from=mozjpeg {{ LibrariesPath }}/mozjpeg-cache / COPY --link --from=opus {{ LibrariesPath }}/opus-cache / COPY --link --from=dav1d {{ LibrariesPath }}/dav1d-cache / COPY --link --from=libde265 {{ LibrariesPath }}/libde265-cache / diff --git a/cmake b/cmake index bf157ab03..621b01ec9 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit bf157ab03f3d07c3822dcdd3e3f90a8e4ccb7d66 +Subproject commit 621b01ec9bd7f953223147daf59ab4c850cb3c40 From f57e2edf2af61a285ad70ebe7a63a7bac95ba4c6 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Apr 2024 00:03:34 +0400 Subject: [PATCH 07/38] Replace mozjpeg with jpegli in snap --- snap/snapcraft.yaml | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8a122ab95..0d79929de 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -131,6 +131,7 @@ parts: cmake-parameters: - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_PREFIX_PATH=$CRAFT_STAGE/usr - -DTDESKTOP_API_ID=611335 - -DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c - -DDESKTOP_APP_USE_PACKAGED_LAZY=ON @@ -158,7 +159,6 @@ parts: after: - ffmpeg - libjxl - - mozjpeg - openal - protobuf - qt @@ -238,10 +238,6 @@ parts: rmdir "$CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas" mv "$CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack/"* "$CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR" rmdir "$CRAFT_PART_INSTALL/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack" - stage: - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libjpeg.so.8.2.2 - after: - - mozjpeg libjxl: source: https://github.com/libjxl/libjxl.git @@ -257,7 +253,7 @@ parts: - -DBUILD_TESTING=OFF - -DJPEGXL_ENABLE_DEVTOOLS=OFF - -DJPEGXL_ENABLE_TOOLS=OFF - - -DJPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF + - -DJPEGXL_INSTALL_JPEGLI_LIBJPEG=ON - -DJPEGXL_ENABLE_DOXYGEN=OFF - -DJPEGXL_ENABLE_MANPAGES=OFF - -DJPEGXL_ENABLE_BENCHMARK=OFF @@ -276,27 +272,6 @@ parts: - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/*.so - -./usr/share - mozjpeg: - source: https://github.com/mozilla/mozjpeg.git - source-depth: 1 - source-tag: v4.1.4 - plugin: cmake - build-environment: - - LDFLAGS: ${LDFLAGS:+$LDFLAGS} -s - cmake-generator: Ninja - cmake-parameters: - - -DCMAKE_BUILD_TYPE=Release - - -DCMAKE_INSTALL_PREFIX=/usr - - -DENABLE_STATIC=OFF - - -DWITH_JPEG8=ON - - -DPNG_SUPPORTED=OFF - prime: - - -./usr/bin - - -./usr/include - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pkgconfig - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/*.so - - -./usr/share - openal: source: https://github.com/kcat/openal-soft.git source-depth: 1 @@ -458,7 +433,9 @@ parts: -confirm-license \ -openssl-linked \ -nomake examples \ - -nomake tests + -nomake tests \ + -- \ + -DCMAKE_PREFIX_PATH=$CRAFT_STAGE/usr cmake --build . -j$CRAFT_PARALLEL_BUILD_COUNT DESTDIR="$CRAFT_PART_INSTALL" cmake --install . @@ -479,7 +456,7 @@ parts: - -./usr/mkspecs - -./usr/modules after: - - mozjpeg + - libjxl - patches rnnoise: @@ -559,10 +536,11 @@ parts: cmake-parameters: - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=/usr + - -DCMAKE_PREFIX_PATH=$CRAFT_STAGE/usr prime: - -./usr/include - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/cmake - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/*.a after: - ffmpeg - - mozjpeg + - libjxl From d9d9a8f49d93434df59a8304d887107f27caa8c1 Mon Sep 17 00:00:00 2001 From: Nyan <93275906+el-garro@users.noreply.github.com> Date: Fri, 12 Apr 2024 09:01:58 -0400 Subject: [PATCH 08/38] Update data_document_resolver.cpp Added the LEXE and WLUA extensions to the IsExecutableName function for Windows. Those are registered by default on Windows devices with LUA installed --- Telegram/SourceFiles/data/data_document_resolver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index b7dc51e2c..be68c2476 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -165,14 +165,14 @@ bool IsExecutableName(const QString &filepath) { ad ade adp app application appref-ms asp asx bas bat bin cab cdxml cer cfg \ chi chm cmd cnt com cpl crt csh der diagcab dll drv eml exe fon fxp gadget \ grp hlp hpj hta htt inf ini ins inx isp isu its jar jnlp job js jse key ksh \ -lnk local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf mda \ -mdb mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml \ +lexe lnk local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf \ +mda mdb mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml \ msh2xml mshxml msi msp mst ops osd paf pcd phar php php3 php4 php5 php7 phps \ php-s pht phtml pif pl plg pm pod prf prg ps1 ps2 ps1xml ps2xml psc1 psc2 \ psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pyzw pyz rb reg rgs scf scr \ sct search-ms settingcontent-ms sh 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"_q; +vtx website wlua ws wsc wsf wsh xbap xll xnk xs"_q; #elif defined Q_OS_MAC // Q_OS_MAC u"\ applescript action app bin command csh osx workflow terminal url caction \ From a503197352c4a5f08899a4b53e34085b513bab65 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 14 Apr 2024 02:25:39 +0400 Subject: [PATCH 09/38] Remove XCBSetDesktopFileName This is done by Qt nowadays --- .../platform/linux/main_window_linux.cpp | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index e6a3b68a6..c8218ca7d 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -99,42 +99,6 @@ void XCBSkipTaskbar(QWindow *window, bool skip) { | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, reinterpret_cast(&xev)); } - -void XCBSetDesktopFileName(QWindow *window) { - const auto connection = base::Platform::XCB::GetConnectionFromQt(); - if (!connection) { - return; - } - - const auto utf8Atom = base::Platform::XCB::GetAtom( - connection, - "UTF8_STRING"); - - if (!utf8Atom.has_value()) { - return; - } - - const auto filenameAtoms = { - base::Platform::XCB::GetAtom(connection, "_GTK_APPLICATION_ID"), - base::Platform::XCB::GetAtom(connection, "_KDE_NET_WM_DESKTOP_FILE"), - }; - - const auto filename = QGuiApplication::desktopFileName().toUtf8(); - - for (const auto atom : filenameAtoms) { - if (atom.has_value()) { - xcb_change_property( - connection, - XCB_PROP_MODE_REPLACE, - window->winId(), - *atom, - *utf8Atom, - 8, - filename.size(), - filename.data()); - } - } -} #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION void SkipTaskbar(QWindow *window, bool skip) { @@ -206,10 +170,6 @@ void MainWindow::initHook() { } return base::EventFilterResult::Continue; }); - -#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION - XCBSetDesktopFileName(windowHandle()); -#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION } void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) { From da1909cc1d88dd9be294ebddb12c24b623ba6319 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 14 Apr 2024 05:45:54 +0400 Subject: [PATCH 10/38] Clean remainings of mozjpeg in snapcraft.yml --- snap/snapcraft.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 0d79929de..c95d0ab94 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -154,8 +154,6 @@ parts: override-build: | craftctl default rm -rf "$CRAFT_PART_INSTALL/usr/share/icons" - stage: - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libjpeg.so.8.2.2 after: - ffmpeg - libjxl @@ -209,8 +207,6 @@ parts: fi done GTK_PATH=$PWD/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gtk-3.0 /usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libgtk-3-0/gtk-query-immodules-3.0 > usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gtk-3.0/3.0.0/immodules/immodules.cache - stage: - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libjpeg.so.8.2.2 after: - telegram @@ -439,8 +435,6 @@ parts: cmake --build . -j$CRAFT_PARALLEL_BUILD_COUNT DESTDIR="$CRAFT_PART_INSTALL" cmake --install . - stage: - - -./usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libjpeg.so.8.2.2 prime: - -./usr/bin - -./usr/doc From bdf5872f04a89d87bf73fd2a4b2f9121b1491072 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 17:11:38 +0300 Subject: [PATCH 11/38] Fixed opening channel earn info section for admins. --- Telegram/SourceFiles/api/api_statistics.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Telegram/SourceFiles/api/api_statistics.cpp b/Telegram/SourceFiles/api/api_statistics.cpp index 9bc31c483..7139c5ebb 100644 --- a/Telegram/SourceFiles/api/api_statistics.cpp +++ b/Telegram/SourceFiles/api/api_statistics.cpp @@ -860,6 +860,7 @@ void EarnStatistics::requestHistory( .token = Data::EarnHistorySlice::OffsetToken(nextToken), }); }).fail([=] { + done({}); _requestId = 0; }).send(); } From 7ffa9844e2076a27eff89f0c066dae18eeb0f478 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 18:29:31 +0300 Subject: [PATCH 12/38] Fixed currency formatting for channel earn info section. --- .../info/channel_statistics/earn/earn_format.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/earn_format.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/earn_format.cpp index ea470af93..4f87fa505 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/earn_format.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/earn_format.cpp @@ -48,8 +48,11 @@ QString MinorPart(EarnInt value) { QString ToUsd(EarnInt value, float64 rate) { constexpr auto kApproximately = QChar(0x2248); - const auto multiplier = EarnInt(rate * Data::kEarnMultiplier); - const auto result = (value * multiplier) / Data::kEarnMultiplier; + + const auto result = value + / float64(Data::kEarnMultiplier) + * rate + * Data::kEarnMultiplier; return QString(kApproximately) + QChar('$') + MajorPart(result) From a37cbd7d05a31b01b856bc1043c011d736e6ea97 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 17:37:54 +0300 Subject: [PATCH 13/38] Initially refactored statistics module to simplify value types changing. --- .../SourceFiles/data/data_statistics_chart.h | 12 ++++--- .../statistics/chart_rulers_data.cpp | 36 ++++++++++--------- .../statistics/chart_rulers_data.h | 12 ++++--- .../SourceFiles/statistics/chart_widget.cpp | 2 +- .../SourceFiles/statistics/segment_tree.cpp | 22 ++++++------ .../SourceFiles/statistics/segment_tree.h | 28 ++++++++------- .../statistics_data_deserialize.cpp | 3 +- .../SourceFiles/statistics/statistics_types.h | 14 ++++++++ .../statistics/view/abstract_chart_view.cpp | 17 ++++----- .../statistics/view/bar_chart_view.cpp | 6 ++-- .../statistics/view/bar_chart_view.h | 3 +- .../view/stack_linear_chart_common.cpp | 2 +- .../view/stack_linear_chart_view.cpp | 10 +++--- Telegram/cmake/td_ui.cmake | 1 + 14 files changed, 97 insertions(+), 71 deletions(-) create mode 100644 Telegram/SourceFiles/statistics/statistics_types.h diff --git a/Telegram/SourceFiles/data/data_statistics_chart.h b/Telegram/SourceFiles/data/data_statistics_chart.h index 5a29ebef7..2354e9e4d 100644 --- a/Telegram/SourceFiles/data/data_statistics_chart.h +++ b/Telegram/SourceFiles/data/data_statistics_chart.h @@ -30,14 +30,15 @@ struct StatisticalChart { [[nodiscard]] int findIndex(int left, int right, float64 v) const; struct Line final { - std::vector y; + std::vector y; Statistic::SegmentTree segmentTree; int id = 0; QString idString; QString name; - int maxValue = 0; - int minValue = std::numeric_limits::max(); + Statistic::ChartValue maxValue = 0; + Statistic::ChartValue minValue = + std::numeric_limits::max(); QString colorKey; QColor color; QColor colorDark; @@ -55,8 +56,9 @@ struct StatisticalChart { float64 max = 0.; } defaultZoomXIndex; - int maxValue = 0; - int minValue = std::numeric_limits::max(); + Statistic::ChartValue maxValue = 0; + Statistic::ChartValue minValue = + std::numeric_limits::max(); float64 oneDayPercentage = 0.; diff --git a/Telegram/SourceFiles/statistics/chart_rulers_data.cpp b/Telegram/SourceFiles/statistics/chart_rulers_data.cpp index 1b4e9c33a..4f9471c8c 100644 --- a/Telegram/SourceFiles/statistics/chart_rulers_data.cpp +++ b/Telegram/SourceFiles/statistics/chart_rulers_data.cpp @@ -12,17 +12,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Statistic { namespace { -constexpr auto kMinLines = int(2); -constexpr auto kMaxLines = int(6); +constexpr auto kMinLines = ChartValue(2); +constexpr auto kMaxLines = ChartValue(6); constexpr auto kStep = 5.; -[[nodiscard]] int Round(int maxValue) { - const auto k = int(maxValue / kStep); +[[nodiscard]] ChartValue Round(ChartValue maxValue) { + const auto k = ChartValue(maxValue / kStep); return (k % 10 == 0) ? maxValue : ((maxValue / 10 + 1) * 10); } -[[nodiscard]] QString Format(int absoluteValue) { - constexpr auto kTooMuch = int(10'000); +[[nodiscard]] QString Format(ChartValue absoluteValue) { + constexpr auto kTooMuch = ChartValue(10'000); return (absoluteValue >= kTooMuch) ? Lang::FormatCountToShort(absoluteValue).string : QString::number(absoluteValue); @@ -31,8 +31,8 @@ constexpr auto kStep = 5.; } // namespace ChartRulersData::ChartRulersData( - int newMaxHeight, - int newMinHeight, + ChartValue newMaxHeight, + ChartValue newMinHeight, bool useMinHeight, float64 rightRatio, Fn leftCustomCaption, @@ -42,11 +42,13 @@ ChartRulersData::ChartRulersData( ? Round(newMaxHeight) : newMaxHeight; - const auto step = std::max(1, int(std::ceil(v / kStep))); + const auto step = std::max( + ChartValue(1), + ChartValue(std::ceil(v / kStep))); auto n = kMaxLines; if (v < kMaxLines) { - n = std::max(2, v + 1); + n = std::max(2, int(v + 1)); } else if (v / 2 < kMaxLines) { n = v / 2 + 1; if (v % 2 != 0) { @@ -87,11 +89,11 @@ ChartRulersData::ChartRulersData( } lines.resize(n); - const auto diffAbsoluteValue = int((n - 1) * step); + const auto diffAbsoluteValue = ChartValue((n - 1) * step); const auto skipFloatValues = (step / rightRatio) < 1; for (auto i = 0; i < n; i++) { auto &line = lines[i]; - const auto value = int(i * step); + const auto value = ChartValue(i * step); line.absoluteValue = newMinHeight + value; line.relativeValue = 1. - value / float64(diffAbsoluteValue); line.caption = leftCustomCaption @@ -103,7 +105,7 @@ ChartRulersData::ChartRulersData( ? rightCustomCaption(line.absoluteValue) : (!skipFloatValues) ? Format(v) - : ((v - int(v)) < 0.01) + : ((v - ChartValue(v)) < 0.01) ? Format(v) : QString(); } @@ -112,8 +114,8 @@ ChartRulersData::ChartRulersData( } void ChartRulersData::computeRelative( - int newMaxHeight, - int newMinHeight) { + ChartValue newMaxHeight, + ChartValue newMinHeight) { for (auto &line : lines) { line.relativeValue = 1. - ((line.absoluteValue - newMinHeight) @@ -121,10 +123,10 @@ void ChartRulersData::computeRelative( } } -int ChartRulersData::LookupHeight(int maxValue) { +ChartValue ChartRulersData::LookupHeight(ChartValue maxValue) { const auto v = (maxValue > 100) ? Round(maxValue) : maxValue; - const auto step = int(std::ceil(v / kStep)); + const auto step = ChartValue(std::ceil(v / kStep)); return step * kStep; } diff --git a/Telegram/SourceFiles/statistics/chart_rulers_data.h b/Telegram/SourceFiles/statistics/chart_rulers_data.h index 4b5d63202..fef960c35 100644 --- a/Telegram/SourceFiles/statistics/chart_rulers_data.h +++ b/Telegram/SourceFiles/statistics/chart_rulers_data.h @@ -7,23 +7,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "statistics/statistics_types.h" + namespace Statistic { struct ChartRulersData final { public: ChartRulersData( - int newMaxHeight, - int newMinHeight, + ChartValue newMaxHeight, + ChartValue newMinHeight, bool useMinHeight, float64 rightRatio, Fn leftCustomCaption = nullptr, Fn rightCustomCaption = nullptr); void computeRelative( - int newMaxHeight, - int newMinHeight); + ChartValue newMaxHeight, + ChartValue newMinHeight); - [[nodiscard]] static int LookupHeight(int maxValue); + [[nodiscard]] static ChartValue LookupHeight(ChartValue maxValue); struct Line final { float64 absoluteValue = 0.; diff --git a/Telegram/SourceFiles/statistics/chart_widget.cpp b/Telegram/SourceFiles/statistics/chart_widget.cpp index 93d225c70..823481e6b 100644 --- a/Telegram/SourceFiles/statistics/chart_widget.cpp +++ b/Telegram/SourceFiles/statistics/chart_widget.cpp @@ -1157,7 +1157,7 @@ void ChartWidget::setupDetails() { return; } const auto maxAbsoluteValue = [&] { - auto maxValue = 0; + auto maxValue = ChartValue(0); for (const auto &l : _chartData.lines) { maxValue = std::max(l.maxValue, maxValue); } diff --git a/Telegram/SourceFiles/statistics/segment_tree.cpp b/Telegram/SourceFiles/statistics/segment_tree.cpp index f19f8b8d6..51c2082ed 100644 --- a/Telegram/SourceFiles/statistics/segment_tree.cpp +++ b/Telegram/SourceFiles/statistics/segment_tree.cpp @@ -14,7 +14,7 @@ constexpr auto kMinArraySize = size_t(30); } // namespace -SegmentTree::SegmentTree(std::vector array) +SegmentTree::SegmentTree(std::vector array) : _array(std::move(array)) { if (_array.size() < kMinArraySize) { return; @@ -28,7 +28,7 @@ SegmentTree::SegmentTree(std::vector array) build(1, 0, _array.size()); } -void SegmentTree::build(int v, int from, int size) { +void SegmentTree::build(ChartValue v, int from, int size) { _heap[v].from = from; _heap[v].to = (from + size - 1); @@ -48,9 +48,9 @@ void SegmentTree::build(int v, int from, int size) { } } -int SegmentTree::rMaxQ(int from, int to) { +ChartValue SegmentTree::rMaxQ(int from, int to) { if (_array.size() < kMinArraySize) { - auto max = 0; + auto max = ChartValue(0); from = std::max(from, 0); to = std::min(to, int(_array.size() - 1)); for (auto i = from; i <= to; i++) { @@ -61,7 +61,7 @@ int SegmentTree::rMaxQ(int from, int to) { return rMaxQ(1, from, to); } -int SegmentTree::rMaxQ(int v, int from, int to) { +ChartValue SegmentTree::rMaxQ(ChartValue v, int from, int to) { const auto &n = _heap[v]; // If you did a range update that contained this node, // you can infer the Min value without going down the tree. @@ -84,9 +84,9 @@ int SegmentTree::rMaxQ(int v, int from, int to) { return 0; } -int SegmentTree::rMinQ(int from, int to) { +ChartValue SegmentTree::rMinQ(int from, int to) { if (_array.size() < kMinArraySize) { - auto min = std::numeric_limits::max(); + auto min = std::numeric_limits::max(); from = std::max(from, 0); to = std::min(to, int(_array.size() - 1)); for (auto i = from; i <= to; i++) { @@ -97,7 +97,7 @@ int SegmentTree::rMinQ(int from, int to) { return rMinQ(1, from, to); } -int SegmentTree::rMinQ(int v, int from, int to) { +ChartValue SegmentTree::rMinQ(ChartValue v, int from, int to) { const auto &n = _heap[v]; // If you did a range update that contained this node, // you can infer the Min value without going down the tree. @@ -117,10 +117,10 @@ int SegmentTree::rMinQ(int v, int from, int to) { return std::min(leftMin, rightMin); } - return std::numeric_limits::max(); + return std::numeric_limits::max(); } -void SegmentTree::propagate(int v) { +void SegmentTree::propagate(ChartValue v) { auto &n = _heap[v]; if (n.pendingVal) { @@ -131,7 +131,7 @@ void SegmentTree::propagate(int v) { } } -void SegmentTree::change(SegmentTree::Node &n, int value) { +void SegmentTree::change(SegmentTree::Node &n, ChartValue value) { n.pendingVal = { value, true }; n.sum = n.size() * value; n.max = value; diff --git a/Telegram/SourceFiles/statistics/segment_tree.h b/Telegram/SourceFiles/statistics/segment_tree.h index e67adc76a..f83b16dd4 100644 --- a/Telegram/SourceFiles/statistics/segment_tree.h +++ b/Telegram/SourceFiles/statistics/segment_tree.h @@ -7,12 +7,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +#include "statistics/statistics_types.h" + namespace Statistic { class SegmentTree final { public: SegmentTree() = default; - SegmentTree(std::vector array); + SegmentTree(std::vector array); [[nodiscard]] bool empty() const { return _array.empty(); @@ -21,20 +23,20 @@ public: return !empty(); } - [[nodiscard]] int rMaxQ(int from, int to); - [[nodiscard]] int rMinQ(int from, int to); + [[nodiscard]] ChartValue rMaxQ(int from, int to); + [[nodiscard]] ChartValue rMinQ(int from, int to); private: struct Node final { - int sum = 0; - int max = 0; - int min = 0; + ChartValue sum = 0; + ChartValue max = 0; + ChartValue min = 0; struct PendingVal { [[nodiscard]] explicit operator bool() const { return available; } - int value = 0; + ChartValue value = 0; bool available = false; }; PendingVal pendingVal; @@ -47,12 +49,12 @@ private: } }; - void build(int v, int from, int size); - void propagate(int v); - void change(Node &n, int value); + void build(ChartValue v, int from, int size); + void propagate(ChartValue v); + void change(Node &n, ChartValue value); - [[nodiscard]] int rMaxQ(int v, int from, int to); - [[nodiscard]] int rMinQ(int v, int from, int to); + [[nodiscard]] ChartValue rMaxQ(ChartValue v, int from, int to); + [[nodiscard]] ChartValue rMinQ(ChartValue v, int from, int to); [[nodiscard]] bool contains(int from1, int to1, int from2, int to2) const; [[nodiscard]] bool intersects( @@ -61,7 +63,7 @@ private: int from2, int to2) const; - std::vector _array; + std::vector _array; std::vector _heap; }; diff --git a/Telegram/SourceFiles/statistics/statistics_data_deserialize.cpp b/Telegram/SourceFiles/statistics/statistics_data_deserialize.cpp index ac649cf13..7f47a396a 100644 --- a/Telegram/SourceFiles/statistics/statistics_data_deserialize.cpp +++ b/Telegram/SourceFiles/statistics/statistics_data_deserialize.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/debug_log.h" #include "data/data_statistics_chart.h" +#include "statistics/statistics_types.h" #include #include @@ -61,7 +62,7 @@ Data::StatisticalChart StatisticalChartFromJSON(const QByteArray &json) { line.isHiddenOnStart = ranges::contains(hiddenLines, columnId); line.y.resize(length); for (auto i = 0; i < length; i++) { - const auto value = int(base::SafeRound( + const auto value = ChartValue(base::SafeRound( array.at(i + 1).toDouble())); line.y[i] = value; if (value > line.maxValue) { diff --git a/Telegram/SourceFiles/statistics/statistics_types.h b/Telegram/SourceFiles/statistics/statistics_types.h new file mode 100644 index 000000000..5d04d3442 --- /dev/null +++ b/Telegram/SourceFiles/statistics/statistics_types.h @@ -0,0 +1,14 @@ +/* +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 Statistic { + +using ChartValue = int64; + +} // namespace Statistic diff --git a/Telegram/SourceFiles/statistics/view/abstract_chart_view.cpp b/Telegram/SourceFiles/statistics/view/abstract_chart_view.cpp index d2c8e6bae..4b5f2929a 100644 --- a/Telegram/SourceFiles/statistics/view/abstract_chart_view.cpp +++ b/Telegram/SourceFiles/statistics/view/abstract_chart_view.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_statistics_chart.h" #include "statistics/chart_lines_filter_controller.h" +#include "statistics/statistics_types.h" namespace Statistic { @@ -71,11 +72,11 @@ AbstractChartView::HeightLimits DefaultHeightLimits( const std::shared_ptr &linesFilter, Data::StatisticalChart &chartData, Limits xIndices) { - auto minValue = std::numeric_limits::max(); - auto maxValue = 0; + auto minValue = std::numeric_limits::max(); + auto maxValue = ChartValue(0); - auto minValueFull = std::numeric_limits::max(); - auto maxValueFull = 0; + auto minValueFull = std::numeric_limits::max(); + auto maxValueFull = ChartValue(0); for (auto &l : chartData.lines) { if (!linesFilter->isEnabled(l.id)) { continue; @@ -83,11 +84,11 @@ AbstractChartView::HeightLimits DefaultHeightLimits( const auto r = ratios.ratio(l.id); const auto lineMax = l.segmentTree.rMaxQ(xIndices.min, xIndices.max); const auto lineMin = l.segmentTree.rMinQ(xIndices.min, xIndices.max); - maxValue = std::max(int(lineMax * r), maxValue); - minValue = std::min(int(lineMin * r), minValue); + maxValue = std::max(ChartValue(lineMax * r), maxValue); + minValue = std::min(ChartValue(lineMin * r), minValue); - maxValueFull = std::max(int(l.maxValue * r), maxValueFull); - minValueFull = std::min(int(l.minValue * r), minValueFull); + maxValueFull = std::max(ChartValue(l.maxValue * r), maxValueFull); + minValueFull = std::min(ChartValue(l.minValue * r), minValueFull); } if (maxValue == minValue) { maxValue = chartData.maxValue; diff --git a/Telegram/SourceFiles/statistics/view/bar_chart_view.cpp b/Telegram/SourceFiles/statistics/view/bar_chart_view.cpp index 8beeaa509..f796e0294 100644 --- a/Telegram/SourceFiles/statistics/view/bar_chart_view.cpp +++ b/Telegram/SourceFiles/statistics/view/bar_chart_view.cpp @@ -256,9 +256,9 @@ AbstractChartView::HeightLimits BarChartView::heightLimits( if (_cachedHeightLimits.ySum.empty()) { _cachedHeightLimits.ySum.reserve(chartData.x.size()); - auto maxValueFull = 0; + auto maxValueFull = ChartValue(0); for (auto i = 0; i < chartData.x.size(); i++) { - auto sum = 0; + auto sum = ChartValue(0); for (const auto &line : chartData.lines) { if (linesFilterController()->isEnabled(line.id)) { sum += line.y[i]; @@ -276,7 +276,7 @@ AbstractChartView::HeightLimits BarChartView::heightLimits( _cachedHeightLimits.ySumSegmentTree.rMaxQ( xIndices.min, xIndices.max), - 1); + ChartValue(1)); return { .full = _cachedHeightLimits.full, .ranged = { 0., float64(max) }, diff --git a/Telegram/SourceFiles/statistics/view/bar_chart_view.h b/Telegram/SourceFiles/statistics/view/bar_chart_view.h index 44c1a7a6e..3105e0dae 100644 --- a/Telegram/SourceFiles/statistics/view/bar_chart_view.h +++ b/Telegram/SourceFiles/statistics/view/bar_chart_view.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "statistics/segment_tree.h" #include "statistics/statistics_common.h" +#include "statistics/statistics_types.h" #include "statistics/view/abstract_chart_view.h" #include "ui/effects/animation_value.h" @@ -48,7 +49,7 @@ private: struct { Limits full; - std::vector ySum; + std::vector ySum; SegmentTree ySumSegmentTree; } _cachedHeightLimits; diff --git a/Telegram/SourceFiles/statistics/view/stack_linear_chart_common.cpp b/Telegram/SourceFiles/statistics/view/stack_linear_chart_common.cpp index a2ca3ff01..b7727bd71 100644 --- a/Telegram/SourceFiles/statistics/view/stack_linear_chart_common.cpp +++ b/Telegram/SourceFiles/statistics/view/stack_linear_chart_common.cpp @@ -81,7 +81,7 @@ PiePartData PiePartsPercentageByIndices( sums.reserve(chartData.lines.size()); auto totalSum = 0.; for (const auto &line : chartData.lines) { - auto sum = 0; + auto sum = ChartValue(0); for (auto i = xIndices.min; i <= xIndices.max; i++) { sum += line.y[i]; } diff --git a/Telegram/SourceFiles/statistics/view/stack_linear_chart_view.cpp b/Telegram/SourceFiles/statistics/view/stack_linear_chart_view.cpp index dc3e00d04..a4e4a7c87 100644 --- a/Telegram/SourceFiles/statistics/view/stack_linear_chart_view.cpp +++ b/Telegram/SourceFiles/statistics/view/stack_linear_chart_view.cpp @@ -165,8 +165,8 @@ void StackLinearChartView::prepareZoom( _transition.zoomedOutXIndices = c.xIndices; _transition.zoomedOutXPercentage = c.xPercentageLimits; } else if (step == TransitionStep::PrepareToZoomIn) { - const auto &[zoomedStart, zoomedEnd] = - _transition.zoomedOutXIndices; + const auto &[zoomedStart, zoomedEnd] + = _transition.zoomedOutXIndices; _transition.lines = std::vector( c.chartData.lines.size(), Transition::TransitionLine()); @@ -624,7 +624,7 @@ void StackLinearChartView::paintZoomed(QPainter &p, const PaintContext &c) { if (selectedLineIndex >= 0) { const auto &line = c.chartData.lines[selectedLineIndex]; - auto sum = 0; + auto sum = ChartValue(0); for (auto i = zoomedStart; i <= zoomedEnd; i++) { sum += line.y[i]; } @@ -669,8 +669,8 @@ void StackLinearChartView::paintZoomedFooter( 0); const auto next = std::clamp(i + offset, zoomedStart, zoomedEnd); - const auto xPointPercentage = - (xPercentage[next] - xPercentage[zoomedStart]) + const auto xPointPercentage + = (xPercentage[next] - xPercentage[zoomedStart]) / (xPercentage[zoomedEnd] - xPercentage[zoomedStart]); const auto xPoint = leftStart + width * xPointPercentage; diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index 3a8f8ef34..524aba51b 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -205,6 +205,7 @@ PRIVATE statistics/statistics_data_deserialize.h statistics/statistics_format_values.cpp statistics/statistics_format_values.h + statistics/statistics_types.h statistics/view/abstract_chart_view.cpp statistics/view/abstract_chart_view.h statistics/view/bar_chart_view.cpp From 1c223e570a2c7c66b17fb4fd1762121b9e4ce24d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 18:56:11 +0300 Subject: [PATCH 14/38] Slightly improved code style for long equality expressions. --- .../SourceFiles/api/api_chat_participants.cpp | 4 ++-- Telegram/SourceFiles/api/api_earn.cpp | 8 +++---- Telegram/SourceFiles/api/api_editing.cpp | 20 ++++++++-------- Telegram/SourceFiles/api/api_user_privacy.cpp | 4 ++-- Telegram/SourceFiles/apiwrap.cpp | 8 +++---- .../SourceFiles/boxes/add_contact_box.cpp | 12 +++++----- .../SourceFiles/boxes/delete_messages_box.cpp | 4 ++-- .../boxes/peers/edit_peer_info_box.cpp | 8 +++---- .../SourceFiles/boxes/premium_preview_box.cpp | 4 ++-- .../SourceFiles/boxes/sticker_set_box.cpp | 8 +++---- Telegram/SourceFiles/calls/calls_call.cpp | 4 ++-- Telegram/SourceFiles/calls/calls_call.h | 8 +++---- Telegram/SourceFiles/calls/calls_panel.h | 4 ++-- .../calls/group/calls_volume_item.cpp | 12 +++++----- .../chat_helpers/field_autocomplete.cpp | 9 +++---- Telegram/SourceFiles/core/application.cpp | 4 ++-- .../SourceFiles/core/core_cloud_password.cpp | 4 ++-- Telegram/SourceFiles/core/core_settings.h | 4 ++-- Telegram/SourceFiles/data/data_poll.cpp | 4 ++-- .../SourceFiles/data/data_statistics_chart.h | 8 +++---- .../SourceFiles/dialogs/dialogs_widget.cpp | 4 ++-- .../editor/photo_editor_content.cpp | 4 ++-- .../SourceFiles/export/export_api_wrap.cpp | 4 ++-- .../admin_log/history_admin_log_item.cpp | 24 +++++++++---------- .../SourceFiles/history/history_drag_area.cpp | 8 +++---- .../SourceFiles/history/history_drag_area.h | 4 ++-- .../history_view_voice_record_bar.cpp | 4 ++-- .../history/view/history_view_list_widget.cpp | 4 ++-- .../history/view/history_view_message.cpp | 4 ++-- .../history/view/history_view_send_action.cpp | 4 ++-- .../view/media/history_view_web_page.cpp | 4 ++-- Telegram/SourceFiles/info/info_top_bar.cpp | 12 +++++----- .../info/media/info_media_list_widget.cpp | 4 ++-- Telegram/SourceFiles/mainwindow.cpp | 4 ++-- .../media/player/media_player_dropdown.cpp | 4 ++-- .../media/system_media_controls_manager.cpp | 4 ++-- .../passport/passport_form_controller.cpp | 4 ++-- .../passport/passport_panel_controller.h | 4 ++-- .../linux/notifications_manager_linux.cpp | 24 +++++++++---------- .../touchbar/items/mac_pinned_chats_item.mm | 10 ++++---- .../mac/touchbar/mac_touchbar_manager.mm | 4 ++-- .../settings/settings_business.cpp | 4 ++-- .../SourceFiles/settings/settings_premium.cpp | 4 ++-- .../SourceFiles/storage/storage_account.cpp | 4 ++-- .../SourceFiles/ui/boxes/choose_date_time.cpp | 4 ++-- .../ui/controls/call_mute_button.cpp | 8 +++---- .../SourceFiles/window/window_peer_menu.cpp | 4 ++-- .../window/window_session_controller.cpp | 8 +++---- 48 files changed, 159 insertions(+), 160 deletions(-) diff --git a/Telegram/SourceFiles/api/api_chat_participants.cpp b/Telegram/SourceFiles/api/api_chat_participants.cpp index 6761d2fff..745e0b883 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.cpp +++ b/Telegram/SourceFiles/api/api_chat_participants.cpp @@ -112,8 +112,8 @@ void ApplyLastList( channel->mgInfo->lastAdmins.clear(); channel->mgInfo->lastRestricted.clear(); channel->mgInfo->lastParticipants.clear(); - channel->mgInfo->lastParticipantsStatus = - MegagroupInfo::LastParticipantsUpToDate + channel->mgInfo->lastParticipantsStatus + = MegagroupInfo::LastParticipantsUpToDate | MegagroupInfo::LastParticipantsOnceReceived; auto botStatus = channel->mgInfo->botStatus; diff --git a/Telegram/SourceFiles/api/api_earn.cpp b/Telegram/SourceFiles/api/api_earn.cpp index e8f38e06b..61cfaf10f 100644 --- a/Telegram/SourceFiles/api/api_earn.cpp +++ b/Telegram/SourceFiles/api/api_earn.cpp @@ -58,10 +58,10 @@ void HandleWithdrawalButton( state->loading = false; auto fields = PasscodeBox::CloudFields::From(pass); - fields.customTitle = - tr::lng_channel_earn_balance_password_title(); - fields.customDescription = - tr::lng_channel_earn_balance_password_description(tr::now); + fields.customTitle + = tr::lng_channel_earn_balance_password_title(); + fields.customDescription + = tr::lng_channel_earn_balance_password_description(tr::now); fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(button, [=]( const Core::CloudPasswordResult &result) { diff --git a/Telegram/SourceFiles/api/api_editing.cpp b/Telegram/SourceFiles/api/api_editing.cpp index 84f0cbfff..1dba418dd 100644 --- a/Telegram/SourceFiles/api/api_editing.cpp +++ b/Telegram/SourceFiles/api/api_editing.cpp @@ -29,20 +29,20 @@ namespace { using namespace rpl::details; template -constexpr auto WithId = - is_callable_plain_v, mtpRequestId>; +constexpr auto WithId + = is_callable_plain_v, mtpRequestId>; template -constexpr auto WithoutId = - is_callable_plain_v>; +constexpr auto WithoutId + = is_callable_plain_v>; template -constexpr auto WithoutCallback = - is_callable_plain_v; +constexpr auto WithoutCallback + = is_callable_plain_v; template -constexpr auto ErrorWithId = - is_callable_plain_v; +constexpr auto ErrorWithId + = is_callable_plain_v; template -constexpr auto ErrorWithoutId = - is_callable_plain_v; +constexpr auto ErrorWithoutId + = is_callable_plain_v; template mtpRequestId EditMessage( diff --git a/Telegram/SourceFiles/api/api_user_privacy.cpp b/Telegram/SourceFiles/api/api_user_privacy.cpp index b27580aaa..d0c17fa6b 100644 --- a/Telegram/SourceFiles/api/api_user_privacy.cpp +++ b/Telegram/SourceFiles/api/api_user_privacy.cpp @@ -307,8 +307,8 @@ void UserPrivacy::reload(Key key) { } void UserPrivacy::pushPrivacy(Key key, const TLRules &rules) { - const auto &saved = (_privacyValues[key] = - TLToRules(rules, _session->data())); + const auto &saved + = (_privacyValues[key] = TLToRules(rules, _session->data())); const auto i = _privacyChanges.find(key); if (i != end(_privacyChanges)) { i->second.fire_copy(saved); diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index b8919617d..20c52fbdd 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1544,8 +1544,8 @@ void ApiWrap::saveStickerSets( writeRecent = true; } - const auto isAttached = - (removedSetId == Data::Stickers::CloudRecentAttachedSetId); + const auto isAttached + = (removedSetId == Data::Stickers::CloudRecentAttachedSetId); const auto flags = isAttached ? MTPmessages_ClearRecentStickers::Flag::f_attached : MTPmessages_ClearRecentStickers::Flags(0); @@ -2494,8 +2494,8 @@ void ApiWrap::refreshFileReference( }, [&](Data::FileOriginPeerPhoto data) { fail(); }, [&](Data::FileOriginStickerSet data) { - const auto isRecentAttached = - (data.setId == Data::Stickers::CloudRecentAttachedSetId); + const auto isRecentAttached + = (data.setId == Data::Stickers::CloudRecentAttachedSetId); if (data.setId == Data::Stickers::CloudRecentSetId || data.setId == Data::Stickers::RecentSetId || isRecentAttached) { diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index ba35e8d98..45d4b1e99 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -605,8 +605,8 @@ void GroupInfoBox::prepare() { _navigation->session().api().selfDestruct().reload(); const auto top = addTopButton(st::infoTopBarMenu); - const auto menu = - top->lifetime().make_state>(); + const auto menu + = top->lifetime().make_state>(); top->setClickedCallback([=] { *menu = base::make_unique_q( top, @@ -1306,8 +1306,8 @@ void SetupChannelBox::handleChange() { && (ch < 'a' || ch > 'z') && (ch < '0' || ch > '9') && ch != '_') { - const auto badSymbols = - tr::lng_create_channel_link_bad_symbols(tr::now); + const auto badSymbols + = tr::lng_create_channel_link_bad_symbols(tr::now); if (_errorText != badSymbols) { _errorText = badSymbols; update(); @@ -1317,8 +1317,8 @@ void SetupChannelBox::handleChange() { } } if (name.size() < Ui::EditPeer::kMinUsernameLength) { - const auto tooShort = - tr::lng_create_channel_link_too_short(tr::now); + const auto tooShort + = tr::lng_create_channel_link_too_short(tr::now); if (_errorText != tooShort) { _errorText = tooShort; update(); diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.cpp b/Telegram/SourceFiles/boxes/delete_messages_box.cpp index 0a939ace6..1def53870 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/delete_messages_box.cpp @@ -232,8 +232,8 @@ void DeleteMessagesBox::prepare() { if (hasScheduledMessages()) { } else if (auto revoke = revokeText(peer)) { const auto &settings = Core::App().settings(); - const auto revokeByDefault = - !settings.rememberedDeleteMessageOnlyForYou(); + const auto revokeByDefault + = !settings.rememberedDeleteMessageOnlyForYou(); _revoke.create( this, revoke->checkbox, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 31faabec1..a1ee68248 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -983,8 +983,8 @@ void Controller::fillHistoryVisibilityButton() { : HistoryVisibility::Visible; _channelHasLocationOriginalValue = channel && channel->hasLocation(); - const auto updateHistoryVisibility = - std::make_shared>(); + const auto updateHistoryVisibility + = std::make_shared>(); const auto boxCallback = crl::guard(this, [=](HistoryVisibility checked) { updateHistoryVisibility->fire(std::move(checked)); @@ -1698,8 +1698,8 @@ void Controller::saveUsernamesOrder() { channel->setUsernames(ranges::views::all( newUsernames ) | ranges::views::transform([&](QString username) { - const auto editable = - (channel->editableUsername() == username); + const auto editable + = (channel->editableUsername() == username); return Data::Username{ .username = std::move(username), .active = true, diff --git a/Telegram/SourceFiles/boxes/premium_preview_box.cpp b/Telegram/SourceFiles/boxes/premium_preview_box.cpp index 67e402da5..da1ab9064 100644 --- a/Telegram/SourceFiles/boxes/premium_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_preview_box.cpp @@ -1240,8 +1240,8 @@ void DecorateListPromoBox( box->setStyle(st::premiumPreviewDoubledLimitsBox); box->widthValue( ) | rpl::start_with_next([=](int width) { - const auto &padding = - st::premiumPreviewDoubledLimitsBox.buttonPadding; + const auto &padding + = st::premiumPreviewDoubledLimitsBox.buttonPadding; button->resizeToWidth(width - padding.left() - padding.right()); diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 414f098e2..88163356c 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -569,8 +569,8 @@ void StickerSetBox::updateButtons() { if (!_inner->shortName().isEmpty()) { const auto top = addTopButton(st::infoTopBarMenu); - const auto menu = - std::make_shared>(); + const auto menu + = std::make_shared>(); top->setClickedCallback([=] { *menu = base::make_unique_q( top, @@ -613,8 +613,8 @@ void StickerSetBox::updateButtons() { _show->showBox(std::move(box)); } }; - const auto menu = - std::make_shared>(); + const auto menu + = std::make_shared>(); top->setClickedCallback([=] { *menu = base::make_unique_q( top, diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 3f6c2a7a8..3a3e68b47 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -945,8 +945,8 @@ void Call::createAndStartController(const MTPDphoneCall &call) { tgcalls::Descriptor descriptor = { .version = versionString, .config = tgcalls::Config{ - .initializationTimeout = - serverConfig.callConnectTimeoutMs / 1000., + .initializationTimeout + = serverConfig.callConnectTimeoutMs / 1000., .receiveTimeout = serverConfig.callPacketTimeoutMs / 1000., .dataSaving = tgcalls::DataSaving::Never, .enableP2P = call.is_p2p_allowed(), diff --git a/Telegram/SourceFiles/calls/calls_call.h b/Telegram/SourceFiles/calls/calls_call.h index 55f48237a..0a99c8067 100644 --- a/Telegram/SourceFiles/calls/calls_call.h +++ b/Telegram/SourceFiles/calls/calls_call.h @@ -277,11 +277,11 @@ private: MTP::Sender _api; Type _type = Type::Outgoing; rpl::variable _state = State::Starting; - rpl::variable _remoteAudioState = - RemoteAudioState::Active; + rpl::variable _remoteAudioState + = RemoteAudioState::Active; rpl::variable _remoteVideoState; - rpl::variable _remoteBatteryState = - RemoteBatteryState::Normal; + rpl::variable _remoteBatteryState + = RemoteBatteryState::Normal; rpl::event_stream _errors; FinishType _finishAfterRequestingCall = FinishType::None; bool _answerAfterDhConfigReceived = false; diff --git a/Telegram/SourceFiles/calls/calls_panel.h b/Telegram/SourceFiles/calls/calls_panel.h index f6c8666d8..11c6dceae 100644 --- a/Telegram/SourceFiles/calls/calls_panel.h +++ b/Telegram/SourceFiles/calls/calls_panel.h @@ -162,8 +162,8 @@ private: object_ptr _status; object_ptr _fingerprint = { nullptr }; object_ptr> _remoteAudioMute = { nullptr }; - object_ptr> _remoteLowBattery = - { nullptr }; + object_ptr> _remoteLowBattery + = { nullptr }; std::unique_ptr _userpic; std::unique_ptr _outgoingVideoBubble; QPixmap _bottomShadow; diff --git a/Telegram/SourceFiles/calls/group/calls_volume_item.cpp b/Telegram/SourceFiles/calls/group/calls_volume_item.cpp index 5942a97e7..d34a51060 100644 --- a/Telegram/SourceFiles/calls/group/calls_volume_item.cpp +++ b/Telegram/SourceFiles/calls/group/calls_volume_item.cpp @@ -25,8 +25,8 @@ const auto kSpeakerThreshold = std::vector{ 50.0f / kMaxVolumePercent, 150.0f / kMaxVolumePercent }; -constexpr auto kVolumeStickedValues = - std::array, 7>{{ +constexpr auto kVolumeStickedValues + = std::array, 7>{{ { 25. / kMaxVolumePercent, 2. / kMaxVolumePercent }, { 50. / kMaxVolumePercent, 2. / kMaxVolumePercent }, { 75. / kMaxVolumePercent, 2. / kMaxVolumePercent }, @@ -93,8 +93,8 @@ MenuVolumeItem::MenuVolumeItem( const auto volume = _localMuted ? 0 : base::SafeRound(_slider->value() * kMaxVolumePercent); - const auto muteProgress = - _crossLineAnimation.value((!volume) ? 1. : 0.); + const auto muteProgress + = _crossLineAnimation.value((!volume) ? 1. : 0.); const auto selected = isSelected(); p.fillRect(clip, selected ? st.itemBgOver : st.itemBg); @@ -174,8 +174,8 @@ MenuVolumeItem::MenuVolumeItem( return; } if (_waitingForUpdateVolume) { - const auto localVolume = - base::SafeRound(_slider->value() * _maxVolume); + const auto localVolume + = base::SafeRound(_slider->value() * _maxVolume); if ((localVolume != newVolume) && (_cloudVolume == newVolume)) { _changeVolumeRequests.fire(int(localVolume)); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index e82ab9b9f..9bc6e88f2 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -437,8 +437,8 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { auto filterNotPassedByUsername = [this](UserData *user) -> bool { if (PrimaryUsername(user).startsWith(_filter, Qt::CaseInsensitive)) { - const auto exactUsername = - (PrimaryUsername(user).size() == _filter.size()); + const auto exactUsername + = (PrimaryUsername(user).size() == _filter.size()); return exactUsername; } return true; @@ -446,8 +446,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { auto filterNotPassedByName = [&](UserData *user) -> bool { for (const auto &nameWord : user->nameWords()) { if (nameWord.startsWith(_filter, Qt::CaseInsensitive)) { - const auto exactUsername = - (PrimaryUsername(user).compare(_filter, Qt::CaseInsensitive) == 0); + const auto exactUsername = PrimaryUsername(user).compare( + _filter, + Qt::CaseInsensitive) == 0; return exactUsername; } } diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 3f643b6dd..917baf16e 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -933,8 +933,8 @@ void Application::handleAppDeactivated() { } rpl::producer Application::appDeactivatedValue() const { - const auto &app = - static_cast(QCoreApplication::instance()); + const auto &app + = static_cast(QCoreApplication::instance()); return rpl::single( app->applicationState() ) | rpl::then( diff --git a/Telegram/SourceFiles/core/core_cloud_password.cpp b/Telegram/SourceFiles/core/core_cloud_password.cpp index 3a65f24d5..a835112dc 100644 --- a/Telegram/SourceFiles/core/core_cloud_password.cpp +++ b/Telegram/SourceFiles/core/core_cloud_password.cpp @@ -313,8 +313,8 @@ CloudPasswordState ParseCloudPasswordState( ParseCloudPasswordAlgo(data.vnew_algo())); result.mtp.newSecureSecret = ValidateNewSecureSecretAlgo( ParseSecureSecretAlgo(data.vnew_secure_algo())); - result.unconfirmedPattern = - qs(data.vemail_unconfirmed_pattern().value_or_empty()); + result.unconfirmedPattern = qs( + data.vemail_unconfirmed_pattern().value_or_empty()); result.pendingResetDate = data.vpending_reset_date().value_or_empty(); result.outdatedClient = [&] { diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index 93e0727d7..12b7fa431 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -984,8 +984,8 @@ private: #else // Q_OS_MAC bool _hardwareAcceleratedVideo = false; #endif // Q_OS_MAC - HistoryView::DoubleClickQuickAction _chatQuickAction = - HistoryView::DoubleClickQuickAction(); + HistoryView::DoubleClickQuickAction _chatQuickAction + = HistoryView::DoubleClickQuickAction(); bool _translateButtonEnabled = false; rpl::variable _translateChatEnabled = true; rpl::variable _translateToRaw = 0; diff --git a/Telegram/SourceFiles/data/data_poll.cpp b/Telegram/SourceFiles/data/data_poll.cpp index f781f95bc..800f3ee32 100644 --- a/Telegram/SourceFiles/data/data_poll.cpp +++ b/Telegram/SourceFiles/data/data_poll.cpp @@ -121,8 +121,8 @@ bool PollData::applyResults(const MTPPollResults &results) { return results.match([&](const MTPDpollResults &results) { _lastResultsUpdate = crl::now(); - const auto newTotalVoters = - results.vtotal_voters().value_or(totalVoters); + const auto newTotalVoters + = results.vtotal_voters().value_or(totalVoters); auto changed = (newTotalVoters != totalVoters); if (const auto list = results.vresults()) { for (const auto &result : list->v) { diff --git a/Telegram/SourceFiles/data/data_statistics_chart.h b/Telegram/SourceFiles/data/data_statistics_chart.h index 2354e9e4d..fba664d34 100644 --- a/Telegram/SourceFiles/data/data_statistics_chart.h +++ b/Telegram/SourceFiles/data/data_statistics_chart.h @@ -37,8 +37,8 @@ struct StatisticalChart { QString idString; QString name; Statistic::ChartValue maxValue = 0; - Statistic::ChartValue minValue = - std::numeric_limits::max(); + Statistic::ChartValue minValue + = std::numeric_limits::max(); QString colorKey; QColor color; QColor colorDark; @@ -57,8 +57,8 @@ struct StatisticalChart { } defaultZoomXIndex; Statistic::ChartValue maxValue = 0; - Statistic::ChartValue minValue = - std::numeric_limits::max(); + Statistic::ChartValue minValue + = std::numeric_limits::max(); float64 oneDayPercentage = 0.; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 8ac5c91b3..873b15324 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -770,8 +770,8 @@ void Widget::updateScrollUpPosition() { _scrollToTop->moveToRight( st::historyToDownPosition.x(), _scroll->height() - top); - const auto shouldBeHidden = - !_scrollToTopIsShown && !_scrollToTopShown.animating(); + const auto shouldBeHidden + = !_scrollToTopIsShown && !_scrollToTopShown.animating(); if (shouldBeHidden != _scrollToTop->isHidden()) { _scrollToTop->setVisible(!shouldBeHidden); } diff --git a/Telegram/SourceFiles/editor/photo_editor_content.cpp b/Telegram/SourceFiles/editor/photo_editor_content.cpp index 065b2a1a6..1a379b9b3 100644 --- a/Telegram/SourceFiles/editor/photo_editor_content.cpp +++ b/Telegram/SourceFiles/editor/photo_editor_content.cpp @@ -48,8 +48,8 @@ PhotoEditorContent::PhotoEditorContent( return; } const auto imageSizeF = [&] { - const auto rotatedSize = - FlipSizeByRotation(size, mods.angle); + const auto rotatedSize + = FlipSizeByRotation(size, mods.angle); const auto m = _crop->cropMargins(); const auto sizeForCrop = rotatedSize - QSize(m.left() + m.right(), m.top() + m.bottom()); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index b50c105f3..69861015c 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -541,8 +541,8 @@ void ApiWrap::requestDialogsCount() { Expects(_startProcess != nullptr); if (_settings->onlySinglePeer()) { - _startProcess->info.dialogsCount = - (_settings->singlePeer.type() == mtpc_inputPeerChannel + _startProcess->info.dialogsCount + = (_settings->singlePeer.type() == mtpc_inputPeerChannel ? 1 : _splits.size()); sendNextStartRequest(); 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 5899117be..53e0926e0 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -738,8 +738,8 @@ void GenerateItems( using LogPromote = MTPDchannelAdminLogEventActionParticipantToggleAdmin; using LogSticker = MTPDchannelAdminLogEventActionChangeStickerSet; using LogEmoji = MTPDchannelAdminLogEventActionChangeEmojiStickerSet; - using LogPreHistory = - MTPDchannelAdminLogEventActionTogglePreHistoryHidden; + using LogPreHistory + = MTPDchannelAdminLogEventActionTogglePreHistoryHidden; using LogPermissions = MTPDchannelAdminLogEventActionDefaultBannedRights; using LogPoll = MTPDchannelAdminLogEventActionStopPoll; using LogDiscussion = MTPDchannelAdminLogEventActionChangeLinkedChat; @@ -749,19 +749,19 @@ void GenerateItems( using LogDiscardCall = MTPDchannelAdminLogEventActionDiscardGroupCall; using LogMute = MTPDchannelAdminLogEventActionParticipantMute; using LogUnmute = MTPDchannelAdminLogEventActionParticipantUnmute; - using LogCallSetting = - MTPDchannelAdminLogEventActionToggleGroupCallSetting; - using LogJoinByInvite = - MTPDchannelAdminLogEventActionParticipantJoinByInvite; - using LogInviteDelete = - MTPDchannelAdminLogEventActionExportedInviteDelete; - using LogInviteRevoke = - MTPDchannelAdminLogEventActionExportedInviteRevoke; + using LogCallSetting + = MTPDchannelAdminLogEventActionToggleGroupCallSetting; + using LogJoinByInvite + = MTPDchannelAdminLogEventActionParticipantJoinByInvite; + using LogInviteDelete + = MTPDchannelAdminLogEventActionExportedInviteDelete; + using LogInviteRevoke + = MTPDchannelAdminLogEventActionExportedInviteRevoke; using LogInviteEdit = MTPDchannelAdminLogEventActionExportedInviteEdit; using LogVolume = MTPDchannelAdminLogEventActionParticipantVolume; using LogTTL = MTPDchannelAdminLogEventActionChangeHistoryTTL; - using LogJoinByRequest = - MTPDchannelAdminLogEventActionParticipantJoinByRequest; + using LogJoinByRequest + = MTPDchannelAdminLogEventActionParticipantJoinByRequest; using LogNoForwards = MTPDchannelAdminLogEventActionToggleNoForwards; using LogSendMessage = MTPDchannelAdminLogEventActionSendMessage; using LogChangeAvailableReactions = MTPDchannelAdminLogEventActionChangeAvailableReactions; diff --git a/Telegram/SourceFiles/history/history_drag_area.cpp b/Telegram/SourceFiles/history/history_drag_area.cpp index 39ba5fe3c..4f99ec778 100644 --- a/Telegram/SourceFiles/history/history_drag_area.cpp +++ b/Telegram/SourceFiles/history/history_drag_area.cpp @@ -52,8 +52,8 @@ DragArea::Areas DragArea::SetupDragAreaToContainer( auto &lifetime = container->lifetime(); container->setAcceptDrops(true); - const auto attachDragDocument = - Ui::CreateChild(container.get()); + const auto attachDragDocument + = Ui::CreateChild(container.get()); const auto attachDragPhoto = Ui::CreateChild(container.get()); attachDragDocument->hide(); @@ -62,8 +62,8 @@ DragArea::Areas DragArea::SetupDragAreaToContainer( attachDragDocument->raise(); attachDragPhoto->raise(); - const auto attachDragState = - lifetime.make_state(DragState::None); + const auto attachDragState + = lifetime.make_state(DragState::None); const auto width = [=] { return container->width(); diff --git a/Telegram/SourceFiles/history/history_drag_area.h b/Telegram/SourceFiles/history/history_drag_area.h index 64e581d58..c9c075c5a 100644 --- a/Telegram/SourceFiles/history/history_drag_area.h +++ b/Telegram/SourceFiles/history/history_drag_area.h @@ -23,8 +23,8 @@ public: DragArea *photo; }; - using CallbackComputeState = - Fn; + using CallbackComputeState + = Fn; static Areas SetupDragAreaToContainer( not_null container, diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index aa0c740da..ade1c9eec 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -372,8 +372,8 @@ TTLButton::TTLButton( return (r.left() + r.width() > parentWidget()->width()); }) | rpl::distinct_until_changed( ) | rpl::start_with_next([=](bool toHide) { - const auto isFirstTooltip = - !Core::App().settings().ttlVoiceClickTooltipHidden(); + const auto isFirstTooltip + = !Core::App().settings().ttlVoiceClickTooltipHidden(); if (isFirstTooltip || (!isFirstTooltip && toHide)) { _tooltip->toggleAnimated(!toHide); } diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 23b7c0be3..dc1255e2c 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -3898,8 +3898,8 @@ bool ListWidget::lastMessageEditRequestNotify() const { if (it == end(list)) { return false; } else { - const auto item = - session().data().groups().findItemToEdit((*it)->data()).get(); + const auto item + = session().data().groups().findItemToEdit((*it)->data()).get(); editMessageRequestNotify(item->fullId()); return true; } diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 100fff459..3a94363e2 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1849,8 +1849,8 @@ void Message::clickHandlerPressedChanged( if (pressed) { if (!_rightAction->second->ripple) { // Create a ripple. - _rightAction->second->ripple = - std::make_unique( + _rightAction->second->ripple + = std::make_unique( st::defaultRippleAnimation, Ui::RippleAnimation::RoundRectMask( Size(rightSize->width()), diff --git a/Telegram/SourceFiles/history/view/history_view_send_action.cpp b/Telegram/SourceFiles/history/view/history_view_send_action.cpp index 5380ccfb5..460941e6d 100644 --- a/Telegram/SourceFiles/history/view/history_view_send_action.cpp +++ b/Telegram/SourceFiles/history/view/history_view_send_action.cpp @@ -150,8 +150,8 @@ bool SendActionPainter::paint( const auto extraAnimationWidth = _animationLeft ? animationWidth * 2 : 0; - const auto left = - (availableWidth < _animationLeft + extraAnimationWidth) + const auto left + = (availableWidth < _animationLeft + extraAnimationWidth) ? 0 : _animationLeft; _sendActionAnimation.paint( diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index fbd61a00e..c275e3b35 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -496,8 +496,8 @@ QSize WebPage::countOptimalSize() { minHeight = resizeGetHeight(maxWidth); } if (_sponsoredData && _sponsoredData->canReport) { - _sponsoredData->widthBeforeHint = - st::webPageTitleStyle.font->width(siteName); + _sponsoredData->widthBeforeHint + = st::webPageTitleStyle.font->width(siteName); const auto &font = st::webPageSponsoredHintFont; _sponsoredData->hintSize = QSize( font->width(tr::lng_sponsored_message_revenue_button(tr::now)) diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index 1e5f34c2f..2caa1ffa8 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -683,13 +683,13 @@ void TopBar::createSelectionControls() { _selectionActionRequests, _cancelSelection->lifetime()); _delete->entity()->setVisible(_canDelete); - const auto archive = - _toggleStoryPin = wrap(Ui::CreateChild>( - this, - object_ptr( + const auto archive = _toggleStoryPin = wrap( + Ui::CreateChild>( this, - _storiesArchive ? _st.storiesSave : _st.storiesArchive), - st::infoTopBarScale)); + object_ptr( + this, + _storiesArchive ? _st.storiesSave : _st.storiesArchive), + st::infoTopBarScale)); registerToggleControlCallback( _toggleStoryPin.data(), [this] { return selectionMode() && _canToggleStoryPin; }); diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index 1a42e6379..4e30f0b09 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -814,8 +814,8 @@ void ListWidget::paintEvent(QPaintEvent *e) { } if (_dateBadge->goodType && clip.intersects(_dateBadge->rect)) { - const auto scrollDateOpacity = - _dateBadge->opacity.value(_dateBadge->shown ? 1. : 0.); + const auto scrollDateOpacity + = _dateBadge->opacity.value(_dateBadge->shown ? 1. : 0.); if (scrollDateOpacity > 0.) { p.setOpacity(scrollDateOpacity); if (_dateBadge->corners.p[0].isNull()) { diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 5e8724b37..93d6d3060 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -77,8 +77,8 @@ base::options::toggle AutoScrollInactiveChat({ } // namespace -const char kOptionAutoScrollInactiveChat[] = - "auto-scroll-inactive-chat"; +const char kOptionAutoScrollInactiveChat[] + = "auto-scroll-inactive-chat"; MainWindow::MainWindow(not_null controller) : Platform::MainWindow(controller) { diff --git a/Telegram/SourceFiles/media/player/media_player_dropdown.cpp b/Telegram/SourceFiles/media/player/media_player_dropdown.cpp index c00765cf8..073ae2531 100644 --- a/Telegram/SourceFiles/media/player/media_player_dropdown.cpp +++ b/Telegram/SourceFiles/media/player/media_player_dropdown.cpp @@ -35,8 +35,8 @@ constexpr auto kSpeedDebounceTimeout = crl::time(1000); return base::SafeRound(speed * 10) / 10.; } -constexpr auto kSpeedStickedValues = - std::array, 7>{{ +constexpr auto kSpeedStickedValues + = std::array, 7>{{ { 0.8, 0.05 }, { 1.0, 0.05 }, { 1.2, 0.05 }, diff --git a/Telegram/SourceFiles/media/system_media_controls_manager.cpp b/Telegram/SourceFiles/media/system_media_controls_manager.cpp index d16685860..91f016aa5 100644 --- a/Telegram/SourceFiles/media/system_media_controls_manager.cpp +++ b/Telegram/SourceFiles/media/system_media_controls_manager.cpp @@ -44,8 +44,8 @@ bool SystemMediaControlsManager::Supported() { SystemMediaControlsManager::SystemMediaControlsManager() : _controls(std::make_unique()) { - using PlaybackStatus = - base::Platform::SystemMediaControls::PlaybackStatus; + using PlaybackStatus + = base::Platform::SystemMediaControls::PlaybackStatus; using Command = base::Platform::SystemMediaControls::Command; _controls->setApplicationName(AppName.utf16()); diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 980888ffb..b0ad0fcdf 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -2686,8 +2686,8 @@ bool FormController::applyPassword(const MTPDaccount_password &result) { settings.notEmptyPassport = result.is_has_secure_values(); settings.request = Core::ParseCloudPasswordCheckRequest(result); settings.unknownAlgo = result.vcurrent_algo() && !settings.request; - settings.unconfirmedPattern = - qs(result.vemail_unconfirmed_pattern().value_or_empty()); + settings.unconfirmedPattern = qs( + result.vemail_unconfirmed_pattern().value_or_empty()); settings.newAlgo = Core::ValidateNewCloudPasswordAlgo( Core::ParseCloudPasswordAlgo(result.vnew_algo())); settings.newSecureAlgo = Core::ValidateNewSecureSecretAlgo( diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index 94cd418c8..5c3d296b4 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -26,8 +26,8 @@ struct EditContactScheme; enum class ReadScanError; -using preferredLangCallback = - Fn(const QString &)>; +using preferredLangCallback + = Fn(const QString &)>; EditDocumentScheme GetDocumentScheme( Scope::Type type, std::optional scansType, diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 0ea48a7de..747e4c2fa 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -315,19 +315,19 @@ bool NotificationData::init( _actions.push_back("inline-reply"); _actions.push_back(tr::lng_notification_reply(tr::now).toStdString()); - _notificationRepliedSignalId = - _interface.signal_notification_replied().connect([=]( - XdgNotifications::Notifications, - uint id, - std::string text) { - Core::Sandbox::Instance().customEnterFromEventLoop([&] { - if (id == _notificationId) { - _manager->notificationReplied( - _id, - { QString::fromStdString(text), {} }); - } + _notificationRepliedSignalId + = _interface.signal_notification_replied().connect([=]( + XdgNotifications::Notifications, + uint id, + std::string text) { + Core::Sandbox::Instance().customEnterFromEventLoop([&] { + if (id == _notificationId) { + _manager->notificationReplied( + _id, + { QString::fromStdString(text), {} }); + } + }); }); - }); } _actionInvokedSignalId = _interface.signal_action_invoked().connect([=]( diff --git a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm index 477075719..ca4f88dad 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_pinned_chats_item.mm @@ -551,13 +551,11 @@ NSRect PeerRectByIndex(int index) { const auto processOnline = [=](const auto &pin) { // TODO: this should be replaced // with the global application timer for online statuses. - const auto onlineChanges = - peerChangedLifetime->make_state>(); + const auto onlineChanges + = peerChangedLifetime->make_state>(); const auto peer = pin->peer; - const auto onlineTimer = - peerChangedLifetime->make_state([=] { - onlineChanges->fire_copy({ peer }); - }); + const auto onlineTimer = peerChangedLifetime->make_state( + [=] { onlineChanges->fire_copy({ peer }); }); const auto callTimer = [=](const auto &pin) { onlineTimer->cancel(); diff --git a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_manager.mm b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_manager.mm index f9c24a5a5..5f314e4b5 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_manager.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_manager.mm @@ -135,8 +135,8 @@ const auto kAudioItemIdentifier = @"touchbarAudio"; if (isEqual(kMainItemIdentifier)) { auto *item = [[GroupTouchBarItem alloc] initWithIdentifier:itemId]; - item.groupTouchBar = - [[[TouchBarMain alloc] + item.groupTouchBar + = [[[TouchBarMain alloc] init:_controller touchBarSwitches:_touchBarSwitches.events()] autorelease]; rpl::combine( diff --git a/Telegram/SourceFiles/settings/settings_business.cpp b/Telegram/SourceFiles/settings/settings_business.cpp index feee8e87c..163716819 100644 --- a/Telegram/SourceFiles/settings/settings_business.cpp +++ b/Telegram/SourceFiles/settings/settings_business.cpp @@ -605,8 +605,8 @@ QPointer Business::createPinnedToBottom( }); { const auto callback = [=](int value) { - const auto options = - _controller->session().api().premium().subscriptionOptions(); + auto &api = _controller->session().api(); + const auto options = api.premium().subscriptionOptions(); if (options.empty()) { return; } diff --git a/Telegram/SourceFiles/settings/settings_premium.cpp b/Telegram/SourceFiles/settings/settings_premium.cpp index d1962e407..601f1f978 100644 --- a/Telegram/SourceFiles/settings/settings_premium.cpp +++ b/Telegram/SourceFiles/settings/settings_premium.cpp @@ -1211,8 +1211,8 @@ QPointer Premium::createPinnedToBottom( #endif { const auto callback = [=](int value) { - const auto options = - _controller->session().api().premium().subscriptionOptions(); + auto &api = _controller->session().api(); + const auto options = api.premium().subscriptionOptions(); if (options.empty()) { return; } diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index ca04135e8..e3c2e69c4 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -1991,8 +1991,8 @@ void Account::readStickerSets( if (datesCount != scnt) { return failed(); } - const auto fillDates = - ((set->id == Data::Stickers::CloudRecentSetId) + const auto fillDates + = ((set->id == Data::Stickers::CloudRecentSetId) || (set->id == Data::Stickers::CloudRecentAttachedSetId)) && (set->stickers.size() == datesCount); if (fillDates) { diff --git a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp index e4d8092a5..8651b5b01 100644 --- a/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp +++ b/Telegram/SourceFiles/ui/boxes/choose_date_time.cpp @@ -146,8 +146,8 @@ ChooseDateTimeBoxDescriptor ChooseDateTimeBox( width); }, content->lifetime()); - const auto calendar = - content->lifetime().make_state>(); + const auto calendar + = content->lifetime().make_state>(); const auto calendarStyle = args.style.calendarStyle; state->day->focusedChanges( ) | rpl::start_with_next([=](bool focused) { diff --git a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp index dfb31807e..731df0c81 100644 --- a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp +++ b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp @@ -414,8 +414,8 @@ void BlobsWidget::init(int diameter) { } // Main circle. - const auto circleProgress = - Clamp(_switchConnectingProgress - kBlobPartAnimation) + const auto circleProgress + = Clamp(_switchConnectingProgress - kBlobPartAnimation) / kFillCirclePartAnimation; const auto skipColoredCircle = (circleProgress == 1.); @@ -744,8 +744,8 @@ void CallMuteButton::init() { }, lifetime()); // State type. - const auto previousType = - lifetime().make_state(_state.current().type); + const auto previousType + = lifetime().make_state(_state.current().type); setHandleMouseState(HandleMouseState::Disabled); refreshGradients(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index c3c0950c2..e03e69c52 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -143,8 +143,8 @@ void ShareBotGame( } // namespace -const char kOptionViewProfileInChatsListContextMenu[] = - "view-profile-in-chats-list-context-menu"; +const char kOptionViewProfileInChatsListContextMenu[] + = "view-profile-in-chats-list-context-menu"; namespace { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 47cf5326c..833ff1a96 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -2015,10 +2015,10 @@ void SessionController::resizeForThirdSection() { auto &settings = Core::App().settings(); auto layout = computeColumnLayout(); - auto tabbedSelectorSectionEnabled = - settings.tabbedSelectorSectionEnabled(); - auto thirdSectionInfoEnabled = - settings.thirdSectionInfoEnabled(); + auto tabbedSelectorSectionEnabled + = settings.tabbedSelectorSectionEnabled(); + auto thirdSectionInfoEnabled + = settings.thirdSectionInfoEnabled(); settings.setTabbedSelectorSectionEnabled(false); settings.setThirdSectionInfoEnabled(false); From d1be7c1ff7f1cb08d416a0db2c9649fbf3c833c9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 19:35:06 +0300 Subject: [PATCH 15/38] Simplified management of PasscodeBox within customCheckCallback. --- Telegram/SourceFiles/api/api_bot.cpp | 13 +++++------ Telegram/SourceFiles/api/api_earn.cpp | 22 +++++++++++++------ Telegram/SourceFiles/boxes/passcode_box.cpp | 2 +- Telegram/SourceFiles/boxes/passcode_box.h | 5 ++++- .../boxes/peers/edit_participant_box.cpp | 10 ++++----- .../payments/payments_checkout_process.cpp | 8 +++---- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index 706b7a7cb..0284ae719 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -236,14 +236,14 @@ void SendBotCallbackDataWithPassword( } else { return; } - const auto box = std::make_shared>(); auto fields = PasscodeBox::CloudFields::From(state); fields.customTitle = tr::lng_bots_password_confirm_title(); fields.customDescription = tr::lng_bots_password_confirm_description(tr::now); fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = [=]( - const Core::CloudPasswordResult &result) { + const Core::CloudPasswordResult &result, + QPointer box) { if (const auto button = getButton()) { if (button->requestId) { return; @@ -257,18 +257,17 @@ void SendBotCallbackDataWithPassword( return; } SendBotCallbackData(strongController, item, row, column, result, [=] { - if (*box) { - (*box)->closeBox(); + if (box) { + box->closeBox(); } }, [=](const QString &error) { - if (*box) { - (*box)->handleCustomCheckError(error); + if (box) { + box->handleCustomCheckError(error); } }); } }; auto object = Box(session, fields); - *box = Ui::MakeWeak(object.data()); show->showBox(std::move(object), Ui::LayerOption::CloseOther); }, *lifetime); } diff --git a/Telegram/SourceFiles/api/api_earn.cpp b/Telegram/SourceFiles/api/api_earn.cpp index 61cfaf10f..d6425ef69 100644 --- a/Telegram/SourceFiles/api/api_earn.cpp +++ b/Telegram/SourceFiles/api/api_earn.cpp @@ -64,19 +64,27 @@ void HandleWithdrawalButton( = tr::lng_channel_earn_balance_password_description(tr::now); fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(button, [=]( - const Core::CloudPasswordResult &result) { + const Core::CloudPasswordResult &result, + QPointer box) { + const auto done = [=](const QString &result) { + if (!result.isEmpty()) { + UrlClickHandler::Open(result); + if (box) { + box->closeBox(); + } + } + }; + const auto fail = [=](const QString &error) { + show->showToast(error); + }; session->api().request( MTPstats_GetBroadcastRevenueWithdrawalUrl( channel->inputChannel, result.result )).done([=](const MTPstats_BroadcastRevenueWithdrawalUrl &r) { - const auto url = qs(r.data().vurl()); - - if (!url.isEmpty()) { - UrlClickHandler::Open(url); - } + done(qs(r.data().vurl())); }).fail([=](const MTP::Error &error) { - show->showToast(error.type()); + fail(error.type()); }).send(); }); show->show(Box(session, fields)); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index e320b434f..840e4872d 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -740,7 +740,7 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) { void PasscodeBox::sendOnlyCheckCloudPassword(const QString &oldPassword) { checkPassword(oldPassword, [=](const Core::CloudPasswordResult &check) { if (const auto onstack = _cloudFields.customCheckCallback) { - onstack(check); + onstack(check, Ui::MakeWeak(this)); } else { Assert(_cloudFields.turningOff); sendClearCloudPassword(check); diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index 684da859a..b651cda64 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -51,7 +51,10 @@ public: TimeId pendingResetDate = 0; // Check cloud password for some action. - Fn customCheckCallback; + using CustomCheck = Fn)>; + CustomCheck customCheckCallback; rpl::producer customTitle; std::optional customDescription; rpl::producer customSubmitButton; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index c1c086ad1..39389d1d5 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -598,19 +598,17 @@ void EditAdminBox::requestTransferPassword(not_null channel) { ) | rpl::take( 1 ) | rpl::start_with_next([=](const Core::CloudPasswordState &state) { - const auto box = std::make_shared>(); auto fields = PasscodeBox::CloudFields::From(state); fields.customTitle = tr::lng_rights_transfer_password_title(); fields.customDescription = tr::lng_rights_transfer_password_description(tr::now); fields.customSubmitButton = tr::lng_passcode_submit(); fields.customCheckCallback = crl::guard(this, [=]( - const Core::CloudPasswordResult &result) { - sendTransferRequestFrom(*box, channel, result); + const Core::CloudPasswordResult &result, + QPointer box) { + sendTransferRequestFrom(box, channel, result); }); - *box = getDelegate()->show(Box( - &channel->session(), - fields)); + getDelegate()->show(Box(&channel->session(), fields)); }, lifetime()); } diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.cpp b/Telegram/SourceFiles/payments/payments_checkout_process.cpp index b9e1b631d..ad7299664 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.cpp +++ b/Telegram/SourceFiles/payments/payments_checkout_process.cpp @@ -766,12 +766,12 @@ void CheckoutProcess::requestPassword() { (index < list.size()) ? list[index].title : QString()); fields.customSubmitButton = tr::lng_payments_password_submit(); fields.customCheckCallback = [=]( - const Core::CloudPasswordResult &result) { + const Core::CloudPasswordResult &result, + QPointer box) { + _enterPasswordBox = box; _form->submit(result); }; - auto owned = Box(_session, fields); - _enterPasswordBox = owned.data(); - _panel->showBox(std::move(owned)); + _panel->showBox(Box(_session, fields)); }); } From abe83ccb8f4de2445a033bcf453274a1ea0d25e8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Apr 2024 20:37:10 +0300 Subject: [PATCH 16/38] Moved inaccessible groups in box for user's own groups to sub-list. Fixed #27729. --- Telegram/SourceFiles/ui/menu_icons.style | 1 + .../window/window_main_menu_helpers.cpp | 51 +++++++++++++++---- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index 862caf79d..4ec165b62 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -151,6 +151,7 @@ menuIconAsTopics: icon {{ "menu/mode_topics", menuIconColor }}; menuIconAsMessages: icon {{ "menu/mode_messages", menuIconColor }}; menuIconTagFilter: icon{{ "menu/tag_filter", menuIconColor }}; menuIconTagRename: icon{{ "menu/tag_rename", menuIconColor }}; +menuIconGroupsHide: icon {{ "menu/hide_members", menuIconColor }}; menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }}; menuIconTTLAnyTextPosition: point(11px, 22px); diff --git a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp index 88c0af421..b70fb833a 100644 --- a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp +++ b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp @@ -27,10 +27,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/rect.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/tooltip.h" +#include "ui/wrap/slide_wrap.h" #include "window/window_controller.h" #include "window/window_session_controller.h" -#include "styles/style_chat.h" // popupMenuExpandedSeparator -#include "styles/style_info.h" // infoTopBarMenu +#include "styles/style_chat.h" +#include "styles/style_info.h" #include "styles/style_menu_icons.h" #include "styles/style_window.h" @@ -177,7 +178,9 @@ not_null AddMyChannelsBox( const auto count = c ? c->membersCount() : g->count; _status.setText( st::defaultTextStyle, - !p->username().isEmpty() + (g && !g->amIn()) + ? tr::lng_chat_status_unaccessible(tr::now) + : !p->username().isEmpty() ? ('@' + p->username()) : (count > 0) ? ((c && !c->isMegagroup()) @@ -219,10 +222,11 @@ not_null AddMyChannelsBox( }; - const auto add = [&](not_null peer) { - const auto row = box->addRow( - object_ptr