From a631a280929a4bc25e54b20516602910df4c16cf Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 7 May 2021 17:33:53 +0300 Subject: [PATCH] Removed App::pixmapFromImageInPlace. --- Telegram/SourceFiles/app.cpp | 4 ---- Telegram/SourceFiles/app.h | 1 - Telegram/SourceFiles/boxes/background_box.cpp | 3 +-- .../boxes/background_preview_box.cpp | 5 ++--- .../SourceFiles/boxes/edit_caption_box.cpp | 8 +++---- Telegram/SourceFiles/boxes/edit_color_box.cpp | 7 +++--- .../chat_helpers/emoji_sets_manager.cpp | 4 ++-- Telegram/SourceFiles/data/data_peer.cpp | 6 ++--- .../SourceFiles/dialogs/dialogs_layout.cpp | 12 +++++++--- .../SourceFiles/dialogs/dialogs_widget.cpp | 3 ++- Telegram/SourceFiles/editor/editor_paint.cpp | 4 ++-- .../editor/scene/scene_item_sticker.cpp | 4 ++-- .../view/history_view_service_message.cpp | 4 ++-- .../media/history_view_theme_document.cpp | 4 ++-- Telegram/SourceFiles/intro/intro_step.cpp | 4 ++-- Telegram/SourceFiles/mainwidget.cpp | 11 +++++++--- Telegram/SourceFiles/mainwindow.cpp | 7 ++++-- .../media/player/media_player_float.cpp | 4 ++-- .../media/view/media_view_group_thumbs.cpp | 4 ++-- .../SourceFiles/overview/overview_layout.cpp | 6 ++--- .../platform/linux/main_window_linux.cpp | 5 ++--- .../platform/mac/main_window_mac.mm | 22 ++++++++++++++----- .../platform/win/file_utilities_win.cpp | 13 ++++++++--- .../platform/win/main_window_win.cpp | 22 ++++++++++++------- .../SourceFiles/settings/settings_chat.cpp | 3 ++- .../settings/settings_notifications.cpp | 8 +++---- .../SourceFiles/ui/effects/round_checkbox.cpp | 19 ++++++++-------- Telegram/SourceFiles/ui/empty_userpic.cpp | 6 ++--- Telegram/SourceFiles/ui/image/image.cpp | 21 +++++++++++++----- Telegram/SourceFiles/ui/special_buttons.cpp | 5 ++--- .../SourceFiles/ui/widgets/multi_select.cpp | 4 ++-- Telegram/SourceFiles/window/main_window.cpp | 2 +- .../window/notifications_manager_default.cpp | 14 +++++++----- .../window/themes/window_theme.cpp | 5 +++-- .../window/themes/window_theme_editor_box.cpp | 3 ++- .../window/window_connecting_widget.cpp | 3 +-- 36 files changed, 152 insertions(+), 108 deletions(-) diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 8c244d6fa..f495c327b 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -282,8 +282,4 @@ namespace App { return result; } - QPixmap pixmapFromImageInPlace(QImage &&image) { - return QPixmap::fromImage(std::move(image), Qt::ColorOnly); - } - } diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index 5d12e4665..9b82f25aa 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -45,6 +45,5 @@ namespace App { constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr); QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0); - QPixmap pixmapFromImageInPlace(QImage &&image); }; diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 6c8c7946a..965840acc 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/background_preview_box.h" #include "boxes/confirm_box.h" #include "window/window_session_controller.h" -#include "app.h" #include "styles/style_overview.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -337,7 +336,7 @@ void BackgroundBox::Inner::validatePaperThumbnail( Data::PatternColor(color), paper.data.patternIntensity()); } - paper.thumbnail = App::pixmapFromImageInPlace(TakeMiddleSample( + paper.thumbnail = Ui::PixmapFromImage(TakeMiddleSample( original, st::backgroundSize)); paper.thumbnail.setDevicePixelRatio(cRetinaFactor()); diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index d5ddf7332..4f78d2ebb 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/confirm_box.h" #include "boxes/background_preview_box.h" #include "window/window_session_controller.h" -#include "app.h" #include "styles/style_chat.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -688,8 +687,8 @@ void BackgroundPreviewBox::setScaledFromImage( if (!_full.isNull()) { startFadeInFrom(std::move(_scaled)); } - _scaled = App::pixmapFromImageInPlace(std::move(image)); - _blurred = App::pixmapFromImageInPlace(std::move(blurred)); + _scaled = Ui::PixmapFromImage(std::move(image)); + _blurred = Ui::PixmapFromImage(std::move(blurred)); if (_blur && (!_paper.document() || !_full.isNull())) { _blur->setDisabled(false); } diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 61ba94cf4..deaf91df4 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -57,10 +57,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/cached_round_corners.h" #include "ui/abstract_button.h" +#include "ui/ui_utility.h" #include "window/window_session_controller.h" #include "confirm_box.h" #include "apiwrap.h" -#include "app.h" // App::pixmapFromImageInPlace. #include "facades.h" // App::LambdaDelayed. #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -209,7 +209,7 @@ EditCaptionBox::EditCaptionBox( | Images::Option::RoundedTopRight | Images::Option::RoundedBottomLeft | Images::Option::RoundedBottomRight; - _thumb = App::pixmapFromImageInPlace(Images::prepare( + _thumb = Ui::PixmapFromImage(Images::prepare( image->original(), _thumbw * cIntRetinaFactor(), 0, @@ -339,7 +339,7 @@ EditCaptionBox::EditCaptionBox( const auto prepareBasicThumb = _refreshThumbnail; const auto scaleThumbDown = [=] { - _thumb = App::pixmapFromImageInPlace(_thumb.toImage().scaled( + _thumb = Ui::PixmapFromImage(_thumb.toImage().scaled( _thumbw * cIntRetinaFactor(), _thumbh * cIntRetinaFactor(), Qt::KeepAspectRatio, @@ -661,7 +661,7 @@ void EditCaptionBox::updateEditPreview() { _photoEditorButton->setVisible(_photo); if (!_doc) { - _thumb = App::pixmapFromImageInPlace( + _thumb = Ui::PixmapFromImage( file->preview.scaled( st::sendMediaPreviewSize * cIntRetinaFactor(), (st::confirmMaxHeight - (showCheckbox diff --git a/Telegram/SourceFiles/boxes/edit_color_box.cpp b/Telegram/SourceFiles/boxes/edit_color_box.cpp index 3c78af799..cb87b2704 100644 --- a/Telegram/SourceFiles/boxes/edit_color_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_color_box.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/ui_utility.h" #include "base/platform/base_platform_info.h" -#include "app.h" #include "styles/style_boxes.h" #include "styles/style_media_view.h" @@ -423,7 +422,7 @@ void EditColorBox::Slider::generatePixmap() { if (!isHorizontal()) { image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); } - _pixmap = App::pixmapFromImageInPlace(std::move(image)); + _pixmap = Ui::PixmapFromImage(std::move(image)); } else if (_type == Type::Opacity) { auto color = anim::shifted(QColor(255, 255, 255, 255)); auto transparent = anim::shifted(QColor(255, 255, 255, 0)); @@ -459,7 +458,7 @@ void EditColorBox::Slider::generatePixmap() { if (!isHorizontal()) { image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0)); } - _pixmap = App::pixmapFromImageInPlace(std::move(image)); + _pixmap = Ui::PixmapFromImage(std::move(image)); } } @@ -530,7 +529,7 @@ void EditColorBox::Slider::setLightnessLimits(int min, int max) { } void EditColorBox::Slider::updatePixmapFromMask() { - _pixmap = App::pixmapFromImageInPlace(style::colorizeImage(_mask, _color)); + _pixmap = Ui::PixmapFromImage(style::colorizeImage(_mask, _color)); } void EditColorBox::Slider::updateCurrentPoint(QPoint localPosition) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp index ddd25a5d7..3cfb623ca 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_sets_manager.cpp @@ -15,10 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/animations.h" #include "ui/effects/radial_animation.h" #include "ui/emoji_config.h" +#include "ui/ui_utility.h" #include "core/application.h" #include "main/main_account.h" #include "mainwidget.h" -#include "app.h" #include "storage/storage_cloud_blob.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" @@ -456,7 +456,7 @@ void Row::setupPreview(const Set &set) { const auto full = original.height(); auto &&preview = ranges::views::zip(_preview, ranges::views::ints(0, int(_preview.size()))); for (auto &&[pixmap, index] : preview) { - pixmap = App::pixmapFromImageInPlace(original.copy( + pixmap = Ui::PixmapFromImage(original.copy( { full * index, 0, full, full } ).scaledToWidth(size, Qt::SmoothTransformation)); pixmap.setDevicePixelRatio(cRetinaFactor()); diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 06ca47c95..3fb9fdaa6 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/empty_userpic.h" #include "ui/text/text_options.h" #include "ui/toasts/common_toasts.h" +#include "ui/ui_utility.h" #include "history/history.h" #include "history/view/history_view_element.h" #include "history/history_item.h" @@ -41,7 +42,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_facade.h" #include "storage/storage_shared_media.h" #include "facades.h" // Ui::showPeerProfile -#include "app.h" namespace { @@ -417,7 +417,7 @@ QPixmap PeerData::genUserpic( Painter p(&result); paintUserpic(p, view, 0, 0, size); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } QPixmap PeerData::genUserpicRounded( @@ -433,7 +433,7 @@ QPixmap PeerData::genUserpicRounded( Painter p(&result); paintUserpicRounded(p, view, 0, 0, size); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } Data::FileOrigin PeerData::userpicOrigin() const { diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index 7d4952f80..0f6da8538 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/empty_userpic.h" #include "ui/text/text_options.h" #include "ui/unread_badge.h" +#include "ui/ui_utility.h" #include "lang/lang_keys.h" #include "support/support_helper.h" #include "main/main_session.h" @@ -29,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_folder.h" #include "data/data_peer_values.h" -#include "app.h" namespace Dialogs { namespace Layout { @@ -601,8 +601,14 @@ void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) if (badgeData->left[index].isNull()) { int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor(); createCircleMask(badgeData, size); - badgeData->left[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg)); - badgeData->right[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, imgsize - imgsizehalf, bg)); + badgeData->left[index] = Ui::PixmapFromImage( + colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg)); + badgeData->right[index] = Ui::PixmapFromImage(colorizeCircleHalf( + badgeData, + imgsize, + imgsizehalf, + imgsize - imgsizehalf, + bg)); } int bar = rect.width() - 2 * sizehalf; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index bb62f9df8..93502d652 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/wrap/fade_wrap.h" #include "ui/effects/radial_animation.h" +#include "ui/ui_utility.h" #include "lang/lang_keys.h" #include "mainwindow.h" #include "mainwidget.h" @@ -651,7 +652,7 @@ void Widget::startWidthAnimation() { QPainter p(&image); Ui::RenderWidget(p, _scroll); } - _widthAnimationCache = App::pixmapFromImageInPlace(std::move(image)); + _widthAnimationCache = Ui::PixmapFromImage(std::move(image)); _scroll->setGeometry(scrollGeometry); _scroll->hide(); } diff --git a/Telegram/SourceFiles/editor/editor_paint.cpp b/Telegram/SourceFiles/editor/editor_paint.cpp index 490275868..ddda079fe 100644 --- a/Telegram/SourceFiles/editor/editor_paint.cpp +++ b/Telegram/SourceFiles/editor/editor_paint.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "editor/editor_paint.h" -#include "app.h" #include "boxes/confirm_box.h" #include "editor/controllers/controllers.h" #include "editor/scene/scene.h" @@ -18,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lottie/lottie_single_player.h" #include "storage/storage_media_prepare.h" #include "ui/chat/attach/attach_prepare.h" +#include "ui/ui_utility.h" #include #include @@ -279,7 +279,7 @@ void Paint::handleMimeData(const QMimeData *data) { } const auto item = std::make_shared( - App::pixmapFromImageInPlace(std::move(image)), + Ui::PixmapFromImage(std::move(image)), _transform.zoom.value(), _lastZ, size, diff --git a/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp b/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp index 34a47bcf9..b758b6bf9 100644 --- a/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp +++ b/Telegram/SourceFiles/editor/scene/scene_item_sticker.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "editor/scene/scene_item_sticker.h" -#include "app.h" #include "chat_helpers/stickers_lottie.h" #include "data/data_document.h" #include "data/data_document_media.h" @@ -15,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lottie/lottie_common.h" #include "lottie/lottie_single_player.h" #include "main/main_session.h" +#include "ui/ui_utility.h" #include "styles/style_editor.h" namespace Editor { @@ -51,7 +51,7 @@ ItemSticker::ItemSticker( Lottie::Quality::High); _lottie.player->updates( ) | rpl::start_with_next([=] { - updatePixmap(App::pixmapFromImageInPlace( + updatePixmap(Ui::PixmapFromImage( _lottie.player->frame())); _lottie.player = nullptr; _lottie.lifetime.destroy(); diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index e26930b14..140f75850 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -16,10 +16,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_channel.h" #include "ui/text/text_options.h" +#include "ui/ui_utility.h" #include "mainwidget.h" #include "layout.h" #include "lang/lang_keys.h" -#include "app.h" #include "styles/style_chat.h" namespace HistoryView { @@ -115,7 +115,7 @@ QPixmap circleCorner(int corner, const style::color &bg) { bg, part); result.setDevicePixelRatio(cRetinaFactor()); - currentCorner = App::pixmapFromImageInPlace(std::move(result)); + currentCorner = Ui::PixmapFromImage(std::move(result)); } return currentCorner; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp index 2d97754c3..7887ac025 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_theme_document.cpp @@ -19,9 +19,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/qthelp_url.h" #include "ui/text/format_values.h" #include "ui/cached_round_corners.h" +#include "ui/ui_utility.h" #include "window/themes/window_theme.h" #include "layout.h" // FullSelection -#include "app.h" // App::pixmapFromImageInPlace. #include "styles/style_chat.h" namespace HistoryView { @@ -259,7 +259,7 @@ void ThemeDocument::prepareThumbnailFrom( Data::PatternColor(_background), _intensity); } - _thumbnail = App::pixmapFromImageInPlace(std::move(original)); + _thumbnail = Ui::PixmapFromImage(std::move(original)); _thumbnailGood = good; } diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index 83a62e99d..ff8997d6e 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -26,13 +26,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/wrap/fade_wrap.h" #include "ui/effects/slide_animation.h" +#include "ui/ui_utility.h" #include "data/data_user.h" #include "data/data_auto_download.h" #include "data/data_session.h" #include "data/data_chat_filters.h" #include "window/window_controller.h" #include "window/themes/window_theme.h" -#include "app.h" #include "styles/style_intro.h" #include "styles/style_window.h" @@ -366,7 +366,7 @@ void Step::prepareCoverMask() { } maskInts += maskIntsPerLineAdded; } - _coverMask = App::pixmapFromImageInPlace(std::move(mask)); + _coverMask = Ui::PixmapFromImage(std::move(mask)); } void Step::paintCover(Painter &p, int top) { diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 072df8ecb..0f3f52ea0 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/resize_area.h" #include "ui/text/text_options.h" #include "ui/emoji_config.h" +#include "ui/ui_utility.h" #include "window/section_memento.h" #include "window/section_widget.h" #include "window/window_connecting_widget.h" @@ -108,7 +109,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_facade.h" #include "storage/storage_shared_media.h" #include "storage/storage_user_photos.h" -#include "app.h" #include "facades.h" #include "styles/style_dialogs.h" #include "styles/style_chat.h" @@ -815,7 +815,7 @@ void MainWidget::cacheBackground() { } _cachedX = 0; _cachedY = 0; - _cachedBackground = App::pixmapFromImageInPlace(std::move(result)); + _cachedBackground = Ui::PixmapFromImage(std::move(result)); } else { auto &bg = Window::Theme::Background()->pixmap(); @@ -823,7 +823,12 @@ void MainWidget::cacheBackground() { Window::Theme::ComputeBackgroundRects(_willCacheFor, bg.size(), to, from); _cachedX = to.x(); _cachedY = to.y(); - _cachedBackground = App::pixmapFromImageInPlace(bg.toImage().copy(from).scaled(to.width() * cIntRetinaFactor(), to.height() * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + _cachedBackground = Ui::PixmapFromImage( + bg.toImage().copy(from).scaled( + to.width() * cIntRetinaFactor(), + to.height() * cIntRetinaFactor(), + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation)); _cachedBackground.setDevicePixelRatio(cRetinaFactor()); } _cachedFor = _willCacheFor; diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index e4bc952e3..c12f73702 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -53,7 +53,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_session_controller.h" #include "window/window_media_preview.h" #include "facades.h" -#include "app.h" #include "styles/style_dialogs.h" #include "styles/style_layers.h" #include "styles/style_window.h" @@ -955,7 +954,11 @@ QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style:: placeSmallCounter(img, size, count, bg, QPoint(), fg); } else { QPainter p(&img); - p.drawPixmap(size / 2, size / 2, App::pixmapFromImageInPlace(iconWithCounter(-size / 2, count, bg, fg, false))); + p.drawPixmap( + size / 2, + size / 2, + Ui::PixmapFromImage( + iconWithCounter(-size / 2, count, bg, fg, false))); } return img; } diff --git a/Telegram/SourceFiles/media/player/media_player_float.cpp b/Telegram/SourceFiles/media/player/media_player_float.cpp index fea2b9012..bcd25405b 100644 --- a/Telegram/SourceFiles/media/player/media_player_float.cpp +++ b/Telegram/SourceFiles/media/player/media_player_float.cpp @@ -25,8 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/core_settings.h" #include "main/main_session.h" #include "main/main_account.h" +#include "ui/ui_utility.h" #include "facades.h" -#include "app.h" #include "styles/style_media_player.h" #include "styles/style_chat.h" @@ -173,7 +173,7 @@ void Float::prepareShadow() { auto extend = 2 * st::lineWidth; p.drawEllipse(getInnerRect().marginsAdded(QMargins(extend, extend, extend, extend))); } - _shadow = App::pixmapFromImageInPlace(Images::prepareBlur(std::move(shadow))); + _shadow = Ui::PixmapFromImage(Images::prepareBlur(std::move(shadow))); } QRect Float::getInnerRect() const { diff --git a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp index 9b64a583d..cdc042e7e 100644 --- a/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp +++ b/Telegram/SourceFiles/media/view/media_view_group_thumbs.cpp @@ -20,9 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/view/media/history_view_media.h" #include "ui/image/image.h" +#include "ui/ui_utility.h" #include "main/main_session.h" #include "core/crash_reports.h" -#include "app.h" #include "styles/style_media_view.h" namespace Media { @@ -287,7 +287,7 @@ void GroupThumbs::Thumb::validateImage() { / pixSize.width(); auto original = _image->original(); original.setDevicePixelRatio(cRetinaFactor()); - _full = App::pixmapFromImageInPlace(original.copy( + _full = Ui::PixmapFromImage(original.copy( (originalWidth - takeWidth) / 2, 0, takeWidth, diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index dd7b7fcb2..890bf2928 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -44,7 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/format_values.h" #include "ui/text/text_options.h" #include "ui/cached_round_corners.h" -#include "app.h" +#include "ui/ui_utility.h" namespace Overview { namespace Layout { @@ -368,7 +368,7 @@ void Photo::setPixFrom(not_null image) { delegate()->unregisterHeavyItem(this); } - _pix = App::pixmapFromImageInPlace(std::move(img)); + _pix = Ui::PixmapFromImage(std::move(img)); } void Photo::ensureDataMediaCreated() const { @@ -459,7 +459,7 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const } img.setDevicePixelRatio(cRetinaFactor()); - _pix = App::pixmapFromImageInPlace(std::move(img)); + _pix = Ui::PixmapFromImage(std::move(img)); _pixBlurred = !(thumbnail || good); } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index f44390860..2dcee5bb8 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/event_filter.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/input_fields.h" -#include "app.h" +#include "ui/ui_utility.h" #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include "base/platform/linux/base_linux_glibmm_helper.h" @@ -355,8 +355,7 @@ QIcon TrayIconGen(int counter, bool muted) { } } - result.addPixmap(App::pixmapFromImageInPlace( - std::move(iconImage))); + result.addPixmap(Ui::PixmapFromImage(std::move(iconImage))); } UpdateIconRegenerationNeeded(result, counter, muted, iconThemeName); diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index f89168bcc..a99cdf98c 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -35,8 +35,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "base/platform/mac/base_utilities_mac.h" #include "ui/widgets/input_fields.h" +#include "ui/ui_utility.h" #include "facades.h" -#include "app.h" #include #include @@ -632,10 +632,22 @@ QIcon MainWindow::generateIconForTray(int counter, bool muted) const { _placeCounter(darkMode, size, counter, bg, muted ? st::trayCounterFgMacInvert : st::trayCounterFg); _placeCounter(lightModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); _placeCounter(darkModeActive, size, counter, st::trayCounterBgMacInvert, st::trayCounterFgMacInvert); - result.addPixmap(App::pixmapFromImageInPlace(std::move(lightMode)), QIcon::Normal, QIcon::Off); - result.addPixmap(App::pixmapFromImageInPlace(std::move(darkMode)), QIcon::Normal, QIcon::On); - result.addPixmap(App::pixmapFromImageInPlace(std::move(lightModeActive)), QIcon::Active, QIcon::Off); - result.addPixmap(App::pixmapFromImageInPlace(std::move(darkModeActive)), QIcon::Active, QIcon::On); + result.addPixmap(Ui::PixmapFromImage( + std::move(lightMode)), + QIcon::Normal, + QIcon::Off); + result.addPixmap(Ui::PixmapFromImage( + std::move(darkMode)), + QIcon::Normal, + QIcon::On); + result.addPixmap(Ui::PixmapFromImage( + std::move(lightModeActive)), + QIcon::Active, + QIcon::Off); + result.addPixmap(Ui::PixmapFromImage( + std::move(darkModeActive)), + QIcon::Active, + QIcon::On); return result; } diff --git a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp index b84359983..ee874015c 100644 --- a/Telegram/SourceFiles/platform/win/file_utilities_win.cpp +++ b/Telegram/SourceFiles/platform/win/file_utilities_win.cpp @@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/application.h" #include "core/crash_reports.h" #include "window/window_controller.h" -#include "app.h" +#include "ui/ui_utility.h" #include #include @@ -90,7 +90,14 @@ HBITMAP IconToBitmap(LPWSTR icon, int iconindex) { if (!iconindex) { // try to read image QImage img(QString::fromWCharArray(icon)); if (!img.isNull()) { - return qt_pixmapToWinHBITMAP(App::pixmapFromImageInPlace(img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)), /* HBitmapAlpha */ 2); + return qt_pixmapToWinHBITMAP( + Ui::PixmapFromImage( + img.scaled( + w, + h, + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation)), + /* HBitmapAlpha */ 2); } } return 0; @@ -431,4 +438,4 @@ bool Get( } } // namespace FileDialog -} // namespace Platform \ No newline at end of file +} // namespace Platform diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 66e3e0a2c..c3cac0b2e 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -20,9 +20,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "storage/localstorage.h" #include "ui/widgets/popup_menu.h" +#include "ui/ui_utility.h" #include "window/themes/window_theme.h" #include "history/history.h" -#include "app.h" #include #include @@ -241,7 +241,7 @@ void MainWindow::psSetupTrayIcon() { if (!trayIcon) { trayIcon = new QSystemTrayIcon(this); - auto icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin())); + auto icon = QIcon(Ui::PixmapFromImage(Core::App().logoNoMargin())); trayIcon->setIcon(icon); connect( @@ -369,13 +369,17 @@ void MainWindow::updateIconCounters() { auto &bg = (muted ? st::trayCounterBgMute : st::trayCounterBg); auto &fg = st::trayCounterFg; - auto iconSmallPixmap16 = App::pixmapFromImageInPlace(iconWithCounter(16, counter, bg, fg, true)); - auto iconSmallPixmap32 = App::pixmapFromImageInPlace(iconWithCounter(32, counter, bg, fg, true)); + auto iconSmallPixmap16 = Ui::PixmapFromImage( + iconWithCounter(16, counter, bg, fg, true)); + auto iconSmallPixmap32 = Ui::PixmapFromImage( + iconWithCounter(32, counter, bg, fg, true)); QIcon iconSmall, iconBig; iconSmall.addPixmap(iconSmallPixmap16); iconSmall.addPixmap(iconSmallPixmap32); - iconBig.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(32, taskbarList.Get() ? 0 : counter, bg, fg, false))); - iconBig.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(64, taskbarList.Get() ? 0 : counter, bg, fg, false))); + iconBig.addPixmap(Ui::PixmapFromImage( + iconWithCounter(32, taskbarList.Get() ? 0 : counter, bg, fg, false))); + iconBig.addPixmap(Ui::PixmapFromImage( + iconWithCounter(64, taskbarList.Get() ? 0 : counter, bg, fg, false))); if (trayIcon) { // Force Qt to use right icon size, not the larger one. QIcon forTrayIcon; @@ -391,8 +395,10 @@ void MainWindow::updateIconCounters() { if (taskbarList.Get()) { if (counter > 0) { QIcon iconOverlay; - iconOverlay.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(-16, counter, bg, fg, false))); - iconOverlay.addPixmap(App::pixmapFromImageInPlace(iconWithCounter(-32, counter, bg, fg, false))); + iconOverlay.addPixmap(Ui::PixmapFromImage( + iconWithCounter(-16, counter, bg, fg, false))); + iconOverlay.addPixmap(Ui::PixmapFromImage( + iconWithCounter(-32, counter, bg, fg, false))); ps_iconOverlay = createHIconFromQIcon(iconOverlay, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); } auto description = (counter > 0) ? tr::lng_unread_bar(tr::now, lt_count, counter) : QString(); diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 8550d3240..bbedcd3fd 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -28,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/radial_animation.h" #include "ui/toast/toast.h" #include "ui/image/image.h" +#include "ui/ui_utility.h" #include "lang/lang_keys.h" #include "export/export_manager.h" #include "window/themes/window_theme.h" @@ -590,7 +591,7 @@ void BackgroundRow::updateImage() { } } Images::prepareRound(back, ImageRoundRadius::Small); - _background = App::pixmapFromImageInPlace(std::move(back)); + _background = Ui::PixmapFromImage(std::move(back)); _background.setDevicePixelRatio(cRetinaFactor()); rtlupdate(radialRect()); diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index a95ef5571..1cdc3f095 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/checkbox.h" #include "ui/widgets/buttons.h" #include "ui/widgets/discrete_sliders.h" +#include "ui/ui_utility.h" #include "lang/lang_keys.h" #include "window/notifications_manager.h" #include "window/window_session_controller.h" @@ -27,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_domain.h" #include "apiwrap.h" #include "facades.h" -#include "app.h" #include "styles/style_settings.h" #include "styles/style_boxes.h" #include "styles/style_window.h" @@ -251,13 +251,13 @@ void NotificationsCount::prepareNotificationSampleSmall() { auto closeLeft = width - 2 * padding; p.fillRect(style::rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg); } - _notificationSampleSmall = App::pixmapFromImageInPlace(std::move(sampleImage)); + _notificationSampleSmall = Ui::PixmapFromImage(std::move(sampleImage)); _notificationSampleSmall.setDevicePixelRatio(cRetinaFactor()); } void NotificationsCount::prepareNotificationSampleUserpic() { if (_notificationSampleUserpic.isNull()) { - _notificationSampleUserpic = App::pixmapFromImageInPlace( + _notificationSampleUserpic = Ui::PixmapFromImage( Core::App().logoNoMargin().scaled( st::notifyPhotoSize * cIntRetinaFactor(), st::notifyPhotoSize * cIntRetinaFactor(), @@ -303,7 +303,7 @@ void NotificationsCount::prepareNotificationSampleLarge() { st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w); } - _notificationSampleLarge = App::pixmapFromImageInPlace(std::move(sampleImage)); + _notificationSampleLarge = Ui::PixmapFromImage(std::move(sampleImage)); } void NotificationsCount::removeSample(SampleWidget *widget) { diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp index 1ef1ee37e..87b4233c5 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp @@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/themes/window_theme.h" #include "ui/rp_widget.h" #include "ui/ui_utility.h" -#include "app.h" #include @@ -79,7 +78,7 @@ QPixmap PrepareOuterWide(const style::RoundCheckbox *st) { size + 2. * half, size + 2. * half)); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } QPixmap PrepareInner(const style::RoundCheckbox *st, bool displayInactive) { @@ -102,7 +101,7 @@ QPixmap PrepareInner(const style::RoundCheckbox *st, bool displayInactive) { size - (displayInactive ? 0. : 2. * half), size - (displayInactive ? 0. : 2. * half))); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } QPixmap PrepareCheck(const style::RoundCheckbox *st) { @@ -116,7 +115,7 @@ QPixmap PrepareCheck(const style::RoundCheckbox *st) { Painter p(&result); st->check.paint(p, 0, 0, size); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } QRect WideDestRect( @@ -238,7 +237,7 @@ QPixmap CheckCaches::paintFrame( remove, remove)); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } CheckCaches *FrameCaches() { @@ -286,8 +285,8 @@ void prepareCheckCaches(const style::RoundCheckbox *st, bool displayInactive, QP auto ellipse = QRect((wideSize - size) / 2, (wideSize - size) / 2, size, size); st->check.paint(p, ellipse.topLeft(), wideSize); } - checkBgCache = App::pixmapFromImageInPlace(std::move(cache)); - checkFullCache = App::pixmapFromImageInPlace(std::move(cacheIcon)); + checkBgCache = Ui::PixmapFromImage(std::move(cache)); + checkFullCache = Ui::PixmapFromImage(std::move(cacheIcon)); } } // namespace @@ -379,7 +378,7 @@ void RoundCheckbox::prepareInactiveCache() { p.setBrush(_st.bgInactive); p.drawEllipse(ellipse); } - _inactiveCacheBg = App::pixmapFromImageInPlace(std::move(cacheBg)); + _inactiveCacheBg = Ui::PixmapFromImage(std::move(cacheBg)); { Painter p(&cacheFg); @@ -391,7 +390,7 @@ void RoundCheckbox::prepareInactiveCache() { p.setBrush(Qt::NoBrush); p.drawEllipse(ellipse); } - _inactiveCacheFg = App::pixmapFromImageInPlace(std::move(cacheFg)); + _inactiveCacheFg = Ui::PixmapFromImage(std::move(cacheFg)); } RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, Fn updateCallback, PaintRoundImage &&paintRoundImage) @@ -475,7 +474,7 @@ void RoundImageCheckbox::prepareWideCache() { p.setCompositionMode(QPainter::CompositionMode_SourceOver); _paintRoundImage(p, (wideSize - size) / 2, (wideSize - size) / 2, wideSize, size); } - _wideCache = App::pixmapFromImageInPlace(std::move(cache)); + _wideCache = Ui::PixmapFromImage(std::move(cache)); } } diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index bdf4551d4..ed3190136 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_peer.h" #include "ui/emoji_config.h" #include "ui/effects/animation_value.h" -#include "app.h" +#include "ui/ui_utility.h" #include "styles/style_chat.h" #include "styles/style_dialogs.h" #include "styles/style_widgets.h" // style::IconButton @@ -171,7 +171,7 @@ template Painter p(&result); callback(p); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } } // namespace @@ -396,7 +396,7 @@ QPixmap EmptyUserpic::generate(int size) { Painter p(&result); paint(p, 0, 0, size, size); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } void EmptyUserpic::fillString(const QString &name) { diff --git a/Telegram/SourceFiles/ui/image/image.cpp b/Telegram/SourceFiles/ui/image/image.cpp index 467425e8b..342a12f88 100644 --- a/Telegram/SourceFiles/ui/image/image.cpp +++ b/Telegram/SourceFiles/ui/image/image.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/cache/storage_cache_database.h" #include "data/data_session.h" #include "main/main_session.h" +#include "ui/ui_utility.h" #include "app.h" using namespace Images; @@ -622,10 +623,11 @@ QPixmap Image::pixNoCache( Assert(colored != nullptr); result = prepareColored(*colored, std::move(result)); } - return App::pixmapFromImageInPlace(std::move(result)); + return Ui::PixmapFromImage(std::move(result)); } - return App::pixmapFromImageInPlace(prepare(_data, w, h, options, outerw, outerh, colored)); + return Ui::PixmapFromImage( + prepare(_data, w, h, options, outerw, outerh, colored)); } QPixmap Image::pixColoredNoCache( @@ -639,12 +641,19 @@ QPixmap Image::pixColoredNoCache( auto img = _data; if (w <= 0 || !width() || !height() || (w == width() && (h <= 0 || h == height()))) { - return App::pixmapFromImageInPlace(prepareColored(add, std::move(img))); + return Ui::PixmapFromImage(prepareColored(add, std::move(img))); } + const auto transformation = smooth + ? Qt::SmoothTransformation + : Qt::FastTransformation; if (h <= 0) { - return App::pixmapFromImageInPlace(prepareColored(add, img.scaledToWidth(w, smooth ? Qt::SmoothTransformation : Qt::FastTransformation))); + return Ui::PixmapFromImage( + prepareColored(add, img.scaledToWidth(w, transformation))); } - return App::pixmapFromImageInPlace(prepareColored(add, img.scaled(w, h, Qt::IgnoreAspectRatio, smooth ? Qt::SmoothTransformation : Qt::FastTransformation))); + return Ui::PixmapFromImage( + prepareColored( + add, + img.scaled(w, h, Qt::IgnoreAspectRatio, transformation))); } QPixmap Image::pixBlurredColoredNoCache( @@ -662,5 +671,5 @@ QPixmap Image::pixBlurredColoredNoCache( img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } - return App::pixmapFromImageInPlace(prepareColored(add, img)); + return Ui::PixmapFromImage(prepareColored(add, img)); } diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index f9b06ec7f..d6e78f62b 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "apiwrap.h" #include "mainwidget.h" #include "facades.h" -#include "app.h" namespace Ui { namespace { @@ -66,7 +65,7 @@ QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) { Painter p(&image); paintCallback(p); } - return App::pixmapFromImageInPlace(std::move(image)); + return Ui::PixmapFromImage(std::move(image)); }; } // namespace @@ -698,7 +697,7 @@ void UserpicButton::setImage(QImage &&image) { Qt::IgnoreAspectRatio, Qt::SmoothTransformation); Images::prepareCircle(small); - _userpic = App::pixmapFromImageInPlace(std::move(small)); + _userpic = Ui::PixmapFromImage(std::move(small)); _userpic.setDevicePixelRatio(cRetinaFactor()); _userpicCustom = _userpicHasImage = true; _result = std::move(image); diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index cef0403f4..f16ce29c7 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -13,8 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/scroll_area.h" #include "ui/effects/cross_animation.h" #include "ui/text/text_options.h" +#include "ui/ui_utility.h" #include "lang/lang_keys.h" -#include "app.h" namespace Ui { namespace { @@ -213,7 +213,7 @@ void MultiSelect::Item::prepareCache() { Painter p(&data); paintOnce(p, _width * (kWideScale - 1) / 2, _st.height * (kWideScale - 1) / 2, cacheWidth); } - _cache = App::pixmapFromImageInPlace(std::move(data)); + _cache = Ui::PixmapFromImage(std::move(data)); } void MultiSelect::Item::setVisibleAnimated(bool visible) { diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 3eb66ef25..41359366d 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -113,7 +113,7 @@ QIcon CreateOfficialIcon(Main::Session *session) { if (session && session->supportMode()) { ConvertIconToBlack(image); } - return QIcon(App::pixmapFromImageInPlace(std::move(image))); + return QIcon(Ui::PixmapFromImage(std::move(image))); } QIcon CreateIcon(Main::Session *session) { diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index e042cd5e4..5335ab677 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/base_platform_last_input.h" #include "base/call_delayed.h" #include "facades.h" -#include "app.h" #include "styles/style_dialogs.h" #include "styles/style_layers.h" #include "styles/style_window.h" @@ -92,7 +91,12 @@ Manager::QueuedNotification::QueuedNotification( QPixmap Manager::hiddenUserpicPlaceholder() const { if (_hiddenUserpicPlaceholder.isNull()) { - _hiddenUserpicPlaceholder = App::pixmapFromImageInPlace(Core::App().logoNoMargin().scaled(st::notifyPhotoSize, st::notifyPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + _hiddenUserpicPlaceholder = Ui::PixmapFromImage( + Core::App().logoNoMargin().scaled( + st::notifyPhotoSize, + st::notifyPhotoSize, + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation)); _hiddenUserpicPlaceholder.setDevicePixelRatio(cRetinaFactor()); } return _hiddenUserpicPlaceholder; @@ -682,7 +686,7 @@ void Notification::prepareActionsCache() { p.fillRect(style::rtlrect(fadeWidth, 0, actionsCacheWidth - fadeWidth, actionsCacheHeight, actionsCacheWidth), st::notificationBg); p.drawPixmapRight(replyRight, _reply->y() - actionsTop, actionsCacheWidth, replyCache); } - _buttonsCache = App::pixmapFromImageInPlace(std::move(actionsCacheImg)); + _buttonsCache = Ui::PixmapFromImage(std::move(actionsCacheImg)); } bool Notification::checkLastInput( @@ -861,7 +865,7 @@ void Notification::updateNotifyDisplay() { titleText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); } - _cache = App::pixmapFromImageInPlace(std::move(img)); + _cache = Ui::PixmapFromImage(std::move(img)); if (!canReply()) { toggleActionButtons(false); } @@ -889,7 +893,7 @@ void Notification::updatePeerPhoto() { width(), st::notifyPhotoSize); } - _cache = App::pixmapFromImageInPlace(std::move(img)); + _cache = Ui::PixmapFromImage(std::move(img)); _userpicView = nullptr; update(); } diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index 2aedf7902..0675156df 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_account.h" // Account::local. #include "main/main_domain.h" // Domain::activeSessionValue. #include "ui/image/image.h" +#include "ui/ui_utility.h" #include "boxes/confirm_box.h" #include "boxes/background_box.h" #include "core/application.h" @@ -754,10 +755,10 @@ void ChatBackground::preparePixmaps(QImage image) { imageForTiledBytes += imageForTiled.bytesPerLine() - (repeatTimesX * bytesInLine); } } - _pixmapForTiled = App::pixmapFromImageInPlace(std::move(imageForTiled)); + _pixmapForTiled = Ui::PixmapFromImage(std::move(imageForTiled)); } _isMonoColorImage = CalculateIsMonoColorImage(image); - _pixmap = App::pixmapFromImageInPlace(std::move(image)); + _pixmap = Ui::PixmapFromImage(std::move(image)); if (!isSmallForTiled) { _pixmapForTiled = _pixmap; } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index bf927f7a0..c713a7598 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/text/format_values.h" #include "ui/special_fields.h" +#include "ui/ui_utility.h" #include "main/main_account.h" #include "main/main_session.h" #include "storage/localstorage.h" @@ -169,7 +170,7 @@ void BackgroundSelector::updateThumbnail() { p.drawImage(QRect(0, 0, size, size), pix, QRect(sx, sy, s, s)); } Images::prepareRound(back, ImageRoundRadius::Small); - _thumbnail = App::pixmapFromImageInPlace(std::move(back)); + _thumbnail = Ui::PixmapFromImage(std::move(back)); _thumbnail.setDevicePixelRatio(cRetinaFactor()); update(); } diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index f9b77b152..f7c4e3839 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/connection_box.h" #include "boxes/abstract_box.h" #include "lang/lang_keys.h" -#include "app.h" #include "styles/style_window.h" namespace Window { @@ -169,7 +168,7 @@ void ConnectionState::Widget::ProxyIcon::refreshCacheImages() { (height() - icon.height()) / 2, width()); } - return App::pixmapFromImageInPlace(std::move(image)); + return Ui::PixmapFromImage(std::move(image)); }; _cacheOn = prepareCache(st::connectingProxyOn); _cacheOff = prepareCache(st::connectingProxyOff);