2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 14:17: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_send_games" = "Send games";
"ktg_admin_log_banned_use_inline" = "Use inline bots"; "ktg_admin_log_banned_use_inline" = "Use inline bots";
"ktg_forward_go_to_chat" = "Go to chat";
// Keys finished // Keys finished

View File

@@ -166,6 +166,9 @@
"ktg_admin_log_banned_send_games": "Send games", "ktg_admin_log_banned_send_games": "Send games",
"ktg_admin_log_banned_use_inline": "Use inline bots", "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. // This string should always be last for better work with Git.
"dummy_last_string": "" "dummy_last_string": ""
} }

View File

@@ -174,6 +174,9 @@
"ktg_admin_log_banned_send_games": "Wyślij gry", "ktg_admin_log_banned_send_games": "Wyślij gry",
"ktg_admin_log_banned_use_inline": "Użyj bota liniowego (inline)", "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. // This string should always be last for better work with Git.
"dummy_last_string": "" "dummy_last_string": ""
} }

View File

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

View File

@@ -166,6 +166,9 @@
"ktg_admin_log_banned_send_games": "Oyunlar Gönder", "ktg_admin_log_banned_send_games": "Oyunlar Gönder",
"ktg_admin_log_banned_use_inline": "İnline Bot'lar Kullan", "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. // This string should always be last for better work with Git.
"dummy_last_string": "" "dummy_last_string": ""
} }

View File

@@ -173,6 +173,9 @@
"ktg_admin_log_banned_send_games": "Надсилати ігри", "ktg_admin_log_banned_send_games": "Надсилати ігри",
"ktg_admin_log_banned_use_inline": "Використання інлайн-ботів", "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. // This string should always be last for better work with Git.
"dummy_last_string": "" "dummy_last_string": ""
} }

View File

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

View File

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

View File

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