tdesktop/Telegram/SourceFiles/facades.cpp

93 lines
2.3 KiB
C++
Raw Normal View History

2015-12-07 13:05:00 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2015-12-07 13:05:00 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2015-12-07 13:05:00 +00:00
*/
2017-09-13 16:57:44 +00:00
#include "facades.h"
#include "api/api_bot.h"
#include "info/info_memento.h"
#include "inline_bots/bot_attach_web_view.h"
#include "core/click_handler_types.h"
#include "core/application.h"
#include "media/clip/media_clip_reader.h"
#include "window/window_session_controller.h"
#include "window/window_peer_menu.h"
#include "history/history_item_components.h"
2019-09-17 16:13:12 +00:00
#include "base/platform/base_platform_info.h"
#include "data/data_peer.h"
#include "data/data_user.h"
#include "mainwindow.h"
2015-12-07 13:05:00 +00:00
#include "mainwidget.h"
#include "apiwrap.h"
2019-07-24 11:45:24 +00:00
#include "main/main_session.h"
2020-06-26 11:48:28 +00:00
#include "main/main_domain.h"
2021-10-18 21:36:55 +00:00
#include "ui/boxes/confirm_box.h"
2019-05-22 14:29:02 +00:00
#include "boxes/url_auth_box.h"
2019-09-18 11:19:05 +00:00
#include "ui/layers/layer_widget.h"
2017-04-13 08:27:10 +00:00
#include "lang/lang_keys.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/view/media/history_view_media.h"
2021-03-23 12:34:34 +00:00
#include "payments/payments_checkout_process.h"
#include "data/data_session.h"
2020-10-10 09:15:37 +00:00
#include "styles/style_chat.h"
2020-06-26 11:48:28 +00:00
namespace {
[[nodiscard]] MainWidget *CheckMainWidget(not_null<Main::Session*> session) {
if (const auto m = App::main()) { // multi good
if (&m->session() == session) {
return m;
}
}
if (&Core::App().domain().active() != &session->account()) {
Core::App().domain().activate(&session->account());
}
if (const auto m = App::main()) { // multi good
if (&m->session() == session) {
return m;
}
}
return nullptr;
}
} // namespace
2015-12-07 13:05:00 +00:00
namespace Ui {
2015-12-07 18:09:05 +00:00
void showChatsList(not_null<Main::Session*> session) {
2020-06-26 11:48:28 +00:00
if (const auto m = CheckMainWidget(session)) {
m->ui_showPeerHistory(
0,
::Window::SectionShow::Way::ClearStack,
2020-06-26 11:48:28 +00:00
0);
}
}
void showPeerHistory(not_null<const History*> history, MsgId msgId) {
2020-06-10 18:08:17 +00:00
showPeerHistory(history->peer, msgId);
}
2020-06-10 18:08:17 +00:00
void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId) {
2020-06-26 11:48:28 +00:00
if (const auto m = CheckMainWidget(&peer->session())) {
m->ui_showPeerHistory(
peer->id,
::Window::SectionShow::Way::ClearStack,
2020-06-26 11:48:28 +00:00
msgId);
2020-06-10 18:08:17 +00:00
}
}
bool skipPaintEvent(QWidget *widget, QPaintEvent *event) {
if (auto w = App::wnd()) {
if (w->contentOverlapped(widget, event)) {
return true;
}
}
return false;
}
} // namespace Ui