mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Open settings when done changing photo.
This commit is contained in:
parent
48cf0a4382
commit
ae819eb1a6
4 changed files with 25 additions and 17 deletions
|
@ -184,11 +184,12 @@ LayerWidget::LayerWidget(
|
||||||
closeLayer();
|
closeLayer();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
const auto weak = Ui::MakeWeak(_content.get());
|
||||||
_content->doneRequests(
|
_content->doneRequests(
|
||||||
) | rpl::start_with_next([=, done = std::move(doneCallback)](
|
) | rpl::start_with_next([=, done = std::move(doneCallback)](
|
||||||
const PhotoModifications &mods) {
|
const PhotoModifications &mods) {
|
||||||
done(mods);
|
done(mods);
|
||||||
closeLayer();
|
if (weak) closeLayer();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
sizeValue(
|
sizeValue(
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_peer_photo.h"
|
#include "api/api_peer_photo.h"
|
||||||
|
#include "settings/settings_information.h" // UpdatePhotoLocally
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -76,8 +77,10 @@ ClickHandlerPtr UserpicSuggestion::createViewLink() {
|
||||||
const auto original = std::make_shared<QImage>(
|
const auto original = std::make_shared<QImage>(
|
||||||
media->image(Data::PhotoSize::Large)->original());
|
media->image(Data::PhotoSize::Large)->original());
|
||||||
const auto callback = [=](QImage &&image) {
|
const auto callback = [=](QImage &&image) {
|
||||||
|
using namespace Settings;
|
||||||
const auto session = &photo->session();
|
const auto session = &photo->session();
|
||||||
const auto user = session->user();
|
const auto user = session->user();
|
||||||
|
UpdatePhotoLocally(user, image);
|
||||||
auto &peerPhotos = session->api().peerPhoto();
|
auto &peerPhotos = session->api().peerPhoto();
|
||||||
if (original->size() == image.size()
|
if (original->size() == image.size()
|
||||||
&& original->constBits() == image.constBits()) {
|
&& original->constBits() == image.constBits()) {
|
||||||
|
@ -85,6 +88,7 @@ ClickHandlerPtr UserpicSuggestion::createViewLink() {
|
||||||
} else {
|
} else {
|
||||||
peerPhotos.upload(user, std::move(image));
|
peerPhotos.upload(user, std::move(image));
|
||||||
}
|
}
|
||||||
|
controller->showSettings(Information::Id());
|
||||||
};
|
};
|
||||||
Editor::PrepareProfilePhoto(
|
Editor::PrepareProfilePhoto(
|
||||||
controller->content(),
|
controller->content(),
|
||||||
|
|
|
@ -266,20 +266,6 @@ private:
|
||||||
return upload;
|
return upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadPhoto(not_null<UserData*> user, QImage image) {
|
|
||||||
auto bytes = QByteArray();
|
|
||||||
auto buffer = QBuffer(&bytes);
|
|
||||||
image.save(&buffer, "JPG", 87);
|
|
||||||
user->setUserpic(
|
|
||||||
base::RandomValue<PhotoId>(),
|
|
||||||
ImageLocation(
|
|
||||||
{ .data = InMemoryLocation{ .bytes = bytes } },
|
|
||||||
image.width(),
|
|
||||||
image.height()),
|
|
||||||
false);
|
|
||||||
user->session().api().peerPhoto().upload(user, std::move(image));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetupPhoto(
|
void SetupPhoto(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
@ -297,8 +283,10 @@ void SetupPhoto(
|
||||||
|
|
||||||
upload->chosenImages(
|
upload->chosenImages(
|
||||||
) | rpl::start_with_next([=](Ui::UserpicButton::ChosenImage &&chosen) {
|
) | rpl::start_with_next([=](Ui::UserpicButton::ChosenImage &&chosen) {
|
||||||
UploadPhoto(self, chosen.image);
|
auto &image = chosen.image;
|
||||||
photo->changeTo(std::move(chosen.image));
|
UpdatePhotoLocally(self, image);
|
||||||
|
photo->changeTo(base::duplicate(image));
|
||||||
|
self->session().api().peerPhoto().upload(self, std::move(image));
|
||||||
}, upload->lifetime());
|
}, upload->lifetime());
|
||||||
|
|
||||||
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
@ -976,6 +964,19 @@ AccountsEvents SetupAccounts(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image) {
|
||||||
|
auto bytes = QByteArray();
|
||||||
|
auto buffer = QBuffer(&bytes);
|
||||||
|
image.save(&buffer, "JPG", 87);
|
||||||
|
user->setUserpic(
|
||||||
|
base::RandomValue<PhotoId>(),
|
||||||
|
ImageLocation(
|
||||||
|
{ .data = InMemoryLocation{ .bytes = bytes } },
|
||||||
|
image.width(),
|
||||||
|
image.height()),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
namespace Badge {
|
namespace Badge {
|
||||||
|
|
||||||
Dialogs::Ui::UnreadBadgeStyle Style() {
|
Dialogs::Ui::UnreadBadgeStyle Style() {
|
||||||
|
|
|
@ -40,6 +40,8 @@ AccountsEvents SetupAccounts(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController*> controller);
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
|
void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image);
|
||||||
|
|
||||||
namespace Badge {
|
namespace Badge {
|
||||||
|
|
||||||
[[nodiscard]] Dialogs::Ui::UnreadBadgeStyle Style();
|
[[nodiscard]] Dialogs::Ui::UnreadBadgeStyle Style();
|
||||||
|
|
Loading…
Add table
Reference in a new issue