Added ability to remember last choice in send files box.

This commit is contained in:
23rd 2022-12-12 14:35:41 +03:00 committed by John Preston
parent 994d789c60
commit 8db8bc466e
2 changed files with 27 additions and 5 deletions

View file

@ -633,15 +633,17 @@ void SendFilesBox::refreshControls() {
}
void SendFilesBox::setupSendWayControls() {
const auto groupFilesFirst = _sendWay.current().groupFiles();
const auto asPhotosFirst = _sendWay.current().sendImagesAsPhotos();
_groupFiles.create(
this,
tr::lng_send_grouped(tr::now),
_sendWay.current().groupFiles(),
groupFilesFirst,
st::defaultBoxCheckbox);
_sendImagesAsPhotos.create(
this,
tr::lng_send_compressed(tr::now),
_sendWay.current().sendImagesAsPhotos(),
asPhotosFirst,
st::defaultBoxCheckbox);
_sendWay.changes(
@ -664,6 +666,21 @@ void SendFilesBox::setupSendWayControls() {
_sendWay = sendWay;
}, lifetime());
_wayRemember.create(
this,
tr::lng_remember(tr::now),
false,
st::defaultBoxCheckbox);
_wayRemember->hide();
rpl::combine(
_groupFiles->checkedValue(),
_sendImagesAsPhotos->checkedValue()
) | rpl::start_with_next([=](bool groupFiles, bool asPhoto) {
_wayRemember->setVisible(
(groupFiles != groupFilesFirst) || (asPhoto != asPhotosFirst));
captionResized();
}, lifetime());
_hintLabel.create(
this,
tr::lng_edit_photo_editor_hint(tr::now),
@ -913,9 +930,10 @@ void SendFilesBox::updateBoxSize() {
if (_caption) {
footerHeight += st::boxPhotoCaptionSkip + _caption->height();
}
const auto pairs = std::array<std::pair<RpWidget*, int>, 3>{ {
const auto pairs = std::array<std::pair<RpWidget*, int>, 4>{ {
{ _groupFiles.data(), st::boxPhotoCompressedSkip },
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
{ _wayRemember.data(), st::boxPhotoCompressedSkip },
{ _hintLabel.data(), st::editMediaLabelMargins.top() },
} };
for (const auto &pair : pairs) {
@ -980,10 +998,11 @@ void SendFilesBox::updateControlsGeometry() {
_emojiToggle->update();
}
}
const auto pairs = std::array<std::pair<RpWidget*, int>, 3>{ {
const auto pairs = std::array<std::pair<RpWidget*, int>, 4>{ {
{ _hintLabel.data(), st::editMediaLabelMargins.top() },
{ _groupFiles.data(), st::boxPhotoCompressedSkip },
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
{ _wayRemember.data(), st::boxPhotoCompressedSkip },
} };
for (const auto &pair : ranges::views::reverse(pairs)) {
const auto pointer = pair.first;
@ -1052,7 +1071,9 @@ void SendFilesBox::send(
return;
}
saveSendWaySettings();
if (_wayRemember && _wayRemember->checked()) {
saveSendWaySettings();
}
for (auto &block : _blocks) {
block.applyAlbumOrder();

View file

@ -187,6 +187,7 @@ private:
object_ptr<Ui::Checkbox> _groupFiles = { nullptr };
object_ptr<Ui::Checkbox> _sendImagesAsPhotos = { nullptr };
object_ptr<Ui::Checkbox> _wayRemember = { nullptr };
object_ptr<Ui::FlatLabel> _hintLabel = { nullptr };
rpl::variable<Ui::SendFilesWay> _sendWay = Ui::SendFilesWay();