From 847c01d6053bc2773605dd25e387b505a98bfe44 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 19 Oct 2021 17:00:21 +0400 Subject: [PATCH] Add Qt 6 support Tested only on Linux so far --- Telegram/CMakeLists.txt | 20 ++++++-- .../SourceFiles/api/api_blocked_peers.cpp | 2 +- Telegram/SourceFiles/api/api_sending.cpp | 2 +- Telegram/SourceFiles/api/api_who_read.cpp | 2 +- Telegram/SourceFiles/apiwrap.cpp | 4 +- Telegram/SourceFiles/boxes/connection_box.cpp | 8 +-- .../boxes/dictionaries_manager.cpp | 5 -- Telegram/SourceFiles/boxes/language_box.cpp | 2 +- Telegram/SourceFiles/boxes/passcode_box.cpp | 3 +- Telegram/SourceFiles/boxes/peer_list_box.cpp | 2 +- Telegram/SourceFiles/boxes/peer_list_box.h | 2 +- .../boxes/peers/edit_participant_box.cpp | 3 +- Telegram/SourceFiles/boxes/share_box.cpp | 4 +- .../SourceFiles/boxes/sticker_set_box.cpp | 4 +- Telegram/SourceFiles/calls/calls_panel.cpp | 1 - .../calls/calls_video_incoming.cpp | 4 +- .../calls/group/calls_group_panel.cpp | 1 - .../calls/group/calls_group_viewport.cpp | 2 +- .../group/calls_group_viewport_opengl.cpp | 2 +- .../calls/group/calls_group_viewport_opengl.h | 4 +- .../SourceFiles/chat_helpers/bot_keyboard.cpp | 2 +- .../SourceFiles/chat_helpers/bot_keyboard.h | 2 +- .../chat_helpers/emoji_keywords.cpp | 2 +- .../chat_helpers/emoji_list_widget.cpp | 4 +- .../chat_helpers/emoji_suggestions_widget.cpp | 2 +- .../chat_helpers/emoji_suggestions_widget.h | 2 +- .../chat_helpers/field_autocomplete.cpp | 13 ++--- .../chat_helpers/message_field.cpp | 11 ++-- .../chat_helpers/spellchecker_common.cpp | 2 +- .../SourceFiles/chat_helpers/tabbed_panel.cpp | 2 +- .../SourceFiles/chat_helpers/tabbed_panel.h | 2 +- Telegram/SourceFiles/core/application.cpp | 4 +- Telegram/SourceFiles/core/changelogs.cpp | 3 +- Telegram/SourceFiles/core/launcher.cpp | 4 +- .../SourceFiles/core/local_url_handlers.cpp | 7 +-- Telegram/SourceFiles/core/sandbox.cpp | 11 ++-- Telegram/SourceFiles/core/sandbox.h | 3 +- Telegram/SourceFiles/core/shortcuts.cpp | 2 +- Telegram/SourceFiles/core/update_checker.cpp | 4 +- .../countries/countries_instance.cpp | 6 ++- Telegram/SourceFiles/data/data_document.cpp | 4 +- .../data/data_document_resolver.cpp | 2 +- .../SourceFiles/data/data_peer_values.cpp | 3 +- Telegram/SourceFiles/data/data_web_page.cpp | 3 +- .../data/stickers/data_stickers.cpp | 6 +-- .../dialogs/dialogs_inner_widget.cpp | 9 ++-- .../dialogs/dialogs_inner_widget.h | 4 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 9 ++-- Telegram/SourceFiles/editor/editor_crop.cpp | 6 +-- Telegram/SourceFiles/editor/editor_paint.cpp | 2 +- .../export/data/export_data_types.cpp | 4 +- .../SourceFiles/export/export_api_wrap.cpp | 4 +- .../export/output/export_output_file.cpp | 7 +-- .../export/output/export_output_html.cpp | 12 ++--- .../export/output/export_output_json.cpp | 2 +- .../view/export_view_panel_controller.cpp | 4 +- .../export/view/export_view_settings.cpp | 3 +- .../SourceFiles/ffmpeg/ffmpeg_utility.cpp | 14 ++---- .../admin_log/history_admin_log_inner.cpp | 2 +- .../admin_log/history_admin_log_inner.h | 2 +- .../admin_log/history_admin_log_item.cpp | 8 +-- Telegram/SourceFiles/history/history.cpp | 7 +-- Telegram/SourceFiles/history/history.h | 2 +- .../history/history_inner_widget.cpp | 5 +- .../history/history_inner_widget.h | 2 +- .../history/history_item_components.cpp | 3 +- .../SourceFiles/history/history_service.cpp | 4 +- .../SourceFiles/history/history_widget.cpp | 12 ++--- .../history_view_compose_controls.cpp | 6 +-- .../history/view/history_view_list_widget.cpp | 2 +- .../history/view/history_view_list_widget.h | 2 +- .../history/view/history_view_view_button.cpp | 1 - .../view/media/history_view_document.cpp | 2 +- .../view/media/history_view_invoice.cpp | 2 +- .../history/view/media/history_view_media.cpp | 16 +++--- .../info/media/info_media_list_widget.cpp | 2 +- .../info/media/info_media_list_widget.h | 2 +- .../inline_bots/inline_bot_layout_item.cpp | 2 +- Telegram/SourceFiles/intro/intro_widget.cpp | 4 +- .../SourceFiles/lang/lang_file_parser.cpp | 4 ++ Telegram/SourceFiles/lang/lang_tag.cpp | 7 +-- .../SourceFiles/lang/lang_text_entity.cpp | 6 +-- Telegram/SourceFiles/logs.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 6 +-- .../media/clip/media_clip_check_streaming.cpp | 1 + .../media/clip/media_clip_ffmpeg.cpp | 2 +- .../media/clip/media_clip_implementation.h | 1 + .../media/player/media_player_panel.cpp | 2 +- .../media/player/media_player_panel.h | 2 +- .../player/media_player_volume_controller.cpp | 2 +- .../player/media_player_volume_controller.h | 2 +- .../streaming/media_streaming_utility.cpp | 2 +- .../streaming/media_streaming_video_track.cpp | 2 +- .../media/view/media_view_overlay_opengl.h | 2 +- .../media/view/media_view_overlay_widget.cpp | 4 +- .../SourceFiles/media/view/media_view_pip.cpp | 3 +- .../media/view/media_view_pip_opengl.h | 2 +- .../mtproto/details/mtproto_dc_key_binder.cpp | 2 +- .../mtproto/details/mtproto_tls_socket.cpp | 2 +- .../mtproto/mtproto_dc_options.cpp | 7 ++- .../mtproto/mtproto_proxy_data.cpp | 5 +- .../SourceFiles/mtproto/session_private.cpp | 2 +- .../mtproto/special_config_request.cpp | 8 +-- .../SourceFiles/overview/overview_layout.cpp | 5 +- .../passport/passport_panel_edit_contact.cpp | 2 +- .../passport/ui/passport_details_row.cpp | 19 +++---- .../payments/stripe/stripe_card_validator.cpp | 10 ++-- .../payments/stripe/stripe_error.cpp | 2 +- .../payments/stripe/stripe_token.cpp | 2 +- .../payments/ui/payments_edit_card.cpp | 20 ++++---- .../payments/ui/payments_field.cpp | 25 +++++----- .../linux/linux_desktop_environment.cpp | 4 +- .../platform/linux/linux_xdp_file_dialog.cpp | 1 - .../platform/linux/main_window_linux.cpp | 50 +++++++++++++------ .../linux/notifications_manager_linux.cpp | 2 +- .../platform/linux/specific_linux.cpp | 4 +- .../platform/mac/file_utilities_mac.mm | 3 +- .../platform/mac/specific_mac_p.mm | 2 - .../profile/profile_block_peer_list.cpp | 2 +- .../profile/profile_block_peer_list.h | 4 +- .../SourceFiles/settings/settings_codes.cpp | 3 +- .../settings/settings_information.cpp | 2 +- Telegram/SourceFiles/stdafx.h | 2 +- .../SourceFiles/storage/localimageloader.cpp | 4 +- .../SourceFiles/storage/storage_account.cpp | 4 +- .../support/support_autocomplete.cpp | 3 +- .../SourceFiles/support/support_helper.cpp | 27 +++++----- .../SourceFiles/support/support_templates.cpp | 2 +- .../ui/boxes/country_select_box.cpp | 7 ++- Telegram/SourceFiles/ui/countryinput.cpp | 3 +- Telegram/SourceFiles/ui/countryinput.h | 2 +- Telegram/SourceFiles/ui/filter_icon_panel.cpp | 2 +- Telegram/SourceFiles/ui/filter_icon_panel.h | 2 +- .../ui/image/image_location_factory.cpp | 8 +-- Telegram/SourceFiles/ui/special_fields.cpp | 12 ++--- .../SourceFiles/ui/text/format_song_name.cpp | 4 +- .../ui/widgets/continuous_sliders.cpp | 2 +- .../ui/widgets/continuous_sliders.h | 2 +- .../SourceFiles/ui/widgets/separate_panel.cpp | 1 - Telegram/SourceFiles/window/main_window.cpp | 9 ++-- .../window/notifications_manager.cpp | 4 +- .../window/notifications_manager_default.cpp | 4 +- .../window/notifications_manager_default.h | 4 +- .../themes/window_theme_editor_block.cpp | 3 +- .../SourceFiles/window/window_peer_menu.cpp | 2 +- Telegram/cmake/lib_stripe.cmake | 1 + Telegram/codegen | 2 +- Telegram/lib_base | 2 +- Telegram/lib_lottie | 2 +- Telegram/lib_spellcheck | 2 +- Telegram/lib_ui | 2 +- Telegram/lib_waylandshells | 2 +- Telegram/lib_webrtc | 2 +- cmake | 2 +- 154 files changed, 382 insertions(+), 339 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 5ce76bd32..ac51d69d1 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1197,7 +1197,7 @@ else() ) endif() -if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) +if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION OR DESKTOP_APP_QT6) remove_target_sources(Telegram ${src_loc} platform/linux/linux_wayland_integration.cpp ) @@ -1289,10 +1289,16 @@ elseif (APPLE) endif() else() if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) + if (NOT DESKTOP_APP_QT6) + target_link_libraries(Telegram + PRIVATE + desktop-app::external_statusnotifieritem + desktop-app::external_dbusmenu_qt + ) + endif() + target_link_libraries(Telegram PRIVATE - desktop-app::external_statusnotifieritem - desktop-app::external_dbusmenu_qt desktop-app::external_glibmm desktop-app::external_glib ) @@ -1309,8 +1315,14 @@ else() target_link_libraries(Telegram PRIVATE desktop-app::lib_waylandshells - desktop-app::external_kwayland ) + + if (NOT DESKTOP_APP_QT6) + target_link_libraries(Telegram + PRIVATE + desktop-app::external_kwayland + ) + endif() endif() endif() diff --git a/Telegram/SourceFiles/api/api_blocked_peers.cpp b/Telegram/SourceFiles/api/api_blocked_peers.cpp index 823147894..f6edad324 100644 --- a/Telegram/SourceFiles/api/api_blocked_peers.cpp +++ b/Telegram/SourceFiles/api/api_blocked_peers.cpp @@ -26,7 +26,7 @@ BlockedPeers::Slice TLToSlice( Data::Session &owner) { const auto create = [&](int count, const QVector &list) { auto slice = BlockedPeers::Slice(); - slice.total = std::max(count, list.size()); + slice.total = std::max(count, int(list.size())); slice.list.reserve(list.size()); for (const auto &contact : list) { contact.match([&](const MTPDpeerBlocked &data) { diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index 114ea5576..8e3b8c848 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -212,7 +212,7 @@ void SendExistingPhoto( } bool SendDice(Api::MessageToSend &message) { - const auto full = message.textWithTags.text.midRef(0).trimmed(); + const auto full = QStringView(message.textWithTags.text).trimmed(); auto length = 0; if (!Ui::Emoji::Find(full.data(), full.data() + full.size(), &length) || length != full.size()) { diff --git a/Telegram/SourceFiles/api/api_who_read.cpp b/Telegram/SourceFiles/api/api_who_read.cpp index 07d1ede61..46c56e57a 100644 --- a/Telegram/SourceFiles/api/api_who_read.cpp +++ b/Telegram/SourceFiles/api/api_who_read.cpp @@ -159,7 +159,7 @@ struct State { auto &entry = context->cache(item); entry.requestId = 0; auto peers = std::vector(); - peers.reserve(std::max(result.v.size(), 1)); + peers.reserve(std::max(int(result.v.size()), 1)); for (const auto &id : result.v) { peers.push_back(UserId(id)); } diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 3fa3c45d4..7511b60ef 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -478,7 +478,7 @@ void ApiWrap::sendMessageFail( link))); } else if (error.type().startsWith(qstr("SLOWMODE_WAIT_"))) { const auto chop = qstr("SLOWMODE_WAIT_").size(); - const auto left = error.type().midRef(chop).toInt(); + const auto left = base::StringViewMid(error.type(), chop).toInt(); if (const auto channel = peer->asChannel()) { const auto seconds = channel->slowmodeSeconds(); if (seconds >= left) { @@ -3263,7 +3263,7 @@ void ApiWrap::requestMessageAfterDate( // So we request a message with offset_date = desired_date - 1 and add_offset = -1. // This should give us the first message with date >= desired_date. const auto offsetId = 0; - const auto offsetDate = static_cast(base::QDateToDateTime(date).toTime_t()) - 1; + const auto offsetDate = static_cast(date.startOfDay().toSecsSinceEpoch()) - 1; const auto addOffset = -1; const auto limit = 1; const auto maxId = 0; diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index cfea47330..05fdd32f4 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -74,7 +74,7 @@ void HostInput::correctValue( QString newText; int newCursor = nowCursor; newText.reserve(now.size()); - for (auto i = 0, l = now.size(); i < l; ++i) { + for (auto i = 0, l = int(now.size()); i < l; ++i) { if (now[i] == ',') { newText.append('.'); } else { @@ -120,7 +120,7 @@ void Base64UrlInput::correctValue( QString newText; newText.reserve(now.size()); auto newPos = nowCursor; - for (auto i = 0, l = now.size(); i < l; ++i) { + for (auto i = 0, l = int(now.size()); i < l; ++i) { const auto ch = now[i]; if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') @@ -537,8 +537,8 @@ void ProxyRow::showMenu() { _deleteClicks.fire({}); }); } - const auto parentTopLeft = window()->mapToGlobal({ 0, 0 }); - const auto buttonTopLeft = _menuToggle->mapToGlobal({ 0, 0 }); + const auto parentTopLeft = window()->mapToGlobal(QPoint()); + const auto buttonTopLeft = _menuToggle->mapToGlobal(QPoint()); const auto parent = QRect(parentTopLeft, window()->size()); const auto button = QRect(buttonTopLeft, _menuToggle->size()); const auto bottom = button.y() diff --git a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp index e8caa8404..d83c9cdef 100644 --- a/Telegram/SourceFiles/boxes/dictionaries_manager.cpp +++ b/Telegram/SourceFiles/boxes/dictionaries_manager.cpp @@ -39,11 +39,6 @@ using DictState = BlobState; using QueryCallback = Fn; constexpr auto kMaxQueryLength = 15; -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) -#define OLD_QT -using QStringView = QString; -#endif - class Inner : public Ui::RpWidget { public: Inner( diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 0516cbf31..2bca858d5 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -478,7 +478,7 @@ void Rows::showMenu(int index) { } } const auto toggle = menuToggleArea(row); - const auto parentTopLeft = window()->mapToGlobal({ 0, 0 }); + const auto parentTopLeft = window()->mapToGlobal(QPoint()); const auto buttonTopLeft = mapToGlobal(toggle.topLeft()); const auto parent = QRect(parentTopLeft, window()->size()); const auto button = QRect(buttonTopLeft, toggle.size()); diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 4e18e4b0b..4dde9db8a 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include "styles/style_passport.h" #include "styles/style_boxes.h" +#include "base/qt_adapters.h" namespace { @@ -525,7 +526,7 @@ void PasscodeBox::setPasswordFail( const MTP::Error &error) { const auto prefix = qstr("EMAIL_UNCONFIRMED_"); if (error.type().startsWith(prefix)) { - const auto codeLength = error.type().midRef(prefix.size()).toInt(); + const auto codeLength = base::StringViewMid(error.type(), prefix.size()).toInt(); closeReplacedBy(); _setRequest = 0; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 6a9478952..110bd9837 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -1240,7 +1240,7 @@ int PeerListContent::resizeGetHeight(int newWidth) { return belowTop + _belowHeight; } -void PeerListContent::enterEventHook(QEvent *e) { +void PeerListContent::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index ce2d6a62a..d679ddaa8 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -622,7 +622,7 @@ protected: int visibleBottom) override; void paintEvent(QPaintEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 94440a24c..ee5365667 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -34,7 +34,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "core/core_cloud_password.h" #include "base/unixtime.h" -#include "base/qt_adapters.h" #include "apiwrap.h" #include "api/api_cloud_password.h" #include "main/main_session.h" @@ -710,7 +709,7 @@ void EditRestrictedBox::showRestrictUntil() { highlighted, [this](const QDate &date) { setRestrictUntil( - static_cast(base::QDateToDateTime(date).toTime_t())); + static_cast(date.startOfDay().toSecsSinceEpoch())); }), Ui::LayerOption::KeepOther); _restrictUntilBox->setMaxDate( diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 5246ceaa3..138a2575d 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -72,7 +72,7 @@ protected: int visibleBottom) override; void paintEvent(QPaintEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; @@ -906,7 +906,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) { } } -void ShareBox::Inner::enterEventHook(QEvent *e) { +void ShareBox::Inner::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 5bca06954..66129523c 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -404,7 +404,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { auto p = StickersPack(); p.reserve(stickers.size()); - for (auto j = 0, c = stickers.size(); j != c; ++j) { + for (auto j = 0, c = int(stickers.size()); j != c; ++j) { auto doc = _controller->session().data().document(stickers[j].v); if (!doc || !doc->sticker()) continue; @@ -532,7 +532,7 @@ void StickerSetBox::Inner::installDone( auto &order = isMasks ? stickers.maskSetsOrderRef() : stickers.setsOrderRef(); - const auto insertAtIndex = 0, currentIndex = order.indexOf(_setId); + const auto insertAtIndex = 0, currentIndex = int(order.indexOf(_setId)); if (currentIndex != insertAtIndex) { if (currentIndex > 0) { order.removeAt(currentIndex); diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index e7372636d..89315a328 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -50,7 +50,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_calls.h" #include "styles/style_chat.h" -#include #include #include #include diff --git a/Telegram/SourceFiles/calls/calls_video_incoming.cpp b/Telegram/SourceFiles/calls/calls_video_incoming.cpp index adfc17f7d..75ad8e6e8 100644 --- a/Telegram/SourceFiles/calls/calls_video_incoming.cpp +++ b/Telegram/SourceFiles/calls/calls_video_incoming.cpp @@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "webrtc/webrtc_video_track.h" #include "styles/style_calls.h" -#include -#include +#include +#include namespace Calls { namespace { diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index c71c5228b..c33dbeb64 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -55,7 +55,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_calls.h" #include "styles/style_layers.h" -#include #include #include #include diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp index ea1849b1d..5fe4dcd5e 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport.cpp @@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_calls.h" #include -#include +#include namespace Calls::Group { namespace { diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp index a33e2f0f2..b11829140 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_peer.h" #include "styles/style_calls.h" -#include +#include namespace Calls::Group { namespace { diff --git a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.h b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.h index cd7eed353..aab98c6fd 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.h +++ b/Telegram/SourceFiles/calls/group/calls_group_viewport_opengl.h @@ -15,8 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_surface.h" #include "ui/gl/gl_image.h" -#include -#include +#include +#include namespace Webrtc { struct FrameWithInfo; diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp index 061ffec71..d1d6b75f9 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.cpp @@ -160,7 +160,7 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) { } } -void BotKeyboard::enterEventHook(QEvent *e) { +void BotKeyboard::enterEventHook(QEnterEvent *e) { _lastMousePos = QCursor::pos(); updateSelected(); } diff --git a/Telegram/SourceFiles/chat_helpers/bot_keyboard.h b/Telegram/SourceFiles/chat_helpers/bot_keyboard.h index 209623461..7e30de14d 100644 --- a/Telegram/SourceFiles/chat_helpers/bot_keyboard.h +++ b/Telegram/SourceFiles/chat_helpers/bot_keyboard.h @@ -74,7 +74,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; private: diff --git a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp index 565754665..72eb9b1d9 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp @@ -132,7 +132,7 @@ void CreateCacheFilePath() { } list.push_back(entry); } - result.maxKeyLength = std::max(result.maxKeyLength, key.size()); + result.maxKeyLength = std::max(result.maxKeyLength, int(key.size())); } result.version = version; return result; diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 5dab2b723..165938446 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -166,7 +166,7 @@ void EmojiColorPicker::showEmoji(EmojiPtr emoji) { _ignoreShow = false; _variants.resize(emoji->variantsCount() + 1); - for (auto i = 0, size = _variants.size(); i != size; ++i) { + for (auto i = 0, size = int(_variants.size()); i != size; ++i) { _variants[i] = emoji->variant(i); } @@ -219,7 +219,7 @@ void EmojiColorPicker::paintEvent(QPaintEvent *e) { p.fillRect(x, st::emojiPanMargins.top() + st::emojiColorsPadding, st::emojiColorsSep, inner.height() - st::emojiColorsPadding * 2, st::emojiColorsSepColor); if (_variants.isEmpty()) return; - for (auto i = 0, count = _variants.size(); i != count; ++i) { + for (auto i = 0, count = int(_variants.size()); i != count; ++i) { drawVariant(p, i); } } diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp index f1e0e176e..3171abd40 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.cpp @@ -495,7 +495,7 @@ void SuggestionsWidget::triggerRow(const Row &row) const { _triggered.fire(row.emoji->text()); } -void SuggestionsWidget::enterEventHook(QEvent *e) { +void SuggestionsWidget::enterEventHook(QEnterEvent *e) { if (!inner().contains(mapToInner(QCursor::pos()))) { clearMouseSelection(); } diff --git a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h index f19873c8e..a580cc8c3 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_suggestions_widget.h @@ -50,7 +50,7 @@ private: void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void scrollByWheelEvent(not_null e); diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index ef2690e54..45b55a9f4 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_chat.h" #include "styles/style_widgets.h" #include "styles/style_chat_helpers.h" +#include "base/qt_adapters.h" #include @@ -84,7 +85,7 @@ private: void paintEvent(QPaintEvent *e) override; void resizeEvent(QResizeEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void mousePressEvent(QMouseEvent *e) override; @@ -257,19 +258,19 @@ void FieldAutocomplete::showFiltered( query = query.toLower(); auto type = Type::Stickers; - auto plainQuery = query.midRef(0); + auto plainQuery = QStringView(query); switch (query.at(0).unicode()) { case '@': type = Type::Mentions; - plainQuery = query.midRef(1); + plainQuery = base::StringViewMid(query, 1); break; case '#': type = Type::Hashtags; - plainQuery = query.midRef(1); + plainQuery = base::StringViewMid(query, 1); break; case '/': type = Type::BotCommands; - plainQuery = query.midRef(1); + plainQuery = base::StringViewMid(query, 1); break; } bool resetScroll = (_type != type || _filter != plainQuery); @@ -1202,7 +1203,7 @@ void FieldAutocomplete::Inner::contextMenuEvent(QContextMenuEvent *e) { } } -void FieldAutocomplete::Inner::enterEventHook(QEvent *e) { +void FieldAutocomplete::Inner::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } diff --git a/Telegram/SourceFiles/chat_helpers/message_field.cpp b/Telegram/SourceFiles/chat_helpers/message_field.cpp index 9a07043f2..6f584d5ab 100644 --- a/Telegram/SourceFiles/chat_helpers/message_field.cpp +++ b/Telegram/SourceFiles/chat_helpers/message_field.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_chat.h" +#include "base/qt_adapters.h" #include #include @@ -93,7 +94,7 @@ QString FieldTagMimeProcessor::tagFromMimeTag(const QString &mimeTag) { const auto userId = _controller->session().userId(); auto match = QRegularExpression(":(\\d+)$").match(mimeTag); if (!match.hasMatch() - || match.capturedRef(1).toULongLong() != userId.bare) { + || match.capturedView(1).toULongLong() != userId.bare) { return QString(); } return mimeTag.mid(0, mimeTag.size() - match.capturedLength()); @@ -380,7 +381,7 @@ InlineBotQuery ParseInlineBotQuery( < inlineUsernameStart + inlineUsernameLength)) { return InlineBotQuery(); } - auto username = text.midRef(inlineUsernameStart, inlineUsernameLength); + auto username = base::StringViewMid(text, inlineUsernameStart, inlineUsernameLength); if (username != result.username) { result.username = username.toString(); if (const auto peer = session->data().peerByUsername(result.username)) { @@ -661,7 +662,7 @@ void MessageLinksParser::parse() { } } const auto range = LinkRange { - domainOffset, + int(domainOffset), static_cast(p - start - domainOffset), QString() }; @@ -685,8 +686,8 @@ void MessageLinksParser::apply( const auto current = _list.current(); const auto computeLink = [&](const LinkRange &range) { return range.custom.isEmpty() - ? text.midRef(range.start, range.length) - : range.custom.midRef(0); + ? base::StringViewMid(text, range.start, range.length) + : QStringView(range.custom); }; const auto changed = [&] { if (current.size() != count) { diff --git a/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp b/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp index 782618dc4..190a8b52b 100644 --- a/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp +++ b/Telegram/SourceFiles/chat_helpers/spellchecker_common.cpp @@ -184,7 +184,7 @@ void AddExceptions() { return word.utf16(); }) | ranges::views::filter([](const auto &word) { return !(Platform::Spellchecker::IsWordInDictionary(word) - || Spellchecker::IsWordSkippable(&word)); + || Spellchecker::IsWordSkippable(word)); }) | ranges::to_vector; ranges::for_each(exceptions, Platform::Spellchecker::AddWord); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index a2ceaff77..fd989566f 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -207,7 +207,7 @@ void TabbedPanel::moveByBottom() { updateContentHeight(); } -void TabbedPanel::enterEventHook(QEvent *e) { +void TabbedPanel::enterEventHook(QEnterEvent *e) { Core::App().registerLeaveSubscription(this); showAnimated(); } diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.h b/Telegram/SourceFiles/chat_helpers/tabbed_panel.h index edaa45fa0..48dba7718 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.h @@ -58,7 +58,7 @@ public: ~TabbedPanel(); protected: - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void otherEnter(); void otherLeave(); diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index e1910e5df..08b31f7de 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/ui_integration.h" #include "chat_helpers/emoji_keywords.h" #include "chat_helpers/stickers_emoji_image_loader.h" +#include "base/qt_adapters.h" #include "base/platform/base_platform_url_scheme.h" #include "base/platform/base_platform_last_input.h" #include "base/platform/base_platform_info.h" @@ -83,7 +84,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/share_box.h" #include "app.h" -#include #include #include #include @@ -830,7 +830,7 @@ bool Application::openCustomUrl( || passcodeLocked()) { return false; } - const auto command = urlTrimmed.midRef(protocol.size(), 8192); + const auto command = base::StringViewMid(urlTrimmed, protocol.size(), 8192); const auto controller = _window ? _window->sessionController() : nullptr; using namespace qthelp; diff --git a/Telegram/SourceFiles/core/changelogs.cpp b/Telegram/SourceFiles/core/changelogs.cpp index 4f794f589..07dd1010b 100644 --- a/Telegram/SourceFiles/core/changelogs.cpp +++ b/Telegram/SourceFiles/core/changelogs.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "storage/storage_domain.h" #include "data/data_session.h" +#include "base/qt_adapters.h" #include "mainwindow.h" #include "apiwrap.h" @@ -194,7 +195,7 @@ void Changelogs::addBetaLog(int changeVersion, const char *changes) { static const auto simple = u"\n- "_q; static const auto separator = QString::fromUtf8("\n\xE2\x80\xA2 "); auto result = QString::fromUtf8(changes).trimmed(); - if (result.startsWith(simple.midRef(1))) { + if (result.startsWith(base::StringViewMid(simple, 1))) { result = separator.mid(1) + result.mid(simple.size() - 1); } return result.replace(simple, separator); diff --git a/Telegram/SourceFiles/core/launcher.cpp b/Telegram/SourceFiles/core/launcher.cpp index dadc86aac..c18eacfb0 100644 --- a/Telegram/SourceFiles/core/launcher.cpp +++ b/Telegram/SourceFiles/core/launcher.cpp @@ -288,6 +288,7 @@ void Launcher::init() { QApplication::setApplicationName(qsl("TelegramDesktop")); QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // fallback session management is useless for tdesktop since it doesn't have // any "are you sure you want to close this window?" dialogs // but it produces bugs like https://github.com/telegramdesktop/tdesktop/issues/5022 @@ -295,6 +296,7 @@ void Launcher::init() { // and https://github.com/telegramdesktop/tdesktop/issues/948 // more info: https://doc.qt.io/qt-5/qguiapplication.html#isFallbackSessionManagementEnabled QApplication::setFallbackSessionManagementEnabled(false); +#endif // Qt < 6.0.0 initHook(); } @@ -402,7 +404,7 @@ void Launcher::prepareSettings() { if (!path.isEmpty()) { auto info = QFileInfo(path); if (info.isSymLink()) { - info = info.symLinkTarget(); + info = QFileInfo(info.symLinkTarget()); } if (info.exists()) { const auto dir = info.absoluteDir().absolutePath(); diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index c137160e1..f375f4eb0 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "main/main_session_settings.h" #include "history/history.h" +#include "base/qt_adapters.h" #include "apiwrap.h" #include @@ -100,7 +101,7 @@ bool SetLanguage( Window::SessionController *controller, const Match &match, const QVariant &context) { - if (match->capturedRef(1).isEmpty()) { + if (match->capturedView(1).isEmpty()) { ShowLanguagesBox(); } else { const auto languageId = match->captured(2); @@ -688,7 +689,7 @@ QString TryConvertUrlToLocal(QString url) { auto matchOptions = RegExOption::CaseInsensitive; auto telegramMeMatch = regex_match(qsl("^(https?://)?(www\\.)?(telegram\\.(me|dog)|t\\.me)/(.+)$"), url, matchOptions); if (telegramMeMatch) { - auto query = telegramMeMatch->capturedRef(5); + auto query = telegramMeMatch->capturedView(5); if (auto joinChatMatch = regex_match(qsl("^(joinchat/|\\+|\\%20)([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) { return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(2)); } else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) { @@ -746,7 +747,7 @@ bool InternalPassportLink(const QString &url) { if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive)) { return false; } - const auto command = urlTrimmed.midRef(qstr("tg://").size()); + const auto command = base::StringViewMid(urlTrimmed, qstr("tg://").size()); using namespace qthelp; const auto matchOptions = RegExOption::CaseInsensitive; diff --git a/Telegram/SourceFiles/core/sandbox.cpp b/Telegram/SourceFiles/core/sandbox.cpp index f26e07d6f..1a4316cd6 100644 --- a/Telegram/SourceFiles/core/sandbox.cpp +++ b/Telegram/SourceFiles/core/sandbox.cpp @@ -265,7 +265,10 @@ void Sandbox::socketReading() { } _localSocketReadData.append(_localSocket.readAll()); if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) { - uint64 pid = _localSocketReadData.midRef(4, _localSocketReadData.length() - 5).toULongLong(); + uint64 pid = base::StringViewMid( + _localSocketReadData, + 4, + _localSocketReadData.length() - 5).toULongLong(); if (pid != kEmptyPidForCommandResponse) { psActivateProcess(pid); } @@ -388,7 +391,7 @@ void Sandbox::readClients() { QString cmds(QString::fromLatin1(i->second)); int32 from = 0, l = cmds.length(); for (int32 to = cmds.indexOf(QChar(';'), from); to >= from; to = (from < l) ? cmds.indexOf(QChar(';'), from) : -1) { - QStringRef cmd(&cmds, from, to - from); + auto cmd = base::StringViewMid(cmds, from, to - from); if (cmd.startsWith(qsl("CMD:"))) { execExternal(cmds.mid(from + 4, to - from - 4)); const auto response = qsl("RES:%1;").arg(QApplication::applicationPid()).toLatin1(); @@ -409,7 +412,7 @@ void Sandbox::readClients() { const auto response = qsl("RES:%1;").arg(responsePid).toLatin1(); i->first->write(response.data(), response.size()); } else { - LOG(("Sandbox Error: unknown command %1 passed in local socket").arg(QString(cmd.constData(), cmd.length()))); + LOG(("Sandbox Error: unknown command %1 passed in local socket").arg(cmd.toString())); } from = to + 1; } @@ -571,7 +574,7 @@ void Sandbox::processPostponedCalls(int level) { bool Sandbox::nativeEventFilter( const QByteArray &eventType, void *message, - long *result) { + base::NativeEventResult *result) { registerEnterFromEventLoop(); return false; } diff --git a/Telegram/SourceFiles/core/sandbox.h b/Telegram/SourceFiles/core/sandbox.h index 01ef9c5c8..58b17d187 100644 --- a/Telegram/SourceFiles/core/sandbox.h +++ b/Telegram/SourceFiles/core/sandbox.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "mtproto/mtproto_proxy_data.h" +#include "base/qt_adapters.h" #include #include @@ -85,7 +86,7 @@ private: bool nativeEventFilter( const QByteArray &eventType, void *message, - long *result) override; + base::NativeEventResult *result) override; void processPostponedCalls(int level); void singleInstanceChecked(); void launchApplication(); diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index 93d350d91..5e5c3fcd2 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "base/parse_helper.h" -#include +#include #include #include #include diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 645ccba1a..df6045a20 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -582,7 +582,7 @@ bool ParseCommonMap( if ((*version).isString()) { const auto string = (*version).toString(); if (const auto index = string.indexOf(':'); index > 0) { - return string.midRef(0, index).toULongLong(); + return base::StringViewMid(string, 0, index).toULongLong(); } return string.toULongLong(); } else if ((*version).isDouble()) { @@ -1014,7 +1014,7 @@ auto MtpChecker::parseText(const QByteArray &text) const return false; } bestLocation.username = full.mid(start + 1, post - start - 1); - bestLocation.postId = full.midRef(post + 1).toInt(); + bestLocation.postId = base::StringViewMid(full, post + 1).toInt(); if (bestLocation.username.isEmpty() || !bestLocation.postId) { LOG(("Update Error: MTP entry '%1' is bad for version %2." ).arg(full diff --git a/Telegram/SourceFiles/countries/countries_instance.cpp b/Telegram/SourceFiles/countries/countries_instance.cpp index 166e270f2..8e6aaf785 100644 --- a/Telegram/SourceFiles/countries/countries_instance.cpp +++ b/Telegram/SourceFiles/countries/countries_instance.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "countries/countries_instance.h" +#include "base/qt_adapters.h" + namespace Countries { namespace { @@ -328,11 +330,11 @@ FormatResult CountriesInstance::format(FormatArgs args) { if (phoneNumber.startsWith(callingCode.callingCode)) { const auto codeSize = callingCode.callingCode.size(); for (const auto &prefix : callingCode.prefixes) { - if (prefix.startsWith(phoneNumber.midRef(codeSize))) { + if (prefix.startsWith(base::StringViewMid(phoneNumber, codeSize))) { isPrefix = true; } if ((codeSize + prefix.size()) > bestLength && - phoneNumber.midRef(codeSize).startsWith(prefix)) { + base::StringViewMid(phoneNumber, codeSize).startsWith(prefix)) { bestCountryPtr = &country; bestCallingCodePtr = &callingCode; bestLength = codeSize + prefix.size(); diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 1d687d9d1..e3983403d 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -988,7 +988,7 @@ QByteArray documentWaveformEncode5bit(const VoiceWaveform &waveform) { // Write each 0-31 unsigned char as 5 bit to result. // We reserve one extra byte to be able to dereference any of required bytes // as a uint16 without overflowing, even the byte with index "bytesCount - 1". - for (auto i = 0, l = waveform.size(); i < l; ++i) { + for (auto i = 0, l = int(waveform.size()); i < l; ++i) { auto byteIndex = (i * 5) / 8; auto bitShift = (i * 5) % 8; auto value = (static_cast(waveform[i]) & 0x1F) << bitShift; @@ -1337,7 +1337,7 @@ bool DocumentData::isAudioFile() const { } return false; } - const auto left = _mimeString.midRef(prefix.size()).toString(); + const auto left = _mimeString.mid(prefix.size()); const auto types = { qstr("x-wav"), qstr("wav"), qstr("mp4") }; return ranges::contains(types, left); } diff --git a/Telegram/SourceFiles/data/data_document_resolver.cpp b/Telegram/SourceFiles/data/data_document_resolver.cpp index 2033bf632..ef2d51e7c 100644 --- a/Telegram/SourceFiles/data/data_document_resolver.cpp +++ b/Telegram/SourceFiles/data/data_document_resolver.cpp @@ -232,7 +232,7 @@ void ResolveDocument( location.accessDisable(); }); const auto path = location.name(); - if (Core::MimeTypeForFile(path).name().startsWith("image/") + if (Core::MimeTypeForFile(QFileInfo(path)).name().startsWith("image/") && QImageReader(path).canRead()) { showDocument(); return true; diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index fc38ba1ea..110afa755 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_user.h" #include "base/unixtime.h" -#include "base/qt_adapters.h" namespace Data { namespace { @@ -40,7 +39,7 @@ int OnlinePhraseChangeInSeconds(TimeId online, TimeId now) { return (hours + 1) * 3600 - (now - online); } const auto nowFull = base::unixtime::parse(now); - const auto tomorrow = base::QDateToDateTime(nowFull.date().addDays(1)); + const auto tomorrow = nowFull.date().addDays(1).startOfDay(); return std::max(static_cast(nowFull.secsTo(tomorrow)), 0); } diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index 1d4e7f7cc..62e86688d 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_channel.h" #include "data/data_document.h" -#include "base/qt_adapters.h" #include "ui/image/image.h" #include "ui/text/text_entity.h" @@ -27,7 +26,7 @@ QString SiteNameFromUrl(const QString &url) { if (m.hasMatch()) pretty = pretty.mid(m.capturedLength()); int32 slash = pretty.indexOf('/'); if (slash > 0) pretty = pretty.mid(0, slash); - QStringList components = pretty.split('.', base::QStringSkipEmptyParts); + QStringList components = pretty.split('.', Qt::SkipEmptyParts); if (components.size() >= 2) { components = components.mid(components.size() - 2); return components.at(0).at(0).toUpper() + components.at(0).mid(1) + '.' + components.at(1); diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index d85c2d142..09293c429 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -679,7 +679,7 @@ void Stickers::setPackAndEmoji( auto p = StickersPack(); p.reserve(stickers.size()); - for (auto j = 0, c = stickers.size(); j != c; ++j) { + for (auto j = 0, c = int(stickers.size()); j != c; ++j) { auto document = owner().document(stickers[j].v); if (!document || !document->sticker()) continue; @@ -1302,7 +1302,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) { set->stickers = pack; set->emoji.clear(); auto &v = d.vpacks().v; - for (auto i = 0, l = v.size(); i != l; ++i) { + for (auto i = 0, l = int(v.size()); i != l; ++i) { if (v[i].type() != mtpc_stickerPack) continue; auto &pack = v[i].c_stickerPack(); @@ -1312,7 +1312,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) { StickersPack p; p.reserve(stickers.size()); - for (auto j = 0, c = stickers.size(); j != c; ++j) { + for (auto j = 0, c = int(stickers.size()); j != c; ++j) { auto doc = owner().document(stickers[j].v); if (!doc || !doc->sticker()) continue; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index e786a7a59..7fdceb59f 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_dialogs.h" #include "styles/style_chat_helpers.h" #include "styles/style_window.h" +#include "base/qt_adapters.h" namespace Dialogs { namespace { @@ -1619,7 +1620,7 @@ void InnerWidget::updateDialogRow( } } -void InnerWidget::enterEventHook(QEvent *e) { +void InnerWidget::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } @@ -1844,7 +1845,7 @@ void InnerWidget::applyFilterUpdate(QString newFilter, bool force) { } } -void InnerWidget::onHashtagFilterUpdate(QStringRef newFilter) { +void InnerWidget::onHashtagFilterUpdate(QStringView newFilter) { if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInChat) { _hashtagFilter = QString(); if (!_hashtagResults.empty()) { @@ -1863,7 +1864,7 @@ void InnerWidget::onHashtagFilterUpdate(QStringRef newFilter) { if (!recent.isEmpty()) { _hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit)); for (const auto &tag : recent) { - if (tag.first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) + if (tag.first.startsWith(base::StringViewMid(_hashtagFilter, 1), Qt::CaseInsensitive) && tag.first.size() + 1 != newFilter.size()) { _hashtagResults.push_back(std::make_unique(tag.first)); if (_hashtagResults.size() == kHashtagResultsLimit) break; @@ -2291,7 +2292,7 @@ void InnerWidget::searchInChat(Key key, PeerData *from) { _searchFromPeer = from; if (_searchInChat) { _controller->closeFolder(); - onHashtagFilterUpdate(QStringRef()); + onHashtagFilterUpdate(QStringView()); _cancelSearchInChat->show(); refreshSearchInChatLabel(); } else { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index e830dbece..bb8d34601 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -114,7 +114,7 @@ public: void searchInChat(Key key, PeerData *from); void applyFilterUpdate(QString newFilter, bool force = false); - void onHashtagFilterUpdate(QStringRef newFilter); + void onHashtagFilterUpdate(QStringView newFilter); PeerData *updateFromParentDrag(QPoint globalPosition); @@ -148,7 +148,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void resizeEvent(QResizeEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index f457761fb..8001a6627 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_chat.h" #include "styles/style_info.h" #include "styles/style_window.h" +#include "base/qt_adapters.h" #include @@ -1475,12 +1476,12 @@ void Widget::showSearchFrom() { void Widget::onFilterCursorMoved(int from, int to) { if (to < 0) to = _filter->cursorPosition(); QString t = _filter->getLastText(); - QStringRef r; + QStringView r; for (int start = to; start > 0;) { --start; if (t.size() <= start) break; if (t.at(start) == '#') { - r = t.midRef(start, to - start); + r = base::StringViewMid(t, start, to - start); break; } if (!t.at(start).isLetterOrNumber() && t.at(start) != '_') break; @@ -1495,7 +1496,9 @@ void Widget::onCompleteHashtag(QString tag) { --start; if (t.size() <= start) break; if (t.at(start) == '#') { - if (cur == start + 1 || t.midRef(start + 1, cur - start - 1) == tag.midRef(0, cur - start - 1)) { + if (cur == start + 1 + || base::StringViewMid(t, start + 1, cur - start - 1) + == base::StringViewMid(tag, 0, cur - start - 1)) { for (; cur < t.size() && cur - start - 1 < tag.size(); ++cur) { if (t.at(cur) != tag.at(cur - start - 1)) break; } diff --git a/Telegram/SourceFiles/editor/editor_crop.cpp b/Telegram/SourceFiles/editor/editor_crop.cpp index 06d3c4700..008a9538b 100644 --- a/Telegram/SourceFiles/editor/editor_crop.cpp +++ b/Telegram/SourceFiles/editor/editor_crop.cpp @@ -92,7 +92,7 @@ void Crop::applyTransform( const auto cropHolder = QRectF(QPointF(), scaledImageSize); const auto cropHolderCenter = cropHolder.center(); - auto matrix = QMatrix() + auto matrix = QTransform() .translate(cropHolderCenter.x(), cropHolderCenter.y()) .scale(flipped ? -1 : 1, 1) .rotate(angle) @@ -151,12 +151,12 @@ void Crop::setCropPaint(QRectF &&rect) { } void Crop::convertCropPaintToOriginal() { - const auto cropHolder = QMatrix() + const auto cropHolder = QTransform() .scale(_ratio.w, _ratio.h) .mapRect(QRectF(QPointF(), FlipSizeByRotation(_imageSize, _angle))); const auto cropHolderCenter = cropHolder.center(); - const auto matrix = QMatrix() + const auto matrix = QTransform() .translate(cropHolderCenter.x(), cropHolderCenter.y()) .rotate(-_angle) .scale((_flipped ? -1 : 1) * 1. / _ratio.w, 1. / _ratio.h) diff --git a/Telegram/SourceFiles/editor/editor_paint.cpp b/Telegram/SourceFiles/editor/editor_paint.cpp index 45780ce13..a943318e7 100644 --- a/Telegram/SourceFiles/editor/editor_paint.cpp +++ b/Telegram/SourceFiles/editor/editor_paint.cpp @@ -133,7 +133,7 @@ void Paint::applyTransform(QRect geometry, int angle, bool flipped) { setGeometry(geometry); const auto size = geometry.size(); - const auto rotatedImageSize = QMatrix() + const auto rotatedImageSize = QTransform() .rotate(angle) .mapRect(QRect(QPoint(), _imageSize)); diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 00057fdf5..dd5046070 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -177,7 +177,7 @@ Utf8String FillLeft(const Utf8String &data, int length, char filler) { } auto result = Utf8String(); result.reserve(length); - for (auto i = 0, count = length - data.size(); i != count; ++i) { + for (auto i = 0, count = length - int(data.size()); i != count; ++i) { result.append(filler); } result.append(data); @@ -1806,7 +1806,7 @@ Utf8String FormatDateTime( if (!date) { return Utf8String(); } - const auto value = QDateTime::fromTime_t(date); + const auto value = QDateTime::fromSecsSinceEpoch(date); return (QString("%1") + dateSeparator + "%2" + dateSeparator + "%3" + separator + "%4" + timeSeparator + "%5" + timeSeparator + "%6" ).arg(value.date().day(), 2, 10, QChar('0') diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index 9f4d27edb..bd62779cc 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -736,7 +736,7 @@ void ApiWrap::requestUserpics( auto startInfo = result.match( [](const MTPDphotos_photos &data) { - return Data::UserpicsInfo{ data.vphotos().v.size() }; + return Data::UserpicsInfo{ int(data.vphotos().v.size()) }; }, [](const MTPDphotos_photosSlice &data) { return Data::UserpicsInfo{ data.vcount().v }; }); @@ -968,7 +968,7 @@ void ApiWrap::requestMessagesCount(int localSplitIndex) { const auto count = result.match( [](const MTPDmessages_messages &data) { - return data.vmessages().v.size(); + return int(data.vmessages().v.size()); }, [](const MTPDmessages_messagesSlice &data) { return data.vcount().v; }, [](const MTPDmessages_channelMessages &data) { diff --git a/Telegram/SourceFiles/export/output/export_output_file.cpp b/Telegram/SourceFiles/export/output/export_output_file.cpp index 544bdbcdf..b9974c1ee 100644 --- a/Telegram/SourceFiles/export/output/export_output_file.cpp +++ b/Telegram/SourceFiles/export/output/export_output_file.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "export/output/export_output_result.h" #include "export/output/export_output_stats.h" +#include "base/qt_adapters.h" #include #include @@ -102,10 +103,10 @@ QString File::PrepareRelativePath( // Not lastIndexOf('.') so that "file.tar.xz" won't be messed up. const auto position = suggested.indexOf('.'); - const auto base = suggested.midRef(0, position).toString(); + const auto base = suggested.mid(0, position); const auto extension = (position >= 0) - ? suggested.midRef(position) - : QStringRef(); + ? base::StringViewMid(suggested, position) + : QStringView(); const auto relativePart = [&](int attempt) { auto result = base + QString(" (%1)").arg(attempt); result.append(extension); diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index f49945551..dd9cc013f 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -283,12 +283,12 @@ bool DisplayDate(TimeId date, TimeId previousDate) { if (!previousDate) { return true; } - return QDateTime::fromTime_t(date).date() - != QDateTime::fromTime_t(previousDate).date(); + return QDateTime::fromSecsSinceEpoch(date).date() + != QDateTime::fromSecsSinceEpoch(previousDate).date(); } QByteArray FormatDateText(TimeId date) { - const auto parsed = QDateTime::fromTime_t(date).date(); + const auto parsed = QDateTime::fromSecsSinceEpoch(date).date(); const auto month = [](int index) { switch (index) { case 1: return "January"; @@ -314,7 +314,7 @@ QByteArray FormatDateText(TimeId date) { } QByteArray FormatTimeText(TimeId date) { - const auto parsed = QDateTime::fromTime_t(date).time(); + const auto parsed = QDateTime::fromSecsSinceEpoch(date).time(); return Data::NumberToString(parsed.hour(), 2) + ':' + Data::NumberToString(parsed.minute(), 2); @@ -1256,8 +1256,8 @@ bool HtmlWriter::Wrap::messageNeedsWrap( return true; } else if (message.viaBotId != previous->viaBotId) { return true; - } else if (QDateTime::fromTime_t(previous->date).date() - != QDateTime::fromTime_t(message.date).date()) { + } else if (QDateTime::fromSecsSinceEpoch(previous->date).date() + != QDateTime::fromSecsSinceEpoch(message.date).date()) { return true; } else if (message.forwarded != previous->forwarded || message.showForwardedAsOriginal != previous->showForwardedAsOriginal diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 9ac9ec3e5..9f116a814 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -71,7 +71,7 @@ QByteArray SerializeString(const QByteArray &value) { QByteArray SerializeDate(TimeId date) { return SerializeString( - QDateTime::fromTime_t(date).toString(Qt::ISODate).toUtf8()); + QDateTime::fromSecsSinceEpoch(date).toString(Qt::ISODate).toUtf8()); } QByteArray StringAllowEmpty(const Data::Utf8String &data) { diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index cc7159ccb..a54b13258 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "base/platform/base_platform_info.h" #include "base/unixtime.h" +#include "base/qt_adapters.h" #include "styles/style_export.h" #include "styles/style_layers.h" @@ -219,7 +220,8 @@ void PanelController::showError(const ApiErrorState &error) { if (error.data.type() == qstr("TAKEOUT_INVALID")) { showError(tr::lng_export_invalid(tr::now)); } else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) { - const auto seconds = std::max(error.data.type().midRef( + const auto seconds = std::max(base::StringViewMid( + error.data.type(), qstr("TAKEOUT_INIT_DELAY_").size()).toInt(), 1); const auto now = QDateTime::currentDateTime(); const auto when = now.addSecs(seconds); diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index 7febd9d95..bf8ecbef3 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/platform_specific.h" #include "core/file_utilities.h" #include "base/unixtime.h" -#include "base/qt_adapters.h" #include "main/main_session.h" #include "styles/style_widgets.h" #include "styles/style_export.h" @@ -479,7 +478,7 @@ void SettingsWidget::editDateLimit( })); }; const auto callback = crl::guard(this, [=](const QDate &date) { - done(base::unixtime::serialize(base::QDateToDateTime(date))); + done(base::unixtime::serialize(date.startOfDay())); if (const auto weak = shared->data()) { weak->closeBox(); } diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index ccaec6630..9de7265af 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -56,13 +56,10 @@ void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) { for (auto i = 0; i != intsCount; ++i) { udst[i] = qUnpremultiply(usrc[i]); } -#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; - layout->convertFromARGB32PM(udst, usrc, intsCount, layout, nullptr); -#else // Qt >= 5.12 +#else // !LIB_FFMPEG_USE_QT_PRIVATE_API static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; layout->storeFromARGB32PM(dst, usrc, 0, intsCount, nullptr, nullptr); -#endif // Qt >= 5.12 +#endif // LIB_FFMPEG_USE_QT_PRIVATE_API } void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { @@ -73,13 +70,10 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { for (auto i = 0; i != intsCount; ++i) { udst[i] = qPremultiply(usrc[i]); } -#elif QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; - layout->convertToARGB32PM(udst, usrc, intsCount, layout, nullptr); -#else // Qt >= 5.12 +#else // !LIB_FFMPEG_USE_QT_PRIVATE_API static const auto layout = &qPixelLayouts[QImage::Format_ARGB32]; layout->fetchToARGB32PM(udst, src, 0, intsCount, nullptr, nullptr); -#endif // Qt >= 5.12 +#endif // LIB_FFMPEG_USE_QT_PRIVATE_API } } // namespace diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 7e938d151..36a8b7623 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -1464,7 +1464,7 @@ void InnerWidget::mouseReleaseEvent(QMouseEvent *e) { } } -void InnerWidget::enterEventHook(QEvent *e) { +void InnerWidget::enterEventHook(QEnterEvent *e) { mouseActionUpdate(QCursor::pos()); return TWidget::enterEventHook(e); } diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h index 3ef1f089e..0f3d1d959 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.h @@ -153,7 +153,7 @@ protected: void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override; 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 2f35898ac..a952902d5 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -38,7 +38,7 @@ TextWithEntities PrepareText(const QString &value, const QString &emptyValue) { result.entities.push_back({ EntityType::Italic, 0, - emptyValue.size() }); + int(emptyValue.size()) }); } } else { TextUtilities::ParseEntities(result, TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands); @@ -296,7 +296,7 @@ TextWithEntities GenerateInviteLinkChangeText( link.entities.push_back({ EntityType::CustomUrl, 0, - link.text.size(), + int(link.text.size()), InternalInviteLinkUrl(newLink) }); } auto result = tr::lng_admin_log_edited_invite_link(tr::now, lt_link, link, Ui::Text::WithEntities); @@ -350,7 +350,7 @@ auto GenerateParticipantString( name.entities.push_back({ EntityType::MentionName, 0, - name.text.size(), + int(name.text.size()), entityData }); } auto username = peer->userName(); @@ -361,7 +361,7 @@ auto GenerateParticipantString( mention.entities.push_back({ EntityType::Mention, 0, - mention.text.size() }); + int(mention.text.size()) }); return tr::lng_admin_log_user_with_username( tr::now, lt_name, diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 17e480fbc..d46c17aa9 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -49,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/crash_reports.h" #include "core/application.h" #include "base/unixtime.h" +#include "base/qt_adapters.h" #include "styles/style_dialogs.h" namespace { @@ -2655,10 +2656,10 @@ void History::cacheTopPromotion( } } -QStringRef History::topPromotionType() const { +QStringView History::topPromotionType() const { return topPromotionAboutShown() - ? _topPromotedType.midRef(5) - : _topPromotedType.midRef(0); + ? base::StringViewMid(_topPromotedType, 5) + : QStringView(_topPromotedType); } bool History::topPromotionAboutShown() const { diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index 88b44b493..b0aaf1a41 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -277,7 +277,7 @@ public: bool promoted, const QString &type, const QString &message); - [[nodiscard]] QStringRef topPromotionType() const; + [[nodiscard]] QStringView topPromotionType() const; [[nodiscard]] QString topPromotionMessage() const; [[nodiscard]] bool topPromotionAboutShown() const; void markTopPromotionAboutShown(); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 12e086937..2bad2f77f 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -76,6 +76,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "app.h" #include "styles/style_chat.h" #include "styles/style_window.h" // st::windowMinWidth +#include "base/qt_adapters.h" #include #include @@ -866,7 +867,7 @@ bool HistoryInner::eventHook(QEvent *e) { || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchCancel) { QTouchEvent *ev = static_cast(e); - if (ev->device()->type() == QTouchDevice::TouchScreen) { + if (ev->device()->type() == base::TouchDevice::TouchScreen) { touchEvent(ev); return true; } @@ -2504,7 +2505,7 @@ void HistoryInner::updateSize() { } } -void HistoryInner::enterEventHook(QEvent *e) { +void HistoryInner::enterEventHook(QEnterEvent *e) { mouseActionUpdate(QCursor::pos()); return TWidget::enterEventHook(e); } diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index 501f8b207..579ff7c1a 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -167,7 +167,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void resizeEvent(QResizeEvent *e) override; void keyPressEvent(QKeyEvent *e) override; diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 8875f9d07..50e8818c5 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_session.h" #include "window/window_session_controller.h" #include "facades.h" -#include "base/qt_adapters.h" #include "styles/style_widgets.h" #include "styles/style_chat.h" @@ -136,7 +135,7 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external) ? Ui::EmptyUserpic::ExternalName() : name)) { nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions()); - const auto parts = name.trimmed().split(' ', base::QStringSkipEmptyParts); + const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts); firstName = parts[0]; for (const auto &part : parts.mid(1)) { if (!lastName.isEmpty()) { diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 109c871c2..769f161b3 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -120,7 +120,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = tr::lng_action_add_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody")); } else { result.links.push_back(fromLink()); - for (auto i = 0, l = users.size(); i != l; ++i) { + for (auto i = 0, l = int(users.size()); i != l; ++i) { auto user = history()->owner().user(users[i].v); result.links.push_back(user->createOpenLink()); @@ -641,7 +641,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText( } else if (users.isEmpty()) { result.text = tr::lng_action_invite_user(tr::now, lt_from, fromLinkText(), lt_user, qsl("somebody"), lt_chat, chatText); } else { - for (auto i = 0, l = users.size(); i != l; ++i) { + for (auto i = 0, l = int(users.size()); i != l; ++i) { auto user = owner->user(users[i].v); result.links.push_back(user->createOpenLink()); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 71938515d..d5946e620 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -168,7 +168,7 @@ const auto kPsaAboutPrefix = "cloud_lng_about_psa_"; [[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) { return std::clamp( - crl::time(1000) * text.text.size() / 14, + crl::time(1000) * int(text.text.size()) / 14, crl::time(1000) * 5, crl::time(1000) * 8); } @@ -1653,7 +1653,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U if (samePeerBot) { if (_history) { TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() }; - MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX }; + MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX }; _history->setLocalDraft(std::make_unique( textWithTags, 0, @@ -1674,7 +1674,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U using Section = Dialogs::EntryState::Section; TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() }; - MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX }; + MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX }; auto draft = std::make_unique( textWithTags, to.currentReplyToId, @@ -6254,8 +6254,8 @@ void HistoryWidget::editMessage(not_null item) { const auto editData = PrepareEditText(item); const auto cursor = MessageCursor { - editData.text.size(), - editData.text.size(), + int(editData.text.size()), + int(editData.text.size()), QFIXED_MAX }; const auto previewPage = [&]() -> WebPageData* { @@ -6550,7 +6550,7 @@ void HistoryWidget::updatePreview() { st::msgNameStyle, tr::lng_preview_loading(tr::now), Ui::NameTextOptions()); - auto linkText = _previewLinks.splitRef(' ').at(0).toString(); + auto linkText = QStringView(_previewLinks).split(' ').at(0).toString(); _previewDescription.setText( st::messageTextStyle, TextUtilities::Clean(linkText), diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index c6c542636..646c19e43 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -2024,8 +2024,8 @@ void ComposeControls::editMessage(not_null item) { } const auto editData = PrepareEditText(item); const auto cursor = MessageCursor{ - editData.text.size(), - editData.text.size(), + int(editData.text.size()), + int(editData.text.size()), QFIXED_MAX }; const auto previewPage = [&]() -> WebPageData* { @@ -2164,7 +2164,7 @@ void ComposeControls::initWebpageProcess() { if (ShowWebPagePreview(*previewData)) { if (const auto till = (*previewData)->pendingTill) { t = tr::lng_preview_loading(tr::now); - d = (*previewLinks).splitRef(' ').at(0).toString(); + d = QStringView(*previewLinks).split(' ').at(0).toString(); const auto timeout = till - base::unixtime::now(); previewTimer->callOnce( diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index a6ea59351..b8b955c3d 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2033,7 +2033,7 @@ void ListWidget::mouseReleaseEvent(QMouseEvent *e) { } } -void ListWidget::enterEventHook(QEvent *e) { +void ListWidget::enterEventHook(QEnterEvent *e) { mouseActionUpdate(QCursor::pos()); return TWidget::enterEventHook(e); } diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.h b/Telegram/SourceFiles/history/view/history_view_list_widget.h index ac9a26660..d690b274a 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.h @@ -277,7 +277,7 @@ protected: void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override; diff --git a/Telegram/SourceFiles/history/view/history_view_view_button.cpp b/Telegram/SourceFiles/history/view/history_view_view_button.cpp index c9c2ce7d4..46ad5ddfc 100644 --- a/Telegram/SourceFiles/history/view/history_view_view_button.cpp +++ b/Telegram/SourceFiles/history/view/history_view_view_button.cpp @@ -132,7 +132,6 @@ ViewButton::Inner::Inner( , link(std::make_shared([=](ClickContext context) { const auto my = context.other.value(); if (const auto controller = my.sessionWindow.get()) { - const auto &data = controller->session().data(); const auto webpage = media->webpage(); if (!webpage) { return; diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index c5cfc8b97..22e75c910 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -89,7 +89,7 @@ void PaintWaveform( const auto active = stm->msgWaveformActive; const auto inactive = stm->msgWaveformInactive; const auto wfSize = wf - ? wf->size() + ? int(wf->size()) : ::Media::Player::kWaveformSamplesCount; const auto activeWidth = base::SafeRound(availableWidth * progress); diff --git a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp index 6f22c5bc3..f962fe3f3 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_invoice.cpp @@ -58,7 +58,7 @@ void Invoice::fillFromData(not_null invoice) { statusText.entities.push_back({ EntityType::Bold, 0, - statusText.text.size() }); + int(statusText.text.size()) }); statusText.text += ' ' + labelText().toUpper(); _status.setMarkedText( st::defaultTextStyle, diff --git a/Telegram/SourceFiles/history/view/media/history_view_media.cpp b/Telegram/SourceFiles/history/view/media/history_view_media.cpp index d0138ffa5..09d24d454 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media.cpp @@ -24,10 +24,10 @@ namespace HistoryView { namespace { [[nodiscard]] TimeId TimeFromMatch( - const QStringRef &hours, - const QStringRef &minutes1, - const QStringRef &minutes2, - const QStringRef &seconds) { + QStringView hours, + QStringView minutes1, + QStringView minutes2, + QStringView seconds) { auto ok1 = true; auto ok2 = true; auto ok3 = true; @@ -71,10 +71,10 @@ TextWithEntities AddTimestampLinks( offset = till; const auto time = TimeFromMatch( - m.capturedRef(1), - m.capturedRef(2), - m.capturedRef(3), - m.capturedRef(4)); + m.capturedView(1), + m.capturedView(2), + m.capturedView(3), + m.capturedView(4)); if (time < 0 || time > duration) { continue; } diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp index bba57353d..0a72d810d 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.cpp +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.cpp @@ -1906,7 +1906,7 @@ void ListWidget::validateTrippleClickStartTime() { } } -void ListWidget::enterEventHook(QEvent *e) { +void ListWidget::enterEventHook(QEnterEvent *e) { mouseActionUpdate(QCursor::pos()); return RpWidget::enterEventHook(e); } diff --git a/Telegram/SourceFiles/info/media/info_media_list_widget.h b/Telegram/SourceFiles/info/media/info_media_list_widget.h index 2c145942e..4c4e39cec 100644 --- a/Telegram/SourceFiles/info/media/info_media_list_widget.h +++ b/Telegram/SourceFiles/info/media/info_media_list_widget.h @@ -169,7 +169,7 @@ private: void mouseReleaseEvent(QMouseEvent *e) override; void mouseDoubleClickEvent(QMouseEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void start(); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp index 83c3a1023..811d93d39 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_item.cpp @@ -199,7 +199,7 @@ ClickHandlerPtr ItemBase::getResultPreviewHandler() const { } QString ItemBase::getResultThumbLetter() const { - auto parts = _result->_url.splitRef('/'); + auto parts = QStringView(_result->_url).split('/'); if (!parts.isEmpty()) { auto domain = parts.at(0); if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index dff8e808d..aa3ad25a9 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "app.h" #include "styles/style_layers.h" #include "styles/style_intro.h" +#include "base/qt_adapters.h" namespace Intro { namespace { @@ -512,7 +513,8 @@ void Widget::resetAccount() { const auto &type = error.type(); if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) { - const auto seconds = type.midRef( + const auto seconds = base::StringViewMid( + type, qstr("2FA_CONFIRM_WAIT_").size()).toInt(); const auto days = (seconds + 59) / 86400; const auto hours = ((seconds + 59) % 86400) / 3600; diff --git a/Telegram/SourceFiles/lang/lang_file_parser.cpp b/Telegram/SourceFiles/lang/lang_file_parser.cpp index 0fb08f5c7..5dac61ac9 100644 --- a/Telegram/SourceFiles/lang/lang_file_parser.cpp +++ b/Telegram/SourceFiles/lang/lang_file_parser.cpp @@ -174,7 +174,11 @@ QByteArray FileParser::ReadFile(const QString &absolutePath, const QString &rela QByteArray data; auto readUtf16Stream = [relativePath, absolutePath](auto &&stream) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + stream.setEncoding(QStringConverter::Utf16); +#else // Qt >= 6.0.0 stream.setCodec("UTF-16"); +#endif // Qt < 6.0.0 auto string = stream.readAll(); if (stream.status() != QTextStream::Ok) { LOG(("Lang Error: Could not read UTF-16 data from '%1' ('%2')").arg(relativePath, absolutePath)); diff --git a/Telegram/SourceFiles/lang/lang_tag.cpp b/Telegram/SourceFiles/lang/lang_tag.cpp index 3ad0309c8..63aef91ed 100644 --- a/Telegram/SourceFiles/lang/lang_tag.cpp +++ b/Telegram/SourceFiles/lang/lang_tag.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "ui/text/text.h" +#include "base/qt_adapters.h" namespace Lang { namespace { @@ -911,7 +912,7 @@ int NonZeroPartToInt(QString value) { } } return (zeros > 0) - ? (zeros < value.size() ? value.midRef(zeros).toInt() : 0) + ? (zeros < value.size() ? base::StringViewMid(value, zeros).toInt() : 0) : (value.isEmpty() ? 0 : value.toInt()); } @@ -1008,11 +1009,11 @@ QString ReplaceTag::Replace(QString &&original, const QString &replacem auto result = QString(); result.reserve(original.size() + replacement.size() - kTagReplacementSize); if (replacementPosition > 0) { - result.append(original.midRef(0, replacementPosition)); + result.append(base::StringViewMid(original, 0, replacementPosition)); } result.append(replacement); if (replacementPosition + kTagReplacementSize < original.size()) { - result.append(original.midRef(replacementPosition + kTagReplacementSize)); + result.append(base::StringViewMid(original, replacementPosition + kTagReplacementSize)); } return result; } diff --git a/Telegram/SourceFiles/lang/lang_text_entity.cpp b/Telegram/SourceFiles/lang/lang_text_entity.cpp index 795a1d612..47e7b886e 100644 --- a/Telegram/SourceFiles/lang/lang_text_entity.cpp +++ b/Telegram/SourceFiles/lang/lang_text_entity.cpp @@ -24,7 +24,7 @@ TextWithEntities ReplaceTag::Call(TextWithEntities &&original, if (originalEntitiesCount != 0 || replacementEntitiesCount != 0) { result.entities.reserve(originalEntitiesCount + replacementEntitiesCount); - auto replacementEnd = replacementPosition + replacement.text.size(); + auto replacementEnd = replacementPosition + int(replacement.text.size()); auto replacementEntity = replacement.entities.cbegin(); auto addReplacementEntitiesUntil = [&replacementEntity, &replacement, &result, replacementPosition, replacementEnd](int untilPosition) { while (replacementEntity != replacement.entities.cend()) { @@ -52,8 +52,8 @@ TextWithEntities ReplaceTag::Call(TextWithEntities &&original, if (end > replacementPosition) { end = end + replacement.text.size() - kTagReplacementSize; } - offset = std::clamp(offset, 0, result.text.size()); - end = std::clamp(end, 0, result.text.size()); + offset = std::clamp(offset, 0, int(result.text.size())); + end = std::clamp(end, 0, int(result.text.size())); // Add all replacement entities that start before the current original entity. addReplacementEntitiesUntil(offset); diff --git a/Telegram/SourceFiles/logs.cpp b/Telegram/SourceFiles/logs.cpp index 37789816d..6d9beeb6a 100644 --- a/Telegram/SourceFiles/logs.cpp +++ b/Telegram/SourceFiles/logs.cpp @@ -165,7 +165,7 @@ private: QStringList oldlogs = working.entryList(QStringList("log_start*.txt"), QDir::Files); for (QStringList::const_iterator i = oldlogs.cbegin(), e = oldlogs.cend(); i != e; ++i) { QString oldlog = cWorkingDir() + *i, oldlogend = i->mid(qstr("log_start").size()); - if (oldlogend.size() == 1 + qstr(".txt").size() && oldlogend.at(0).isDigit() && oldlogend.midRef(1) == qstr(".txt")) { + if (oldlogend.size() == 1 + qstr(".txt").size() && oldlogend.at(0).isDigit() && base::StringViewMid(oldlogend, 1) == qstr(".txt")) { bool removed = QFile(oldlog).remove(); LOG(("Old start log '%1' found, deleted: %2").arg(*i, Logs::b(removed))); } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index d17ff72dc..f098abd65 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -531,8 +531,8 @@ bool MainWidget::shareUrl( TextWithTags::Tags() }; MessageCursor cursor = { - url.size() + 1, - url.size() + 1 + text.size(), + int(url.size()) + 1, + int(url.size()) + 1 + int(text.size()), QFIXED_MAX }; auto history = peer->owner().history(peer); @@ -558,7 +558,7 @@ bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) { } const auto h = peer->owner().history(peer); TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() }; - MessageCursor cursor = { botAndQuery.size(), botAndQuery.size(), QFIXED_MAX }; + MessageCursor cursor = { int(botAndQuery.size()), int(botAndQuery.size()), QFIXED_MAX }; h->setLocalDraft(std::make_unique( textWithTags, 0, diff --git a/Telegram/SourceFiles/media/clip/media_clip_check_streaming.cpp b/Telegram/SourceFiles/media/clip/media_clip_check_streaming.cpp index 247a88291..e60eed1d9 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_check_streaming.cpp +++ b/Telegram/SourceFiles/media/clip/media_clip_check_streaming.cpp @@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include namespace Media { namespace Clip { diff --git a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp index 5d46bd822..e1161a9b7 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp +++ b/Telegram/SourceFiles/media/clip/media_clip_ffmpeg.cpp @@ -225,7 +225,7 @@ bool FFMpegReaderImplementation::renderFrame(QImage &to, bool &hasAlpha, const Q } // AV_NUM_DATA_POINTERS defined in AVFrame struct uint8_t *toData[AV_NUM_DATA_POINTERS] = { to.bits(), nullptr }; - int toLinesize[AV_NUM_DATA_POINTERS] = { to.bytesPerLine(), 0 }; + int toLinesize[AV_NUM_DATA_POINTERS] = { int(to.bytesPerLine()), 0 }; sws_scale(_swsContext, _frame->data, _frame->linesize, 0, _frame->height, toData, toLinesize); } if (hasAlpha) { diff --git a/Telegram/SourceFiles/media/clip/media_clip_implementation.h b/Telegram/SourceFiles/media/clip/media_clip_implementation.h index 7e709fe60..21ba4d54b 100644 --- a/Telegram/SourceFiles/media/clip/media_clip_implementation.h +++ b/Telegram/SourceFiles/media/clip/media_clip_implementation.h @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include +#include namespace Core { class FileLocation; diff --git a/Telegram/SourceFiles/media/player/media_player_panel.cpp b/Telegram/SourceFiles/media/player/media_player_panel.cpp index b09b5f912..e10743023 100644 --- a/Telegram/SourceFiles/media/player/media_player_panel.cpp +++ b/Telegram/SourceFiles/media/player/media_player_panel.cpp @@ -164,7 +164,7 @@ void Panel::paintEvent(QPaintEvent *e) { Ui::FillRoundRect(p, shadowedRect, st::menuBg, Ui::MenuCorners, nullptr, parts); } -void Panel::enterEventHook(QEvent *e) { +void Panel::enterEventHook(QEnterEvent *e) { if (_ignoringEnterEvents || contentTooSmall()) return; _hideTimer.cancel(); diff --git a/Telegram/SourceFiles/media/player/media_player_panel.h b/Telegram/SourceFiles/media/player/media_player_panel.h index eeb987c5a..17446fdc5 100644 --- a/Telegram/SourceFiles/media/player/media_player_panel.h +++ b/Telegram/SourceFiles/media/player/media_player_panel.h @@ -44,7 +44,7 @@ public: protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; private: diff --git a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp index 9a6686f97..a453f74cf 100644 --- a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp +++ b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp @@ -149,7 +149,7 @@ void VolumeWidget::paintEvent(QPaintEvent *e) { Ui::FillRoundRect(p, QRect(shadowedRect.x(), -st::roundRadiusSmall, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::roundRadiusSmall), st::menuBg, Ui::MenuCorners, nullptr, parts); } -void VolumeWidget::enterEventHook(QEvent *e) { +void VolumeWidget::enterEventHook(QEnterEvent *e) { _hideTimer.stop(); if (_a_appearance.animating()) { onShowStart(); diff --git a/Telegram/SourceFiles/media/player/media_player_volume_controller.h b/Telegram/SourceFiles/media/player/media_player_volume_controller.h index c5d35a70a..386910817 100644 --- a/Telegram/SourceFiles/media/player/media_player_volume_controller.h +++ b/Telegram/SourceFiles/media/player/media_player_volume_controller.h @@ -59,7 +59,7 @@ public: protected: void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override; diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_utility.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_utility.cpp index 1e3746807..6a65b7769 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_utility.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_utility.cpp @@ -160,7 +160,7 @@ QImage ConvertFrame( // AV_NUM_DATA_POINTERS defined in AVFrame struct uint8_t *data[AV_NUM_DATA_POINTERS] = { storage.bits(), nullptr }; - int linesize[AV_NUM_DATA_POINTERS] = { storage.bytesPerLine(), 0 }; + int linesize[AV_NUM_DATA_POINTERS] = { int(storage.bytesPerLine()), 0 }; sws_scale( stream.swscale.get(), diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp index ee1da69a1..ba0e4b586 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp @@ -55,7 +55,7 @@ static_assert(kDisplaySkipped != kTimeUnknown); 0, }; uint8_t *dstData[AV_NUM_DATA_POINTERS] = { result.bits(), nullptr }; - int dstLinesize[AV_NUM_DATA_POINTERS] = { result.bytesPerLine(), 0 }; + int dstLinesize[AV_NUM_DATA_POINTERS] = { int(result.bytesPerLine()), 0 }; sws_scale( swscale.get(), diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.h b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.h index 14f4b3457..d9b5dff34 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.h +++ b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_image.h" #include "ui/gl/gl_primitives.h" -#include +#include namespace Media::View { diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index ff739f55f..31e129007 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -74,13 +74,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "facades.h" #include "styles/style_media_view.h" #include "styles/style_chat.h" +#include "base/qt_adapters.h" #ifdef Q_OS_MAC #include "platform/mac/touchbar/mac_touchbar_media_view.h" #endif // Q_OS_MAC #include -#include #include #include #include @@ -4430,7 +4430,7 @@ bool OverlayWidget::handleContextMenu(std::optional position) { } bool OverlayWidget::handleTouchEvent(not_null e) { - if (e->device()->type() != QTouchDevice::TouchScreen) { + if (e->device()->type() != base::TouchDevice::TouchScreen) { return false; } else if (e->type() == QEvent::TouchBegin && !e->touchPoints().isEmpty() diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 1be7250a1..4c407d94e 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -33,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_widgets.h" #include "styles/style_window.h" #include "styles/style_media_view.h" -#include "base/qt_adapters.h" #include #include @@ -51,7 +50,7 @@ constexpr auto kMsInSecond = 1000; } [[nodiscard]] QRect ScreenFromPosition(QPoint point) { - const auto screen = base::QScreenNearestTo(point); + const auto screen = QGuiApplication::screenAt(point); const auto use = screen ? screen : QGuiApplication::primaryScreen(); return use ? use->availableGeometry() diff --git a/Telegram/SourceFiles/media/view/media_view_pip_opengl.h b/Telegram/SourceFiles/media/view/media_view_pip_opengl.h index 52f4fcf63..e5b005019 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip_opengl.h +++ b/Telegram/SourceFiles/media/view/media_view_pip_opengl.h @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_image.h" #include "ui/gl/gl_primitives.h" -#include +#include namespace Media::View { diff --git a/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp b/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp index 3e1cdd8cf..740ca287f 100644 --- a/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp +++ b/Telegram/SourceFiles/mtproto/details/mtproto_dc_key_binder.cpp @@ -107,7 +107,7 @@ SerializedRequest DcKeyBinder::prepareRequest( DcKeyBindState DcKeyBinder::handleResponse(const mtpBuffer &response) { Expects(!response.isEmpty()); - auto from = response.begin(); + auto from = response.data(); const auto end = from + response.size(); auto error = MTPRpcError(); if (response[0] == mtpc_boolTrue) { diff --git a/Telegram/SourceFiles/mtproto/details/mtproto_tls_socket.cpp b/Telegram/SourceFiles/mtproto/details/mtproto_tls_socket.cpp index 962e0268b..fe3c3d152 100644 --- a/Telegram/SourceFiles/mtproto/details/mtproto_tls_socket.cpp +++ b/Telegram/SourceFiles/mtproto/details/mtproto_tls_socket.cpp @@ -710,7 +710,7 @@ int64 TlsSocket::read(bytes::span buffer) { while (_incomingGoodDataLimit) { const auto available = std::min( _incomingGoodDataLimit, - _incoming.size() - _incomingGoodDataOffset); + int(_incoming.size()) - _incomingGoodDataOffset); if (available <= 0) { return written; } diff --git a/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp b/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp index 26862b6df..b6ef68f9b 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp @@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/facade.h" #include "mtproto/connection_tcp.h" #include "storage/serialize_common.h" -#include "base/qt_adapters.h" #include #include @@ -754,10 +753,12 @@ bool DcOptions::loadFromFile(const QString &path) { return false; } QTextStream stream(&f); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) stream.setCodec("UTF-8"); +#endif // Qt < 6.0.0 while (!stream.atEnd()) { auto line = stream.readLine(); - auto components = line.split(QRegularExpression(R"(\s)"), base::QStringSkipEmptyParts); + auto components = line.split(QRegularExpression(R"(\s)"), Qt::SkipEmptyParts); if (components.isEmpty() || components[0].startsWith('#')) { continue; } @@ -816,7 +817,9 @@ bool DcOptions::writeToFile(const QString &path) const { return false; } QTextStream stream(&f); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) stream.setCodec("UTF-8"); +#endif // Qt < 6.0.0 ReadLocker lock(this); for (const auto &item : _data) { diff --git a/Telegram/SourceFiles/mtproto/mtproto_proxy_data.cpp b/Telegram/SourceFiles/mtproto/mtproto_proxy_data.cpp index 1a031b561..edc2fa2e6 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_proxy_data.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_proxy_data.cpp @@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/mtproto_proxy_data.h" #include "base/qthelp_url.h" +#include "base/qt_adapters.h" namespace MTP { namespace { @@ -71,11 +72,11 @@ namespace { return result; } -[[nodiscard]] QStringRef Base64UrlInner(const QString &password) { +[[nodiscard]] QStringView Base64UrlInner(const QString &password) { Expects(password.size() > 2); // Skip one or two '=' at the end of the string. - return password.midRef(0, [&] { + return base::StringViewMid(password, 0, [&] { auto result = password.size(); for (auto i = 0; i != 2; ++i) { const auto prev = result - 1; diff --git a/Telegram/SourceFiles/mtproto/session_private.cpp b/Telegram/SourceFiles/mtproto/session_private.cpp index 7b64e62e9..fcb67f2de 100644 --- a/Telegram/SourceFiles/mtproto/session_private.cpp +++ b/Telegram/SourceFiles/mtproto/session_private.cpp @@ -535,7 +535,7 @@ MTPVector SessionPrivate::prepareInitParams() { const auto local = QDateTime::currentDateTime(); const auto utc = QDateTime(local.date(), local.time(), Qt::UTC); const auto shift = base::unixtime::now() - (TimeId)::time(nullptr); - const auto delta = int(utc.toTime_t()) - int(local.toTime_t()) - shift; + const auto delta = int(utc.toSecsSinceEpoch()) - int(local.toSecsSinceEpoch()) - shift; auto sliced = delta; while (sliced < -12 * 3600) { sliced += 24 * 3600; diff --git a/Telegram/SourceFiles/mtproto/special_config_request.cpp b/Telegram/SourceFiles/mtproto/special_config_request.cpp index 12f292a7a..4b014fc75 100644 --- a/Telegram/SourceFiles/mtproto/special_config_request.cpp +++ b/Telegram/SourceFiles/mtproto/special_config_request.cpp @@ -143,7 +143,7 @@ QByteArray ParseRealtimeResponse(const QByteArray &bytes) { } const auto number = [&](int index) { - return match.capturedRef(index).toInt(); + return match.capturedView(index).toInt(); }; const auto day = number(1); const auto month = [&] { @@ -161,9 +161,9 @@ QByteArray ParseRealtimeResponse(const QByteArray &bytes) { "Nov", "Dec" }; - const auto captured = match.capturedRef(2); + const auto captured = match.capturedView(2); for (auto i = begin(months); i != end(months); ++i) { - if (captured == (*i)) { + if (captured == QString(*i)) { return 1 + int(i - begin(months)); } } @@ -369,7 +369,7 @@ void SpecialConfigRequest::handleHeaderUnixtime( LOG(("Config Error: Bad 'Date' header received: %1").arg(date)); return; } - base::unixtime::http_update(parsed.toTime_t()); + base::unixtime::http_update(parsed.toSecsSinceEpoch()); if (_timeDoneCallback) { _timeDoneCallback(); } diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 7c65a724c..8911db8cf 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -38,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_cursor_state.h" #include "history/view/media/history_view_document.h" // DrawThumbnailAsSongCover #include "base/unixtime.h" -#include "base/qt_adapters.h" #include "ui/effects/round_checkbox.h" #include "ui/image/image.h" #include "ui/text/format_song_document_name.h" @@ -1557,14 +1556,14 @@ Link::Link( _title = _page->title; } - auto parts = mainUrl.splitRef('/'); + auto parts = QStringView(mainUrl).split('/'); if (!parts.isEmpty()) { auto domain = parts.at(0); if (parts.size() > 2 && domain.endsWith(':') && parts.at(1).isEmpty()) { // http:// and others domain = parts.at(2); } - parts = domain.split('@').back().split('.', base::QStringSkipEmptyParts); + parts = domain.split('@').back().split('.', Qt::SkipEmptyParts); if (parts.size() > 1) { _letter = parts.at(parts.size() - 2).at(0).toUpper(); if (_title.isEmpty()) { diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index 86729e8ce..c0505fe49 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -135,7 +135,7 @@ void VerifyBox::setupControls( link.entities.push_back({ EntityType::CustomUrl, 0, - link.text.size(), + int(link.text.size()), QString("internal:resend") }); const auto label = _content->add( object_ptr( diff --git a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp index a7499b686..dab638d9f 100644 --- a/Telegram/SourceFiles/passport/ui/passport_details_row.cpp +++ b/Telegram/SourceFiles/passport/ui/passport_details_row.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "countries/countries_instance.h" #include "styles/style_layers.h" #include "styles/style_passport.h" +#include "base/qt_adapters.h" #include @@ -61,7 +62,7 @@ void PostcodeInput::correctValue( QString newText; newText.reserve(now.size()); auto newPos = nowCursor; - for (auto i = 0, l = now.size(); i < l; ++i) { + for (auto i = 0, l = int(now.size()); i < l; ++i) { const auto ch = now[i]; if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') @@ -411,11 +412,11 @@ QDate ValidateDate(const QString &value) { } auto result = QDate(); const auto readInt = [](const QString &value) { - auto ref = value.midRef(0); - while (!ref.isEmpty() && ref.at(0) == '0') { - ref = ref.mid(1); + auto view = QStringView(value); + while (!view.isEmpty() && view.at(0) == '0') { + view = base::StringViewMid(view, 1); } - return ref.toInt(); + return view.toInt(); }; result.setDate( readInt(match.captured(3)), @@ -639,11 +640,11 @@ bool DateRow::setFocusFast() { int DateRow::number(const object_ptr &field) const { const auto text = field->getLastText(); - auto ref = text.midRef(0); - while (!ref.isEmpty() && ref.at(0) == '0') { - ref = ref.mid(1); + auto view = QStringView(text); + while (!view.isEmpty() && view.at(0) == '0') { + view = base::StringViewMid(view, 1); } - return ref.toInt(); + return view.toInt(); } int DateRow::day() const { diff --git a/Telegram/SourceFiles/payments/stripe/stripe_card_validator.cpp b/Telegram/SourceFiles/payments/stripe/stripe_card_validator.cpp index 7930b4eaf..c1352fe9e 100644 --- a/Telegram/SourceFiles/payments/stripe/stripe_card_validator.cpp +++ b/Telegram/SourceFiles/payments/stripe/stripe_card_validator.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "stripe/stripe_card_validator.h" +#include "base/qt_adapters.h" + #include #include @@ -75,13 +77,13 @@ struct BinRange { const BinRange &range, const QString &sanitized) { const auto minWithLow = std::min(sanitized.size(), range.low.size()); - if (sanitized.midRef(0, minWithLow).toInt() - < range.low.midRef(0, minWithLow).toInt()) { + if (base::StringViewMid(sanitized, 0, minWithLow).toInt() + < base::StringViewMid(range.low, 0, minWithLow).toInt()) { return false; } const auto minWithHigh = std::min(sanitized.size(), range.high.size()); - if (sanitized.midRef(0, minWithHigh).toInt() - > range.high.midRef(0, minWithHigh).toInt()) { + if (base::StringViewMid(sanitized, 0, minWithHigh).toInt() + > base::StringViewMid(range.high, 0, minWithHigh).toInt()) { return false; } return true; diff --git a/Telegram/SourceFiles/payments/stripe/stripe_error.cpp b/Telegram/SourceFiles/payments/stripe/stripe_error.cpp index 72f843252..c5be7e010 100644 --- a/Telegram/SourceFiles/payments/stripe/stripe_error.cpp +++ b/Telegram/SourceFiles/payments/stripe/stripe_error.cpp @@ -62,7 +62,7 @@ Error Error::DecodedObjectFromResponse(QJsonObject object) { if (first) { first = false; } else { - word = word[0].toUpper() + word.midRef(1); + word = word[0].toUpper() + word.mid(1); } } const auto parameter = parameterWords.join(QString()); diff --git a/Telegram/SourceFiles/payments/stripe/stripe_token.cpp b/Telegram/SourceFiles/payments/stripe/stripe_token.cpp index 66a131a36..d91e48be3 100644 --- a/Telegram/SourceFiles/payments/stripe/stripe_token.cpp +++ b/Telegram/SourceFiles/payments/stripe/stripe_token.cpp @@ -33,7 +33,7 @@ Token Token::DecodedObjectFromAPIResponse(QJsonObject object) { } const auto tokenId = object.value("id").toString(); const auto livemode = object.value("livemode").toBool(); - const auto created = QDateTime::fromTime_t( + const auto created = QDateTime::fromSecsSinceEpoch( object.value("created").toDouble()); auto result = Token(tokenId, livemode, created); const auto card = object.value("card"); diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp b/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp index d09b6da23..7de2bb0ff 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp @@ -45,8 +45,8 @@ struct SimpleFieldState { [[nodiscard]] SimpleFieldState NumbersOnlyState(SimpleFieldState state) { return { .value = RemoveNonNumbers(state.value), - .position = RemoveNonNumbers( - state.value.mid(0, state.position)).size(), + .position = int(RemoveNonNumbers( + state.value.mid(0, state.position)).size()), }; } @@ -94,19 +94,19 @@ struct SimpleFieldState { [[nodiscard]] bool IsBackspace(const FieldValidateRequest &request) { return (request.wasAnchor == request.wasPosition) && (request.wasPosition == request.nowPosition + 1) - && (request.wasValue.midRef(0, request.wasPosition - 1) - == request.nowValue.midRef(0, request.nowPosition)) - && (request.wasValue.midRef(request.wasPosition) - == request.nowValue.midRef(request.nowPosition)); + && (request.wasValue.mid(0, request.wasPosition - 1) + == request.nowValue.mid(0, request.nowPosition)) + && (request.wasValue.mid(request.wasPosition) + == request.nowValue.mid(request.nowPosition)); } [[nodiscard]] bool IsDelete(const FieldValidateRequest &request) { return (request.wasAnchor == request.wasPosition) && (request.wasPosition == request.nowPosition) - && (request.wasValue.midRef(0, request.wasPosition) - == request.nowValue.midRef(0, request.nowPosition)) - && (request.wasValue.midRef(request.wasPosition + 1) - == request.nowValue.midRef(request.nowPosition)); + && (request.wasValue.mid(0, request.wasPosition) + == request.nowValue.mid(0, request.nowPosition)) + && (request.wasValue.mid(request.wasPosition + 1) + == request.nowValue.mid(request.nowPosition)); } template < diff --git a/Telegram/SourceFiles/payments/ui/payments_field.cpp b/Telegram/SourceFiles/payments/ui/payments_field.cpp index 12309984a..522a7aa3b 100644 --- a/Telegram/SourceFiles/payments/ui/payments_field.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_field.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "countries/countries_instance.h" #include "base/platform/base_platform_info.h" #include "base/event_filter.h" +#include "base/qt_adapters.h" #include "styles/style_payments.h" #include @@ -49,11 +50,11 @@ struct SimpleFieldState { ); const auto digitsLimit = 16 - rule.exponent; const auto beforePosition = state.value.mid(0, state.position); - auto decimalPosition = withDecimal.lastIndexOf(rule.decimal); + auto decimalPosition = int(withDecimal.lastIndexOf(rule.decimal)); if (decimalPosition < 0) { state = { .value = RemoveNonNumbers(state.value), - .position = RemoveNonNumbers(beforePosition).size(), + .position = int(RemoveNonNumbers(beforePosition).size()), }; } else { const auto onlyNumbersBeforeDecimal = RemoveNonNumbers( @@ -62,7 +63,7 @@ struct SimpleFieldState { .value = (onlyNumbersBeforeDecimal + QChar(rule.decimal) + RemoveNonNumbers(state.value.mid(decimalPosition + 1))), - .position = (RemoveNonNumbers(beforePosition).size() + .position = int(RemoveNonNumbers(beforePosition).size() + (state.position > decimalPosition ? 1 : 0)), }; decimalPosition = onlyNumbersBeforeDecimal.size(); @@ -133,19 +134,19 @@ struct SimpleFieldState { [[nodiscard]] bool IsBackspace(const FieldValidateRequest &request) { return (request.wasAnchor == request.wasPosition) && (request.wasPosition == request.nowPosition + 1) - && (request.wasValue.midRef(0, request.wasPosition - 1) - == request.nowValue.midRef(0, request.nowPosition)) - && (request.wasValue.midRef(request.wasPosition) - == request.nowValue.midRef(request.nowPosition)); + && (base::StringViewMid(request.wasValue, 0, request.wasPosition - 1) + == base::StringViewMid(request.nowValue, 0, request.nowPosition)) + && (base::StringViewMid(request.wasValue, request.wasPosition) + == base::StringViewMid(request.nowValue, request.nowPosition)); } [[nodiscard]] bool IsDelete(const FieldValidateRequest &request) { return (request.wasAnchor == request.wasPosition) && (request.wasPosition == request.nowPosition) - && (request.wasValue.midRef(0, request.wasPosition) - == request.nowValue.midRef(0, request.nowPosition)) - && (request.wasValue.midRef(request.wasPosition + 1) - == request.nowValue.midRef(request.nowPosition)); + && (base::StringViewMid(request.wasValue, 0, request.wasPosition) + == base::StringViewMid(request.nowValue, 0, request.nowPosition)) + && (base::StringViewMid(request.wasValue, request.wasPosition + 1) + == base::StringViewMid(request.nowValue, request.nowPosition)); } [[nodiscard]] auto MoneyValidator(const CurrencyRule &rule) { @@ -345,7 +346,7 @@ struct SimpleFieldState { const auto symbol = QChar(rule.decimal); const auto decimal = text.indexOf(symbol); const auto zeros = (decimal >= 0) - ? std::max(rule.exponent - (text.size() - decimal - 1), 0) + ? std::max(rule.exponent - int(text.size() - decimal - 1), 0) : rule.stripDotZero ? 0 : rule.exponent; diff --git a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp index ac8c8c28a..ec0f0b735 100644 --- a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp @@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/linux_desktop_environment.h" -#include "base/qt_adapters.h" - namespace Platform { namespace DesktopEnvironment { namespace { @@ -21,7 +19,7 @@ QString GetEnv(const char *name) { Type Compute() { auto xdgCurrentDesktop = GetEnv("XDG_CURRENT_DESKTOP").toLower(); - auto list = xdgCurrentDesktop.split(':', base::QStringSkipEmptyParts); + auto list = xdgCurrentDesktop.split(':', Qt::SkipEmptyParts); auto desktopSession = GetEnv("DESKTOP_SESSION").toLower(); auto slash = desktopSession.lastIndexOf('/'); auto kdeSession = GetEnv("KDE_SESSION_VERSION"); diff --git a/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp b/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp index 5361d034f..f1d502a07 100644 --- a/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_xdp_file_dialog.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/linux/linux_wayland_integration.h" #include "storage/localstorage.h" #include "base/random.h" -#include "base/qt_adapters.h" #include #include diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index e7cce3a7d..dd7919826 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -50,8 +50,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #include +#else // Qt < 6.0.0 +class StatusNotifierItem; +class DBusMenuExporter; +#endif // Qt >= 6.0.0 #include #include @@ -389,7 +394,7 @@ void ForceDisabled(QAction *action, bool disabled) { } #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -bool IsIndicatorApplication() { +[[maybe_unused]] bool IsIndicatorApplication() { // Hack for indicator-application, // which doesn't handle icons sent across D-Bus: // save the icon to a temp file @@ -417,7 +422,7 @@ bool IsIndicatorApplication() { return Result; } -std::unique_ptr TrayIconFile( +[[maybe_unused]] std::unique_ptr TrayIconFile( const QIcon &icon, QObject *parent = nullptr) { static const auto templateName = AppRuntimeDirectory() @@ -646,6 +651,7 @@ private: #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION void MainWindow::Private::setSNITrayIcon(int counter, bool muted) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const auto iconName = GetTrayIconName(counter, muted); const auto panelIconName = GetPanelIconName(counter, muted); @@ -681,9 +687,11 @@ void MainWindow::Private::setSNITrayIcon(int counter, bool muted) { sniTrayIcon->setIconByPixmap(icon); sniTrayIcon->setToolTipIconByPixmap(icon); } +#endif // Qt < 6.0.0 } void MainWindow::Private::attachToSNITrayIcon() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) sniTrayIcon->setToolTipTitle(AppName.utf16()); connect(sniTrayIcon, &StatusNotifierItem::activateRequested, @@ -699,6 +707,7 @@ void MainWindow::Private::attachToSNITrayIcon() { _public->handleTrayIconActication(QSystemTrayIcon::MiddleClick); }); }); +#endif // Qt < 6.0.0 } void MainWindow::Private::handleSNIHostRegistered() { @@ -787,9 +796,11 @@ MainWindow::MainWindow(not_null controller) : Window::MainWindow(controller) , _private(std::make_unique(this)) { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qDBusRegisterMetaType(); qDBusRegisterMetaType(); qDBusRegisterMetaType(); +#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } @@ -916,8 +927,9 @@ void MainWindow::psSetupTrayIcon() { const auto counter = Core::App().unreadBadge(); const auto muted = Core::App().unreadBadgeMuted(); - if (_sniAvailable) { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + if (_sniAvailable) { LOG(("Using SNI tray icon.")); if (!_private->sniTrayIcon) { _private->sniTrayIcon = new StatusNotifierItem( @@ -932,19 +944,25 @@ void MainWindow::psSetupTrayIcon() { _private->attachToSNITrayIcon(); } updateIconCounters(); -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION - } else { - LOG(("Using Qt tray icon.")); - if (!trayIcon) { - trayIcon = new QSystemTrayIcon(this); - trayIcon->setIcon(TrayIconGen(counter, muted)); - attachToTrayIcon(trayIcon); - } - updateIconCounters(); - - trayIcon->show(); + return; } +#endif // Qt < 6.0.0 +#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + + LOG(("Using Qt tray icon.")); + if (!trayIcon) { + trayIcon = new QSystemTrayIcon(this); + if (_sniAvailable) { + trayIcon->setContextMenu(trayIconMenu); + } + trayIcon->setIcon(TrayIconGen(counter, muted)); + + attachToTrayIcon(trayIcon); + } + updateIconCounters(); + + trayIcon->show(); } void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) { @@ -952,11 +970,13 @@ void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) { return; } else if (mode == WorkMode::WindowOnly) { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (_private->sniTrayIcon) { _private->sniTrayIcon->setContextMenu(0); _private->sniTrayIcon->deleteLater(); } _private->sniTrayIcon = nullptr; +#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION if (trayIcon) { @@ -1219,9 +1239,11 @@ void MainWindow::createGlobalMenu() { about->setMenuRole(QAction::AboutQtRole); #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) _private->mainMenuExporter = new DBusMenuExporter( kMainMenuObjectPath.utf16(), psMainMenu); +#endif // Qt < 6.0.0 if (_private->appMenuSupported) { RegisterAppMenu(windowHandle(), kMainMenuObjectPath.utf16()); diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index f1088ee90..ac149705f 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -683,7 +683,7 @@ void NotificationData::setImage(const QString &imagePath) { _hints[_imageKey] = MakeGlibVariant(std::tuple{ image.width(), image.height(), - image.bytesPerLine(), + int(image.bytesPerLine()), true, 8, 4, diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 9c1254d33..66acd0b2f 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/platform/linux/ui_linux_wayland_integration.h" #include "platform/linux/linux_desktop_environment.h" #include "platform/linux/linux_wayland_integration.h" -#include "base/qt_adapters.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "storage/localstorage.h" @@ -40,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#include #include #include #include @@ -670,7 +668,7 @@ void start() { LOG(("Launcher filename: %1").arg(QGuiApplication::desktopFileName())); #ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION - qputenv("QT_WAYLAND_SHELL_INTEGRATION", "desktop-app-xdg-shell;xdg-shell;wl-shell"); + qputenv("QT_WAYLAND_SHELL_INTEGRATION", "desktop-app-xdg-shell;xdg-shell"); #endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION qputenv("PULSE_PROP_application.name", AppName.utf8()); diff --git a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm index 3f94ee818..995f8f598 100644 --- a/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm +++ b/Telegram/SourceFiles/platform/mac/file_utilities_mac.mm @@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/mac/base_utilities_mac.h" #include "lang/lang_keys.h" -#include "base/qt_adapters.h" #include "styles/style_window.h" #include @@ -399,7 +398,7 @@ bool UnsafeShowOpenWithDropdown(const QString &filepath, QPoint menuPosition) { NSString *file = Q2NSString(filepath); @try { OpenFileWithInterface *menu = [[[OpenFileWithInterface alloc] init:file] autorelease]; - const auto screen = base::QScreenNearestTo(menuPosition); + const auto screen = QGuiApplication::screenAt(menuPosition); if (!screen) { return false; } diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index 71c0cbc16..1af409348 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -276,7 +276,6 @@ void objc_outputDebugString(const QString &str) { } void objc_start() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) // Patch: Fix macOS regression. On 10.14.4, it crashes on GPU switches. // See https://bugreports.qt.io/browse/QTCREATORBUG-22215 const auto version = QOperatingSystemVersion::current(); @@ -285,7 +284,6 @@ void objc_start() { && version.microVersion() == 4) { qputenv("QT_MAC_PRO_WEBENGINE_WORKAROUND", "1"); } -#endif // Qt 5.9.0 _sharedDelegate = [[ApplicationDelegate alloc] init]; [[NSApplication sharedApplication] setDelegate:_sharedDelegate]; diff --git a/Telegram/SourceFiles/profile/profile_block_peer_list.cpp b/Telegram/SourceFiles/profile/profile_block_peer_list.cpp index 4f5918398..329d15ab3 100644 --- a/Telegram/SourceFiles/profile/profile_block_peer_list.cpp +++ b/Telegram/SourceFiles/profile/profile_block_peer_list.cpp @@ -186,7 +186,7 @@ void PeerListWidget::mousePressReleased(Qt::MouseButton button) { repaintSelectedRow(); } -void PeerListWidget::enterEventHook(QEvent *e) { +void PeerListWidget::enterEventHook(QEnterEvent *e) { _mousePosition = QCursor::pos(); updateSelection(); } diff --git a/Telegram/SourceFiles/profile/profile_block_peer_list.h b/Telegram/SourceFiles/profile/profile_block_peer_list.h index 002db0233..02a208ef8 100644 --- a/Telegram/SourceFiles/profile/profile_block_peer_list.h +++ b/Telegram/SourceFiles/profile/profile_block_peer_list.h @@ -102,9 +102,9 @@ protected: void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void enterFromChildEvent(QEvent *e, QWidget *child) override { - enterEventHook(e); + enterEventHook(nullptr); } void leaveEventHook(QEvent *e) override; void leaveToChildEvent(QEvent *e, QWidget *child) override { diff --git a/Telegram/SourceFiles/settings/settings_codes.cpp b/Telegram/SourceFiles/settings/settings_codes.cpp index 20953b948..a5f756939 100644 --- a/Telegram/SourceFiles/settings/settings_codes.cpp +++ b/Telegram/SourceFiles/settings/settings_codes.cpp @@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/audio/media_audio_track.h" #include "settings/settings_common.h" #include "api/api_updates.h" +#include "base/qt_adapters.h" #include "zlib.h" @@ -294,7 +295,7 @@ void CodesFeedString(SessionController *window, const QString &text) { secret += text.toLower(); int size = secret.size(), from = 0; while (size > from) { - auto piece = secret.midRef(from); + auto piece = base::StringViewMid(secret,from); auto found = false; for (const auto &[key, method] : codes) { if (piece == key) { diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 6c3dc62d8..065333bf1 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -241,7 +241,7 @@ void SetupRows( result.entities.push_back({ EntityType::CustomUrl, 0, - add.size(), + int(add.size()), "internal:edit_username" }); return result; }); diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 5f097b541..f119159b8 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -73,7 +73,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#include +#include // Fix Google Breakpad build for Mac App Store and Linux version #ifdef Q_OS_UNIX diff --git a/Telegram/SourceFiles/storage/localimageloader.cpp b/Telegram/SourceFiles/storage/localimageloader.cpp index 424bb5c7f..f268563c2 100644 --- a/Telegram/SourceFiles/storage/localimageloader.cpp +++ b/Telegram/SourceFiles/storage/localimageloader.cpp @@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/mime_type.h" #include "base/unixtime.h" #include "base/random.h" -#include "base/qt_adapters.h" #include "editor/scene/scene.h" // Editor::Scene::attachedStickers #include "media/audio/media_audio.h" #include "media/clip/media_clip_reader.h" @@ -35,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include namespace { @@ -864,7 +864,7 @@ void FileLoadTask::process(Args &&args) { // We have an example of dark .png image that when being sent without // removing its color space is displayed fine on tdesktop, but with // a light gray background on mobile apps. - base::QClearColorSpace(full); + full.setColorSpace(QColorSpace()); QBuffer buffer(&filedata); QImageWriter writer(&buffer, "JPEG"); writer.setQuality(87); diff --git a/Telegram/SourceFiles/storage/storage_account.cpp b/Telegram/SourceFiles/storage/storage_account.cpp index 5a1c72d61..e9c2616d7 100644 --- a/Telegram/SourceFiles/storage/storage_account.cpp +++ b/Telegram/SourceFiles/storage/storage_account.cpp @@ -2447,10 +2447,10 @@ std::optional Account::saveRecentHashtags( i = m.capturedStart(); next = m.capturedEnd(); if (m.hasMatch()) { - if (!m.capturedRef(1).isEmpty()) { + if (!m.capturedView(1).isEmpty()) { ++i; } - if (!m.capturedRef(2).isEmpty()) { + if (!m.capturedView(2).isEmpty()) { --next; } } diff --git a/Telegram/SourceFiles/support/support_autocomplete.cpp b/Telegram/SourceFiles/support/support_autocomplete.cpp index d458e85ed..1faf4fbf9 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.cpp +++ b/Telegram/SourceFiles/support/support_autocomplete.cpp @@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "base/unixtime.h" #include "base/call_delayed.h" -#include "base/qt_adapters.h" #include "main/main_session.h" #include "main/main_session_settings.h" #include "apiwrap.h" @@ -477,7 +476,7 @@ void Autocomplete::submitValue(const QString &value) { const auto contact = value.mid( prefix.size(), (line > 0) ? (line - prefix.size()) : -1); - const auto parts = contact.split(' ', base::QStringSkipEmptyParts); + const auto parts = contact.split(' ', Qt::SkipEmptyParts); if (parts.size() > 1) { const auto phone = parts[0]; const auto firstName = parts[1]; diff --git a/Telegram/SourceFiles/support/support_helper.cpp b/Telegram/SourceFiles/support/support_helper.cpp index 7c11507a7..21b9455ab 100644 --- a/Telegram/SourceFiles/support/support_helper.cpp +++ b/Telegram/SourceFiles/support/support_helper.cpp @@ -177,18 +177,18 @@ uint32 ParseOccupationTag(History *history) { return 0; } const auto &text = draft->textWithTags.text; - const auto parts = text.splitRef(';'); + const auto parts = QStringView(text).split(';'); auto valid = false; auto result = uint32(); for (const auto &part : parts) { if (part.startsWith(qstr("t:"))) { - if (part.mid(2).toInt() >= base::unixtime::now()) { + if (base::StringViewMid(part, 2).toInt() >= base::unixtime::now()) { valid = true; } else { return 0; } } else if (part.startsWith(qstr("u:"))) { - result = part.mid(2).toUInt(); + result = base::StringViewMid(part, 2).toUInt(); } } return valid ? result : 0; @@ -203,18 +203,18 @@ QString ParseOccupationName(History *history) { return QString(); } const auto &text = draft->textWithTags.text; - const auto parts = text.splitRef(';'); + const auto parts = QStringView(text).split(';'); auto valid = false; auto result = QString(); for (const auto &part : parts) { if (part.startsWith(qstr("t:"))) { - if (part.mid(2).toInt() >= base::unixtime::now()) { + if (base::StringViewMid(part, 2).toInt() >= base::unixtime::now()) { valid = true; } else { return 0; } } else if (part.startsWith(qstr("n:"))) { - result = part.mid(2).toString(); + result = base::StringViewMid(part, 2).toString(); } } return valid ? result : QString(); @@ -229,18 +229,18 @@ TimeId OccupiedBySomeoneTill(History *history) { return 0; } const auto &text = draft->textWithTags.text; - const auto parts = text.splitRef(';'); + const auto parts = QStringView(text).split(';'); auto valid = false; auto result = TimeId(); for (const auto &part : parts) { if (part.startsWith(qstr("t:"))) { - if (part.mid(2).toInt() >= base::unixtime::now()) { - result = part.mid(2).toInt(); + if (base::StringViewMid(part, 2).toInt() >= base::unixtime::now()) { + result = base::StringViewMid(part, 2).toInt(); } else { return 0; } } else if (part.startsWith(qstr("u:"))) { - if (part.mid(2).toUInt() != OccupationTag()) { + if (base::StringViewMid(part, 2).toUInt() != OccupationTag()) { valid = true; } else { return 0; @@ -562,11 +562,14 @@ QString InterpretSendPath( for (const auto &line : lines) { if (line.startsWith(qstr("from: "))) { if (window->session().userId().bare - != line.midRef(qstr("from: ").size()).toULongLong()) { + != base::StringViewMid( + line, + qstr("from: ").size()).toULongLong()) { return "App Error: Wrong current user."; } } else if (line.startsWith(qstr("channel: "))) { - const auto channelId = line.midRef( + const auto channelId = base::StringViewMid( + line, qstr("channel: ").size()).toULongLong(); toId = peerFromChannel(channelId); } else if (line.startsWith(qstr("file: "))) { diff --git a/Telegram/SourceFiles/support/support_templates.cpp b/Telegram/SourceFiles/support/support_templates.cpp index 6d528a505..d665b3fd4 100644 --- a/Telegram/SourceFiles/support/support_templates.cpp +++ b/Telegram/SourceFiles/support/support_templates.cpp @@ -433,7 +433,7 @@ int CountMaxKeyLength(const TemplatesData &data) { for (const auto &[path, file] : data.files) { for (const auto &[normalized, question] : file.questions) { for (const auto &key : question.normalizedKeys) { - accumulate_max(result, key.size()); + accumulate_max(result, int(key.size())); } } } diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp index 89be48553..ffeee6c02 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/multi_select.h" #include "ui/effects/ripple_animation.h" #include "countries/countries_instance.h" -#include "base/qt_adapters.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_intro.h" @@ -50,7 +49,7 @@ public: protected: void paintEvent(QPaintEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; @@ -241,7 +240,7 @@ void CountrySelectBox::Inner::init() { : QString()); const auto namesList = std::move(full).toLower().split( QRegularExpression("[\\s\\-]"), - base::QStringSkipEmptyParts); + Qt::SkipEmptyParts); auto &names = _namesList.emplace_back(); names.reserve(namesList.size()); for (const auto &name : namesList) { @@ -315,7 +314,7 @@ void CountrySelectBox::Inner::paintEvent(QPaintEvent *e) { } } -void CountrySelectBox::Inner::enterEventHook(QEvent *e) { +void CountrySelectBox::Inner::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 2fe0f51a4..67d5aabf5 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/ripple_animation.h" #include "ui/boxes/country_select_box.h" #include "countries/countries_instance.h" -#include "base/qt_adapters.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_intro.h" @@ -143,7 +142,7 @@ void CountryInput::mousePressEvent(QMouseEvent *e) { } } -void CountryInput::enterEventHook(QEvent *e) { +void CountryInput::enterEventHook(QEnterEvent *e) { setMouseTracking(true); } diff --git a/Telegram/SourceFiles/ui/countryinput.h b/Telegram/SourceFiles/ui/countryinput.h index 511ed4c2f..a6828e8f2 100644 --- a/Telegram/SourceFiles/ui/countryinput.h +++ b/Telegram/SourceFiles/ui/countryinput.h @@ -41,7 +41,7 @@ protected: void paintEvent(QPaintEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mousePressEvent(QMouseEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; private: diff --git a/Telegram/SourceFiles/ui/filter_icon_panel.cpp b/Telegram/SourceFiles/ui/filter_icon_panel.cpp index 2ae8eee4f..dfdbf3bac 100644 --- a/Telegram/SourceFiles/ui/filter_icon_panel.cpp +++ b/Telegram/SourceFiles/ui/filter_icon_panel.cpp @@ -266,7 +266,7 @@ void FilterIconPanel::paintEvent(QPaintEvent *e) { } } -void FilterIconPanel::enterEventHook(QEvent *e) { +void FilterIconPanel::enterEventHook(QEnterEvent *e) { Core::App().registerLeaveSubscription(this); showAnimated(); } diff --git a/Telegram/SourceFiles/ui/filter_icon_panel.h b/Telegram/SourceFiles/ui/filter_icon_panel.h index 44b4f6c1a..04a02f936 100644 --- a/Telegram/SourceFiles/ui/filter_icon_panel.h +++ b/Telegram/SourceFiles/ui/filter_icon_panel.h @@ -35,7 +35,7 @@ public: [[nodiscard]] rpl::producer chosen() const; private: - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void otherEnter(); void otherLeave(); diff --git a/Telegram/SourceFiles/ui/image/image_location_factory.cpp b/Telegram/SourceFiles/ui/image/image_location_factory.cpp index dc3776d57..3c242f803 100644 --- a/Telegram/SourceFiles/ui/image/image_location_factory.cpp +++ b/Telegram/SourceFiles/ui/image/image_location_factory.cpp @@ -65,7 +65,7 @@ ImageWithLocation FromPhotoSize( data.vw().v, data.vh().v), .bytes = bytes, - .bytesCount = bytes.size(), + .bytesCount = int(bytes.size()), }; }, [&](const MTPDphotoSizeProgressive &data) { // #TODO layer118 @@ -160,7 +160,7 @@ ImageWithLocation FromPhotoSize( data.vw().v, data.vh().v), .bytes = bytes, - .bytesCount = bytes.size(), + .bytesCount = int(bytes.size()), }; }, [&](const MTPDphotoSizeProgressive &data) { if (data.vsizes().v.isEmpty()) { @@ -238,7 +238,7 @@ ImageWithLocation FromPhotoSize( data.vw().v, data.vh().v), .bytes = bytes, - .bytesCount = bytes.size(), + .bytesCount = int(bytes.size()), }; }, [&](const MTPDphotoSizeProgressive &data) { if (data.vsizes().v.isEmpty()) { @@ -299,7 +299,7 @@ ImageWithLocation FromImageInMemory( image.height()), .bytes = bytes, .preloaded = image, - .bytesCount = bytes.size(), + .bytesCount = int(bytes.size()), }; } diff --git a/Telegram/SourceFiles/ui/special_fields.cpp b/Telegram/SourceFiles/ui/special_fields.cpp index 551577a15..61cb4198a 100644 --- a/Telegram/SourceFiles/ui/special_fields.cpp +++ b/Telegram/SourceFiles/ui/special_fields.cpp @@ -41,7 +41,7 @@ void CountryCodeInput::codeSelected(const QString &code) { auto wasText = getLastText(); auto wasCursor = cursorPosition(); auto newText = '+' + code; - auto newCursor = newText.size(); + auto newCursor = int(newText.size()); setText(newText); _nosignal = true; correctValue(wasText, wasCursor, newText, newCursor); @@ -200,7 +200,7 @@ void PhonePartInput::addedToNumber(const QString &added) { auto wasText = getLastText(); auto wasCursor = cursorPosition(); auto newText = added + wasText; - auto newCursor = newText.size(); + auto newCursor = int(newText.size()); setText(newText); setCursorPosition(added.length()); correctValue(wasText, wasCursor, newText, newCursor); @@ -231,7 +231,7 @@ void PhonePartInput::chooseCode(const QString &code) { auto wasText = getLastText(); auto wasCursor = cursorPosition(); auto newText = getLastText(); - auto newCursor = newText.size(); + auto newCursor = int(newText.size()); correctValue(wasText, wasCursor, newText, newCursor); startPlaceholderAnimation(); @@ -271,7 +271,7 @@ void UsernameInput::correctValue( QString &now, int &nowCursor) { auto newPos = nowCursor; - auto from = 0, len = now.size(); + auto from = 0, len = int(now.size()); for (; from < len; ++from) { if (!now.at(from).isSpace()) { break; @@ -303,7 +303,7 @@ PhoneInput::PhoneInput( if (value.isEmpty()) { clearText(); } else { - auto pos = value.size(); + auto pos = int(value.size()); correctValue(QString(), 0, value, pos); } } @@ -316,7 +316,7 @@ void PhoneInput::focusInEvent(QFocusEvent *e) { void PhoneInput::clearText() { auto value = _defaultValue; setText(value); - auto pos = value.size(); + auto pos = int(value.size()); correctValue(QString(), 0, value, pos); } diff --git a/Telegram/SourceFiles/ui/text/format_song_name.cpp b/Telegram/SourceFiles/ui/text/format_song_name.cpp index 388112e1c..c3f161de6 100644 --- a/Telegram/SourceFiles/ui/text/format_song_name.cpp +++ b/Telegram/SourceFiles/ui/text/format_song_name.cpp @@ -66,8 +66,8 @@ TextWithEntities FormatSongName::textWithEntities( EntityType::Semibold, 0, _composedName.performer.isEmpty() - ? result.text.size() - : _composedName.performer.size(), + ? int(result.text.size()) + : int(_composedName.performer.size()), }); } return result; diff --git a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp index 0ce108581..0d57b74d7 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp +++ b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp @@ -136,7 +136,7 @@ void ContinuousSlider::updateDownValueFromPos(const QPoint &pos) { } } -void ContinuousSlider::enterEventHook(QEvent *e) { +void ContinuousSlider::enterEventHook(QEnterEvent *e) { setOver(true); } diff --git a/Telegram/SourceFiles/ui/widgets/continuous_sliders.h b/Telegram/SourceFiles/ui/widgets/continuous_sliders.h index 8b03e4a8e..77a0efd03 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_sliders.h +++ b/Telegram/SourceFiles/ui/widgets/continuous_sliders.h @@ -59,7 +59,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void wheelEvent(QWheelEvent *e) override; - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; float64 fadeOpacity() const { diff --git a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp index ccc7559e8..4fdad987c 100644 --- a/Telegram/SourceFiles/ui/widgets/separate_panel.cpp +++ b/Telegram/SourceFiles/ui/widgets/separate_panel.cpp @@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include #include -#include namespace Ui { diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 66f5e3130..27c249b39 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -36,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_widgets.h" #include "styles/style_window.h" -#include #include #include #include @@ -655,7 +654,7 @@ void MainWindow::updateUnreadCounter() { } QRect MainWindow::computeDesktopRect() const { - return QApplication::desktop()->availableGeometry(this); + return (screen() ? screen() : QApplication::primaryScreen())->availableGeometry(); } void MainWindow::savePosition(Qt::WindowState state) { @@ -791,12 +790,12 @@ void MainWindow::showRightColumn(object_ptr widget) { } int MainWindow::maximalExtendBy() const { - auto desktop = QDesktopWidget().availableGeometry(this); + auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry(); return std::max(desktop.width() - body()->width(), 0); } bool MainWindow::canExtendNoMove(int extendBy) const { - auto desktop = QDesktopWidget().availableGeometry(this); + auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry(); auto inner = body()->mapToGlobal(body()->rect()); auto innerRight = (inner.x() + inner.width() + extendBy); auto desktopRight = (desktop.x() + desktop.width()); @@ -804,7 +803,7 @@ bool MainWindow::canExtendNoMove(int extendBy) const { } int MainWindow::tryToExtendWidthBy(int addToWidth) { - auto desktop = QDesktopWidget().availableGeometry(this); + auto desktop = (screen() ? screen() : QApplication::primaryScreen())->availableGeometry(); auto inner = body()->mapToGlobal(body()->rect()); accumulate_min( addToWidth, diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 97b01272e..a97851a1d 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -650,8 +650,8 @@ void Manager::notificationActivated( reply, replyToId, MessageCursor{ - reply.text.size(), - reply.text.size(), + int(reply.text.size()), + int(reply.text.size()), QFIXED_MAX, }, Data::PreviewState::Allowed); diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index bfa2f5e69..8bfda66d2 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -1015,7 +1015,7 @@ bool Notification::unlinkSession(not_null session) { return unlink; } -void Notification::enterEventHook(QEvent *e) { +void Notification::enterEventHook(QEnterEvent *e) { if (!_history) return; manager()->stopAllHiding(); if (!_replyArea && canReply()) { @@ -1096,7 +1096,7 @@ void HideAllButton::stopHiding() { hideStop(); } -void HideAllButton::enterEventHook(QEvent *e) { +void HideAllButton::enterEventHook(QEnterEvent *e) { _mouseOver = true; update(); } diff --git a/Telegram/SourceFiles/window/notifications_manager_default.h b/Telegram/SourceFiles/window/notifications_manager_default.h index 1f45b18b8..9ad491bcc 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.h +++ b/Telegram/SourceFiles/window/notifications_manager_default.h @@ -239,7 +239,7 @@ public: std::optional lastInputTime); protected: - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void paintEvent(QPaintEvent *e) override; void mousePressEvent(QMouseEvent *e) override; @@ -308,7 +308,7 @@ public: void stopHiding(); protected: - void enterEventHook(QEvent *e) override; + void enterEventHook(QEnterEvent *e) override; void leaveEventHook(QEvent *e) override; void mousePressEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp index 08c1a7a68..a1e533d00 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_block.cpp @@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/edit_color_box.h" #include "lang/lang_keys.h" #include "base/call_delayed.h" -#include "base/qt_adapters.h" namespace Window { namespace Theme { @@ -160,7 +159,7 @@ void EditorBlock::Row::fillSearchIndex() { + ' ' + _valueString; const auto words = toIndex.toLower().split( SearchSplitter, - base::QStringSkipEmptyParts); + Qt::SkipEmptyParts); for (const auto &word : words) { _searchWords.emplace(word); _searchStartChars.emplace(word[0]); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index e98e8b4fe..fb3faa80c 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -64,7 +64,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_boxes.h" #include "styles/style_window.h" // st::windowMinWidth -#include +#include namespace Window { namespace { diff --git a/Telegram/cmake/lib_stripe.cmake b/Telegram/cmake/lib_stripe.cmake index 8581b5a27..b57b15f6a 100644 --- a/Telegram/cmake/lib_stripe.cmake +++ b/Telegram/cmake/lib_stripe.cmake @@ -54,6 +54,7 @@ PUBLIC target_link_libraries(lib_stripe PUBLIC + desktop-app::lib_base desktop-app::lib_crl desktop-app::external_qt ) diff --git a/Telegram/codegen b/Telegram/codegen index 7567b0349..83aee6211 160000 --- a/Telegram/codegen +++ b/Telegram/codegen @@ -1 +1 @@ -Subproject commit 7567b0349aedafadda5282705ede280e544a560a +Subproject commit 83aee6211bfe016dc20c8dd9616b1456a9f20c5e diff --git a/Telegram/lib_base b/Telegram/lib_base index e4b41e940..f89fa2087 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit e4b41e9409def2f65a021571e67e8ec3ec34f90e +Subproject commit f89fa20871a093188795c005447837449c487d50 diff --git a/Telegram/lib_lottie b/Telegram/lib_lottie index 33427eb49..c75d91f75 160000 --- a/Telegram/lib_lottie +++ b/Telegram/lib_lottie @@ -1 +1 @@ -Subproject commit 33427eb49c0b9a22651956df3290ec06d436742d +Subproject commit c75d91f75ef87077f07ea6f7087343274b3eb5ff diff --git a/Telegram/lib_spellcheck b/Telegram/lib_spellcheck index 212d660cb..7eb030da7 160000 --- a/Telegram/lib_spellcheck +++ b/Telegram/lib_spellcheck @@ -1 +1 @@ -Subproject commit 212d660cbbb49592103de7a98fcb1c0f16efc36b +Subproject commit 7eb030da7e681c56ce2619c13840b9f8f4adae0d diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 165147063..87b121069 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 165147063811463505e0928160392488782b5201 +Subproject commit 87b121069f9027a014b499e01b71ddd3180d4f94 diff --git a/Telegram/lib_waylandshells b/Telegram/lib_waylandshells index 59b0ee55a..c2a17c511 160000 --- a/Telegram/lib_waylandshells +++ b/Telegram/lib_waylandshells @@ -1 +1 @@ -Subproject commit 59b0ee55a68976d27f1bf7cec0e11d5939e185e7 +Subproject commit c2a17c51104a49e635152283e2e1757a0872d9e7 diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index 861948683..9d617f174 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit 86194868334e3b51bc6300176d935c2beb84e37d +Subproject commit 9d617f17463d07ff45515800c8fd865939144413 diff --git a/cmake b/cmake index 13575af1f..8540bd0b6 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 13575af1f3b4bca559a1f57f89197dcd4d07d882 +Subproject commit 8540bd0b6007648792e700719b291f83fc75d9da