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:
@@ -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();
|
||||
|
Reference in New Issue
Block a user