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

Add "Send when online" to the send button context menu.

This commit is contained in:
John Preston
2023-04-22 22:26:09 +04:00
parent 4201a0193c
commit e285b22398
24 changed files with 80 additions and 31 deletions

View File

@@ -1102,6 +1102,9 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
send),
Ui::LayerOption::KeepOther);
};
const auto sendWhenOnline = [=] {
send(Api::DefaultSendWhenOnlineOptions());
};
options->scrollToWidget(
) | rpl::start_with_next([=](not_null<QWidget*> widget) {
@@ -1130,7 +1133,8 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
submit.data(),
sendMenuType,
sendSilent,
sendScheduled);
sendScheduled,
sendWhenOnline);
addButton(tr::lng_cancel(), [=] { closeBox(); });
return result;

View File

@@ -508,7 +508,8 @@ void SendFilesBox::refreshButtons() {
_send,
[=] { return _sendMenuType; },
[=] { sendSilent(); },
[=] { sendScheduled(); });
[=] { sendScheduled(); },
[=] { sendWhenOnline(); });
}
addButton(tr::lng_cancel(), [=] { closeBox(); });
_addFile = addLeftButton(
@@ -584,7 +585,8 @@ void SendFilesBox::addMenuButton() {
_menu.get(),
_sendMenuType,
[=] { sendSilent(); },
[=] { sendScheduled(); });
[=] { sendScheduled(); },
[=] { sendWhenOnline(); });
}
_menu->popup(QCursor::pos());
return true;
@@ -1390,4 +1392,8 @@ void SendFilesBox::sendScheduled() {
Ui::LayerOption::KeepOther);
}
void SendFilesBox::sendWhenOnline() {
send(Api::DefaultSendWhenOnlineOptions());
}
SendFilesBox::~SendFilesBox() = default;

View File

@@ -179,6 +179,7 @@ private:
void send(Api::SendOptions options, bool ctrlShiftEnter = false);
void sendSilent();
void sendScheduled();
void sendWhenOnline();
void captionResized();
void saveSendWaySettings();

View File

@@ -502,7 +502,8 @@ void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) {
_menu.get(),
sendMenuType(),
[=] { submitSilent(); },
[=] { submitScheduled(); });
[=] { submitScheduled(); },
[=] { submitWhenOnline(); });
const auto success = (result == SendMenu::FillMenuResult::Success);
if (_descriptor.forwardOptions.show || success) {
_menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom);
@@ -599,6 +600,10 @@ void ShareBox::submitScheduled() {
Ui::LayerOption::KeepOther);
}
void ShareBox::submitWhenOnline() {
submit(Api::DefaultSendWhenOnlineOptions());
}
void ShareBox::copyLink() {
if (const auto onstack = _descriptor.copyCallback) {
onstack();

View File

@@ -118,6 +118,7 @@ private:
void submit(Api::SendOptions options);
void submitSilent();
void submitScheduled();
void submitWhenOnline();
void copyLink();
bool searchByUsername(bool useCache = false);

View File

@@ -1023,7 +1023,8 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
_menu.get(),
type,
SendMenu::DefaultSilentCallback(sendSelected),
SendMenu::DefaultScheduleCallback(this, type, sendSelected));
SendMenu::DefaultScheduleCallback(this, type, sendSelected),
SendMenu::DefaultWhenOnlineCallback(sendSelected));
const auto controller = _controller;
const auto toggleFavedSticker = [=] {