mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to remember last choice in send files box.
This commit is contained in:
parent
994d789c60
commit
8db8bc466e
2 changed files with 27 additions and 5 deletions
|
@ -633,15 +633,17 @@ void SendFilesBox::refreshControls() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::setupSendWayControls() {
|
void SendFilesBox::setupSendWayControls() {
|
||||||
|
const auto groupFilesFirst = _sendWay.current().groupFiles();
|
||||||
|
const auto asPhotosFirst = _sendWay.current().sendImagesAsPhotos();
|
||||||
_groupFiles.create(
|
_groupFiles.create(
|
||||||
this,
|
this,
|
||||||
tr::lng_send_grouped(tr::now),
|
tr::lng_send_grouped(tr::now),
|
||||||
_sendWay.current().groupFiles(),
|
groupFilesFirst,
|
||||||
st::defaultBoxCheckbox);
|
st::defaultBoxCheckbox);
|
||||||
_sendImagesAsPhotos.create(
|
_sendImagesAsPhotos.create(
|
||||||
this,
|
this,
|
||||||
tr::lng_send_compressed(tr::now),
|
tr::lng_send_compressed(tr::now),
|
||||||
_sendWay.current().sendImagesAsPhotos(),
|
asPhotosFirst,
|
||||||
st::defaultBoxCheckbox);
|
st::defaultBoxCheckbox);
|
||||||
|
|
||||||
_sendWay.changes(
|
_sendWay.changes(
|
||||||
|
@ -664,6 +666,21 @@ void SendFilesBox::setupSendWayControls() {
|
||||||
_sendWay = sendWay;
|
_sendWay = sendWay;
|
||||||
}, lifetime());
|
}, 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(
|
_hintLabel.create(
|
||||||
this,
|
this,
|
||||||
tr::lng_edit_photo_editor_hint(tr::now),
|
tr::lng_edit_photo_editor_hint(tr::now),
|
||||||
|
@ -913,9 +930,10 @@ void SendFilesBox::updateBoxSize() {
|
||||||
if (_caption) {
|
if (_caption) {
|
||||||
footerHeight += st::boxPhotoCaptionSkip + _caption->height();
|
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 },
|
{ _groupFiles.data(), st::boxPhotoCompressedSkip },
|
||||||
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
|
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
|
||||||
|
{ _wayRemember.data(), st::boxPhotoCompressedSkip },
|
||||||
{ _hintLabel.data(), st::editMediaLabelMargins.top() },
|
{ _hintLabel.data(), st::editMediaLabelMargins.top() },
|
||||||
} };
|
} };
|
||||||
for (const auto &pair : pairs) {
|
for (const auto &pair : pairs) {
|
||||||
|
@ -980,10 +998,11 @@ void SendFilesBox::updateControlsGeometry() {
|
||||||
_emojiToggle->update();
|
_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() },
|
{ _hintLabel.data(), st::editMediaLabelMargins.top() },
|
||||||
{ _groupFiles.data(), st::boxPhotoCompressedSkip },
|
{ _groupFiles.data(), st::boxPhotoCompressedSkip },
|
||||||
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
|
{ _sendImagesAsPhotos.data(), st::boxPhotoCompressedSkip },
|
||||||
|
{ _wayRemember.data(), st::boxPhotoCompressedSkip },
|
||||||
} };
|
} };
|
||||||
for (const auto &pair : ranges::views::reverse(pairs)) {
|
for (const auto &pair : ranges::views::reverse(pairs)) {
|
||||||
const auto pointer = pair.first;
|
const auto pointer = pair.first;
|
||||||
|
@ -1052,7 +1071,9 @@ void SendFilesBox::send(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSendWaySettings();
|
if (_wayRemember && _wayRemember->checked()) {
|
||||||
|
saveSendWaySettings();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &block : _blocks) {
|
for (auto &block : _blocks) {
|
||||||
block.applyAlbumOrder();
|
block.applyAlbumOrder();
|
||||||
|
|
|
@ -187,6 +187,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::Checkbox> _wayRemember = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _hintLabel = { nullptr };
|
object_ptr<Ui::FlatLabel> _hintLabel = { nullptr };
|
||||||
rpl::variable<Ui::SendFilesWay> _sendWay = Ui::SendFilesWay();
|
rpl::variable<Ui::SendFilesWay> _sendWay = Ui::SendFilesWay();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue