mirror of https://github.com/procxx/kepka.git
emoji button with progress done for inline bot requests
This commit is contained in:
parent
ff481c810f
commit
85f46cef8c
|
@ -1307,6 +1307,13 @@ btnAttachEmoji: iconedButton(btnAttachDocument) {
|
||||||
|
|
||||||
width: 33px;
|
width: 33px;
|
||||||
}
|
}
|
||||||
|
emojiCircle: size(19px, 19px);
|
||||||
|
emojiCirclePeriod: 1500;
|
||||||
|
emojiCircleDuration: 500;
|
||||||
|
emojiCircleTop: 13px;
|
||||||
|
emojiCircleLine: 2px;
|
||||||
|
emojiCircleFg: #b9b9b9;
|
||||||
|
emojiCirclePart: 3.5;
|
||||||
btnBotKbShow: iconedButton(btnAttachEmoji) {
|
btnBotKbShow: iconedButton(btnAttachEmoji) {
|
||||||
icon: sprite(375px, 74px, 21px, 21px);
|
icon: sprite(375px, 74px, 21px, 21px);
|
||||||
iconPos: point(6px, 12px);
|
iconPos: point(6px, 12px);
|
||||||
|
|
|
@ -548,7 +548,7 @@ void Application::stopUpdate() {
|
||||||
void Application::startUpdateCheck(bool forceWait) {
|
void Application::startUpdateCheck(bool forceWait) {
|
||||||
updateCheckTimer.stop();
|
updateCheckTimer.stop();
|
||||||
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
|
if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
|
||||||
|
|
||||||
int32 constDelay = cBetaVersion() ? 600 : UpdateDelayConstPart, randDelay = cBetaVersion() ? 300 : UpdateDelayRandPart;
|
int32 constDelay = cBetaVersion() ? 600 : UpdateDelayConstPart, randDelay = cBetaVersion() ? 300 : UpdateDelayRandPart;
|
||||||
int32 updateInSecs = cLastUpdateCheck() + constDelay + int32(MTP::nonce<uint32>() % randDelay) - unixtime();
|
int32 updateInSecs = cLastUpdateCheck() + constDelay + int32(MTP::nonce<uint32>() % randDelay) - unixtime();
|
||||||
bool sendRequest = (updateInSecs <= 0 || updateInSecs > (constDelay + randDelay));
|
bool sendRequest = (updateInSecs <= 0 || updateInSecs > (constDelay + randDelay));
|
||||||
|
@ -684,7 +684,7 @@ void Application::socketError(QLocalSocket::LocalSocketError e) {
|
||||||
socket.close();
|
socket.close();
|
||||||
|
|
||||||
psCheckLocalSocket(serverName);
|
psCheckLocalSocket(serverName);
|
||||||
|
|
||||||
if (!server.listen(serverName)) {
|
if (!server.listen(serverName)) {
|
||||||
DEBUG_LOG(("Application Error: failed to start listening to %1 server, error %2").arg(serverName).arg(int(server.serverError())));
|
DEBUG_LOG(("Application Error: failed to start listening to %1 server, error %2").arg(serverName).arg(int(server.serverError())));
|
||||||
return App::quit();
|
return App::quit();
|
||||||
|
@ -769,7 +769,7 @@ void Application::startApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
|
|
||||||
if (state != Local::ReadMapPassNeeded) {
|
if (state != Local::ReadMapPassNeeded) {
|
||||||
checkMapVersion();
|
checkMapVersion();
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ Application::~Application() {
|
||||||
cSetChatDogImage(0);
|
cSetChatDogImage(0);
|
||||||
|
|
||||||
style::stopManager();
|
style::stopManager();
|
||||||
|
|
||||||
delete _translator;
|
delete _translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 238 KiB |
|
@ -3560,10 +3560,13 @@ void EmojiPan::inlineBotChanged() {
|
||||||
}
|
}
|
||||||
_inlineCache.clear();
|
_inlineCache.clear();
|
||||||
s_inner.inlineBotChanged();
|
s_inner.inlineBotChanged();
|
||||||
|
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
||||||
_inlineRequestId = 0;
|
_inlineRequestId = 0;
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
|
|
||||||
InlineCache::iterator it = _inlineCache.find(_inlineQuery);
|
InlineCache::iterator it = _inlineCache.find(_inlineQuery);
|
||||||
|
|
||||||
|
@ -3659,6 +3662,8 @@ void EmojiPan::inlineResultsDone(const MTPmessages_BotResults &result) {
|
||||||
|
|
||||||
bool EmojiPan::inlineResultsFail(const RPCError &error) {
|
bool EmojiPan::inlineResultsFail(const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (mtpIsFlood(error)) return false;
|
||||||
|
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
_inlineRequestId = 0;
|
_inlineRequestId = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3674,6 +3679,7 @@ void EmojiPan::queryInlineBot(UserData *bot, QString query) {
|
||||||
if (_inlineRequestId) {
|
if (_inlineRequestId) {
|
||||||
MTP::cancel(_inlineRequestId);
|
MTP::cancel(_inlineRequestId);
|
||||||
_inlineRequestId = 0;
|
_inlineRequestId = 0;
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
}
|
}
|
||||||
if (_inlineCache.contains(query)) {
|
if (_inlineCache.contains(query)) {
|
||||||
_inlineRequestTimer.stop();
|
_inlineRequestTimer.stop();
|
||||||
|
@ -3696,6 +3702,7 @@ void EmojiPan::onInlineRequest() {
|
||||||
nextOffset = i.value()->nextOffset;
|
nextOffset = i.value()->nextOffset;
|
||||||
if (nextOffset.isEmpty()) return;
|
if (nextOffset.isEmpty()) return;
|
||||||
}
|
}
|
||||||
|
Notify::inlineBotRequesting(true);
|
||||||
_inlineRequestId = MTP::send(MTPmessages_GetInlineBotResults(_inlineBot->inputUser, MTP_string(_inlineQuery), MTP_string(nextOffset)), rpcDone(&EmojiPan::inlineResultsDone), rpcFail(&EmojiPan::inlineResultsFail));
|
_inlineRequestId = MTP::send(MTPmessages_GetInlineBotResults(_inlineBot->inputUser, MTP_string(_inlineQuery), MTP_string(nextOffset)), rpcDone(&EmojiPan::inlineResultsDone), rpcFail(&EmojiPan::inlineResultsFail));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,10 @@ namespace Notify {
|
||||||
if (MainWidget *m = App::main()) m->notify_botCommandsChanged(user);
|
if (MainWidget *m = App::main()) m->notify_botCommandsChanged(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inlineBotRequesting(bool requesting) {
|
||||||
|
if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting);
|
||||||
|
}
|
||||||
|
|
||||||
void migrateUpdated(PeerData *peer) {
|
void migrateUpdated(PeerData *peer) {
|
||||||
if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer);
|
if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,8 @@ namespace Notify {
|
||||||
void userIsContactChanged(UserData *user, bool fromThisApp = false);
|
void userIsContactChanged(UserData *user, bool fromThisApp = false);
|
||||||
void botCommandsChanged(UserData *user);
|
void botCommandsChanged(UserData *user);
|
||||||
|
|
||||||
|
void inlineBotRequesting(bool requesting);
|
||||||
|
|
||||||
void migrateUpdated(PeerData *peer);
|
void migrateUpdated(PeerData *peer);
|
||||||
|
|
||||||
void clipStopperHidden(ClipStopperType type);
|
void clipStopperHidden(ClipStopperType type);
|
||||||
|
|
|
@ -289,6 +289,59 @@ void MaskedButton::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EmojiButton::EmojiButton(QWidget *parent, const style::iconedButton &st) : IconedButton(parent, st)
|
||||||
|
, _loading(false)
|
||||||
|
, _a_loading(animation(this, &EmojiButton::step_loading)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmojiButton::paintEvent(QPaintEvent *e) {
|
||||||
|
QPainter p(this);
|
||||||
|
|
||||||
|
uint64 ms = getms();
|
||||||
|
float64 loading = a_loading.current(ms, _loading ? 1 : 0);
|
||||||
|
p.setOpacity(_opacity * (1 - loading));
|
||||||
|
|
||||||
|
p.fillRect(e->rect(), a_bg.current());
|
||||||
|
|
||||||
|
p.setOpacity(a_opacity.current() * _opacity * (1 - loading));
|
||||||
|
|
||||||
|
const QRect &i((_state & StateDown) ? _st.downIcon : _st.icon);
|
||||||
|
if (i.width()) {
|
||||||
|
const QPoint &t((_state & StateDown) ? _st.downIconPos : _st.iconPos);
|
||||||
|
p.drawPixmap(t, App::sprite(), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect inner(QPoint((width() - st::emojiCircle.width()) / 2, st::emojiCircleTop), st::emojiCircle);
|
||||||
|
int32 full = 5760;
|
||||||
|
int32 start = qRound(full * float64(ms % uint64(st::emojiCirclePeriod)) / st::emojiCirclePeriod), part = qRound(full / st::emojiCirclePart);
|
||||||
|
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
|
|
||||||
|
p.setPen(QPen(st::emojiCircleFg->c, st::emojiCircleLine));
|
||||||
|
p.setOpacity(a_opacity.current() * _opacity);
|
||||||
|
p.drawEllipse(inner);
|
||||||
|
|
||||||
|
p.setPen(QPen(st::white->c, st::emojiCircleLine));
|
||||||
|
p.setOpacity(loading);
|
||||||
|
p.drawArc(inner, (full - start) % full, part);
|
||||||
|
|
||||||
|
p.setRenderHint(QPainter::HighQualityAntialiasing, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmojiButton::setLoading(bool loading) {
|
||||||
|
if (_loading != loading) {
|
||||||
|
EnsureAnimation(a_loading, _loading ? 1. : 0., func(this, &EmojiButton::update));
|
||||||
|
a_loading.start(loading ? 1. : 0., st::emojiCircleDuration);
|
||||||
|
_loading = loading;
|
||||||
|
if (_loading) {
|
||||||
|
_a_loading.start();
|
||||||
|
} else {
|
||||||
|
_a_loading.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BoxButton::BoxButton(QWidget *parent, const QString &text, const style::BoxButton &st) : Button(parent)
|
BoxButton::BoxButton(QWidget *parent, const QString &text, const style::BoxButton &st) : Button(parent)
|
||||||
, _text(text.toUpper())
|
, _text(text.toUpper())
|
||||||
, _fullText(text.toUpper())
|
, _fullText(text.toUpper())
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
QString getText() const;
|
QString getText() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onStateChange(int oldState, ButtonStateChangeSource source);
|
void onStateChange(int oldState, ButtonStateChangeSource source);
|
||||||
|
@ -136,6 +136,28 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EmojiButton : public IconedButton {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
EmojiButton(QWidget *parent, const style::iconedButton &st);
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *e);
|
||||||
|
void setLoading(bool loading);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _loading;
|
||||||
|
FloatAnimation a_loading;
|
||||||
|
Animation _a_loading;
|
||||||
|
|
||||||
|
void step_loading(uint64 ms, bool timer) {
|
||||||
|
if (timer) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class BoxButton : public Button {
|
class BoxButton : public Button {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -3028,6 +3028,10 @@ void HistoryWidget::notify_botCommandsChanged(UserData *user) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryWidget::notify_inlineBotRequesting(bool requesting) {
|
||||||
|
_attachEmoji.setLoading(requesting);
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
|
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
|
||||||
if (_peer && _peer == user) {
|
if (_peer && _peer == user) {
|
||||||
_list->notifyIsBotChanged();
|
_list->notifyIsBotChanged();
|
||||||
|
@ -4971,6 +4975,7 @@ bool HistoryWidget::hasBroadcastToggle() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result) {
|
void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result) {
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
_inlineBotUsername = QString();
|
_inlineBotUsername = QString();
|
||||||
if (result.type() == mtpc_contacts_resolvedPeer) {
|
if (result.type() == mtpc_contacts_resolvedPeer) {
|
||||||
const MTPDcontacts_resolvedPeer &d(result.c_contacts_resolvedPeer());
|
const MTPDcontacts_resolvedPeer &d(result.c_contacts_resolvedPeer());
|
||||||
|
@ -4982,6 +4987,8 @@ void HistoryWidget::inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result)
|
||||||
|
|
||||||
bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
|
bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
|
||||||
if (mtpIsFlood(error)) return false;
|
if (mtpIsFlood(error)) return false;
|
||||||
|
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
if (name == _inlineBotUsername) {
|
if (name == _inlineBotUsername) {
|
||||||
_inlineBot = 0;
|
_inlineBot = 0;
|
||||||
onCheckMentionDropdown();
|
onCheckMentionDropdown();
|
||||||
|
@ -5335,10 +5342,12 @@ void HistoryWidget::onCheckMentionDropdown() {
|
||||||
_field.getMentionHashtagBotCommandStart(start, _inlineBot, _inlineBotUsername);
|
_field.getMentionHashtagBotCommandStart(start, _inlineBot, _inlineBotUsername);
|
||||||
if (inlineBotUsername != _inlineBotUsername) {
|
if (inlineBotUsername != _inlineBotUsername) {
|
||||||
if (_inlineBotResolveRequestId) {
|
if (_inlineBotResolveRequestId) {
|
||||||
|
Notify::inlineBotRequesting(false);
|
||||||
MTP::cancel(_inlineBotResolveRequestId);
|
MTP::cancel(_inlineBotResolveRequestId);
|
||||||
_inlineBotResolveRequestId = 0;
|
_inlineBotResolveRequestId = 0;
|
||||||
}
|
}
|
||||||
if (_inlineBot == InlineBotLookingUpData) {
|
if (_inlineBot == InlineBotLookingUpData) {
|
||||||
|
Notify::inlineBotRequesting(true);
|
||||||
_inlineBotResolveRequestId = MTP::send(MTPcontacts_ResolveUsername(MTP_string(_inlineBotUsername)), rpcDone(&HistoryWidget::inlineBotResolveDone), rpcFail(&HistoryWidget::inlineBotResolveFail, _inlineBotUsername));
|
_inlineBotResolveRequestId = MTP::send(MTPcontacts_ResolveUsername(MTP_string(_inlineBotUsername)), rpcDone(&HistoryWidget::inlineBotResolveDone), rpcFail(&HistoryWidget::inlineBotResolveFail, _inlineBotUsername));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,6 +568,7 @@ public:
|
||||||
void notify_historyItemLayoutChanged(const HistoryItem *item);
|
void notify_historyItemLayoutChanged(const HistoryItem *item);
|
||||||
void notify_automaticLoadSettingsChangedGif();
|
void notify_automaticLoadSettingsChangedGif();
|
||||||
void notify_botCommandsChanged(UserData *user);
|
void notify_botCommandsChanged(UserData *user);
|
||||||
|
void notify_inlineBotRequesting(bool requesting);
|
||||||
void notify_userIsBotChanged(UserData *user);
|
void notify_userIsBotChanged(UserData *user);
|
||||||
void notify_migrateUpdated(PeerData *peer);
|
void notify_migrateUpdated(PeerData *peer);
|
||||||
void notify_clipStopperHidden(ClipStopperType type);
|
void notify_clipStopperHidden(ClipStopperType type);
|
||||||
|
@ -784,7 +785,9 @@ private:
|
||||||
|
|
||||||
FlatButton _send, _unblock, _botStart, _joinChannel, _muteUnmute;
|
FlatButton _send, _unblock, _botStart, _joinChannel, _muteUnmute;
|
||||||
mtpRequestId _unblockRequest, _reportSpamRequest;
|
mtpRequestId _unblockRequest, _reportSpamRequest;
|
||||||
IconedButton _attachDocument, _attachPhoto, _attachEmoji, _kbShow, _kbHide, _cmdStart;
|
IconedButton _attachDocument, _attachPhoto;
|
||||||
|
EmojiButton _attachEmoji;
|
||||||
|
IconedButton _kbShow, _kbHide, _cmdStart;
|
||||||
FlatCheckbox _broadcast;
|
FlatCheckbox _broadcast;
|
||||||
bool _cmdStartShown;
|
bool _cmdStartShown;
|
||||||
MessageField _field;
|
MessageField _field;
|
||||||
|
|
|
@ -759,6 +759,10 @@ void MainWidget::notify_botCommandsChanged(UserData *bot) {
|
||||||
history.notify_botCommandsChanged(bot);
|
history.notify_botCommandsChanged(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWidget::notify_inlineBotRequesting(bool requesting) {
|
||||||
|
history.notify_inlineBotRequesting(requesting);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWidget::notify_userIsBotChanged(UserData *bot) {
|
void MainWidget::notify_userIsBotChanged(UserData *bot) {
|
||||||
history.notify_userIsBotChanged(bot);
|
history.notify_userIsBotChanged(bot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,6 +416,7 @@ public:
|
||||||
void ui_showPeerHistory(quint64 peer, qint32 msgId, bool back);
|
void ui_showPeerHistory(quint64 peer, qint32 msgId, bool back);
|
||||||
|
|
||||||
void notify_botCommandsChanged(UserData *bot);
|
void notify_botCommandsChanged(UserData *bot);
|
||||||
|
void notify_inlineBotRequesting(bool requesting);
|
||||||
void notify_userIsBotChanged(UserData *bot);
|
void notify_userIsBotChanged(UserData *bot);
|
||||||
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
|
void notify_userIsContactChanged(UserData *user, bool fromThisApp);
|
||||||
void notify_migrateUpdated(PeerData *peer);
|
void notify_migrateUpdated(PeerData *peer);
|
||||||
|
|
Loading…
Reference in New Issue