2019-08-08 17:07:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "window/section_widget.h"
|
|
|
|
#include "window/section_memento.h"
|
|
|
|
#include "history/view/history_view_list_widget.h"
|
2019-08-16 15:08:51 +00:00
|
|
|
#include "data/data_messages.h"
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
class History;
|
2019-08-16 17:07:30 +00:00
|
|
|
enum class SendMediaType;
|
|
|
|
struct SendingAlbum;
|
2020-08-10 12:22:54 +00:00
|
|
|
|
|
|
|
namespace SendMenu {
|
|
|
|
enum class Type;
|
|
|
|
} // namespace SendMenu
|
2019-08-08 17:07:55 +00:00
|
|
|
|
2019-08-16 15:08:51 +00:00
|
|
|
namespace Api {
|
|
|
|
struct SendOptions;
|
|
|
|
} // namespace Api
|
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
namespace Ui {
|
|
|
|
class ScrollArea;
|
|
|
|
class PlainShadow;
|
|
|
|
class FlatButton;
|
|
|
|
class HistoryDownButton;
|
2020-10-13 12:07:53 +00:00
|
|
|
struct PreparedList;
|
2020-10-17 09:51:55 +00:00
|
|
|
class SendFilesWay;
|
2019-08-08 17:07:55 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Profile {
|
|
|
|
class BackButton;
|
|
|
|
} // namespace Profile
|
|
|
|
|
2019-08-16 17:07:30 +00:00
|
|
|
namespace InlineBots {
|
|
|
|
class Result;
|
|
|
|
} // namespace InlineBots
|
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
|
|
|
|
class Element;
|
|
|
|
class TopBarWidget;
|
|
|
|
class ScheduledMemento;
|
2019-08-16 09:32:42 +00:00
|
|
|
class ComposeControls;
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
class ScheduledWidget final
|
|
|
|
: public Window::SectionWidget
|
|
|
|
, private ListDelegate {
|
|
|
|
public:
|
|
|
|
ScheduledWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<History*> history);
|
2019-08-16 09:32:42 +00:00
|
|
|
~ScheduledWidget();
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
not_null<History*> history() const;
|
|
|
|
Dialogs::RowDescriptor activeChat() const override;
|
2020-11-21 23:18:58 +00:00
|
|
|
bool preventsClose(Fn<void()> &&continueCallback) const override;
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
bool hasTopBarShadow() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap grabForShowAnimation(
|
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
|
|
|
|
|
|
|
bool showInternal(
|
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) override;
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> createMemento() override;
|
2019-08-08 17:07:55 +00:00
|
|
|
|
2021-07-26 23:18:11 +00:00
|
|
|
Window::SectionActionResult sendBotCommand(
|
|
|
|
Bot::SendCommandRequest request) override;
|
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
void setInternalState(
|
|
|
|
const QRect &geometry,
|
|
|
|
not_null<ScheduledMemento*> memento);
|
|
|
|
|
2019-08-16 12:44:20 +00:00
|
|
|
// Tabbed selector management.
|
2020-05-05 12:55:05 +00:00
|
|
|
bool pushTabbedSelectorToThirdSection(
|
|
|
|
not_null<PeerData*> peer,
|
2019-08-16 12:44:20 +00:00
|
|
|
const Window::SectionShow ¶ms) override;
|
|
|
|
bool returnTabbedSelector() override;
|
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
// Float player interface.
|
2020-06-25 14:17:37 +00:00
|
|
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
|
|
|
QRect floatPlayerAvailableRect() override;
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
// ListDelegate interface.
|
|
|
|
Context listContext() override;
|
|
|
|
void listScrollTo(int top) override;
|
|
|
|
void listCancelRequest() override;
|
|
|
|
void listDeleteRequest() override;
|
|
|
|
rpl::producer<Data::MessagesSlice> listSource(
|
|
|
|
Data::MessagePosition aroundId,
|
|
|
|
int limitBefore,
|
|
|
|
int limitAfter) override;
|
|
|
|
bool listAllowsMultiSelect() override;
|
2019-08-08 22:39:42 +00:00
|
|
|
bool listIsItemGoodForSelection(not_null<HistoryItem*> item) override;
|
2019-08-08 17:07:55 +00:00
|
|
|
bool listIsLessInOrder(
|
|
|
|
not_null<HistoryItem*> first,
|
|
|
|
not_null<HistoryItem*> second) override;
|
|
|
|
void listSelectionChanged(SelectedItems &&items) override;
|
|
|
|
void listVisibleItemsChanged(HistoryItemsList &&items) override;
|
2020-09-15 15:30:34 +00:00
|
|
|
MessagesBarData listMessagesBar(
|
2019-08-08 17:07:55 +00:00
|
|
|
const std::vector<not_null<Element*>> &elements) override;
|
|
|
|
void listContentRefreshed() override;
|
|
|
|
ClickHandlerPtr listDateLink(not_null<Element*> view) override;
|
2020-08-28 12:48:54 +00:00
|
|
|
bool listElementHideReply(not_null<const Element*> view) override;
|
2020-09-22 11:30:15 +00:00
|
|
|
bool listElementShownUnread(not_null<const Element*> view) override;
|
2020-09-04 16:11:36 +00:00
|
|
|
bool listIsGoodForAroundPosition(not_null<const Element *> view) override;
|
2020-11-10 16:38:21 +00:00
|
|
|
void listSendBotCommand(
|
|
|
|
const QString &command,
|
|
|
|
const FullMsgId &context) override;
|
2020-11-10 18:51:20 +00:00
|
|
|
void listHandleViaClick(not_null<UserData*> bot) override;
|
2021-08-27 20:44:47 +00:00
|
|
|
not_null<Ui::ChatTheme*> listChatTheme() override;
|
2019-08-08 17:07:55 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
void showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) override;
|
|
|
|
void showFinishedHook() override;
|
|
|
|
void doSetInnerFocus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onScroll();
|
|
|
|
void updateInnerVisibleArea();
|
|
|
|
void updateControlsGeometry();
|
|
|
|
void updateAdaptiveLayout();
|
|
|
|
void saveState(not_null<ScheduledMemento*> memento);
|
|
|
|
void restoreState(not_null<ScheduledMemento*> memento);
|
|
|
|
void showAtPosition(Data::MessagePosition position);
|
|
|
|
bool showAtPositionNow(Data::MessagePosition position);
|
|
|
|
|
2019-08-16 09:32:42 +00:00
|
|
|
void setupComposeControls();
|
|
|
|
|
2020-06-10 11:46:27 +00:00
|
|
|
void setupDragArea();
|
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
void setupScrollDownButton();
|
|
|
|
void scrollDownClicked();
|
|
|
|
void scrollDownAnimationFinish();
|
|
|
|
void updateScrollDownVisibility();
|
|
|
|
void updateScrollDownPosition();
|
|
|
|
|
2019-08-09 17:58:58 +00:00
|
|
|
void confirmSendNowSelected();
|
2019-08-08 17:07:55 +00:00
|
|
|
void confirmDeleteSelected();
|
|
|
|
void clearSelected();
|
|
|
|
|
2019-08-16 15:08:51 +00:00
|
|
|
void send();
|
|
|
|
void send(Api::SendOptions options);
|
2020-09-29 15:05:48 +00:00
|
|
|
void sendVoice(QByteArray bytes, VoiceWaveform waveform, int duration);
|
|
|
|
void sendVoice(
|
|
|
|
QByteArray bytes,
|
|
|
|
VoiceWaveform waveform,
|
|
|
|
int duration,
|
|
|
|
Api::SendOptions options);
|
2020-06-01 17:22:03 +00:00
|
|
|
void edit(
|
|
|
|
not_null<HistoryItem*> item,
|
2020-06-06 13:25:50 +00:00
|
|
|
Api::SendOptions options,
|
|
|
|
mtpRequestId *const saveEditMsgRequestId);
|
2019-08-16 15:08:51 +00:00
|
|
|
void highlightSingleNewMessage(const Data::MessagesSlice &slice);
|
2019-08-16 17:07:30 +00:00
|
|
|
void chooseAttach();
|
2020-08-10 12:22:54 +00:00
|
|
|
[[nodiscard]] SendMenu::Type sendMenuType() const;
|
2019-08-16 17:07:30 +00:00
|
|
|
|
|
|
|
void uploadFile(const QByteArray &fileContent, SendMediaType type);
|
|
|
|
bool confirmSendingFiles(
|
|
|
|
QImage &&image,
|
|
|
|
QByteArray &&content,
|
2020-10-15 14:27:16 +00:00
|
|
|
std::optional<bool> overrideSendImagesAsPhotos = std::nullopt,
|
2019-08-16 17:07:30 +00:00
|
|
|
const QString &insertTextOnCancel = QString());
|
|
|
|
bool confirmSendingFiles(
|
2020-10-13 12:07:53 +00:00
|
|
|
Ui::PreparedList &&list,
|
2019-08-16 17:07:30 +00:00
|
|
|
const QString &insertTextOnCancel = QString());
|
2020-05-15 12:47:10 +00:00
|
|
|
bool confirmSendingFiles(
|
|
|
|
not_null<const QMimeData*> data,
|
2020-10-15 14:27:16 +00:00
|
|
|
std::optional<bool> overrideSendImagesAsPhotos = std::nullopt,
|
2020-05-15 12:47:10 +00:00
|
|
|
const QString &insertTextOnCancel = QString());
|
2020-10-13 12:07:53 +00:00
|
|
|
bool showSendingFilesError(const Ui::PreparedList &list) const;
|
2020-10-17 09:51:55 +00:00
|
|
|
void sendingFilesConfirmed(
|
2020-10-13 12:07:53 +00:00
|
|
|
Ui::PreparedList &&list,
|
2020-10-17 09:51:55 +00:00
|
|
|
Ui::SendFilesWay way,
|
2019-08-16 17:07:30 +00:00
|
|
|
TextWithTags &&caption,
|
|
|
|
Api::SendOptions options,
|
2020-10-17 09:51:55 +00:00
|
|
|
bool ctrlShiftEnter);
|
2019-08-16 17:07:30 +00:00
|
|
|
|
|
|
|
void sendExistingDocument(not_null<DocumentData*> document);
|
|
|
|
bool sendExistingDocument(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
Api::SendOptions options);
|
|
|
|
void sendExistingPhoto(not_null<PhotoData*> photo);
|
|
|
|
bool sendExistingPhoto(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
Api::SendOptions options);
|
|
|
|
void sendInlineResult(
|
|
|
|
not_null<InlineBots::Result*> result,
|
|
|
|
not_null<UserData*> bot);
|
|
|
|
void sendInlineResult(
|
|
|
|
not_null<InlineBots::Result*> result,
|
|
|
|
not_null<UserData*> bot,
|
|
|
|
Api::SendOptions options);
|
2019-08-16 15:08:51 +00:00
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
const not_null<History*> _history;
|
2021-08-27 20:44:47 +00:00
|
|
|
std::shared_ptr<Ui::ChatTheme> _theme;
|
2019-08-08 17:07:55 +00:00
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
QPointer<ListWidget> _inner;
|
|
|
|
object_ptr<TopBarWidget> _topBar;
|
|
|
|
object_ptr<Ui::PlainShadow> _topBarShadow;
|
2019-08-16 09:32:42 +00:00
|
|
|
std::unique_ptr<ComposeControls> _composeControls;
|
2019-08-08 17:07:55 +00:00
|
|
|
bool _skipScrollEvent = false;
|
|
|
|
|
|
|
|
FullMsgId _highlightMessageId;
|
|
|
|
std::optional<Data::MessagePosition> _nextAnimatedScrollPosition;
|
|
|
|
int _nextAnimatedScrollDelta = 0;
|
|
|
|
|
|
|
|
Ui::Animations::Simple _scrollDownShown;
|
|
|
|
bool _scrollDownIsShown = false;
|
|
|
|
object_ptr<Ui::HistoryDownButton> _scrollDown;
|
|
|
|
|
2019-08-16 15:08:51 +00:00
|
|
|
Data::MessagesSlice _lastSlice;
|
2019-08-16 17:07:30 +00:00
|
|
|
bool _choosingAttach = false;
|
2019-08-16 15:08:51 +00:00
|
|
|
|
2019-08-08 17:07:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScheduledMemento : public Window::SectionMemento {
|
|
|
|
public:
|
|
|
|
ScheduledMemento(not_null<History*> history)
|
2019-09-02 12:22:01 +00:00
|
|
|
: _history(history) {
|
2019-08-08 17:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
object_ptr<Window::SectionWidget> createWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
Window::Column column,
|
|
|
|
const QRect &geometry) override;
|
|
|
|
|
|
|
|
not_null<History*> getHistory() const {
|
|
|
|
return _history;
|
|
|
|
}
|
|
|
|
|
|
|
|
not_null<ListMemento*> list() {
|
|
|
|
return &_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const not_null<History*> _history;
|
|
|
|
ListMemento _list;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-08-28 10:01:55 +00:00
|
|
|
} // namespace HistoryView
|