| 378 | } |
| 379 | |
| 380 | BackgroundBox::Inner::Inner( |
| 381 | QWidget *parent, |
| 382 | not_null<Main::Session*> session, |
| 383 | PeerData *forPeer) |
| 384 | : RpWidget(parent) |
| 385 | , _session(session) |
| 386 | , _forPeer(forPeer) |
| 387 | , _api(&_session->mtp()) |
| 388 | , _check( |
| 389 | std::make_unique<Ui::RoundCheckbox>( |
| 390 | st::overviewCheck, |
| 391 | [=] { update(); })) { |
| 392 | _check->setChecked(true, anim::type::instant); |
| 393 | resize( |
| 394 | st::boxWideWidth, |
| 395 | (2 * (st::backgroundSize.height() + st::backgroundPadding) |
| 396 | + st::backgroundPadding)); |
| 397 | |
| 398 | Window::Theme::IsNightModeValue( |
| 399 | ) | rpl::on_next([=] { |
| 400 | updatePapers(); |
| 401 | }, lifetime()); |
| 402 | requestPapers(); |
| 403 | |
| 404 | _session->downloaderTaskFinished( |
| 405 | ) | rpl::on_next([=] { |
| 406 | update(); |
| 407 | }, lifetime()); |
| 408 | |
| 409 | style::PaletteChanged( |
| 410 | ) | rpl::on_next([=] { |
| 411 | _check->invalidateCache(); |
| 412 | }, lifetime()); |
| 413 | |
| 414 | if (forChannel()) { |
| 415 | _session->data().cloudThemes().chatThemesUpdated( |
| 416 | ) | rpl::on_next([=] { |
| 417 | updatePapers(); |
| 418 | }, lifetime()); |
| 419 | } else { |
| 420 | using Update = Window::Theme::BackgroundUpdate; |
| 421 | Window::Theme::Background()->updates( |
| 422 | ) | rpl::on_next([=](const Update &update) { |
| 423 | if (update.type == Update::Type::New) { |
| 424 | sortPapers(); |
| 425 | requestPapers(); |
| 426 | this->update(); |
| 427 | } |
| 428 | }, lifetime()); |
| 429 | } |
| 430 | |
| 431 | setMouseTracking(true); |
| 432 | } |
| 433 | |
| 434 | void BackgroundBox::Inner::requestPapers() { |
| 435 | if (forChannel()) { |
nothing calls this directly
no test coverage detected