2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Use Images::Read instead of App::readImage.

This commit is contained in:
John Preston
2021-08-11 18:40:17 +03:00
parent b150ab8ef5
commit c79cd0b692
56 changed files with 155 additions and 293 deletions

View File

@@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h"
#include "boxes/background_box.h"
#include "core/application.h"
#include "app.h"
#include "styles/style_widgets.h"
#include "styles/style_chat.h"
@@ -323,7 +322,10 @@ bool LoadTheme(
LOG(("Theme Error: bad background image size in the theme file."));
return false;
}
auto background = App::readImage(backgroundContent);
auto background = Images::Read({
.content = backgroundContent,
.forceOpaque = true,
}).image;
if (background.isNull()) {
LOG(("Theme Error: could not read background image in the theme file."));
return false;

View File

@@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/multi_select.h"
#include "ui/widgets/dropdown_menu.h"
#include "ui/toast/toast.h"
#include "ui/image/image_prepare.h"
#include "ui/ui_utility.h"
#include "base/parse_helper.h"
#include "base/zlib_help.h"
@@ -31,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/edit_color_box.h"
#include "lang/lang_keys.h"
#include "facades.h"
#include "app.h"
#include "styles/style_window.h"
#include "styles/style_dialogs.h"
#include "styles/style_layers.h"
@@ -789,7 +789,10 @@ void Editor::importTheme() {
_inner->applyNewPalette(parsed.palette);
_inner->recreateRows();
updateControlsGeometry();
auto image = App::readImage(parsed.background);
auto image = Images::Read({
.content = parsed.background,
.forceOpaque = true,
}).image;
if (!image.isNull() && !image.size().isEmpty()) {
Background()->set(Data::CustomWallPaper(), std::move(image));
Background()->setTile(parsed.tiled);

View File

@@ -40,7 +40,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/file_upload.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "app.h"
#include "styles/style_widgets.h"
#include "styles/style_window.h"
#include "styles/style_settings.h"
@@ -186,15 +185,14 @@ void BackgroundSelector::chooseBackgroundFromFile() {
}
}
if (!content.isEmpty()) {
auto format = QByteArray();
auto image = App::readImage(content, &format);
if (!image.isNull()
&& (format == "jpeg"
|| format == "jpg"
|| format == "png")) {
_background = image;
auto read = Images::Read({ .content = content });
if (!read.image.isNull()
&& (read.format == "jpeg"
|| read.format == "jpg"
|| read.format == "png")) {
_background = std::move(read.image);
_parsed.background = content;
_parsed.isPng = (format == "png");
_parsed.isPng = (read.format == "png");
const auto phrase = _parsed.isPng
? tr::lng_theme_editor_read_from_png
: tr::lng_theme_editor_read_from_jpg;

View File

@@ -33,7 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h"
#include "apiwrap.h" // ApiWrap::acceptTerms.
#include "facades.h"
#include "app.h"
#include "styles/style_layers.h"
#include <QtGui/QWindow>