2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 16:45:12 +00:00

Remove some usages of App::main().

This commit is contained in:
John Preston
2020-06-10 22:08:17 +04:00
parent ea86433be5
commit ee43027bea
53 changed files with 518 additions and 429 deletions

View File

@@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h"
#include "boxes/confirm_box.h"
#include "boxes/background_preview_box.h"
#include "window/window_session_controller.h"
#include "app.h"
#include "styles/style_history.h"
#include "styles/style_layers.h"
@@ -396,18 +397,18 @@ QImage PrepareScaledFromFull(
BackgroundPreviewBox::BackgroundPreviewBox(
QWidget*,
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const Data::WallPaper &paper)
: _session(session)
: _controller(controller)
, _text1(GenerateTextItem(
delegate(),
_session->data().history(
_controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text1(tr::now),
false))
, _text2(GenerateTextItem(
delegate(),
_session->data().history(
_controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text2(tr::now),
true))
@@ -417,7 +418,9 @@ BackgroundPreviewBox::BackgroundPreviewBox(
if (_media) {
_media->thumbnailWanted(_paper.fileOrigin());
}
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
subscribe(_controller->session().downloaderTaskFinished(), [=] {
update();
});
}
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
@@ -500,9 +503,9 @@ void BackgroundPreviewBox::createBlurCheckbox() {
void BackgroundPreviewBox::apply() {
const auto install = (_paper.id() != Window::Theme::Background()->id())
&& Data::IsCloudWallPaper(_paper);
App::main()->setChatBackground(_paper, std::move(_full));
_controller->content()->setChatBackground(_paper, std::move(_full));
if (install) {
_session->api().request(MTPaccount_InstallWallPaper(
_controller->session().api().request(MTPaccount_InstallWallPaper(
_paper.mtpInput(),
_paper.mtpSettings()
)).send();
@@ -763,12 +766,12 @@ void BackgroundPreviewBox::checkLoadedDocument() {
}
bool BackgroundPreviewBox::Start(
not_null<Main::Session*> session,
not_null<Window::SessionController*> controller,
const QString &slug,
const QMap<QString, QString> &params) {
if (const auto paper = Data::WallPaper::FromColorSlug(slug)) {
Ui::show(Box<BackgroundPreviewBox>(
session,
controller,
paper->withUrlParams(params)));
return true;
}
@@ -776,9 +779,10 @@ bool BackgroundPreviewBox::Start(
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
return false;
}
session->api().requestWallPaper(slug, [=](const Data::WallPaper &result) {
controller->session().api().requestWallPaper(slug, [=](
const Data::WallPaper &result) {
Ui::show(Box<BackgroundPreviewBox>(
session,
controller,
result.withUrlParams(params)));
}, [](const RPCError &error) {
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));