2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Bundle silent and scheduled to Api::SendOptions.

This commit is contained in:
John Preston
2019-08-12 13:11:34 +01:00
parent 0b08810d5a
commit caef7dde24
27 changed files with 413 additions and 349 deletions

View File

@@ -195,7 +195,7 @@ void ShareBox::prepareCommentField() {
const auto field = _comment->entity();
connect(field, &Ui::InputField::submitted, [=] {
submit();
submit({});
});
field->setInstantReplaces(Ui::InstantReplaces::Default());
@@ -242,7 +242,7 @@ void ShareBox::prepare() {
_select->setSubmittedCallback([=](Qt::KeyboardModifiers modifiers) {
if (modifiers.testFlag(Qt::ControlModifier)
|| modifiers.testFlag(Qt::MetaModifier)) {
submit();
submit({});
} else {
_inner->selectActive();
}
@@ -412,12 +412,13 @@ void ShareBox::createButtons() {
clearButtons();
if (_hasSelected) {
const auto send = addButton(tr::lng_share_confirm(), [=] {
submit();
submit({});
});
SetupSendWithoutSound(
send,
[=] { return true; },
[=] { submit(true); });
[=] { submitSilent(); },
[=] { submitScheduled(); });
} else if (_copyCallback) {
addButton(tr::lng_share_copy_link(), [=] { copyLink(); });
}
@@ -451,15 +452,27 @@ void ShareBox::innerSelectedChanged(PeerData *peer, bool checked) {
update();
}
void ShareBox::submit(bool silent) {
void ShareBox::submit(Api::SendOptions options) {
if (_submitCallback) {
_submitCallback(
_inner->selected(),
_comment->entity()->getTextWithAppliedMarkdown(),
silent);
options);
}
}
void ShareBox::submitSilent() {
auto options = Api::SendOptions();
options.silent = true;
submit(options);
}
void ShareBox::submitScheduled() {
auto options = Api::SendOptions();
options.scheduled = INT_MAX;
submit(options);
}
void ShareBox::copyLink() {
if (_copyCallback) {
_copyCallback();