Remember scroll state between topic openings.

This commit is contained in:
John Preston
2022-11-03 16:29:22 +04:00
parent d7f2385275
commit 0dd45de254
14 changed files with 103 additions and 28 deletions

View File

@@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "editor/editor_crop.h"
#include "styles/style_editor.h"
#include "styles/style_basic.h"
#include "styles/style_dialogs.h"
namespace Editor {
namespace {
@@ -145,6 +147,10 @@ void Crop::setCropPaint(QRectF &&rect) {
_painterPath.addRect(_innerRect);
if (_data.cropType == EditorData::CropType::Ellipse) {
_painterPath.addEllipse(_cropPaint);
} else if (_data.cropType == EditorData::CropType::RoundedRect) {
const auto radius = std::min(_cropPaint.width(), _cropPaint.height())
* st::roundRadiusLarge / float64(st::defaultDialogRow.photoSize);
_painterPath.addRoundedRect(_cropPaint, radius, radius);
} else {
_painterPath.addRect(_cropPaint);
}

View File

@@ -27,6 +27,7 @@ struct EditorData {
enum class CropType {
Rect,
Ellipse,
RoundedRect,
};
CropType cropType = CropType::Rect;

View File

@@ -67,6 +67,7 @@ void OpenWithPreparedFile(
void PrepareProfilePhoto(
not_null<Ui::RpWidget*> parent,
not_null<Window::Controller*> controller,
ImageRoundRadius radius,
Fn<void(QImage &&image)> &&doneCallback,
QImage &&image) {
const auto resizeToMinSize = [=](
@@ -119,7 +120,9 @@ void PrepareProfilePhoto(
PhotoModifications{ .crop = std::move(crop) },
std::move(applyModifications),
EditorData{
.cropType = EditorData::CropType::Ellipse,
.cropType = (radius == ImageRoundRadius::Ellipse
? EditorData::CropType::Ellipse
: EditorData::CropType::RoundedRect),
.keepAspectRatio = true, }),
Ui::LayerOption::KeepOther);
}
@@ -127,6 +130,7 @@ void PrepareProfilePhoto(
void PrepareProfilePhotoFromFile(
not_null<Ui::RpWidget*> parent,
not_null<Window::Controller*> controller,
ImageRoundRadius radius,
Fn<void(QImage &&image)> &&doneCallback) {
const auto callback = [=, done = std::move(doneCallback)](
const FileDialog::OpenResult &result) mutable {
@@ -142,6 +146,7 @@ void PrepareProfilePhotoFromFile(
PrepareProfilePhoto(
parent,
controller,
radius,
std::move(done),
std::move(image));
};

View File

@@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "editor/photo_editor_common.h"
#include "ui/image/image.h"
enum class ImageRoundRadius;
namespace Ui {
struct PreparedFile;
} // namespace Ui
@@ -34,12 +36,14 @@ void OpenWithPreparedFile(
void PrepareProfilePhoto(
not_null<Ui::RpWidget*> parent,
not_null<Window::Controller*> controller,
ImageRoundRadius radius,
Fn<void(QImage &&image)> &&doneCallback,
QImage &&image);
void PrepareProfilePhotoFromFile(
not_null<Ui::RpWidget*> parent,
not_null<Window::Controller*> controller,
ImageRoundRadius radius,
Fn<void(QImage &&image)> &&doneCallback);
class PhotoEditor;