mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 06:37:24 +02:00
Check some more App::main()s.
This commit is contained in:
parent
0ad7dcaef9
commit
b0f9ad71dd
15 changed files with 91 additions and 57 deletions
|
@ -193,8 +193,8 @@ void SendExistingDocument(
|
|||
if (document->sticker()) {
|
||||
if (const auto main = App::main()) {
|
||||
main->incrementSticker(document);
|
||||
document->owner().stickers().notifyRecentUpdated();
|
||||
}
|
||||
document->owner().stickers().notifyRecentUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -461,8 +461,8 @@ void StickerSetBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
const auto index = stickerFromGlobalPos(e->globalPos());
|
||||
if (index >= 0 && index < _pack.size() && !isMasksSet()) {
|
||||
const auto sticker = _pack[index];
|
||||
Ui::PostponeCall(crl::guard(App::main(), [=] {
|
||||
if (App::main()->onSendSticker(sticker)) {
|
||||
Ui::PostponeCall(crl::guard(_controller, [=] {
|
||||
if (_controller->content()->sendExistingDocument(sticker)) {
|
||||
Ui::hideSettingsAndLayer();
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -302,10 +302,14 @@ void BoxController::refreshAbout() {
|
|||
}
|
||||
|
||||
void BoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
auto itemsRow = static_cast<Row*>(row.get());
|
||||
auto itemId = itemsRow->maxItemId();
|
||||
InvokeQueued(App::main(), [peerId = row->peer()->id, itemId] {
|
||||
Ui::showPeerHistory(peerId, itemId);
|
||||
const auto itemsRow = static_cast<Row*>(row.get());
|
||||
const auto itemId = itemsRow->maxItemId();
|
||||
const auto window = _window;
|
||||
crl::on_main(window, [=, peer = row->peer()] {
|
||||
window->showPeerHistory(
|
||||
peer,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
itemId);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -904,16 +904,18 @@ ClickHandlerPtr goToMessageClickHandler(
|
|||
MsgId msgId,
|
||||
FullMsgId returnToId) {
|
||||
return std::make_shared<LambdaClickHandler>([=] {
|
||||
if (const auto main = App::main()) {
|
||||
if (const auto returnTo = peer->owner().message(returnToId)) {
|
||||
if (returnTo->history()->peer == peer) {
|
||||
main->pushReplyReturn(returnTo);
|
||||
if (const auto main = App::main()) { // multi good
|
||||
if (&main->session() == &peer->session()) {
|
||||
if (const auto returnTo = peer->owner().message(returnToId)) {
|
||||
if (returnTo->history()->peer == peer) {
|
||||
main->pushReplyReturn(returnTo);
|
||||
}
|
||||
}
|
||||
main->controller()->showPeerHistory(
|
||||
peer,
|
||||
Window::SectionShow::Way::Forward,
|
||||
msgId);
|
||||
}
|
||||
App::wnd()->sessionController()->showPeerHistory(
|
||||
peer,
|
||||
Window::SectionShow::Way::Forward,
|
||||
msgId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -506,8 +506,9 @@ bool AddDeleteMessageAction(
|
|||
}
|
||||
}
|
||||
}
|
||||
const auto controller = list->controller();
|
||||
const auto itemId = item->fullId();
|
||||
menu->addAction(tr::lng_context_delete_msg(tr::now), [=] {
|
||||
const auto callback = crl::guard(controller, [=] {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (asGroup) {
|
||||
if (const auto group = owner->groups().find(item)) {
|
||||
|
@ -519,7 +520,7 @@ bool AddDeleteMessageAction(
|
|||
}
|
||||
if (const auto message = item->toHistoryMessage()) {
|
||||
if (message->uploading()) {
|
||||
App::main()->cancelUploadLayer(item);
|
||||
controller->content()->cancelUploadLayer(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -527,6 +528,7 @@ bool AddDeleteMessageAction(
|
|||
Ui::show(Box<DeleteMessagesBox>(item, suggestModerateActions));
|
||||
}
|
||||
});
|
||||
menu->addAction(tr::lng_context_delete_msg(tr::now), callback);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -305,6 +305,10 @@ Main::Session &ListWidget::session() const {
|
|||
return _controller->session();
|
||||
}
|
||||
|
||||
not_null<Window::SessionController*> ListWidget::controller() const {
|
||||
return _controller;
|
||||
}
|
||||
|
||||
not_null<ListDelegate*> ListWidget::delegate() const {
|
||||
return _delegate;
|
||||
}
|
||||
|
|
|
@ -137,9 +137,9 @@ public:
|
|||
not_null<Window::SessionController*> controller,
|
||||
not_null<ListDelegate*> delegate);
|
||||
|
||||
Main::Session &session() const;
|
||||
|
||||
not_null<ListDelegate*> delegate() const;
|
||||
[[nodiscard]] Main::Session &session() const;
|
||||
[[nodiscard]] not_null<Window::SessionController*> controller() const;
|
||||
[[nodiscard]] not_null<ListDelegate*> delegate() const;
|
||||
|
||||
// Set the correct scroll position after being resized.
|
||||
void restoreScrollPosition();
|
||||
|
@ -437,8 +437,8 @@ private:
|
|||
|
||||
static constexpr auto kMinimalIdsLimit = 24;
|
||||
|
||||
not_null<ListDelegate*> _delegate;
|
||||
not_null<Window::SessionController*> _controller;
|
||||
const not_null<ListDelegate*> _delegate;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
Data::MessagePosition _aroundPosition;
|
||||
Data::MessagePosition _shownAtPosition;
|
||||
Context _context;
|
||||
|
|
|
@ -1668,8 +1668,10 @@ ClickHandlerPtr Message::fastReplyLink() const {
|
|||
const auto itemId = data()->fullId();
|
||||
_fastReplyLink = std::make_shared<LambdaClickHandler>([=] {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (const auto main = App::main()) {
|
||||
main->replyToItem(item);
|
||||
if (const auto main = App::main()) { // multi good
|
||||
if (&main->session() == &owner->session()) {
|
||||
main->replyToItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1108,7 +1108,7 @@ void MainWidget::onSendFileConfirm(
|
|||
_history->sendFileConfirmed(file, oldId);
|
||||
}
|
||||
|
||||
bool MainWidget::onSendSticker(DocumentData *document) {
|
||||
bool MainWidget::sendExistingDocument(not_null<DocumentData*> document) {
|
||||
return _history->sendExistingDocument(document);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
void onSendFileConfirm(
|
||||
const std::shared_ptr<FileLoadResult> &file,
|
||||
const std::optional<FullMsgId> &oldId);
|
||||
bool onSendSticker(DocumentData *sticker);
|
||||
bool sendExistingDocument(not_null<DocumentData*> sticker);
|
||||
|
||||
bool isActive() const;
|
||||
[[nodiscard]] bool doWeMarkAsRead() const;
|
||||
|
|
|
@ -1444,6 +1444,10 @@ void OverlayWidget::onForward() {
|
|||
if (!_session) {
|
||||
return;
|
||||
}
|
||||
const auto &active = _session->windows();
|
||||
if (active.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto item = _session->data().message(_msgid);
|
||||
if (!item || !IsServerMsgId(item->id) || item->serviceMsg()) {
|
||||
return;
|
||||
|
@ -1451,7 +1455,7 @@ void OverlayWidget::onForward() {
|
|||
|
||||
close();
|
||||
Window::ShowForwardMessagesBox(
|
||||
App::wnd()->sessionController(),
|
||||
active.front(),
|
||||
{ 1, item->fullId() });
|
||||
}
|
||||
|
||||
|
@ -1474,8 +1478,12 @@ void OverlayWidget::onDelete() {
|
|||
return false;
|
||||
};
|
||||
|
||||
const auto &active = _session->windows();
|
||||
if (active.empty()) {
|
||||
return;
|
||||
}
|
||||
if (deletingPeerPhoto()) {
|
||||
App::main()->deletePhotoLayer(_photo);
|
||||
active.front()->content()->deletePhotoLayer(_photo);
|
||||
} else if (const auto item = session->data().message(_msgid)) {
|
||||
const auto suggestModerateActions = true;
|
||||
Ui::show(Box<DeleteMessagesBox>(item, suggestModerateActions));
|
||||
|
|
|
@ -602,18 +602,20 @@ void AppendEmojiPacks(
|
|||
}
|
||||
|
||||
- (void) buttonActionPin:(NSButton *)sender {
|
||||
const auto active = Core::App().activeWindow();
|
||||
const auto controller = active ? active->sessionController() : nullptr;
|
||||
const auto openFolder = [=] {
|
||||
if (!App::wnd()) {
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
if (const auto folder = _session->data().folderLoaded(Data::Folder::kId)) {
|
||||
App::wnd()->sessionController()->openFolder(folder);
|
||||
controller->openFolder(folder);
|
||||
}
|
||||
};
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([=] {
|
||||
self.number == kArchiveId
|
||||
? openFolder()
|
||||
: App::main()->choosePeer(self.number == kSavedMessagesId
|
||||
: controller->content()->choosePeer(self.number == kSavedMessagesId
|
||||
? _session->userPeerId()
|
||||
: self.peer->id, ShowAtUnreadMsgId);
|
||||
});
|
||||
|
@ -1477,6 +1479,8 @@ void AppendEmojiPacks(
|
|||
- (void) buttonAction:(NSButton *)sender {
|
||||
const auto command = sender.tag;
|
||||
|
||||
const auto active = Core::App().activeWindow();
|
||||
const auto controller = active ? active->sessionController() : nullptr;
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([=] {
|
||||
switch (command) {
|
||||
case kCommandPlayPause:
|
||||
|
@ -1489,7 +1493,7 @@ void AppendEmojiPacks(
|
|||
Media::Player::instance()->next(kSongType);
|
||||
break;
|
||||
case kCommandClosePlayer:
|
||||
App::main()->closeBothPlayers();
|
||||
controller->content()->closeBothPlayers();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -384,6 +384,7 @@ private:
|
|||
crl::time radialTimeShift() const;
|
||||
void radialAnimationCallback(crl::time now);
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
QPixmap _background;
|
||||
object_ptr<Ui::LinkButton> _chooseFromGallery;
|
||||
object_ptr<Ui::LinkButton> _chooseFromFile;
|
||||
|
@ -400,6 +401,7 @@ BackgroundRow::BackgroundRow(
|
|||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: RpWidget(parent)
|
||||
, _controller(controller)
|
||||
, _chooseFromGallery(
|
||||
this,
|
||||
tr::lng_settings_bg_from_gallery(tr::now),
|
||||
|
@ -433,7 +435,7 @@ void BackgroundRow::paintEvent(QPaintEvent *e) {
|
|||
const auto radial = _radial.animating();
|
||||
const auto radialOpacity = radial ? _radial.opacity() : 0.;
|
||||
if (radial) {
|
||||
const auto backThumb = App::main()->newBackgroundThumb();
|
||||
const auto backThumb = _controller->content()->newBackgroundThumb();
|
||||
if (!backThumb) {
|
||||
p.drawPixmap(0, 0, _background);
|
||||
} else {
|
||||
|
@ -494,14 +496,14 @@ int BackgroundRow::resizeGetHeight(int newWidth) {
|
|||
}
|
||||
|
||||
float64 BackgroundRow::radialProgress() const {
|
||||
return App::main()->chatBackgroundProgress();
|
||||
return _controller->content()->chatBackgroundProgress();
|
||||
}
|
||||
|
||||
bool BackgroundRow::radialLoading() const {
|
||||
const auto main = App::main();
|
||||
if (main->chatBackgroundLoading()) {
|
||||
main->checkChatBackground();
|
||||
if (main->chatBackgroundLoading()) {
|
||||
const auto widget = _controller->content();
|
||||
if (widget->chatBackgroundLoading()) {
|
||||
widget->checkChatBackground();
|
||||
if (widget->chatBackgroundLoading()) {
|
||||
return true;
|
||||
} else {
|
||||
const_cast<BackgroundRow*>(this)->updateImage();
|
||||
|
@ -788,9 +790,7 @@ void SetupMessages(
|
|||
|
||||
group->setChangedCallback([=](SendByType value) {
|
||||
controller->session().settings().setSendSubmitWay(value);
|
||||
if (App::main()) {
|
||||
App::main()->ctrlEnterSubmitUpdated();
|
||||
}
|
||||
controller->content()->ctrlEnterSubmitUpdated();
|
||||
controller->session().saveSettingsDelayed();
|
||||
});
|
||||
|
||||
|
|
|
@ -246,7 +246,8 @@ void BlockedBoxController::loadMoreRows() {
|
|||
}
|
||||
|
||||
void BlockedBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
InvokeQueued(App::main(), [peerId = row->peer()->id] {
|
||||
const auto peer = row->peer();
|
||||
crl::on_main(&peer->session(), [peerId = peer->id] {
|
||||
Ui::showPeerHistory(peerId, ShowAtUnreadMsgId);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -170,7 +170,9 @@ bool PinnedLimitReached(Dialogs::Key key, FilterId filterId) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void TogglePinnedDialog(Dialogs::Key key) {
|
||||
void TogglePinnedDialog(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Dialogs::Key key) {
|
||||
if (!key.entry()->folderKnown()) {
|
||||
return;
|
||||
}
|
||||
|
@ -198,15 +200,16 @@ void TogglePinnedDialog(Dialogs::Key key) {
|
|||
)).send();
|
||||
}
|
||||
if (isPinned) {
|
||||
if (const auto main = App::main()) {
|
||||
main->dialogsToUp();
|
||||
}
|
||||
controller->content()->dialogsToUp();
|
||||
}
|
||||
}
|
||||
|
||||
void TogglePinnedDialog(Dialogs::Key key, FilterId filterId) {
|
||||
void TogglePinnedDialog(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Dialogs::Key key,
|
||||
FilterId filterId) {
|
||||
if (!filterId) {
|
||||
return TogglePinnedDialog(key);
|
||||
return TogglePinnedDialog(controller, key);
|
||||
}
|
||||
const auto owner = &key.entry()->owner();
|
||||
|
||||
|
@ -227,9 +230,7 @@ void TogglePinnedDialog(Dialogs::Key key, FilterId filterId) {
|
|||
owner->setChatPinned(key, filterId, isPinned);
|
||||
Api::SaveNewFilterPinned(&owner->session(), filterId);
|
||||
if (isPinned) {
|
||||
if (const auto main = App::main()) {
|
||||
main->dialogsToUp();
|
||||
}
|
||||
controller->content()->dialogsToUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +316,10 @@ void Filler::addTogglePin() {
|
|||
: tr::lng_context_pin_to_top(tr::now);
|
||||
};
|
||||
const auto pinToggle = [=] {
|
||||
TogglePinnedDialog(peer->owner().history(peer), filterId);
|
||||
TogglePinnedDialog(
|
||||
_controller,
|
||||
peer->owner().history(peer),
|
||||
filterId);
|
||||
};
|
||||
const auto pinAction = _addAction(pinText(isPinned), pinToggle);
|
||||
|
||||
|
@ -344,8 +348,10 @@ void Filler::addInfo() {
|
|||
}
|
||||
|
||||
//void Filler::addSearch() {
|
||||
// _addAction(tr::lng_profile_search_messages(tr::now), [peer = _peer] {
|
||||
// App::main()->searchInChat(peer->owner().history(peer));
|
||||
// const auto controller = _controller;
|
||||
// const auto peer = _peer;
|
||||
// _addAction(tr::lng_profile_search_messages(tr::now), [=] {
|
||||
// controller->content()->searchInChat(peer->owner().history(peer));
|
||||
// });
|
||||
//}
|
||||
|
||||
|
@ -689,8 +695,8 @@ void FolderFiller::addTogglesForArchive() {
|
|||
}
|
||||
//
|
||||
//void FolderFiller::addInfo() {
|
||||
// auto controller = _controller;
|
||||
// auto feed = _feed;
|
||||
// const auto controller = _controller;
|
||||
// const auto feed = _feed;
|
||||
// _addAction(tr::lng_context_view_feed_info(tr::now), [=] {
|
||||
// controller->showSection(Info::Memento(
|
||||
// feed,
|
||||
|
@ -707,8 +713,9 @@ void FolderFiller::addTogglesForArchive() {
|
|||
//
|
||||
//void FolderFiller::addSearch() {
|
||||
// const auto feed = _feed;
|
||||
// const auto controller = _controller;
|
||||
// _addAction(tr::lng_profile_search_messages(tr::now), [=] {
|
||||
// App::main()->searchInChat(feed);
|
||||
// controller->content()->searchInChat(feed);
|
||||
// });
|
||||
//}
|
||||
//
|
||||
|
|
Loading…
Add table
Reference in a new issue