init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
80
Telegram/lib_ui/ui/widgets/fields/custom_field_object.h
Normal file
80
Telegram/lib_ui/ui/widgets/fields/custom_field_object.h
Normal file
@@ -0,0 +1,80 @@
|
||||
// This file is part of Desktop App Toolkit,
|
||||
// a set of libraries for developing nice desktop applications.
|
||||
//
|
||||
// For license and copyright information please follow this link:
|
||||
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <QtGui/QTextObjectInterface>
|
||||
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/text/text.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class InputField;
|
||||
class RpWidget;
|
||||
struct InputFieldTextRange;
|
||||
|
||||
class CustomFieldObject : public QObject, public QTextObjectInterface {
|
||||
public:
|
||||
CustomFieldObject(
|
||||
not_null<InputField*> field,
|
||||
Text::MarkedContext context,
|
||||
Fn<bool()> pausedEmoji,
|
||||
Fn<bool()> pausedSpoiler);
|
||||
~CustomFieldObject();
|
||||
|
||||
void *qt_metacast(const char *iid) override;
|
||||
|
||||
QSizeF intrinsicSize(
|
||||
QTextDocument *doc,
|
||||
int posInDocument,
|
||||
const QTextFormat &format) override;
|
||||
void drawObject(
|
||||
QPainter *painter,
|
||||
const QRectF &rect,
|
||||
QTextDocument *doc,
|
||||
int posInDocument,
|
||||
const QTextFormat &format) override;
|
||||
|
||||
void setCollapsedText(int quoteId, TextWithTags text);
|
||||
[[nodiscard]] const TextWithTags &collapsedText(int quoteId) const;
|
||||
|
||||
void setNow(crl::time now);
|
||||
|
||||
void clearEmoji();
|
||||
void clearQuotes();
|
||||
|
||||
[[nodiscard]] std::unique_ptr<RpWidget> createSpoilerOverlay();
|
||||
void refreshSpoilerShown(InputFieldTextRange range);
|
||||
|
||||
private:
|
||||
struct Quote {
|
||||
TextWithTags text;
|
||||
Text::String string;
|
||||
};
|
||||
|
||||
using Factory = Fn<std::unique_ptr<Text::CustomEmoji>(QStringView)>;
|
||||
[[nodiscard]] Factory makeFactory();
|
||||
[[nodiscard]] Text::MarkedContext makeFieldContext();
|
||||
|
||||
const not_null<InputField*> _field;
|
||||
const Text::MarkedContext _context;
|
||||
const Fn<bool()> _pausedEmoji;
|
||||
const Fn<bool()> _pausedSpoiler;
|
||||
const Factory _factory;
|
||||
|
||||
base::flat_map<uint64, std::unique_ptr<Text::CustomEmoji>> _emoji;
|
||||
base::flat_map<int, Quote> _quotes;
|
||||
crl::time _now = 0;
|
||||
int _skip = 0;
|
||||
|
||||
Animations::Simple _spoilerOpacity;
|
||||
bool _spoilerHidden = false;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user