2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Use rpl for Window::Theme::Background updates.

This commit is contained in:
John Preston
2021-07-15 14:12:38 +03:00
parent 7e83088a84
commit 4276b6cce0
66 changed files with 203 additions and 262 deletions

View File

@@ -242,7 +242,6 @@ MainWidget::MainWidget(
, _cacheBackgroundTimer([=] { cacheBackground(); })
, _viewsIncrementTimer([=] { viewsIncrement(); })
, _changelogs(Core::Changelogs::Create(&controller->session())) {
updateScrollColors();
setupConnectingWidget();
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
@@ -347,11 +346,13 @@ MainWidget::MainWidget(
QCoreApplication::instance()->installEventFilter(this);
using Update = Window::Theme::BackgroundUpdate;
subscribe(Window::Theme::Background(), [this](const Update &update) {
if (update.type == Update::Type::New || update.type == Update::Type::Changed) {
Window::Theme::Background()->updates(
) | rpl::start_with_next([=](const Update &update) {
if (update.type == Update::Type::New
|| update.type == Update::Type::Changed) {
clearCachedBackground();
}
});
}, lifetime());
subscribe(Media::Player::instance()->playerWidgetOver(), [this](bool over) {
if (over) {
@@ -1173,10 +1174,6 @@ QPixmap MainWidget::cachedBackground(const QRect &forRect, int &x, int &y) {
return QPixmap();
}
void MainWidget::updateScrollColors() {
_history->updateScrollColors();
}
void MainWidget::setChatBackground(
const Data::WallPaper &background,
QImage &&image) {
@@ -1197,8 +1194,7 @@ void MainWidget::setChatBackground(
checkChatBackground();
const auto tile = Data::IsLegacy1DefaultWallPaper(background);
using Update = Window::Theme::BackgroundUpdate;
Window::Theme::Background()->notify(Update(Update::Type::Start, tile));
Window::Theme::Background()->downloadingStarted(tile);
}
bool MainWidget::isReadyChatBackground(