2016-08-19 17:26:31 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-08-19 17:26:31 +00:00
|
|
|
*/
|
2018-09-02 14:23:52 +00:00
|
|
|
#include "old_settings/settings_cover.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_photo.h"
|
2018-01-17 16:21:01 +00:00
|
|
|
#include "data/data_session.h"
|
2016-11-16 10:44:06 +00:00
|
|
|
#include "ui/widgets/labels.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2017-11-13 15:50:10 +00:00
|
|
|
#include "ui/special_buttons.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
#include "observer_peer.h"
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "messenger.h"
|
|
|
|
#include "mainwindow.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
#include "apiwrap.h"
|
2017-08-04 14:54:32 +00:00
|
|
|
#include "auth_session.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
#include "profile/profile_cover_drop_area.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "boxes/photo_crop_box.h"
|
|
|
|
#include "boxes/add_contact_box.h"
|
2018-09-02 14:23:52 +00:00
|
|
|
#include "styles/style_old_settings.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
#include "styles/style_profile.h" // for divider
|
2017-02-28 10:51:00 +00:00
|
|
|
#include "platform/platform_file_utilities.h"
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2018-09-02 14:23:52 +00:00
|
|
|
namespace OldSettings {
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2017-11-13 15:50:10 +00:00
|
|
|
CoverWidget::CoverWidget(QWidget *parent, UserData *self)
|
|
|
|
: BlockWidget(parent, self, QString())
|
2018-09-11 12:50:40 +00:00
|
|
|
, _self(self)
|
2017-11-13 15:50:10 +00:00
|
|
|
, _userpicButton(
|
|
|
|
this,
|
|
|
|
App::wnd()->controller(),
|
|
|
|
_self,
|
|
|
|
Ui::UserpicButton::Role::OpenPhoto,
|
|
|
|
st::settingsPhoto)
|
2016-08-19 17:26:31 +00:00
|
|
|
, _name(this, st::settingsNameLabel)
|
2016-10-31 12:29:26 +00:00
|
|
|
, _editNameInline(this, st::settingsEditButton)
|
2017-05-30 15:21:05 +00:00
|
|
|
, _setPhoto(this, langFactory(lng_settings_upload), st::settingsPrimaryButton)
|
|
|
|
, _editName(this, langFactory(lng_settings_edit), st::settingsSecondaryButton) {
|
2017-07-26 11:53:49 +00:00
|
|
|
if (_self) {
|
|
|
|
_self->updateFull();
|
|
|
|
}
|
2016-08-19 17:26:31 +00:00
|
|
|
setAcceptDrops(true);
|
|
|
|
|
|
|
|
_name->setSelectable(true);
|
|
|
|
_name->setContextCopyText(lang(lng_profile_copy_fullname));
|
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
_setPhoto->setClickedCallback(App::LambdaDelayed(
|
|
|
|
st::settingsPrimaryButton.ripple.hideDuration,
|
|
|
|
this,
|
|
|
|
[this] { chooseNewPhoto(); }));
|
|
|
|
_editName->addClickHandler([this] { editName(); });
|
|
|
|
_editNameInline->addClickHandler([this] { editName(); });
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
auto observeEvents = Notify::PeerUpdate::Flag::NameChanged | Notify::PeerUpdate::Flag::PhotoChanged;
|
2016-09-26 18:33:34 +00:00
|
|
|
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
|
2016-09-26 13:57:08 +00:00
|
|
|
notifyPeerUpdated(update);
|
2016-09-26 18:33:34 +00:00
|
|
|
}));
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
_userpicButton->addClickHandler([this] { showPhoto(); });
|
2016-08-19 17:26:31 +00:00
|
|
|
validatePhoto();
|
|
|
|
|
|
|
|
refreshNameText();
|
2016-12-03 12:10:35 +00:00
|
|
|
|
|
|
|
subscribe(Global::RefConnectionTypeChanged(), [this] { refreshStatusText(); });
|
2016-08-19 17:26:31 +00:00
|
|
|
refreshStatusText();
|
|
|
|
}
|
|
|
|
|
|
|
|
PhotoData *CoverWidget::validatePhoto() const {
|
2017-12-15 16:25:47 +00:00
|
|
|
Expects(_self != nullptr);
|
|
|
|
|
2017-12-05 06:41:43 +00:00
|
|
|
const auto photo = _self->userpicPhotoId()
|
2018-01-17 16:21:01 +00:00
|
|
|
? Auth().data().photo(_self->userpicPhotoId()).get()
|
2017-12-05 06:41:43 +00:00
|
|
|
: nullptr;
|
2016-12-31 13:34:41 +00:00
|
|
|
_userpicButton->setPointerCursor(photo != nullptr && photo->date != 0);
|
2017-12-05 06:41:43 +00:00
|
|
|
if (_self->userpicPhotoUnknown() || (photo && !photo->date)) {
|
2017-08-04 14:54:32 +00:00
|
|
|
Auth().api().requestFullPeer(_self);
|
2016-08-19 17:26:31 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return photo;
|
|
|
|
}
|
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
void CoverWidget::showPhoto() {
|
2017-12-15 16:25:47 +00:00
|
|
|
if (const auto photo = validatePhoto()) {
|
2017-08-08 09:31:48 +00:00
|
|
|
Messenger::Instance().showPhoto(photo, _self);
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
void CoverWidget::cancelPhotoUpload() {
|
2017-02-23 10:59:19 +00:00
|
|
|
refreshStatusText();
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CoverWidget::resizeGetHeight(int newWidth) {
|
|
|
|
int newHeight = 0;
|
|
|
|
|
|
|
|
newHeight += st::settingsMarginTop;
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
auto margins = getMargins();
|
|
|
|
_userpicButton->moveToLeft(
|
|
|
|
margins.left() + contentLeft() + st::settingsPhotoLeft,
|
|
|
|
margins.top() + newHeight,
|
|
|
|
newWidth);
|
2016-08-19 17:26:31 +00:00
|
|
|
|
|
|
|
int infoLeft = _userpicButton->x() + _userpicButton->width();
|
|
|
|
_statusPosition = QPoint(infoLeft + st::settingsStatusLeft, _userpicButton->y() + st::settingsStatusTop);
|
|
|
|
if (_cancelPhotoUpload) {
|
2017-09-13 16:57:44 +00:00
|
|
|
_cancelPhotoUpload->moveToLeft(
|
|
|
|
margins.left()
|
|
|
|
+ _statusPosition.x()
|
|
|
|
+ st::settingsStatusFont->width(_statusText)
|
|
|
|
+ st::settingsStatusFont->spacew,
|
|
|
|
margins.top() + _statusPosition.y(),
|
|
|
|
newWidth);
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
2017-05-30 15:21:05 +00:00
|
|
|
refreshButtonsGeometry(newWidth);
|
2016-08-27 04:49:18 +00:00
|
|
|
refreshNameGeometry(newWidth);
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2017-11-13 15:50:10 +00:00
|
|
|
newHeight += st::settingsPhoto.size.height();
|
2016-08-19 17:26:31 +00:00
|
|
|
newHeight += st::settingsMarginBottom;
|
|
|
|
|
|
|
|
_dividerTop = newHeight;
|
2016-12-02 19:16:35 +00:00
|
|
|
newHeight += st::profileDividerLeft.height();
|
2016-08-19 17:26:31 +00:00
|
|
|
|
|
|
|
newHeight += st::settingsBlocksTop;
|
|
|
|
|
|
|
|
resizeDropArea();
|
|
|
|
return newHeight;
|
|
|
|
}
|
|
|
|
|
2017-05-30 15:21:05 +00:00
|
|
|
void CoverWidget::refreshButtonsGeometry(int newWidth) {
|
2017-09-13 16:57:44 +00:00
|
|
|
auto margins = getMargins();
|
|
|
|
auto buttonLeft = margins.left() + _userpicButton->x() + _userpicButton->width() + st::settingsButtonLeft;
|
|
|
|
_setPhoto->moveToLeft(
|
|
|
|
buttonLeft,
|
|
|
|
margins.top() + _userpicButton->y() + st::settingsButtonTop,
|
|
|
|
newWidth);
|
2017-05-30 15:21:05 +00:00
|
|
|
buttonLeft += _setPhoto->width() + st::settingsButtonSkip;
|
2017-09-13 16:57:44 +00:00
|
|
|
_editName->moveToLeft(
|
|
|
|
buttonLeft,
|
|
|
|
margins.top() + _setPhoto->y(),
|
|
|
|
newWidth);
|
2017-05-30 15:21:05 +00:00
|
|
|
_editNameVisible = (buttonLeft + _editName->width() + st::settingsButtonSkip <= newWidth);
|
|
|
|
_editName->setVisible(_editNameVisible);
|
|
|
|
}
|
|
|
|
|
2016-08-19 17:26:31 +00:00
|
|
|
void CoverWidget::refreshNameGeometry(int newWidth) {
|
2017-09-13 16:57:44 +00:00
|
|
|
auto margins = getMargins();
|
|
|
|
auto infoLeft = _userpicButton->x() + _userpicButton->width();
|
2017-09-20 19:44:22 +00:00
|
|
|
auto nameLeft = infoLeft + st::settingsNameLeft;
|
|
|
|
auto nameTop = _userpicButton->y() + st::settingsNameTop;
|
2017-09-13 16:57:44 +00:00
|
|
|
auto nameWidth = newWidth - infoLeft - st::settingsNameLeft;
|
2016-08-27 04:49:18 +00:00
|
|
|
auto editNameInlineVisible = !_editNameVisible;
|
|
|
|
if (editNameInlineVisible) {
|
|
|
|
nameWidth -= _editNameInline->width();
|
|
|
|
}
|
|
|
|
|
2017-09-20 19:44:22 +00:00
|
|
|
_name->resizeToNaturalWidth(nameWidth);
|
2017-09-13 16:57:44 +00:00
|
|
|
_name->moveToLeft(
|
|
|
|
margins.left() + nameLeft,
|
|
|
|
margins.top() + nameTop,
|
|
|
|
newWidth);
|
|
|
|
|
|
|
|
_editNameInline->moveToLeft(
|
2017-11-30 14:00:25 +00:00
|
|
|
margins.left() + nameLeft + _name->widthNoMargins() + st::settingsNameLabel.margin.right(),
|
|
|
|
margins.top() + nameTop - st::settingsNameLabel.margin.top(),
|
2017-09-13 16:57:44 +00:00
|
|
|
newWidth);
|
2016-08-27 04:49:18 +00:00
|
|
|
_editNameInline->setVisible(editNameInlineVisible);
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::paintContents(Painter &p) {
|
|
|
|
p.setFont(st::settingsStatusFont);
|
|
|
|
p.setPen(_statusTextIsOnline ? st::settingsStatusFgActive : st::settingsStatusFg);
|
|
|
|
p.drawTextLeft(_statusPosition.x(), _statusPosition.y(), width(), _statusText);
|
|
|
|
|
|
|
|
paintDivider(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::resizeDropArea() {
|
|
|
|
if (_dropArea) {
|
|
|
|
_dropArea->setGeometry(0, 0, width(), _dividerTop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::dropAreaHidden(Profile::CoverDropArea *dropArea) {
|
|
|
|
if (_dropArea == dropArea) {
|
|
|
|
_dropArea.destroyDelayed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CoverWidget::mimeDataHasImage(const QMimeData *mimeData) const {
|
|
|
|
if (!mimeData) return false;
|
|
|
|
|
|
|
|
if (mimeData->hasImage()) return true;
|
|
|
|
|
|
|
|
auto uriListFormat = qsl("text/uri-list");
|
|
|
|
if (!mimeData->hasFormat(uriListFormat)) return false;
|
|
|
|
|
|
|
|
const auto &urls = mimeData->urls();
|
|
|
|
if (urls.size() != 1) return false;
|
|
|
|
|
|
|
|
auto &url = urls.at(0);
|
|
|
|
if (!url.isLocalFile()) return false;
|
|
|
|
|
2017-02-28 10:51:00 +00:00
|
|
|
auto file = Platform::File::UrlToLocal(url);
|
2016-08-19 17:26:31 +00:00
|
|
|
|
|
|
|
QFileInfo info(file);
|
|
|
|
if (info.isDir()) return false;
|
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
if (info.size() > App::kImageSizeLimit) return false;
|
2016-08-19 17:26:31 +00:00
|
|
|
|
|
|
|
for (auto &ext : cImgExtensions()) {
|
|
|
|
if (file.endsWith(ext, Qt::CaseInsensitive)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::dragEnterEvent(QDragEnterEvent *e) {
|
|
|
|
if (!mimeDataHasImage(e->mimeData())) {
|
|
|
|
e->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!_dropArea) {
|
|
|
|
auto title = lang(lng_profile_drop_area_title);
|
|
|
|
auto subtitle = lang(lng_settings_drop_area_subtitle);
|
2016-12-13 17:07:56 +00:00
|
|
|
_dropArea.create(this, title, subtitle);
|
2016-08-19 17:26:31 +00:00
|
|
|
resizeDropArea();
|
|
|
|
}
|
|
|
|
_dropArea->showAnimated();
|
|
|
|
e->setDropAction(Qt::CopyAction);
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::dragLeaveEvent(QDragLeaveEvent *e) {
|
|
|
|
if (_dropArea && !_dropArea->hiding()) {
|
2016-09-26 12:09:59 +00:00
|
|
|
_dropArea->hideAnimated([this](Profile::CoverDropArea *area) { dropAreaHidden(area); });
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::dropEvent(QDropEvent *e) {
|
|
|
|
auto mimeData = e->mimeData();
|
|
|
|
|
|
|
|
QImage img;
|
|
|
|
if (mimeData->hasImage()) {
|
|
|
|
img = qvariant_cast<QImage>(mimeData->imageData());
|
|
|
|
} else {
|
2016-09-26 18:17:36 +00:00
|
|
|
auto urls = mimeData->urls();
|
2016-08-19 17:26:31 +00:00
|
|
|
if (urls.size() == 1) {
|
|
|
|
auto &url = urls.at(0);
|
|
|
|
if (url.isLocalFile()) {
|
2017-02-28 10:51:00 +00:00
|
|
|
img = App::readImage(Platform::File::UrlToLocal(url));
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_dropArea->hiding()) {
|
2016-09-26 12:09:59 +00:00
|
|
|
_dropArea->hideAnimated([this](Profile::CoverDropArea *area) { dropAreaHidden(area); });
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
e->acceptProposedAction();
|
|
|
|
|
|
|
|
showSetPhotoBox(img);
|
2017-12-18 16:25:24 +00:00
|
|
|
|
|
|
|
App::wnd()->activateWindow();
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::paintDivider(Painter &p) {
|
2016-12-02 19:16:35 +00:00
|
|
|
auto dividerHeight = st::profileDividerLeft.height();
|
|
|
|
auto divider = rtlrect(0, _dividerTop, width(), dividerHeight, width());
|
|
|
|
p.fillRect(divider, st::profileDividerBg);
|
|
|
|
auto dividerFillTop = rtlrect(0, _dividerTop, width(), st::profileDividerTop.height(), width());
|
|
|
|
st::profileDividerTop.fill(p, dividerFillTop);
|
|
|
|
auto dividerFillBottom = rtlrect(0, _dividerTop + dividerHeight - st::profileDividerBottom.height(), width(), st::profileDividerBottom.height(), width());
|
|
|
|
st::profileDividerBottom.fill(p, dividerFillBottom);
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
|
|
|
|
if (update.peer != _self) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (update.flags & Notify::PeerUpdate::Flag::NameChanged) {
|
|
|
|
refreshNameText();
|
|
|
|
}
|
2016-12-31 13:34:41 +00:00
|
|
|
if (update.flags & Notify::PeerUpdate::Flag::PhotoChanged) {
|
|
|
|
validatePhoto();
|
|
|
|
}
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::refreshNameText() {
|
|
|
|
_name->setText(App::peerName(_self));
|
|
|
|
refreshNameGeometry(width());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::refreshStatusText() {
|
2018-09-06 11:13:54 +00:00
|
|
|
if (false) {
|
2017-02-23 10:59:19 +00:00
|
|
|
_statusText = lang(lng_settings_uploading_photo);
|
|
|
|
_statusTextIsOnline = false;
|
|
|
|
if (!_cancelPhotoUpload) {
|
2017-09-13 16:57:44 +00:00
|
|
|
auto margins = getMargins();
|
2017-02-23 10:59:19 +00:00
|
|
|
_cancelPhotoUpload.create(this, lang(lng_cancel), st::defaultLinkButton);
|
2017-11-30 14:00:25 +00:00
|
|
|
_cancelPhotoUpload->addClickHandler([this] { cancelPhotoUpload(); });
|
2017-02-23 10:59:19 +00:00
|
|
|
_cancelPhotoUpload->show();
|
2017-09-13 16:57:44 +00:00
|
|
|
_cancelPhotoUpload->moveToLeft(
|
|
|
|
margins.left()
|
|
|
|
+ _statusPosition.x()
|
|
|
|
+ st::settingsStatusFont->width(_statusText)
|
|
|
|
+ st::settingsStatusFont->spacew,
|
|
|
|
margins.top() + _statusPosition.y());
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
2017-02-23 10:59:19 +00:00
|
|
|
update();
|
|
|
|
return;
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_cancelPhotoUpload.destroy();
|
2016-12-03 12:10:35 +00:00
|
|
|
auto state = MTP::dcstate();
|
|
|
|
if (state == MTP::ConnectingState || state == MTP::DisconnectedState || state < 0) {
|
|
|
|
_statusText = lang(lng_status_connecting);
|
|
|
|
_statusTextIsOnline = false;
|
|
|
|
} else {
|
|
|
|
_statusText = lang(lng_status_online);
|
|
|
|
_statusTextIsOnline = true;
|
|
|
|
}
|
2016-08-19 17:26:31 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
void CoverWidget::chooseNewPhoto() {
|
2016-11-28 15:45:07 +00:00
|
|
|
auto imageExtensions = cImgExtensions();
|
2017-02-28 15:43:03 +00:00
|
|
|
auto filter = qsl("Image files (*") + imageExtensions.join(qsl(" *")) + qsl(");;") + FileDialog::AllFilesFilter();
|
2018-04-17 15:19:34 +00:00
|
|
|
const auto callback = [=](const FileDialog::OpenResult &result) {
|
2017-02-28 15:43:03 +00:00
|
|
|
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QImage img;
|
|
|
|
if (!result.remoteContent.isEmpty()) {
|
|
|
|
img = App::readImage(result.remoteContent);
|
|
|
|
} else {
|
|
|
|
img = App::readImage(result.paths.front());
|
|
|
|
}
|
2016-08-19 17:26:31 +00:00
|
|
|
|
2017-02-28 15:43:03 +00:00
|
|
|
showSetPhotoBox(img);
|
2018-04-17 15:19:34 +00:00
|
|
|
};
|
|
|
|
FileDialog::GetOpenPath(
|
|
|
|
this,
|
|
|
|
lang(lng_choose_image),
|
|
|
|
filter,
|
2018-06-04 15:35:11 +00:00
|
|
|
crl::guard(this, callback));
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 14:00:25 +00:00
|
|
|
void CoverWidget::editName() {
|
2017-12-02 12:04:22 +00:00
|
|
|
Ui::show(Box<EditNameBox>(self()));
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::showSetPhotoBox(const QImage &img) {
|
|
|
|
if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
|
2016-12-13 17:07:56 +00:00
|
|
|
Ui::show(Box<InformBox>(lang(lng_bad_photo)));
|
2016-08-19 17:26:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-13 12:02:53 +00:00
|
|
|
auto peer = _self;
|
|
|
|
auto box = Ui::show(Box<PhotoCropBox>(img, peer));
|
2017-12-22 07:05:20 +00:00
|
|
|
box->ready(
|
|
|
|
) | rpl::start_with_next([=](QImage &&image) {
|
2018-09-06 11:13:54 +00:00
|
|
|
Auth().api().uploadPeerPhoto(peer, std::move(image));
|
2017-12-22 07:05:20 +00:00
|
|
|
}, box->lifetime());
|
2018-03-29 19:49:31 +00:00
|
|
|
box->boxClosing() | rpl::start_with_next([=] {
|
|
|
|
onPhotoUploadStatusChanged();
|
|
|
|
}, lifetime());
|
2016-08-19 17:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CoverWidget::onPhotoUploadStatusChanged(PeerId peerId) {
|
|
|
|
if (!peerId || peerId == _self->id) {
|
|
|
|
refreshStatusText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Settings
|