2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Add simple forwarding options on bar click.

This commit is contained in:
John Preston
2021-08-31 19:47:38 +03:00
parent e9a5c45f34
commit 9dfc60026e
18 changed files with 378 additions and 94 deletions

View File

@@ -502,20 +502,20 @@ void MainWidget::floatPlayerDoubleClickEvent(
_controller->showPeerHistoryAtItem(item);
}
bool MainWidget::setForwardDraft(PeerId peerId, MessageIdsList &&items) {
bool MainWidget::setForwardDraft(PeerId peerId, Data::ForwardDraft &&draft) {
Expects(peerId != 0);
const auto peer = session().data().peer(peerId);
const auto error = GetErrorTextForSending(
peer,
session().data().idsToItems(items),
session().data().idsToItems(draft.ids),
true);
if (!error.isEmpty()) {
Ui::show(Box<InformBox>(error), Ui::LayerOption::KeepOther);
return false;
}
peer->owner().history(peer)->setForwardDraft(std::move(items));
peer->owner().history(peer)->setForwardDraft(std::move(draft));
_controller->showPeerHistory(
peer,
SectionShow::Way::Forward,
@@ -603,7 +603,10 @@ void MainWidget::onFilesOrForwardDrop(
Expects(peerId != 0);
if (data->hasFormat(qsl("application/x-td-forward"))) {
if (!setForwardDraft(peerId, session().data().takeMimeForwardIds())) {
auto draft = Data::ForwardDraft{
.ids = session().data().takeMimeForwardIds(),
};
if (!setForwardDraft(peerId, std::move(draft))) {
// We've already released the mouse button, so the forwarding is cancelled.
if (_hider) {
_hider->startHide();
@@ -704,9 +707,9 @@ void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
floatPlayerCheckVisibility();
}
void MainWidget::showForwardLayer(MessageIdsList &&items) {
auto callback = [=, items = std::move(items)](PeerId peer) mutable {
return setForwardDraft(peer, std::move(items));
void MainWidget::showForwardLayer(Data::ForwardDraft &&draft) {
auto callback = [=, draft = std::move(draft)](PeerId peer) mutable {
return setForwardDraft(peer, std::move(draft));
};
hiderLayer(base::make_unique_q<Window::HistoryHider>(
this,