Added photo editor hint to SendFilesBox.

This commit is contained in:
23rd 2021-04-26 11:23:54 +03:00
parent 18154e403a
commit e30eacff41
2 changed files with 33 additions and 14 deletions

View file

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_media_prepare.h" #include "storage/storage_media_prepare.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "chat_helpers/message_field.h" #include "chat_helpers/message_field.h"
#include "chat_helpers/send_context_menu.h" #include "chat_helpers/send_context_menu.h"
@ -667,6 +668,11 @@ void SendFilesBox::setupSendWayControls() {
sendWay.setSendImagesAsPhotos(_sendImagesAsPhotos->checked()); sendWay.setSendImagesAsPhotos(_sendImagesAsPhotos->checked());
_sendWay = sendWay; _sendWay = sendWay;
}, lifetime()); }, lifetime());
_hintLabel.create(
this,
tr::lng_edit_photo_editor_hint(tr::now),
st::editMediaHintLabel);
} }
void SendFilesBox::updateSendWayControlsVisibility() { void SendFilesBox::updateSendWayControlsVisibility() {
@ -674,6 +680,11 @@ void SendFilesBox::updateSendWayControlsVisibility() {
_groupFiles->setVisible(_list.hasGroupOption(onlyOne)); _groupFiles->setVisible(_list.hasGroupOption(onlyOne));
_sendImagesAsPhotos->setVisible( _sendImagesAsPhotos->setVisible(
_list.hasSendImagesAsPhotosOption(onlyOne)); _list.hasSendImagesAsPhotosOption(onlyOne));
_hintLabel->setVisible(
_controller->session().settings().photoEditorHintShown()
? _list.hasSendImagesAsPhotosOption(false)
: false);
} }
void SendFilesBox::setupCaption() { void SendFilesBox::setupCaption() {
@ -877,14 +888,15 @@ void SendFilesBox::updateBoxSize() {
if (_caption) { if (_caption) {
footerHeight += st::boxPhotoCaptionSkip + _caption->height(); footerHeight += st::boxPhotoCaptionSkip + _caption->height();
} }
const auto pointers = { const auto pairs = std::array<std::pair<RpWidget*, int>, 3>{ {
_groupFiles.data(), { _groupFiles.data(), st::boxPhotoCompressedSkip },
_sendImagesAsPhotos.data(), { _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
}; { _hintLabel.data(), st::editMediaLabelMargins.top() },
for (auto pointer : pointers) { } };
for (const auto &pair : pairs) {
const auto pointer = pair.first;
if (pointer && !pointer->isHidden()) { if (pointer && !pointer->isHidden()) {
footerHeight += st::boxPhotoCompressedSkip footerHeight += pair.second + pointer->heightNoMargins();
+ pointer->heightNoMargins();
} }
} }
_footerHeight = footerHeight; _footerHeight = footerHeight;
@ -943,16 +955,18 @@ void SendFilesBox::updateControlsGeometry() {
_emojiToggle->update(); _emojiToggle->update();
} }
} }
const auto pointers = { const auto pairs = std::array<std::pair<RpWidget*, int>, 3>{ {
_groupFiles.data(), { _hintLabel.data(), st::editMediaLabelMargins.top() },
_sendImagesAsPhotos.data(), { _groupFiles.data(), st::boxPhotoCompressedSkip },
}; { _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
for (const auto pointer : ranges::views::reverse(pointers)) { } };
for (const auto &pair : ranges::views::reverse(pairs)) {
const auto pointer = pair.first;
if (pointer && !pointer->isHidden()) { if (pointer && !pointer->isHidden()) {
pointer->moveToLeft( pointer->moveToLeft(
st::boxPhotoPadding.left(), st::boxPhotoPadding.left(),
bottom - pointer->heightNoMargins()); bottom - pointer->heightNoMargins());
bottom -= st::boxPhotoCompressedSkip + pointer->heightNoMargins(); bottom -= pair.second + pointer->heightNoMargins();
} }
} }
_scroll->resize(width(), bottom - _titleHeight.current()); _scroll->resize(width(), bottom - _titleHeight.current());
@ -1004,7 +1018,10 @@ void SendFilesBox::send(
block.applyAlbumOrder(); block.applyAlbumOrder();
} }
Storage::ApplyModifications(_list); if (Storage::ApplyModifications(_list)) {
_controller->session().settings().incrementPhotoEditorHintShown();
_controller->session().saveSettings();
}
_confirmed = true; _confirmed = true;
if (_confirmedCallback) { if (_confirmedCallback) {

View file

@ -35,6 +35,7 @@ struct GroupMediaLayout;
class EmojiButton; class EmojiButton;
class AlbumPreview; class AlbumPreview;
class VerticalLayout; class VerticalLayout;
class FlatLabel;
} // namespace Ui } // namespace Ui
namespace Window { namespace Window {
@ -184,6 +185,7 @@ private:
object_ptr<Ui::Checkbox> _groupFiles = { nullptr }; object_ptr<Ui::Checkbox> _groupFiles = { nullptr };
object_ptr<Ui::Checkbox> _sendImagesAsPhotos = { nullptr }; object_ptr<Ui::Checkbox> _sendImagesAsPhotos = { nullptr };
object_ptr<Ui::FlatLabel> _hintLabel = { nullptr };
rpl::variable<Ui::SendFilesWay> _sendWay = Ui::SendFilesWay(); rpl::variable<Ui::SendFilesWay> _sendWay = Ui::SendFilesWay();
rpl::variable<int> _footerHeight = 0; rpl::variable<int> _footerHeight = 0;