diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index b12715c29..1b888ff37 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -522,24 +522,24 @@ bool MainWidget::setForwardDraft(PeerId peerId, Data::ForwardDraft &&draft) { bool MainWidget::shareUrl( PeerId peerId, const QString &url, - const QString &text) { + const QString &text) const { Expects(peerId != 0); const auto peer = session().data().peer(peerId); if (!peer->canWrite()) { - Ui::show(Ui::MakeInformBox(tr::lng_share_cant())); + _controller->show(Ui::MakeInformBox(tr::lng_share_cant())); return false; } - TextWithTags textWithTags = { + const auto textWithTags = TextWithTags{ url + '\n' + text, TextWithTags::Tags() }; - MessageCursor cursor = { + const auto cursor = MessageCursor{ int(url.size()) + 1, int(url.size()) + 1 + int(text.size()), QFIXED_MAX }; - auto history = peer->owner().history(peer); + const auto history = peer->owner().history(peer); history->setLocalDraft(std::make_unique( textWithTags, 0, @@ -552,7 +552,9 @@ bool MainWidget::shareUrl( return true; } -bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) { +bool MainWidget::inlineSwitchChosen( + PeerId peerId, + const QString &botAndQuery) const { Expects(peerId != 0); const auto peer = session().data().peer(peerId); @@ -561,8 +563,15 @@ bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) { return false; } const auto h = peer->owner().history(peer); - TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() }; - MessageCursor cursor = { int(botAndQuery.size()), int(botAndQuery.size()), QFIXED_MAX }; + const auto textWithTags = TextWithTags{ + botAndQuery, + TextWithTags::Tags(), + }; + const auto cursor = MessageCursor{ + int(botAndQuery.size()), + int(botAndQuery.size()), + QFIXED_MAX + }; h->setLocalDraft(std::make_unique( textWithTags, 0, diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index c7e3b2bb9..df1315aa0 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -177,11 +177,6 @@ public: void inlineSwitchLayer(const QString &botAndQuery); void hiderLayer(base::unique_qptr h); bool setForwardDraft(PeerId peer, Data::ForwardDraft &&draft); - bool shareUrl( - PeerId peerId, - const QString &url, - const QString &text); - bool inlineSwitchChosen(PeerId peerId, const QString &botAndQuery); bool sendPaths(PeerId peerId); void onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data); bool selectingPeer() const; @@ -258,6 +253,12 @@ private: [[nodiscard]] auto thirdSectionForCurrentMainSection(Dialogs::Key key) -> std::shared_ptr; + bool shareUrl( + PeerId peerId, + const QString &url, + const QString &text) const; + bool inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) const; + void setupConnectingWidget(); void createPlayer(); void playerHeightUpdated();