mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
moved context bots to emojipan, fixed webpage thumb image size
This commit is contained in:
@@ -491,7 +491,7 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class EmojiPan : public TWidget {
|
||||
class EmojiPan : public TWidget, public RPCSender {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -524,6 +524,9 @@ public:
|
||||
bool eventFilter(QObject *obj, QEvent *e);
|
||||
void stickersInstalled(uint64 setId);
|
||||
|
||||
void showContextResults(UserData *bot, QString query);
|
||||
void clearContextResults();
|
||||
|
||||
bool overlaps(const QRect &globalRect) {
|
||||
if (isHidden() || !_cache.isNull()) return false;
|
||||
|
||||
@@ -563,6 +566,8 @@ public slots:
|
||||
void onSaveConfig();
|
||||
void onSaveConfigDelayed(int32 delay);
|
||||
|
||||
void onContextRequest();
|
||||
|
||||
signals:
|
||||
|
||||
void emojiSelected(EmojiPtr emoji);
|
||||
@@ -633,12 +638,50 @@ private:
|
||||
|
||||
QTimer _saveConfigTimer;
|
||||
|
||||
// context bots
|
||||
struct ContextResult {
|
||||
ContextResult(uint64 queryId)
|
||||
: queryId(queryId)
|
||||
, doc(0)
|
||||
, photo(0)
|
||||
, width(0)
|
||||
, height(0)
|
||||
, duration(0)
|
||||
, noWebPage(false) {
|
||||
}
|
||||
uint64 queryId;
|
||||
QString id, type;
|
||||
DocumentData *doc;
|
||||
PhotoData *photo;
|
||||
QString title, description, url, thumb_url;
|
||||
QString content_type, content_url;
|
||||
int32 width, height, duration;
|
||||
|
||||
QString message; // botContextMessageText
|
||||
bool noWebPage;
|
||||
EntitiesInText entities;
|
||||
QString caption; // if message.isEmpty() use botContextMessageMediaAuto
|
||||
};
|
||||
struct ContextCacheEntry {
|
||||
QString nextOffset;
|
||||
QList<ContextResult> results;
|
||||
};
|
||||
typedef QMap<QString, ContextCacheEntry> ContextCache;
|
||||
ContextCache _contextCache;
|
||||
QTimer _contextRequestTimer;
|
||||
|
||||
void refreshContextRows(bool toDown);
|
||||
UserData *_contextBot;
|
||||
QString _contextQuery, _contextNextQuery, _contextNextOffset;
|
||||
mtpRequestId _contextRequestId;
|
||||
void contextResultsDone(const MTPmessages_BotResults &result);
|
||||
bool contextResultsFail(const RPCError &error);
|
||||
|
||||
};
|
||||
|
||||
typedef QList<UserData*> MentionRows;
|
||||
typedef QList<QString> HashtagRows;
|
||||
typedef QList<QPair<UserData*, const BotCommand*> > BotCommandRows;
|
||||
typedef QList<QString> ContextRows;
|
||||
|
||||
class MentionsDropdown;
|
||||
class MentionsInner : public TWidget {
|
||||
@@ -646,7 +689,7 @@ class MentionsInner : public TWidget {
|
||||
|
||||
public:
|
||||
|
||||
MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows, ContextRows *crows);
|
||||
MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows);
|
||||
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
@@ -680,7 +723,6 @@ private:
|
||||
MentionRows *_mrows;
|
||||
HashtagRows *_hrows;
|
||||
BotCommandRows *_brows;
|
||||
ContextRows *_crows;
|
||||
int32 _sel;
|
||||
bool _mouseSel;
|
||||
QPoint _mousePos;
|
||||
@@ -688,7 +730,7 @@ private:
|
||||
bool _overDelete;
|
||||
};
|
||||
|
||||
class MentionsDropdown : public TWidget, public RPCSender {
|
||||
class MentionsDropdown : public TWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -700,7 +742,6 @@ public:
|
||||
void fastHide();
|
||||
|
||||
bool clearFilteredBotCommands();
|
||||
void showContextResults(UserData *bot, QString query);
|
||||
void showFiltered(PeerData *peer, QString start);
|
||||
void updateFiltered(bool toDown = false);
|
||||
void setBoundings(QRect boundings);
|
||||
@@ -723,11 +764,6 @@ public:
|
||||
|
||||
return rect().contains(QRect(mapFromGlobal(globalRect.topLeft()), globalRect.size()));
|
||||
}
|
||||
void clearContextResults();
|
||||
|
||||
void ui_repaintSavedGif(const LayoutSavedGif *layout);
|
||||
bool ui_isSavedGifVisible(const LayoutSavedGif *layout);
|
||||
bool ui_isGifBeingChosen();
|
||||
|
||||
~MentionsDropdown();
|
||||
|
||||
@@ -741,7 +777,6 @@ public slots:
|
||||
void hideFinish();
|
||||
|
||||
void showStart();
|
||||
void onContextRequest();
|
||||
|
||||
private:
|
||||
|
||||
@@ -751,51 +786,12 @@ private:
|
||||
MentionRows _mrows;
|
||||
HashtagRows _hrows;
|
||||
BotCommandRows _brows;
|
||||
ContextRows _crows;
|
||||
|
||||
struct ContextResult {
|
||||
ContextResult(uint64 queryId)
|
||||
: queryId(queryId)
|
||||
, doc(0)
|
||||
, photo(0)
|
||||
, width(0)
|
||||
, height(0)
|
||||
, duration(0)
|
||||
, noWebPage(false) {
|
||||
}
|
||||
uint64 queryId;
|
||||
QString id, type;
|
||||
DocumentData *doc;
|
||||
PhotoData *photo;
|
||||
QString title, description, url, thumb_url;
|
||||
QString content_type, content_url;
|
||||
int32 width, height, duration;
|
||||
|
||||
QString message; // botContextMessageText
|
||||
bool noWebPage;
|
||||
EntitiesInText entities;
|
||||
QString caption; // if message.isEmpty() use botContextMessageMediaAuto
|
||||
};
|
||||
struct ContextCacheEntry {
|
||||
QString nextOffset;
|
||||
QList<ContextResult> results;
|
||||
};
|
||||
typedef QMap<QString, ContextCacheEntry> ContextCache;
|
||||
ContextCache _contextCache;
|
||||
QTimer _contextRequestTimer;
|
||||
|
||||
void refreshContextRows(bool toDown);
|
||||
void rowsUpdated(const MentionRows &rows, const HashtagRows &hrows, const BotCommandRows &brows, const ContextRows &crows, bool toDown);
|
||||
void rowsUpdated(const MentionRows &rows, const HashtagRows &hrows, const BotCommandRows &brows, bool toDown);
|
||||
|
||||
ScrollArea _scroll;
|
||||
MentionsInner _inner;
|
||||
|
||||
UserData *_contextBot;
|
||||
QString _contextQuery, _contextNextQuery, _contextNextOffset;
|
||||
mtpRequestId _contextRequestId;
|
||||
void contextResultsDone(const MTPmessages_BotResults &result);
|
||||
bool contextResultsFail(const RPCError &error);
|
||||
|
||||
ChatData *_chat;
|
||||
UserData *_user;
|
||||
ChannelData *_channel;
|
||||
|
Reference in New Issue
Block a user