### Install AyuGram Desktop from Nixpkgs Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install ayugram-desktop from the Nixpkgs channel. ```bash Install `ayugram-desktop` from [nixpkgs](https://search.nixos.org/packages?channel=unstable&show=ayugram-desktop) ``` -------------------------------- ### Install AyuGram Desktop with Winget Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Use Winget to install AyuGram Desktop on Windows. ```bash winget install RadolynLabs.AyuGramDesktop ``` -------------------------------- ### Install Metainfo File Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Installs the application's metainfo XML file to the system's metainfo directory. ```cmake install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.ayugram.desktop.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") ``` -------------------------------- ### Install AyuGram Desktop with Scoop Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Add the extras bucket and install AyuGram Desktop using Scoop on Windows. ```bash scoop bucket add extras scoop install ayugram ``` -------------------------------- ### Install AyuGram Desktop with NixOS Flake Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install ayugram-desktop using a NixOS flake from the specified repository. ```bash Install `ayugram-desktop` from [ndfined-crp/ayugram-desktop](https://github.com/ndfined-crp/ayugram-desktop) ``` -------------------------------- ### Install AyuGram Desktop with Homebrew Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install AyuGram Desktop as a cask using Homebrew on macOS. ```bash brew install --cask ayugram ``` -------------------------------- ### Install AyuGram Desktop with EPM Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install AyuGram Desktop using the EPM package manager. ```bash epm play ayugram ``` -------------------------------- ### Install AyuGram Desktop via Flatpak Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install AyuGram Desktop using Flatpak for any Linux distribution. ```bash Flatpak: https://github.com/0FL01/AyuGramDesktop-flatpak ``` -------------------------------- ### Install AyuGram Desktop with DNF (Fedora) Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install AyuGram Desktop from the RPM Fusion repository using DNF on Fedora. ```bash dnf install ayugram-desktop ``` -------------------------------- ### Install Homebrew and Dependencies Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-mac.md Installs Homebrew and essential build tools like git, automake, cmake, wget, pkg-config, gnu-tar, ninja, nasm, and meson. It also sets the Xcode command-line tools path. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install git automake cmake wget pkg-config gnu-tar ninja nasm meson sudo xcode-select -s /Applications/Xcode.app/Contents/Developer ``` -------------------------------- ### Clone Source Code and Prepare Libraries Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-linux.md Clone the Ayugram Desktop repository and run the preparation script for Linux. Ensure Poetry, Docker, and Docker-Buildx are installed beforehand. ```bash git clone --recursive https://github.com/AyuGram/AyuGramDesktop.git tdesktop ./tdesktop/Telegram/build/prepare/linux.sh ``` -------------------------------- ### Starting RPL Pipelines with Subscription Lifetime Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Start pipelines using `std::move` on producers. Pass `rpl::lifetime` to `rpl::on_next` for automatic unsubscription, or store the returned lifetime manually. ```cpp std::move(counter) | rpl::on_next([=](int value) { qDebug() << "Received: " << value; }, lifetime); // Without lifetime parameter - MUST store returned lifetime: auto subscriptionLifetime = std::move(counter) | rpl::on_next([=](int value) { // process value }); ``` -------------------------------- ### Install AyuGram Desktop from AUR (Arch Linux) Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install the ayugram-desktop package from the Arch User Repository (AUR) on Arch Linux. ```bash Install `ayugram-desktop` from [AUR](https://aur.archlinux.org/packages/ayugram-desktop). ``` -------------------------------- ### Install AyuGram Desktop from AUR (Prebuilt Binaries) Source: https://github.com/ayugram/ayugramdesktop/blob/dev/README.md Install the ayugram-desktop-bin package from the Arch User Repository (AUR) on Arch Linux. Note: these binaries are not officially maintained. ```bash Install `ayugram-desktop-bin` from [AUR](https://aur.archlinux.org/packages/ayugram-desktop-bin). ``` -------------------------------- ### Linux Desktop Integration Files Configuration Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Configures and installs Linux desktop integration files, including service files, metainfo, and application icons. ```cmake include(GNUInstallDirs) configure_file("../lib/xdg/com.ayugram.desktop.service" "${CMAKE_CURRENT_BINARY_DIR}/com.ayugram.desktop.service" @ONLY) configure_file("../lib/xdg/com.ayugram.desktop.metainfo.xml" "${CMAKE_CURRENT_BINARY_DIR}/com.ayugram.desktop.metainfo.xml" @ONLY) generate_appstream_changelog(Telegram "${CMAKE_SOURCE_DIR}/changelog.txt" "${CMAKE_CURRENT_BINARY_DIR}/com.ayugram.desktop.metainfo.xml") ``` -------------------------------- ### Install Linux Tray Icons and Desktop Entry Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Installs symbolic tray icons and the main desktop entry file for the Ayugram application on Linux. ```cmake install(FILES "Resources/icons/tray_monochrome.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/symbolic/apps" RENAME "com.ayugram.desktop-symbolic.svg") install(FILES "Resources/icons/tray_monochrome_attention.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/symbolic/apps" RENAME "com.ayugram.desktop-attention-symbolic.svg") install(FILES "Resources/icons/tray_monochrome_mute.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/symbolic/apps" RENAME "com.ayugram.desktop-mute-symbolic.svg") install(FILES "../lib/xdg/com.ayugram.desktop.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/com.ayugram.desktop.service" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services") ``` -------------------------------- ### Install Telegram Executable and Icons on Linux Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Installs the main Telegram executable and various icon sizes for the desktop application on Linux systems. ```cmake install(TARGETS Telegram RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}") install(FILES "Resources/art/icon16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon16@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon32@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon48@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon64@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon128@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon256@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256@2/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "com.ayugram.desktop.png") install(FILES "Resources/art/icon512@2x.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512@2/apps" RENAME "com.ayugram.desktop.png") ``` -------------------------------- ### Multi-line Expressions: Operators at Start of Continuation Lines Source: https://github.com/ayugram/ayugramdesktop/blob/dev/REVIEW.md When splitting expressions across lines, place operators like '&&', '||', ';', or '+' at the beginning of continuation lines. This improves readability by clearly marking lines as continuations. ```cpp // BAD - continuation looks like scope code: if (const auto &lottie = animation->lottie; lottie && lottie->valid() && lottie->framesCount() > 1) { lottie->animate([=] { ``` ```cpp // GOOD - semicolon at start signals continuation: if (const auto &lottie = animation->lottie ; lottie && lottie->valid() && lottie->framesCount() > 1) { lottie->animate([=] { ``` ```cpp // BAD - trailing && makes next line look like independent code: if (veryLongExpression() && anotherLongExpression() && anotherOne()) { doSomething(); ``` ```cpp // GOOD - leading && clearly marks continuation: if (veryLongExpression() && anotherLongExpression() && anotherOne()) { doSomething(); ``` -------------------------------- ### Custom Style Definitions Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Defines custom button styles using a .style file, inheriting properties and overriding specific values. Includes basic and primary button examples. ```style using "ui/basic.style"; using "ui/widgets/widgets.style"; MyButtonStyle { textPadding: margins; icon: icon; height: pixels; } defaultButton: MyButtonStyle { textPadding: margins(10px, 15px, 10px, 15px); icon: icon{{ "gui/icons/search", iconColor }}; height: 30px; } primaryButton: MyButtonStyle(defaultButton) { icon: icon{{ "gui/icons/check", iconColor }}; } ``` -------------------------------- ### Clone Source Code and Prepare Libraries Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-win-x64.md Clone the AyuGram Desktop repository recursively and run the Windows build preparation script. Ensure you are in the correct build directory and use the x64 Native Tools Command Prompt. ```bash git clone --recursive https://github.com/AyuGram/AyuGramDesktop.git tdesktop tdesktop\Telegram\build\prepare\win.bat ``` -------------------------------- ### StartupTask Source Files Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Specifies the source file for the 'StartupTask' target. ```cmake nice_target_sources(StartupTask ${src_loc} PRIVATE _other/startup_task_win.cpp ) ``` -------------------------------- ### Configure Project for Windows 64-bit Build Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-win-x64.md Configure the project for a 64-bit build, specifying API ID and API Hash. This command should be run from the tdesktop/Telegram directory. ```bash configure.bat x64 -D TDESKTOP_API_ID=2040 -D TDESKTOP_API_HASH=b18441a1ff607e10a989891a5462e627 ``` -------------------------------- ### Define StartupTask Executable Target Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Defines the 'StartupTask' executable target for Windows, initializes it, and adds it as a dependency to the 'Telegram' target. ```cmake add_executable(StartupTask WIN32) init_non_host_target(StartupTask) add_dependencies(Telegram StartupTask) ``` -------------------------------- ### StartupTask Runtime Output Directory Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Sets the runtime output directory for the 'StartupTask' target. ```cmake set_target_properties(StartupTask PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder} ) ``` -------------------------------- ### Accessing Style Properties in C++ Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Demonstrates how to include style headers and access style properties like height, icon, and padding from C++ code using the 'st' namespace. ```cpp #include "styles/style_widgets.h" // Access style members int height = st::primaryButton.height; const style::icon &icon = st::primaryButton.icon; style::margins padding = st::primaryButton.textPadding; // Use in painting void MyWidget::paintEvent(QPaintEvent *e) { Painter p(this); p.fillRect(rect(), st::chatInput.backgroundColor); } ``` -------------------------------- ### Configure Project with API Credentials Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-mac.md Configures the build with specific API ID and API Hash for Telegram. This step is performed in the tdesktop/Telegram directory. ```bash ./configure.sh -D TDESKTOP_API_ID=2040 -D TDESKTOP_API_HASH=b18441a1ff607e10a989891a5462e627 ``` -------------------------------- ### Immediate String Formatting with Agents Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Use `tr::now` as the first argument for immediate QString translations. Placeholders follow the `lt_tag_name, value` pattern. ```cpp auto currentTitle = tr::lng_settings_title(tr::now); auto currentConfirmation = tr::lng_confirm_delete_item( tr::now, lt_item_name, currentItemName); auto filesText = tr::lng_files_selected(tr::now, lt_count, count); ``` -------------------------------- ### Handling API Response Constructors in C++ Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Illustrates how to handle API responses with multiple possible constructors using '.match()' or by explicitly checking the type and using constructor-specific accessors like '.c_user()'. ```cpp // Using match: result.match([&](const MTPDuser &data) { ... }, [&](const MTPDuserEmpty &data) { ... }); // Or explicit type check: if (result.type() == mtpc_user) { const auto &data = result.c_user(); // asserts on type mismatch } ``` -------------------------------- ### Build Release Version using Docker Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-linux.md Build the release version of Ayugram Desktop using a Docker container. This command mounts the current directory into the container and executes the build script with specified API credentials. ```bash docker run --rm -it \ -u $(id -u) \ -v "$PWD:/usr/src/tdesktop" \ ghcr.io/telegramdesktop/tdesktop/centos_env:latest \ /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ -D TDESKTOP_API_ID=2040 \ -D TDESKTOP_API_HASH=b18441a1ff607e10a989891a5462e627 ``` -------------------------------- ### Use RAII for Resource Cleanup Source: https://github.com/ayugram/ayugramdesktop/blob/dev/REVIEW.md Employ RAII wrappers like `gsl::finally` for resource cleanup (e.g., Win32 HANDLEs, file descriptors) instead of manual calls. This ensures resources are released correctly even if early returns are introduced later, preventing leaks. ```cpp // BAD - manual cleanup, fragile with early returns: const auto snapshot = CreateToolhelp32Snapshot(...); if (snapshot != INVALID_HANDLE_VALUE) { // ... logic that might grow early returns ... CloseHandle(snapshot); } // GOOD - RAII guard, cleanup runs on any exit path: const auto snapshot = CreateToolhelp32Snapshot(...); if (snapshot == INVALID_HANDLE_VALUE) { return; } const auto guard = gsl::finally([&] { CloseHandle(snapshot); }); // ... logic, early returns are safe ... ``` -------------------------------- ### Making Telegram API Requests in C++ Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Demonstrates the standard pattern for making API requests using 'api()', generated 'MTP...' types, and callbacks. Handles both successful responses with multiple constructors using '.match()' and single constructors using '.data()', as well as API errors. ```cpp api().request(MTPnamespace_MethodName( MTP_flags(flags_value), MTP_inputPeer(peer), MTP_string(messageText), MTP_long(randomId), MTP_vector() )).done([=](const MTPResponseType &result) { // Handle successful response // Multiple constructors - use .match() or check type: result.match([&](const MTPDuser &data) { // use data.vfirst_name().v }, [&](const MTPDuserEmpty &data) { // handle empty user }); // Single constructor - use .data() shortcut: const auto &data = result.data(); // use data.vmessages().v }).fail([=](const MTP::Error &error) { // Handle API error if (error.type() == u"FLOOD_WAIT_X"_q) { // Handle flood wait } }).handleFloodErrors().send(); ``` -------------------------------- ### Configure Mac Store Bundle Properties Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Sets properties for a Mac App Store build, including bundle identifier, entitlements file, output name, and linking options for the Breakpad framework. It also includes a custom command to copy the Breakpad framework. ```cmake if (build_macstore) set(bundle_identifier "org.telegram.desktop") set(bundle_entitlements "Telegram Lite.entitlements") set(output_name "Telegram Lite") target_link_options(Telegram PRIVATE -F${libs_loc}/breakpad/src/client/mac/build/Release ) target_link_frameworks(Telegram PRIVATE Breakpad) add_custom_command(TARGET Telegram PRE_LINK COMMAND rm -rf $/../Frameworks COMMAND mkdir -p $/../Frameworks COMMAND cp -a ${libs_loc}/breakpad/src/client/mac/build/Release/Breakpad.framework $/../Frameworks/Breakpad.framework COMMAND rm -rf $/../Frameworks/Breakpad.framework/Resources/crash_report_sender.app COMMAND rm -rf $/../Frameworks/Breakpad.framework/Resources/Inspector ) else() if (CMAKE_GENERATOR STREQUAL Xcode) set(bundle_identifier "one.ayugram.AyuGramDesktop$<$:Debug>") else() set(bundle_identifier "one.ayugram.AyuGramDesktop") endif() set(bundle_entitlements "Telegram.entitlements") set(output_name "AyuGram") endif() ``` -------------------------------- ### Send Inline and Block Code Source: https://github.com/ayugram/ayugramdesktop/blob/dev/changelog.txt Demonstrates the syntax for sending inline code using backticks and blocks of code using triple backticks. ```text Send code without text and emoji replaces using `such syntax` for inline parts and ```such syntax``` for blocks of code. ``` -------------------------------- ### Compile App Icons using actool Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Adds a custom command to compile application icons using the 'actool' executable for macOS targets. This command is executed pre-link and handles icon compilation and copying to the resources directory. ```cmake foreach (icon ${ayugram_icons}) add_custom_command(TARGET Telegram PRE_LINK COMMAND mkdir -p "${ICON_OUTPUT_DIR}" COMMAND ${ACTOOL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/Telegram/AppIcon-${icon}.icon" --compile "${ICON_OUTPUT_DIR}" --app-icon AppIcon-${icon} --enable-on-demand-resources NO --development-region en --target-device mac --platform macosx --minimum-deployment-target 10.13 --output-partial-info-plist /dev/null --output-format human-readable-text COMMENT "Compiling icon ${icon}" COMMAND cp "${ICON_OUTPUT_DIR}/AppIcon-${icon}.icns" "$/../Resources") endforeach() ``` -------------------------------- ### Avoid Wrapping Live Producers in rpl::single Source: https://github.com/ayugram/ayugramdesktop/blob/dev/REVIEW.md Do not wrap live language switching keys like `tr::lng_*()` in `rpl::single()`. This captures a frozen snapshot and prevents automatic updates when the language changes. Call the lang key directly to maintain live updates. ```cpp // BAD - frozen snapshot, won't update on language change: rpl::single(tr::lng_ai_compose_title(tr::now)) // GOOD - live producer that updates automatically: tr::lng_ai_compose_title() ``` -------------------------------- ### Visual Studio Code Dev Containers Configuration Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-linux.md Configure Visual Studio Code settings for Dev Containers to build Ayugram Desktop within a containerized environment. Replace YOUR_API_ID and YOUR_API_HASH with your actual credentials. ```json { "cmake.configureSettings": { "TDESKTOP_API_ID": "YOUR_API_ID", "TDESKTOP_API_HASH": "YOUR_API_HASH" } } ``` -------------------------------- ### Reactive String Formatting with Agents Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Omit `tr::now` for reactive `rpl::producer` translations. Reactive placeholders for `{count}` use `rpl::producer` with `| tr::to_count()`. ```cpp auto titleProducer = tr::lng_settings_title(); auto confirmationProducer = tr::lng_confirm_delete_item( lt_item_name, std::move(itemNameProducer)); auto filesTextProducer = tr::lng_files_selected( lt_count, countProducer | tr::to_count()); ``` -------------------------------- ### Build Debug Version using Docker Source: https://github.com/ayugram/ayugramdesktop/blob/dev/docs/building-linux.md Build the debug version of Ayugram Desktop using a Docker container. This is similar to the release build but sets the CONFIG environment variable to Debug. ```bash docker run --rm -it \ -u $(id -u) \ -v "$PWD:/usr/src/tdesktop" \ -e CONFIG=Debug \ ghcr.io/telegramdesktop/tdesktop/centos_env:latest \ /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ -D TDESKTOP_API_ID=2040 \ -D TDESKTOP_API_HASH=b18441a1ff607e10a989891a5462e627 ``` -------------------------------- ### Include Library Subdirectories Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Includes various library subdirectories into the build system, allowing for modular development and management of different project components. ```cmake add_subdirectory(lib_rpl) ``` ```cmake add_subdirectory(lib_crl) ``` ```cmake add_subdirectory(lib_base) ``` ```cmake add_subdirectory(lib_ui) ``` ```cmake add_subdirectory(lib_tl) ``` ```cmake add_subdirectory(lib_spellcheck) ``` ```cmake add_subdirectory(lib_storage) ``` ```cmake add_subdirectory(lib_lottie) ``` ```cmake add_subdirectory(lib_qr) ``` ```cmake add_subdirectory(lib_translate) ``` ```cmake add_subdirectory(lib_webrtc) ``` ```cmake add_subdirectory(lib_webview) ``` ```cmake add_subdirectory(codegen) ``` -------------------------------- ### Use tr:: projections for TextWithEntities Source: https://github.com/ayugram/ayugramdesktop/blob/dev/REVIEW.md Prefer `tr::` projection helpers over `Ui::Text::` equivalents for conciseness and uniform behavior. Use `tr::marked()` for creating `TextWithEntities`. ```cpp // BAD - verbose Ui::Text:: functions: tr::lng_some_key( tr::now, lt_name, Ui::Text::Bold(name), lt_group, Ui::Text::Bold(group), Ui::Text::RichLangValue) // GOOD - concise tr:: helpers: tr::lng_some_key( tr::now, lt_name, tr::bold(name), lt_group, tr::bold(group), tr::rich) ``` ```cpp // BAD - verbose constructor: auto text = TextWithEntities(); auto text = TextWithEntities{ u"hello"_q }; auto text = TextWithEntities().append(u"hello"_q); // GOOD - concise: auto text = tr::marked(); auto text = tr::marked(u"hello"_q); ``` -------------------------------- ### String Definitions for Localization Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Defines localized strings in a .strings file, including simple strings, strings with placeholders, and pluralized strings. ```strings "lng_settings_title" = "Settings"; "lng_confirm_delete_item" = "Are you sure you want to delete {item_name}?"; "lng_files_selected#one" = "{count} file selected"; "lng_files_selected#other" = "{count} files selected"; ``` -------------------------------- ### Conditional Linking for DirectX Helper (Qt < 6) Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Links the win_directx_helper library for Windows builds when the Qt version is less than 6. This is specific to the Telegram target. ```cmake if (QT_VERSION LESS 6) target_link_libraries(Telegram PRIVATE desktop-app::win_directx_helper) endif() ``` -------------------------------- ### Generate D-Bus Interface Files Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Generates D-Bus interface files for Telegram, specifically for XdgBackground and XdgNotifications. This is part of the Linux platform integration. ```cmake include(${cmake_helpers_loc}/external/glib/generate_dbus.cmake) generate_dbus(Telegram org.freedesktop.portal. XdpBackground ${third_party_loc}/xdg-desktop-portal/data/org.freedesktop.portal.Background.xml) generate_dbus(Telegram org.freedesktop. XdgNotifications ${src_loc}/platform/linux/org.freedesktop.Notifications.xml) ``` -------------------------------- ### Add Custom Command for Resource Copying Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Defines a custom command to be executed before linking the Telegram target. This command creates a Resources directory and copies compiled UI and spellcheck resource files into it. ```cmake add_custom_command(TARGET Telegram PRE_LINK COMMAND mkdir -p $/../Resources COMMAND cp ${CMAKE_BINARY_DIR}/lib_ui.rcc $/../Resources COMMAND cp ${CMAKE_BINARY_DIR}/lib_spellcheck.rcc $/../Resources ) ``` -------------------------------- ### Rich Text Projection with Agents Source: https://github.com/ayugram/ayugramdesktop/blob/dev/AGENTS.md Use `tr::` helpers as the last argument for rich text projection or as placeholder wrappers. `tr::marked` converts QString to TextWithEntities. ```cpp // As last argument (projector): auto title = tr::lng_export_progress_title(tr::now, tr::bold); auto text = tr::lng_proxy_incorrect_secret(tr::now, tr::rich); // As placeholder value wrapper + projector: auto desc = tr::lng_some_key( tr::now, lt_name, tr::bold(userName), lt_group, tr::bold(groupName), tr::rich); // Nested tr::lng as placeholder: auto linked = tr::lng_settings_birthday_contacts( lt_link, tr::lng_settings_birthday_contacts_link(tr::url(link)), tr::marked); ``` -------------------------------- ### Process Language String Files Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt Iterates through a list of language codes, sets the macOSX package location for their Localizable.strings files, and adds them as sources to the Telegram target. It also creates a source group for these files. ```cmake set(lang_packs en de es it nl ko pt-BR ) foreach (lang ${lang_packs}) set(strings_path ${res_loc}/langs/${lang}.lproj/Localizable.strings) set_source_files_properties(${strings_path} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${lang}.lproj ) target_sources(Telegram PRIVATE ${strings_path}) source_group(TREE ${res_loc} PREFIX Resources FILES ${strings_path}) endforeach() ``` -------------------------------- ### macOS Updater Post-Build Command Source: https://github.com/ayugram/ayugramdesktop/blob/dev/Telegram/CMakeLists.txt For macOS builds, this command copies the Updater executable to the Frameworks directory after the build is complete. ```cmake add_custom_command(TARGET Updater POST_BUILD COMMAND mkdir -p $/../Frameworks COMMAND cp $ $/../Frameworks/ ) ```