2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 06:07:45 +00:00

Go to chat in forward

This commit is contained in:
RadRussianRus 2020-07-08 09:24:46 +03:00
parent a67772fdfa
commit aabe77b89c
9 changed files with 42 additions and 4 deletions

View File

@ -2576,4 +2576,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_admin_log_banned_send_games" = "Send games";
"ktg_admin_log_banned_use_inline" = "Use inline bots";
"ktg_forward_go_to_chat" = "Go to chat";
// Keys finished

View File

@ -166,6 +166,9 @@
"ktg_admin_log_banned_send_games": "Send games",
"ktg_admin_log_banned_use_inline": "Use inline bots",
// New strings
"ktg_forward_go_to_chat": "Go to chat",
// This string should always be last for better work with Git.
"dummy_last_string": ""
}

View File

@ -174,6 +174,9 @@
"ktg_admin_log_banned_send_games": "Wyślij gry",
"ktg_admin_log_banned_use_inline": "Użyj bota liniowego (inline)",
// New strings
"ktg_forward_go_to_chat": "Go to chat",
// This string should always be last for better work with Git.
"dummy_last_string": ""
}

View File

@ -173,6 +173,9 @@
"ktg_admin_log_banned_send_games": "Отправка игр",
"ktg_admin_log_banned_use_inline": "Отправка через ботов",
// New strings
"ktg_forward_go_to_chat": "Перейти в чат",
// This string should always be last for better work with Git.
"dummy_last_string": ""
}

View File

@ -166,6 +166,9 @@
"ktg_admin_log_banned_send_games": "Oyunlar Gönder",
"ktg_admin_log_banned_use_inline": "İnline Bot'lar Kullan",
// New strings
"ktg_forward_go_to_chat": "Go to chat",
// This string should always be last for better work with Git.
"dummy_last_string": ""
}

View File

@ -173,6 +173,9 @@
"ktg_admin_log_banned_send_games": "Надсилати ігри",
"ktg_admin_log_banned_use_inline": "Використання інлайн-ботів",
// New strings
"ktg_forward_go_to_chat": "Go to chat",
// This string should always be last for better work with Git.
"dummy_last_string": ""
}

View File

@ -157,12 +157,14 @@ ShareBox::ShareBox(
not_null<Window::SessionNavigation*> navigation,
CopyCallback &&copyCallback,
SubmitCallback &&submitCallback,
FilterCallback &&filterCallback)
FilterCallback &&filterCallback,
GoToChatCallback &&goToChatCallback)
: _navigation(navigation)
, _api(&_navigation->session().mtp())
, _copyCallback(std::move(copyCallback))
, _submitCallback(std::move(submitCallback))
, _filterCallback(std::move(filterCallback))
, _goToChatCallback(goToChatCallback ? std::move(goToChatCallback) : nullptr)
, _select(
this,
st::contactsMultiSelect,
@ -420,6 +422,11 @@ SendMenuType ShareBox::sendMenuType() const {
void ShareBox::createButtons() {
clearButtons();
if (_hasSelected) {
if (_goToChatCallback && _inner->selected().size() == 1) {
const auto singleChat = _inner->selected().at(0);
addLeftButton(tr::ktg_forward_go_to_chat(), [=] { goToChat(singleChat); });
}
const auto send = addButton(tr::lng_share_confirm(), [=] {
submit({});
});
@ -489,14 +496,20 @@ void ShareBox::copyLink() {
}
}
void ShareBox::goToChat(not_null<PeerData*> peer) {
if (_goToChatCallback) {
_goToChatCallback(peer);
}
}
void ShareBox::selectedChanged() {
auto hasSelected = _inner->hasSelected();
if (_hasSelected != hasSelected) {
_hasSelected = hasSelected;
createButtons();
_comment->toggle(_hasSelected, anim::type::normal);
_comment->resizeToWidth(st::boxWideWidth);
}
createButtons();
update();
}

View File

@ -57,13 +57,15 @@ public:
TextWithTags&&,
Api::SendOptions)>;
using FilterCallback = Fn<bool(PeerData*)>;
using GoToChatCallback = Fn<void(PeerData *peer)>;
ShareBox(
QWidget*,
not_null<Window::SessionNavigation*> navigation,
CopyCallback &&copyCallback,
SubmitCallback &&submitCallback,
FilterCallback &&filterCallback);
FilterCallback &&filterCallback,
GoToChatCallback &&goToChatCallback = nullptr);
protected:
void prepare() override;
@ -80,6 +82,7 @@ private:
void submitSilent();
void submitScheduled();
void copyLink();
void goToChat(not_null<PeerData*> peer);
bool searchByUsername(bool useCache = false);
SendMenuType sendMenuType() const;
@ -108,6 +111,7 @@ private:
CopyCallback _copyCallback;
SubmitCallback _submitCallback;
FilterCallback _filterCallback;
GoToChatCallback _goToChatCallback;
object_ptr<Ui::MultiSelect> _select;
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;

View File

@ -1169,11 +1169,15 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
auto copyLinkCallback = canCopyLink
? Fn<void()>(std::move(copyCallback))
: Fn<void()>();
auto goToChatCallback = [navigation, data](PeerData *peer) {
navigation->parentController()->content()->setForwardDraft(peer->id, std::move(data->msgIds));
};
*weak = Ui::show(Box<ShareBox>(
App::wnd()->sessionController(),
std::move(copyLinkCallback),
std::move(submitCallback),
std::move(filterCallback)));
std::move(filterCallback),
std::move(goToChatCallback)));
return weak->data();
}