2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Colorize bubbles according to a custom chat theme.

This commit is contained in:
John Preston
2021-08-27 23:44:47 +03:00
parent 5de83ef30c
commit beff635e45
38 changed files with 479 additions and 165 deletions

View File

@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "support/support_autocomplete.h"
#include "ui/chat/chat_theme.h"
#include "ui/chat/chat_style.h"
#include "ui/widgets/scroll_area.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/buttons.h"
@@ -25,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "apiwrap.h"
#include "window/window_session_controller.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_window.h"
#include "styles/style_layers.h"
@@ -502,9 +504,11 @@ ConfirmContactBox::ConfirmContactBox(
const Contact &data,
Fn<void(Qt::KeyboardModifiers)> submit)
: SimpleElementDelegate(controller, [=] { update(); })
, _chatStyle(std::make_unique<Ui::ChatStyle>())
, _comment(GenerateCommentItem(this, history, data))
, _contact(GenerateContactItem(this, history, data))
, _submit(submit) {
_chatStyle->apply(controller->defaultChatTheme().get());
}
void ConfirmContactBox::prepare() {
@@ -565,13 +569,11 @@ void ConfirmContactBox::paintEvent(QPaintEvent *e) {
p.fillRect(e->rect(), st::boxBg);
const auto context = HistoryView::PaintContext{
.st = style::main_palette::get(),
.bubblesPattern = nullptr, // #TODO bubbles
.viewport = rect(),
.clip = rect(),
.now = crl::now(),
};
const auto theme = controller()->defaultChatTheme().get();
const auto context = theme->preparePaintContext(
_chatStyle.get(),
rect(),
rect());
p.translate(st::boxPadding.left(), 0);
if (_comment) {
_comment->draw(p, context);

View File

@@ -24,6 +24,7 @@ class SessionController;
namespace Ui {
class ScrollArea;
class InputField;
class ChatStyle;
} // namespace Ui
namespace Support {
@@ -83,6 +84,7 @@ protected:
void keyPressEvent(QKeyEvent *e) override;
private:
std::unique_ptr<Ui::ChatStyle> _chatStyle;
AdminLog::OwnedItem _comment;
AdminLog::OwnedItem _contact;
Fn<void(Qt::KeyboardModifiers)> _submit;