2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 00:25:17 +00:00

Initial chat theme changing.

This commit is contained in:
John Preston
2021-09-24 19:10:25 +04:00
parent 80028e41f3
commit ab0d2bf9c6
20 changed files with 773 additions and 120 deletions

View File

@@ -125,6 +125,14 @@ void ActivateWindow(not_null<SessionController*> controller) {
Ui::ActivateWindowDelayed(window);
}
bool operator==(const PeerThemeOverride &a, const PeerThemeOverride &b) {
return (a.peer == b.peer) && (a.theme == b.theme);
}
bool operator!=(const PeerThemeOverride &a, const PeerThemeOverride &b) {
return !(a == b);
}
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
: _chat(chat)
, _date(date) {
@@ -1208,6 +1216,10 @@ void SessionController::clearChooseReportMessages() {
content()->clearChooseReportMessages();
}
void SessionController::toggleChooseChatTheme(not_null<PeerData*> peer) {
content()->toggleChooseChatTheme(peer);
}
void SessionController::updateColumnLayout() {
content()->updateColumnLayout();
}
@@ -1397,7 +1409,7 @@ auto SessionController::cachedChatThemeValue(
const auto i = _customChatThemes.find(key);
if (i != end(_customChatThemes)) {
if (auto strong = i->second.theme.lock()) {
pushToLastUsed(strong);
pushLastUsedChatTheme(strong);
return rpl::single(std::move(strong));
}
}
@@ -1413,12 +1425,12 @@ auto SessionController::cachedChatThemeValue(
if (theme->key() != key) {
return false;
}
pushToLastUsed(theme);
pushLastUsedChatTheme(theme);
return true;
}) | rpl::take(limit));
}
void SessionController::pushToLastUsed(
void SessionController::pushLastUsedChatTheme(
const std::shared_ptr<Ui::ChatTheme> &theme) {
const auto i = ranges::find(_lastUsedCustomChatThemes, theme);
if (i == end(_lastUsedCustomChatThemes)) {
@@ -1444,6 +1456,21 @@ void SessionController::clearCachedChatThemes() {
_customChatThemes.clear();
}
void SessionController::overridePeerTheme(
not_null<PeerData*> peer,
std::shared_ptr<Ui::ChatTheme> theme) {
_peerThemeOverride = PeerThemeOverride{
peer,
theme ? theme : _defaultChatTheme,
};
}
void SessionController::clearPeerThemeOverride(not_null<PeerData*> peer) {
if (_peerThemeOverride.current().peer == peer.get()) {
_peerThemeOverride = PeerThemeOverride();
}
}
void SessionController::pushDefaultChatBackground() {
const auto background = Theme::Background();
const auto &paper = background->paper();