2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/localimageloader.h"
|
2016-10-26 16:43:13 +00:00
|
|
|
#include "ui/widgets/tooltip.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "history/history_common.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "chat_helpers/field_autocomplete.h"
|
2016-05-19 12:03:51 +00:00
|
|
|
#include "window/section_widget.h"
|
2016-10-05 16:56:27 +00:00
|
|
|
#include "core/single_timer.h"
|
2017-04-08 13:27:53 +00:00
|
|
|
#include "ui/widgets/input_fields.h"
|
2016-04-29 13:46:16 +00:00
|
|
|
|
|
|
|
namespace InlineBots {
|
|
|
|
namespace Layout {
|
|
|
|
class ItemBase;
|
2017-03-27 18:11:51 +00:00
|
|
|
class Widget;
|
2016-04-29 13:46:16 +00:00
|
|
|
} // namespace Layout
|
|
|
|
class Result;
|
|
|
|
} // namespace InlineBots
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-19 17:18:23 +00:00
|
|
|
namespace Ui {
|
2017-03-27 12:24:38 +00:00
|
|
|
class AbstractButton;
|
2016-06-17 18:18:01 +00:00
|
|
|
class InnerDropdown;
|
2016-10-26 16:43:13 +00:00
|
|
|
class DropdownMenu;
|
2016-10-12 19:34:25 +00:00
|
|
|
class PlainShadow;
|
2016-10-26 16:43:13 +00:00
|
|
|
class PopupMenu;
|
|
|
|
class IconButton;
|
|
|
|
class HistoryDownButton;
|
|
|
|
class EmojiButton;
|
2016-12-26 22:46:36 +00:00
|
|
|
class SendButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
class FlatButton;
|
|
|
|
class LinkButton;
|
|
|
|
class RoundButton;
|
2016-05-19 17:18:23 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
class TopBarWidget;
|
|
|
|
} // namespace Window
|
|
|
|
|
2017-03-29 14:04:00 +00:00
|
|
|
namespace ChatHelpers {
|
2017-04-08 14:05:19 +00:00
|
|
|
class TabbedPanel;
|
2017-04-09 18:06:06 +00:00
|
|
|
class TabbedSection;
|
|
|
|
class TabbedSelector;
|
2017-03-29 14:04:00 +00:00
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
|
|
|
class DragArea;
|
2016-11-11 13:46:04 +00:00
|
|
|
class SilentToggle;
|
2016-11-28 15:45:07 +00:00
|
|
|
class SendFilesBox;
|
2017-04-08 13:27:53 +00:00
|
|
|
class BotKeyboard;
|
|
|
|
class MessageField;
|
|
|
|
class HistoryInner;
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2015-09-08 12:20:30 +00:00
|
|
|
class ReportSpamPanel : public TWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-04-06 16:49:42 +00:00
|
|
|
ReportSpamPanel(QWidget *parent);
|
2015-09-08 12:20:30 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void setReported(bool reported, PeerData *onPeer);
|
2015-09-08 17:22:29 +00:00
|
|
|
|
2015-09-08 12:20:30 +00:00
|
|
|
signals:
|
|
|
|
void hideClicked();
|
|
|
|
void reportClicked();
|
2015-09-08 17:22:29 +00:00
|
|
|
void clearClicked();
|
2015-09-08 12:20:30 +00:00
|
|
|
|
2016-10-18 10:32:33 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2015-09-08 12:20:30 +00:00
|
|
|
|
2016-10-18 10:32:33 +00:00
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatButton> _report;
|
|
|
|
object_ptr<Ui::FlatButton> _hide;
|
|
|
|
object_ptr<Ui::LinkButton> _clear;
|
2015-09-08 12:20:30 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-06 17:23:13 +00:00
|
|
|
class HistoryHider : public TWidget, private base::Subscriber {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-07-18 10:37:34 +00:00
|
|
|
HistoryHider(MainWidget *parent, bool forwardSelected); // forward messages
|
|
|
|
HistoryHider(MainWidget *parent, UserData *sharedContact); // share contact
|
|
|
|
HistoryHider(MainWidget *parent); // send path from command line argument
|
2015-10-18 12:49:34 +00:00
|
|
|
HistoryHider(MainWidget *parent, const QString &url, const QString &text); // share url
|
2016-04-08 14:16:52 +00:00
|
|
|
HistoryHider(MainWidget *parent, const QString &botAndQuery); // inline switch button handler
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-04-04 20:01:34 +00:00
|
|
|
bool withConfirm() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-03-24 10:00:27 +00:00
|
|
|
bool offerPeer(PeerId peer);
|
2014-12-12 16:27:03 +00:00
|
|
|
QString offeredText() const;
|
2016-04-08 14:16:52 +00:00
|
|
|
QString botAndQuery() const {
|
|
|
|
return _botAndQuery;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
bool wasOffered() const;
|
|
|
|
|
|
|
|
void forwardDone();
|
|
|
|
|
|
|
|
~HistoryHider();
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
public slots:
|
2014-05-30 08:53:19 +00:00
|
|
|
void startHide();
|
|
|
|
void forward();
|
|
|
|
|
2015-04-04 20:01:34 +00:00
|
|
|
signals:
|
|
|
|
void forwarded();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
2016-12-07 13:32:25 +00:00
|
|
|
void animationCallback();
|
2014-07-18 10:37:34 +00:00
|
|
|
void init();
|
2014-05-30 08:53:19 +00:00
|
|
|
MainWidget *parent();
|
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
UserData *_sharedContact = nullptr;
|
|
|
|
bool _forwardSelected = false;
|
|
|
|
bool _sendPath = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-18 12:49:34 +00:00
|
|
|
QString _shareUrl, _shareText;
|
2016-04-08 14:16:52 +00:00
|
|
|
QString _botAndQuery;
|
2015-10-18 12:49:34 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::RoundButton> _send;
|
|
|
|
object_ptr<Ui::RoundButton> _cancel;
|
2016-10-01 12:34:23 +00:00
|
|
|
PeerData *_offered = nullptr;
|
2015-12-08 12:33:37 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_opacity;
|
2015-12-08 12:33:37 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
QRect _box;
|
|
|
|
bool _hiding = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
mtpRequestId _forwardRequest = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
int _chooseWidth = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-01 12:34:23 +00:00
|
|
|
Text _toText;
|
|
|
|
int32 _toTextWidth = 0;
|
|
|
|
QPixmap _cacheForAnim;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-08-27 04:49:18 +00:00
|
|
|
class HistoryWidget : public TWidget, public RPCSender, private base::Subscriber {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-03-27 12:24:38 +00:00
|
|
|
HistoryWidget(QWidget *parent, gsl::not_null<Window::Controller*> controller);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-03-19 09:18:19 +00:00
|
|
|
void start();
|
|
|
|
|
2015-09-13 08:41:27 +00:00
|
|
|
void messagesReceived(PeerData *peer, const MTPmessages_Messages &messages, mtpRequestId requestId);
|
2015-07-17 19:17:37 +00:00
|
|
|
void historyLoaded();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void windowShown();
|
2016-06-03 12:45:33 +00:00
|
|
|
bool doWeReadServerHistory() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-18 10:32:33 +00:00
|
|
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
2016-03-01 02:36:23 +00:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void updateTopBarSelection();
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
bool paintTopBar(Painter &p, int decreaseWidth, TimeMs ms);
|
2016-06-17 18:18:01 +00:00
|
|
|
QRect getMembersShowAreaGeometry() const;
|
|
|
|
void setMembersShowAreaActive(bool active);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void loadMessages();
|
2014-07-04 11:12:54 +00:00
|
|
|
void loadMessagesDown();
|
2015-07-17 19:17:37 +00:00
|
|
|
void firstLoadMessages();
|
|
|
|
void delayedShowAt(MsgId showAtMsgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
void peerMessagesUpdated(PeerId peer);
|
|
|
|
void peerMessagesUpdated();
|
|
|
|
|
2015-03-19 09:18:19 +00:00
|
|
|
void newUnreadMsg(History *history, HistoryItem *item);
|
2014-05-30 08:53:19 +00:00
|
|
|
void historyToDown(History *history);
|
2016-06-03 12:45:33 +00:00
|
|
|
void historyWasRead(ReadServerHistoryChecks checks);
|
2015-06-17 19:43:03 +00:00
|
|
|
void historyCleared(History *history);
|
2016-06-03 12:45:33 +00:00
|
|
|
void unreadCountChanged(History *history);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QRect historyRect() const;
|
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void updateSendAction(History *history, SendAction::Type type, int32 progress = 0);
|
|
|
|
void cancelSendAction(History *history, SendAction::Type type);
|
2015-08-01 08:33:00 +00:00
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void updateRecentStickers();
|
2015-05-19 15:46:45 +00:00
|
|
|
void stickersInstalled(uint64 setId);
|
2015-08-01 08:33:00 +00:00
|
|
|
void sendActionDone(const MTPBool &result, mtpRequestId req);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void destroyData();
|
2015-10-28 02:41:13 +00:00
|
|
|
|
2015-12-31 15:27:21 +00:00
|
|
|
void updateFieldPlaceholder();
|
2016-01-09 11:24:16 +00:00
|
|
|
void updateStickersByEmoji();
|
2015-12-31 15:27:21 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
bool confirmSendingFiles(const QList<QUrl> &files, CompressConfirm compressed = CompressConfirm::Auto, const QString *addedComment = nullptr);
|
|
|
|
bool confirmSendingFiles(const QStringList &files, CompressConfirm compressed = CompressConfirm::Auto, const QString *addedComment = nullptr);
|
|
|
|
bool confirmSendingFiles(const QImage &image, const QByteArray &content, CompressConfirm compressed = CompressConfirm::Auto, const QString &insertTextOnCancel = QString());
|
|
|
|
bool confirmSendingFiles(const QMimeData *data, CompressConfirm compressed = CompressConfirm::Auto, const QString &insertTextOnCancel = QString());
|
|
|
|
bool confirmShareContact(const QString &phone, const QString &fname, const QString &lname, const QString *addedComment = nullptr);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
void uploadFile(const QByteArray &fileContent, SendMediaType type);
|
|
|
|
void uploadFiles(const QStringList &files, SendMediaType type);
|
|
|
|
|
|
|
|
void sendFileConfirmed(const FileLoadResultPtr &file);
|
2015-10-27 02:39:02 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateControlsVisibility();
|
2016-10-18 10:32:33 +00:00
|
|
|
void updateControlsGeometry();
|
2016-08-17 15:14:08 +00:00
|
|
|
void updateOnlineDisplay();
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateOnlineDisplayTimer();
|
|
|
|
|
|
|
|
void onShareContact(const PeerId &peer, UserData *contact);
|
|
|
|
|
2015-03-19 09:18:19 +00:00
|
|
|
void shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, int32 userId = 0);
|
2014-08-22 14:55:23 +00:00
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
History *history() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
PeerData *peer() const;
|
2015-10-03 10:09:09 +00:00
|
|
|
void setMsgId(MsgId showAtMsgId);
|
2015-07-17 19:17:37 +00:00
|
|
|
MsgId msgId() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
bool hasTopBarShadow() const {
|
|
|
|
return peer() != nullptr;
|
|
|
|
}
|
|
|
|
void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams ¶ms);
|
2016-12-05 11:01:08 +00:00
|
|
|
void finishAnimation();
|
2015-10-17 14:52:26 +00:00
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
void doneShow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QPoint clampMousePosition(QPoint point);
|
|
|
|
|
|
|
|
void checkSelectingScroll(QPoint point);
|
|
|
|
void noSelectingScroll();
|
|
|
|
|
|
|
|
bool touchScroll(const QPoint &delta);
|
2015-12-31 15:27:21 +00:00
|
|
|
|
2015-12-11 18:11:38 +00:00
|
|
|
uint64 animActiveTimeStart(const HistoryItem *msg) const;
|
2014-07-04 11:12:54 +00:00
|
|
|
void stopAnimActive();
|
|
|
|
|
2014-08-20 05:32:50 +00:00
|
|
|
void fillSelectedItems(SelectedItemSet &sel, bool forDelete = true);
|
2016-03-11 12:20:58 +00:00
|
|
|
void itemEdited(HistoryItem *item);
|
2014-08-20 05:32:50 +00:00
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void updateScrollColors();
|
|
|
|
|
2015-03-19 09:18:19 +00:00
|
|
|
MsgId replyToId() const;
|
2016-03-10 10:15:21 +00:00
|
|
|
void messageDataReceived(ChannelData *channel, MsgId msgId);
|
2015-09-03 10:48:40 +00:00
|
|
|
bool lastForceReplyReplied(const FullMsgId &replyTo = FullMsgId(NoChannel, -1)) const;
|
2016-06-14 16:26:41 +00:00
|
|
|
bool cancelReply(bool lastKeyboardUsed = false);
|
2016-02-25 10:32:31 +00:00
|
|
|
void cancelEdit();
|
2015-03-24 10:00:27 +00:00
|
|
|
void updateForwarding(bool force = false);
|
|
|
|
void cancelForwarding(); // called by MainWidget
|
|
|
|
|
|
|
|
void clearReplyReturns();
|
|
|
|
void pushReplyReturn(HistoryItem *item);
|
|
|
|
QList<MsgId> replyReturns();
|
|
|
|
void setReplyReturns(PeerId peer, const QList<MsgId> &replyReturns);
|
|
|
|
void calcNextReplyReturn();
|
2015-03-19 09:18:19 +00:00
|
|
|
|
2015-04-06 22:15:29 +00:00
|
|
|
void updatePreview();
|
|
|
|
void previewCancel();
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_recording(float64 ms, bool timer);
|
2015-05-29 18:52:43 +00:00
|
|
|
void stopRecording(bool send);
|
|
|
|
|
2015-06-17 19:43:03 +00:00
|
|
|
void onListEscapePressed();
|
2016-06-21 15:58:07 +00:00
|
|
|
void onListEnterPressed();
|
2015-06-17 19:43:03 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo);
|
2016-11-20 12:54:07 +00:00
|
|
|
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
|
2017-03-27 18:11:51 +00:00
|
|
|
bool insertBotCommand(const QString &cmd);
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2016-03-01 02:36:23 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
2016-04-01 15:32:26 +00:00
|
|
|
|
|
|
|
// With force=true the markup is updated even if it is
|
|
|
|
// already shown for the passed history item.
|
|
|
|
void updateBotKeyboard(History *h = nullptr, bool force = false);
|
2015-06-18 17:24:54 +00:00
|
|
|
|
2015-06-24 17:24:48 +00:00
|
|
|
DragState getDragState(const QMimeData *d);
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void fastShowAtEnd(History *h);
|
2015-10-18 12:49:34 +00:00
|
|
|
void applyDraft(bool parseLinks = true);
|
2015-11-20 18:24:44 +00:00
|
|
|
void showHistory(const PeerId &peer, MsgId showAtMsgId, bool reload = false);
|
2015-07-17 19:17:37 +00:00
|
|
|
void clearDelayedShowAt();
|
|
|
|
void clearAllLoadRequests();
|
2016-06-03 18:24:27 +00:00
|
|
|
void saveFieldToHistoryLocalDraft();
|
|
|
|
|
|
|
|
void applyCloudDraft(History *history);
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
void updateHistoryDownPosition();
|
|
|
|
void updateHistoryDownVisibility();
|
2015-09-07 15:53:46 +00:00
|
|
|
|
2015-09-12 19:00:56 +00:00
|
|
|
void updateAfterDrag();
|
2016-04-09 11:02:50 +00:00
|
|
|
void updateFieldSubmitSettings();
|
2015-09-16 13:04:08 +00:00
|
|
|
|
|
|
|
void setInnerFocus();
|
2015-09-20 08:55:41 +00:00
|
|
|
bool canSendMessages(PeerData *peer) const;
|
2015-09-12 19:00:56 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void updateNotifySettings();
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
void saveGif(DocumentData *doc);
|
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
bool contentOverlapped(const QRect &globalRect);
|
|
|
|
|
2016-02-28 12:36:23 +00:00
|
|
|
void grabStart() override {
|
2015-10-17 14:52:26 +00:00
|
|
|
_inGrab = true;
|
2016-10-18 10:32:33 +00:00
|
|
|
updateControlsGeometry();
|
2015-10-17 14:52:26 +00:00
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
void grapWithoutTopBarShadow();
|
|
|
|
void grabFinish() override;
|
2015-10-17 14:52:26 +00:00
|
|
|
|
2015-12-23 16:48:44 +00:00
|
|
|
bool isItemVisible(HistoryItem *item);
|
|
|
|
|
2016-12-31 13:34:41 +00:00
|
|
|
void confirmDeleteContextItem();
|
|
|
|
void confirmDeleteSelectedItems();
|
|
|
|
void deleteContextItem(bool forEveryone);
|
|
|
|
void deleteSelectedItems(bool forEveryone);
|
|
|
|
|
2016-04-06 17:02:22 +00:00
|
|
|
void app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col);
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
void ui_repaintHistoryItem(const HistoryItem *item);
|
2016-03-29 17:17:00 +00:00
|
|
|
PeerData *ui_getPeerForMouseAction();
|
2015-12-13 11:17:15 +00:00
|
|
|
|
|
|
|
void notify_historyItemLayoutChanged(const HistoryItem *item);
|
2015-12-11 18:11:38 +00:00
|
|
|
void notify_botCommandsChanged(UserData *user);
|
2016-01-01 09:58:05 +00:00
|
|
|
void notify_inlineBotRequesting(bool requesting);
|
2016-04-01 15:32:26 +00:00
|
|
|
void notify_replyMarkupUpdated(const HistoryItem *item);
|
2016-04-08 09:20:10 +00:00
|
|
|
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
|
2016-08-12 16:28:10 +00:00
|
|
|
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
|
2015-12-11 18:11:38 +00:00
|
|
|
void notify_userIsBotChanged(UserData *user);
|
|
|
|
void notify_migrateUpdated(PeerData *peer);
|
2016-03-19 16:55:15 +00:00
|
|
|
void notify_handlePendingHistoryUpdate();
|
2015-11-20 13:34:37 +00:00
|
|
|
|
2016-07-14 11:20:46 +00:00
|
|
|
bool cmd_search();
|
|
|
|
bool cmd_next_chat();
|
|
|
|
bool cmd_previous_chat();
|
2016-02-27 19:39:51 +00:00
|
|
|
|
2016-12-19 16:51:29 +00:00
|
|
|
~HistoryWidget();
|
|
|
|
|
2016-10-18 10:32:33 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2016-10-18 10:32:33 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
signals:
|
|
|
|
void cancelled();
|
2015-10-03 10:09:09 +00:00
|
|
|
void historyShown(History *history, MsgId atMsgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public slots:
|
2014-11-14 23:23:35 +00:00
|
|
|
void onCancel();
|
2015-03-19 09:18:19 +00:00
|
|
|
void onReplyToMessage();
|
2016-02-21 12:30:16 +00:00
|
|
|
void onEditMessage();
|
2016-03-10 10:15:21 +00:00
|
|
|
void onPinMessage();
|
|
|
|
void onUnpinMessage();
|
|
|
|
void onPinnedHide();
|
2016-02-25 17:23:42 +00:00
|
|
|
void onCopyPostLink();
|
2016-02-25 10:32:31 +00:00
|
|
|
void onFieldBarCancel();
|
2015-04-06 22:15:29 +00:00
|
|
|
|
2015-08-01 08:33:00 +00:00
|
|
|
void onCancelSendAction();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void onStickerPackInfo();
|
|
|
|
|
2015-04-06 22:15:29 +00:00
|
|
|
void onPreviewParse();
|
|
|
|
void onPreviewCheck();
|
|
|
|
void onPreviewTimeout();
|
2014-11-14 23:23:35 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void peerUpdated(PeerData *data);
|
|
|
|
|
2016-02-25 16:19:54 +00:00
|
|
|
void onPhotoUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
|
|
|
|
void onDocumentUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file);
|
|
|
|
void onThumbDocumentUploaded(const FullMsgId &msgId, bool silent, const MTPInputFile &file, const MTPInputFile &thumb);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-03 10:48:40 +00:00
|
|
|
void onPhotoProgress(const FullMsgId &msgId);
|
|
|
|
void onDocumentProgress(const FullMsgId &msgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-03 10:48:40 +00:00
|
|
|
void onPhotoFailed(const FullMsgId &msgId);
|
|
|
|
void onDocumentFailed(const FullMsgId &msgId);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-09-08 17:22:29 +00:00
|
|
|
void onReportSpamClicked();
|
|
|
|
void onReportSpamHide();
|
|
|
|
void onReportSpamClear();
|
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
void onScroll();
|
2014-07-04 11:12:54 +00:00
|
|
|
void onHistoryToEnd();
|
2015-03-19 09:18:19 +00:00
|
|
|
void onSend(bool ctrlShiftEnter = false, MsgId replyTo = -1);
|
2015-09-21 20:57:42 +00:00
|
|
|
|
2015-08-12 18:01:32 +00:00
|
|
|
void onUnblock();
|
2015-06-17 19:43:03 +00:00
|
|
|
void onBotStart();
|
2015-09-21 20:57:42 +00:00
|
|
|
void onJoinChannel();
|
|
|
|
void onMuteUnmute();
|
2016-02-25 16:19:54 +00:00
|
|
|
void onBroadcastSilentChange();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-06-17 19:43:03 +00:00
|
|
|
void onKbToggle(bool manual = true);
|
2015-06-24 17:24:48 +00:00
|
|
|
void onCmdStart();
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void activate();
|
2016-01-09 11:24:16 +00:00
|
|
|
void onStickersUpdated();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onTextChange();
|
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
void onFieldTabbed();
|
2016-09-11 08:38:14 +00:00
|
|
|
bool onStickerSend(DocumentData *sticker);
|
2015-12-31 05:34:43 +00:00
|
|
|
void onPhotoSend(PhotoData *photo);
|
2016-04-04 21:09:46 +00:00
|
|
|
void onInlineResultSend(InlineBots::Result *result, UserData *bot);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
void onWindowVisibleChanged();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-09-30 14:11:09 +00:00
|
|
|
void forwardMessage();
|
|
|
|
void selectMessage();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void onFieldFocused();
|
|
|
|
void onFieldResize();
|
2016-04-29 13:46:16 +00:00
|
|
|
void onCheckFieldAutocomplete();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onScrollTimer();
|
|
|
|
|
|
|
|
void onForwardSelected();
|
|
|
|
void onClearSelected();
|
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
void onAnimActiveStep();
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void onDraftSaveDelayed();
|
|
|
|
void onDraftSave(bool delayed = false);
|
2016-06-03 18:24:27 +00:00
|
|
|
void onCloudDraftSave();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2015-01-02 14:55:24 +00:00
|
|
|
void updateStickers();
|
|
|
|
|
2015-05-29 18:52:43 +00:00
|
|
|
void onRecordError();
|
2016-02-12 16:35:06 +00:00
|
|
|
void onRecordDone(QByteArray result, VoiceWaveform waveform, qint32 samples);
|
|
|
|
void onRecordUpdate(quint16 level, qint32 samples);
|
2015-05-29 18:52:43 +00:00
|
|
|
|
2016-01-03 08:01:14 +00:00
|
|
|
void onUpdateHistoryItems();
|
|
|
|
|
2016-03-21 18:40:00 +00:00
|
|
|
// checks if we are too close to the top or to the bottom
|
|
|
|
// in the scroll area and preloads history if needed
|
|
|
|
void preloadHistoryIfNeeded();
|
|
|
|
|
2016-04-09 11:02:50 +00:00
|
|
|
private slots:
|
2016-04-29 13:46:16 +00:00
|
|
|
void onHashtagOrBotCommandInsert(QString str, FieldAutocomplete::ChooseMethod method);
|
|
|
|
void onMentionInsert(UserData *user);
|
2016-04-09 11:02:50 +00:00
|
|
|
void onInlineBotCancel();
|
2016-06-21 14:19:24 +00:00
|
|
|
void onMembersDropdownShow();
|
2016-04-09 11:02:50 +00:00
|
|
|
|
2016-06-22 18:41:13 +00:00
|
|
|
void onModerateKeyActivate(int index, bool *outHandled);
|
|
|
|
|
2016-05-09 12:03:06 +00:00
|
|
|
void updateField();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
private:
|
2017-03-27 18:11:51 +00:00
|
|
|
struct SendingFilesLists {
|
|
|
|
QList<QUrl> nonLocalUrls;
|
|
|
|
QStringList directories;
|
|
|
|
QStringList emptyFiles;
|
|
|
|
QStringList tooLargeFiles;
|
|
|
|
QStringList filesToSend;
|
|
|
|
bool allFilesForCompress = true;
|
|
|
|
};
|
|
|
|
|
2017-04-06 16:49:42 +00:00
|
|
|
void fullPeerUpdated(PeerData *peer);
|
2017-03-27 12:24:38 +00:00
|
|
|
void topBarClick();
|
2017-04-09 18:06:06 +00:00
|
|
|
void toggleTabbedSelectorMode();
|
|
|
|
void updateTabbedSelectorSectionShown();
|
|
|
|
void recountChatWidth();
|
|
|
|
int minimalWidthForTabbedSelectorSection() const;
|
|
|
|
void setReportSpamStatus(DBIPeerReportSpamStatus status);
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
void animationCallback();
|
2016-12-26 22:46:36 +00:00
|
|
|
void updateOverStates(QPoint pos);
|
|
|
|
void recordStartCallback();
|
|
|
|
void recordStopCallback(bool active);
|
|
|
|
void recordUpdateCallback(QPoint globalPos);
|
2016-11-28 15:45:07 +00:00
|
|
|
void chooseAttach();
|
2016-12-07 13:32:25 +00:00
|
|
|
void historyDownAnimationFinish();
|
2016-12-26 22:46:36 +00:00
|
|
|
void sendButtonClicked();
|
2016-11-28 15:45:07 +00:00
|
|
|
SendingFilesLists getSendingFilesLists(const QList<QUrl> &files);
|
|
|
|
SendingFilesLists getSendingFilesLists(const QStringList &files);
|
|
|
|
void getSendingLocalFileInfo(SendingFilesLists &result, const QString &filepath);
|
|
|
|
bool confirmSendingFiles(const SendingFilesLists &lists, CompressConfirm compressed = CompressConfirm::Auto, const QString *addedComment = nullptr);
|
|
|
|
template <typename Callback>
|
|
|
|
bool validateSendingFiles(const SendingFilesLists &lists, Callback callback);
|
|
|
|
template <typename SendCallback>
|
2016-12-13 17:07:56 +00:00
|
|
|
bool showSendFilesBox(object_ptr<SendFilesBox> box, const QString &insertTextOnCancel, const QString *addedComment, SendCallback callback);
|
2016-11-28 15:45:07 +00:00
|
|
|
|
|
|
|
// If an empty filepath is found we upload (possible) "image" with (possible) "content".
|
2017-03-10 14:14:10 +00:00
|
|
|
void uploadFilesAfterConfirmation(const QStringList &files, const QByteArray &content, const QImage &image, std::unique_ptr<FileLoadTask::MediaInformation> information, SendMediaType type, QString caption);
|
2016-11-28 15:45:07 +00:00
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
void itemRemoved(HistoryItem *item);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-09 11:02:50 +00:00
|
|
|
// Updates position of controls around the message field,
|
|
|
|
// like send button, emoji button and others.
|
|
|
|
void moveFieldControls();
|
|
|
|
void updateFieldSize();
|
|
|
|
|
2016-06-10 15:11:44 +00:00
|
|
|
bool historyHasNotFreezedUnreadBar(History *history) const;
|
2016-06-10 15:34:35 +00:00
|
|
|
bool canWriteMessage() const;
|
2017-03-27 18:11:51 +00:00
|
|
|
void orderWidgets();
|
2016-06-10 15:11:44 +00:00
|
|
|
|
2016-04-09 11:02:50 +00:00
|
|
|
void clearInlineBot();
|
|
|
|
void inlineBotChanged();
|
|
|
|
|
2016-05-08 16:11:47 +00:00
|
|
|
// Look in the _field for the inline bot and query string.
|
|
|
|
void updateInlineBotQuery();
|
|
|
|
|
|
|
|
// Request to show results in the emoji panel.
|
|
|
|
void applyInlineBotQuery(UserData *bot, const QString &query);
|
|
|
|
|
2016-06-14 16:26:41 +00:00
|
|
|
void cancelReplyAfterMediaSend(bool lastKeyboardUsed);
|
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideSelectorControlsAnimated();
|
2016-06-20 11:31:12 +00:00
|
|
|
int countMembersDropdownHeightMax() const;
|
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
gsl::not_null<Window::Controller*> _controller;
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
MsgId _replyToId = 0;
|
2016-02-25 10:32:31 +00:00
|
|
|
Text _replyToName;
|
2016-03-22 19:43:47 +00:00
|
|
|
int _replyToNameVersion = 0;
|
2015-03-19 09:18:19 +00:00
|
|
|
void updateReplyToName();
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
int _chatWidth = 0;
|
2016-03-22 19:43:47 +00:00
|
|
|
MsgId _editMsgId = 0;
|
2016-02-25 10:32:31 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
HistoryItem *_replyEditMsg = nullptr;
|
2016-02-25 10:32:31 +00:00
|
|
|
Text _replyEditMsgText;
|
2016-05-09 12:03:06 +00:00
|
|
|
mutable SingleTimer _updateEditTimeLeftDisplay;
|
2016-02-25 10:32:31 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _fieldBarCancel;
|
2016-03-10 10:15:21 +00:00
|
|
|
void updateReplyEditTexts(bool force = false);
|
|
|
|
|
|
|
|
struct PinnedBar {
|
|
|
|
PinnedBar(MsgId msgId, HistoryWidget *parent);
|
2016-10-18 15:19:13 +00:00
|
|
|
~PinnedBar();
|
2016-03-10 10:15:21 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
MsgId msgId = 0;
|
|
|
|
HistoryItem *msg = nullptr;
|
2016-03-10 10:15:21 +00:00
|
|
|
Text text;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> cancel;
|
|
|
|
object_ptr<Ui::PlainShadow> shadow;
|
2016-03-10 10:15:21 +00:00
|
|
|
};
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<PinnedBar> _pinnedBar;
|
2016-03-10 10:15:21 +00:00
|
|
|
void updatePinnedBar(bool force = false);
|
|
|
|
bool pinnedMsgVisibilityUpdated();
|
2016-03-15 19:38:30 +00:00
|
|
|
void destroyPinnedBar();
|
2016-03-10 10:15:21 +00:00
|
|
|
void unpinDone(const MTPUpdates &updates);
|
|
|
|
|
2016-09-11 08:38:14 +00:00
|
|
|
bool sendExistingDocument(DocumentData *doc, const QString &caption);
|
2016-01-07 09:49:54 +00:00
|
|
|
void sendExistingPhoto(PhotoData *photo, const QString &caption);
|
2015-12-31 05:34:43 +00:00
|
|
|
|
2016-05-09 12:03:06 +00:00
|
|
|
void drawField(Painter &p, const QRect &rect);
|
|
|
|
void paintEditHeader(Painter &p, const QRect &rect, int left, int top) const;
|
2016-12-05 11:01:08 +00:00
|
|
|
void drawRecording(Painter &p, float64 recordActive);
|
2016-03-10 10:15:21 +00:00
|
|
|
void drawPinnedBar(Painter &p);
|
2015-03-19 09:18:19 +00:00
|
|
|
|
2016-02-25 10:32:31 +00:00
|
|
|
void updateMouseTracking();
|
|
|
|
|
2016-03-18 19:05:08 +00:00
|
|
|
// destroys _history and _migrated unread bars
|
|
|
|
void destroyUnreadBar();
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _saveEditMsgRequestId = 0;
|
2016-02-25 10:32:31 +00:00
|
|
|
void saveEditMsg();
|
|
|
|
void saveEditMsgDone(History *history, const MTPUpdates &updates, mtpRequestId req);
|
|
|
|
bool saveEditMsgFail(History *history, const RPCError &error, mtpRequestId req);
|
|
|
|
|
2016-03-12 16:32:28 +00:00
|
|
|
static const mtpRequestId ReportSpamRequestNeeded = -1;
|
2016-03-22 19:43:47 +00:00
|
|
|
DBIPeerReportSpamStatus _reportSpamStatus = dbiprsUnknown;
|
|
|
|
mtpRequestId _reportSpamSettingRequestId = ReportSpamRequestNeeded;
|
2015-09-07 15:53:46 +00:00
|
|
|
void updateReportSpamStatus();
|
2016-03-12 16:32:28 +00:00
|
|
|
void requestReportSpamSetting();
|
|
|
|
void reportSpamSettingDone(const MTPPeerSettings &result, mtpRequestId req);
|
|
|
|
bool reportSpamSettingFail(const RPCError &error, mtpRequestId req);
|
2015-09-07 15:53:46 +00:00
|
|
|
|
2015-04-06 22:15:29 +00:00
|
|
|
QString _previewLinks;
|
2016-03-22 19:43:47 +00:00
|
|
|
WebPageData *_previewData = nullptr;
|
2015-04-06 22:15:29 +00:00
|
|
|
typedef QMap<QString, WebPageId> PreviewCache;
|
|
|
|
PreviewCache _previewCache;
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _previewRequest = 0;
|
|
|
|
Text _previewTitle;
|
|
|
|
Text _previewDescription;
|
2015-04-06 22:15:29 +00:00
|
|
|
SingleTimer _previewTimer;
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _previewCancelled = false;
|
2015-04-06 22:15:29 +00:00
|
|
|
void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req);
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _replyForwardPressed = false;
|
2015-04-07 23:03:32 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
HistoryItem *_replyReturn = nullptr;
|
2015-03-24 10:00:27 +00:00
|
|
|
QList<MsgId> _replyReturns;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
bool messagesFailed(const RPCError &error, mtpRequestId requestId);
|
2016-05-27 16:47:46 +00:00
|
|
|
void addMessagesToFront(PeerData *peer, const QVector<MTPMessage> &messages);
|
|
|
|
void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-06 17:02:22 +00:00
|
|
|
struct BotCallbackInfo {
|
2016-09-15 19:15:49 +00:00
|
|
|
UserData *bot;
|
2016-04-06 17:02:22 +00:00
|
|
|
FullMsgId msgId;
|
|
|
|
int row, col;
|
2016-09-07 09:04:57 +00:00
|
|
|
bool game;
|
2016-04-06 17:02:22 +00:00
|
|
|
};
|
|
|
|
void botCallbackDone(BotCallbackInfo info, const MTPmessages_BotCallbackAnswer &answer, mtpRequestId req);
|
|
|
|
bool botCallbackFail(BotCallbackInfo info, const RPCError &error, mtpRequestId req);
|
2016-03-29 17:17:00 +00:00
|
|
|
|
2016-03-14 17:45:59 +00:00
|
|
|
enum ScrollChangeType {
|
|
|
|
ScrollChangeNone,
|
2016-03-31 14:06:40 +00:00
|
|
|
|
|
|
|
// When we toggle a pinned message.
|
2016-03-14 17:45:59 +00:00
|
|
|
ScrollChangeAdd,
|
2016-03-31 14:06:40 +00:00
|
|
|
|
|
|
|
// When loading a history part while scrolling down.
|
|
|
|
ScrollChangeNoJumpToBottom,
|
2016-03-14 17:45:59 +00:00
|
|
|
};
|
|
|
|
struct ScrollChange {
|
|
|
|
ScrollChangeType type;
|
|
|
|
int value;
|
|
|
|
};
|
2016-03-19 16:55:15 +00:00
|
|
|
void updateListSize(bool initial = false, bool loadedDown = false, const ScrollChange &change = { ScrollChangeNone, 0 });
|
2016-03-14 17:45:59 +00:00
|
|
|
|
2016-04-04 08:57:36 +00:00
|
|
|
// Does any of the shown histories has this flag set.
|
|
|
|
bool hasPendingResizedItems() const {
|
|
|
|
return (_history && _history->hasPendingResizedItems()) || (_migrated && _migrated->hasPendingResizedItems());
|
|
|
|
}
|
|
|
|
|
2016-03-31 14:06:40 +00:00
|
|
|
// Counts scrollTop for placing the scroll right at the unread
|
|
|
|
// messages bar, choosing from _history and _migrated unreadBar.
|
|
|
|
int unreadBarTop() const;
|
|
|
|
|
2015-12-27 21:37:48 +00:00
|
|
|
void saveGifDone(DocumentData *doc, const MTPBool &result);
|
|
|
|
|
2015-09-08 17:22:29 +00:00
|
|
|
void reportSpamDone(PeerData *peer, const MTPBool &result, mtpRequestId request);
|
|
|
|
bool reportSpamFail(const RPCError &error, mtpRequestId request);
|
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void unblockDone(PeerData *peer, const MTPBool &result, mtpRequestId req);
|
|
|
|
bool unblockFail(const RPCError &error, mtpRequestId req);
|
2015-09-08 17:22:29 +00:00
|
|
|
void blockDone(PeerData *peer, const MTPBool &result);
|
2015-08-12 18:01:32 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
void joinDone(const MTPUpdates &result, mtpRequestId req);
|
|
|
|
bool joinFail(const RPCError &error, mtpRequestId req);
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void countHistoryShowFrom();
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _stickersUpdateRequest = 0;
|
2015-01-02 14:55:24 +00:00
|
|
|
void stickersGot(const MTPmessages_AllStickers &stickers);
|
|
|
|
bool stickersFailed(const RPCError &error);
|
|
|
|
|
2016-07-15 15:58:52 +00:00
|
|
|
mtpRequestId _recentStickersUpdateRequest = 0;
|
|
|
|
void recentStickersGot(const MTPmessages_RecentStickers &stickers);
|
|
|
|
bool recentStickersFailed(const RPCError &error);
|
|
|
|
|
2016-06-27 16:25:21 +00:00
|
|
|
mtpRequestId _featuredStickersUpdateRequest = 0;
|
|
|
|
void featuredStickersGot(const MTPmessages_FeaturedStickers &stickers);
|
|
|
|
bool featuredStickersFailed(const RPCError &error);
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _savedGifsUpdateRequest = 0;
|
2015-12-27 21:37:48 +00:00
|
|
|
void savedGifsGot(const MTPmessages_SavedGifs &gifs);
|
|
|
|
bool savedGifsFailed(const RPCError &error);
|
2015-01-02 14:55:24 +00:00
|
|
|
|
2016-05-05 16:04:17 +00:00
|
|
|
enum class TextUpdateEvent {
|
|
|
|
SaveDraft = 0x01,
|
|
|
|
SendTyping = 0x02,
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(TextUpdateEvents, TextUpdateEvent);
|
|
|
|
Q_DECLARE_FRIEND_OPERATORS_FOR_FLAGS(TextUpdateEvents);
|
|
|
|
|
2016-06-09 14:31:10 +00:00
|
|
|
void writeDrafts(Data::Draft **localDraft, Data::Draft **editDraft);
|
2016-02-25 10:32:31 +00:00
|
|
|
void writeDrafts(History *history);
|
2016-11-15 11:56:49 +00:00
|
|
|
void setFieldText(const TextWithTags &textWithTags, TextUpdateEvents events = 0, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction = Ui::FlatTextarea::ClearUndoHistory);
|
|
|
|
void clearFieldText(TextUpdateEvents events = 0, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction = Ui::FlatTextarea::ClearUndoHistory) {
|
2016-05-05 16:04:17 +00:00
|
|
|
setFieldText(TextWithTags(), events, undoHistoryAction);
|
2016-04-09 11:02:50 +00:00
|
|
|
}
|
2014-11-05 17:43:32 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void updateDragAreas();
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
// when scroll position or scroll area size changed this method
|
|
|
|
// updates the boundings of the visible area in HistoryInner
|
|
|
|
void visibleAreaUpdated();
|
|
|
|
|
2015-09-20 08:55:41 +00:00
|
|
|
bool readyToForward() const;
|
2016-02-25 16:19:54 +00:00
|
|
|
bool hasSilentToggle() const;
|
2015-09-07 07:52:37 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
PeerData *_peer = nullptr;
|
|
|
|
|
|
|
|
// cache current _peer in _clearPeer when showing clear history box
|
|
|
|
PeerData *_clearPeer = nullptr;
|
|
|
|
|
|
|
|
ChannelId _channel = NoChannel;
|
|
|
|
bool _canSendMessages = false;
|
|
|
|
MsgId _showAtMsgId = ShowAtUnreadMsgId;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _firstLoadRequest = 0;
|
|
|
|
mtpRequestId _preloadRequest = 0;
|
|
|
|
mtpRequestId _preloadDownRequest = 0;
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
MsgId _delayedShowAtMsgId = -1; // wtf?
|
|
|
|
mtpRequestId _delayedShowAtRequest = 0;
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
MsgId _activeAnimMsgId = 0;
|
2014-07-13 09:50:38 +00:00
|
|
|
|
2017-03-27 12:24:38 +00:00
|
|
|
object_ptr<Ui::AbstractButton> _backAnimationButton = { nullptr };
|
|
|
|
object_ptr<Window::TopBarWidget> _topBar;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
QPointer<HistoryInner> _list;
|
2016-03-22 19:43:47 +00:00
|
|
|
History *_migrated = nullptr;
|
|
|
|
History *_history = nullptr;
|
|
|
|
bool _histInited = false; // initial updateListSize() called
|
2016-04-08 09:20:10 +00:00
|
|
|
int _addToScroll = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-08 09:20:10 +00:00
|
|
|
int _lastScroll = 0;// gifs optimization
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs _lastScrolled = 0;
|
2016-04-08 09:20:10 +00:00
|
|
|
QTimer _updateHistoryItems;
|
2016-01-03 08:01:14 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _historyDownShown;
|
|
|
|
bool _historyDownIsShown = false;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::HistoryDownButton> _historyDown;
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<FieldAutocomplete> _fieldAutocomplete;
|
2016-04-09 11:02:50 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
UserData *_inlineBot = nullptr;
|
2015-12-30 19:09:20 +00:00
|
|
|
QString _inlineBotUsername;
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _inlineBotResolveRequestId = 0;
|
2016-12-26 22:46:36 +00:00
|
|
|
bool _isInlineBot = false;
|
2015-12-30 19:09:20 +00:00
|
|
|
void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result);
|
2015-12-31 15:27:21 +00:00
|
|
|
bool inlineBotResolveFail(QString name, const RPCError &error);
|
2015-03-19 09:18:19 +00:00
|
|
|
|
2015-06-19 22:13:56 +00:00
|
|
|
bool isBotStart() const;
|
2015-08-12 18:01:32 +00:00
|
|
|
bool isBlocked() const;
|
2015-09-21 20:57:42 +00:00
|
|
|
bool isJoinChannel() const;
|
|
|
|
bool isMuteUnmute() const;
|
2015-06-24 17:24:48 +00:00
|
|
|
bool updateCmdStartShown();
|
2016-12-26 22:46:36 +00:00
|
|
|
void updateSendButtonType();
|
|
|
|
bool showRecordButton() const;
|
|
|
|
bool showInlineBotCancel() const;
|
2015-06-19 22:13:56 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
object_ptr<ReportSpamPanel> _reportSpamPanel = { nullptr };
|
2015-09-08 12:20:30 +00:00
|
|
|
|
2016-12-26 22:46:36 +00:00
|
|
|
object_ptr<Ui::SendButton> _send;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatButton> _unblock;
|
|
|
|
object_ptr<Ui::FlatButton> _botStart;
|
|
|
|
object_ptr<Ui::FlatButton> _joinChannel;
|
|
|
|
object_ptr<Ui::FlatButton> _muteUnmute;
|
2016-03-22 19:43:47 +00:00
|
|
|
mtpRequestId _unblockRequest = 0;
|
|
|
|
mtpRequestId _reportSpamRequest = 0;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _attachToggle;
|
2017-04-09 18:06:06 +00:00
|
|
|
object_ptr<Ui::EmojiButton> _tabbedSelectorToggle;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::IconButton> _botKeyboardShow;
|
|
|
|
object_ptr<Ui::IconButton> _botKeyboardHide;
|
|
|
|
object_ptr<Ui::IconButton> _botCommandStart;
|
|
|
|
object_ptr<SilentToggle> _silent;
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _cmdStartShown = false;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<MessageField> _field;
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _recording = false;
|
|
|
|
bool _inField = false;
|
|
|
|
bool _inReplyEdit = false;
|
|
|
|
bool _inPinnedMsg = false;
|
2016-11-18 13:34:58 +00:00
|
|
|
bool _inClickable = false;
|
2016-12-05 11:01:08 +00:00
|
|
|
int _recordingSamples = 0;
|
|
|
|
int _recordCancelWidth;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
// This can animate for a very long time (like in music playing),
|
|
|
|
// so it should be a BasicAnimation, not an Animation.
|
|
|
|
BasicAnimation _a_recording;
|
|
|
|
anim::value a_recordingLevel;
|
|
|
|
|
2015-11-23 15:34:38 +00:00
|
|
|
bool kbWasHidden() const;
|
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _kbShown = false;
|
|
|
|
HistoryItem *_kbReplyTo = nullptr;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _kbScroll;
|
|
|
|
QPointer<BotKeyboard> _keyboard;
|
2015-06-15 17:19:24 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InnerDropdown> _membersDropdown = { nullptr };
|
2016-06-21 14:19:24 +00:00
|
|
|
QTimer _membersDropdownShowTimer;
|
2016-06-17 18:18:01 +00:00
|
|
|
|
2017-03-27 18:11:51 +00:00
|
|
|
object_ptr<InlineBots::Layout::Widget> _inlineResults = { nullptr };
|
2017-04-08 14:05:19 +00:00
|
|
|
object_ptr<ChatHelpers::TabbedPanel> _tabbedPanel;
|
2017-04-09 18:06:06 +00:00
|
|
|
object_ptr<ChatHelpers::TabbedSection> _tabbedSection = { nullptr };
|
|
|
|
QPointer<ChatHelpers::TabbedSelector> _tabbedSelector;
|
2016-03-22 19:43:47 +00:00
|
|
|
DragState _attachDrag = DragStateNone;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<DragArea> _attachDragDocument, _attachDragPhoto;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
int32 _selCount; // < 0 - text selected, focus list, not _field
|
|
|
|
|
2015-10-27 02:39:02 +00:00
|
|
|
TaskQueue _fileLoader;
|
2016-05-05 16:04:17 +00:00
|
|
|
TextUpdateEvents _textUpdateEvents = (TextUpdateEvent::SaveDraft | TextUpdateEvent::SendTyping);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-22 19:43:47 +00:00
|
|
|
int64 _serviceImageCacheSize = 0;
|
2015-07-17 19:17:37 +00:00
|
|
|
QString _confirmSource;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
QString _titlePeerText;
|
2016-06-10 11:18:55 +00:00
|
|
|
bool _titlePeerTextOnline = false;
|
|
|
|
int _titlePeerTextWidth = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _a_show;
|
2016-12-05 11:01:08 +00:00
|
|
|
Window::SlideDirection _showDirection;
|
2016-05-19 12:03:51 +00:00
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QTimer _scrollTimer;
|
2016-03-22 19:43:47 +00:00
|
|
|
int32 _scrollDelta = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-07-04 11:12:54 +00:00
|
|
|
QTimer _animActiveTimer;
|
2016-03-22 19:43:47 +00:00
|
|
|
float64 _animActiveStart = 0;
|
2014-07-04 11:12:54 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
QMap<QPair<History*, SendAction::Type>, mtpRequestId> _sendActionRequests;
|
2015-08-01 08:33:00 +00:00
|
|
|
QTimer _sendActionStopTimer;
|
2014-11-05 17:43:32 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
TimeMs _saveDraftStart = 0;
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _saveDraftText = false;
|
2016-06-03 18:24:27 +00:00
|
|
|
QTimer _saveDraftTimer, _saveCloudDraftTimer;
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::PlainShadow> _topShadow;
|
2017-04-09 18:06:06 +00:00
|
|
|
object_ptr<Ui::PlainShadow> _rightShadow = { nullptr };
|
2016-03-22 19:43:47 +00:00
|
|
|
bool _inGrab = false;
|
2015-10-17 08:31:48 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2016-05-05 16:04:17 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(HistoryWidget::TextUpdateEvents)
|