2017-12-22 09:16:23 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-22 09:16:23 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-22 09:16:23 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "boxes/abstract_box.h"
|
2020-10-13 15:07:53 +03:00
|
|
|
#include "ui/chat/attach/attach_prepare.h"
|
2017-12-22 09:16:23 +04:00
|
|
|
|
2018-11-22 16:48:50 +04:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class TabbedPanel;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2018-05-26 17:58:21 +03:00
|
|
|
namespace Window {
|
2019-06-06 13:21:40 +03:00
|
|
|
class SessionController;
|
2018-05-26 17:58:21 +03:00
|
|
|
} // namespace Window
|
|
|
|
|
2018-01-14 19:02:25 +03:00
|
|
|
namespace Data {
|
2020-05-25 18:16:04 +04:00
|
|
|
class PhotoMedia;
|
2018-01-14 19:02:25 +03:00
|
|
|
} // namespace Data
|
2018-01-13 15:45:11 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
namespace Ui {
|
2021-07-09 14:59:48 +03:00
|
|
|
class AbstractSinglePreview;
|
2018-05-20 20:42:30 +03:00
|
|
|
class InputField;
|
2018-11-22 16:48:50 +04:00
|
|
|
class EmojiButton;
|
2021-07-09 14:59:48 +03:00
|
|
|
class VerticalLayout;
|
|
|
|
class FadeShadow;
|
2020-10-20 11:19:48 +03:00
|
|
|
enum class AlbumType;
|
2017-12-22 09:16:23 +04:00
|
|
|
} // namespace Ui
|
|
|
|
|
2021-07-09 14:59:48 +03:00
|
|
|
class EditCaptionBox final : public Ui::BoxContent {
|
2017-12-22 09:16:23 +04:00
|
|
|
public:
|
2018-05-26 17:58:21 +03:00
|
|
|
EditCaptionBox(
|
|
|
|
QWidget*,
|
2019-06-06 13:21:40 +03:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-05-26 17:58:21 +03:00
|
|
|
not_null<HistoryItem*> item);
|
2020-05-20 15:04:56 +04:00
|
|
|
~EditCaptionBox();
|
2017-12-22 09:16:23 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2019-03-30 11:53:28 +03:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-12-22 09:16:23 +04:00
|
|
|
|
|
|
|
private:
|
2021-07-09 14:59:48 +03:00
|
|
|
void rebuildPreview();
|
|
|
|
void setupEditEventHandler();
|
|
|
|
void setupPhotoEditorEventHandler();
|
|
|
|
void setupShadows();
|
|
|
|
void setupField();
|
|
|
|
void setupControls();
|
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
void updateBoxSize();
|
2021-07-09 14:59:48 +03:00
|
|
|
void captionResized();
|
2017-12-22 09:16:23 +04:00
|
|
|
|
2018-11-22 16:48:50 +04:00
|
|
|
void setupEmojiPanel();
|
|
|
|
void updateEmojiPanelGeometry();
|
2019-09-05 13:51:36 +03:00
|
|
|
void emojiFilterForGeometry(not_null<QEvent*> event);
|
2018-11-22 16:48:50 +04:00
|
|
|
|
2020-06-13 16:08:55 +03:00
|
|
|
void setupDragArea();
|
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
void save();
|
|
|
|
|
2019-04-01 22:09:14 +03:00
|
|
|
bool fileFromClipboard(not_null<const QMimeData*> data);
|
2019-03-27 00:14:51 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
int errorTopSkip() const;
|
|
|
|
|
2020-10-20 11:19:48 +03:00
|
|
|
bool setPreparedList(Ui::PreparedList &&list);
|
2019-03-29 13:51:19 +03:00
|
|
|
|
2020-06-11 20:09:46 +04:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
2021-07-09 14:59:48 +03:00
|
|
|
const not_null<HistoryItem*> _historyItem;
|
2021-07-20 18:42:05 +03:00
|
|
|
const bool _isAllowedEditMedia;
|
2021-07-09 14:59:48 +03:00
|
|
|
const Ui::AlbumType _albumType;
|
2020-06-11 20:09:46 +04:00
|
|
|
|
2021-07-09 14:59:48 +03:00
|
|
|
const base::unique_qptr<Ui::VerticalLayout> _controls;
|
|
|
|
const base::unique_qptr<Ui::ScrollArea> _scroll;
|
|
|
|
const base::unique_qptr<Ui::InputField> _field;
|
|
|
|
const base::unique_qptr<Ui::EmojiButton> _emojiToggle;
|
2021-07-20 18:42:05 +03:00
|
|
|
const base::unique_qptr<Ui::FadeShadow> _topShadow, _bottomShadow;
|
2021-07-09 14:59:48 +03:00
|
|
|
|
|
|
|
base::unique_qptr<Ui::AbstractSinglePreview> _content;
|
2018-11-22 16:48:50 +04:00
|
|
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
|
|
|
base::unique_qptr<QObject> _emojiFilter;
|
2017-12-22 09:16:23 +04:00
|
|
|
|
2021-07-09 14:59:48 +03:00
|
|
|
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
2019-03-21 15:17:18 +03:00
|
|
|
|
2020-10-13 15:07:53 +03:00
|
|
|
Ui::PreparedList _preparedList;
|
2019-03-27 00:14:51 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
mtpRequestId _saveRequestId = 0;
|
|
|
|
|
2021-07-20 18:42:05 +03:00
|
|
|
bool _isPhoto = false;
|
2019-04-04 19:31:34 +03:00
|
|
|
bool _asFile = false;
|
2019-03-24 15:39:19 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
QString _error;
|
|
|
|
|
2021-07-09 14:59:48 +03:00
|
|
|
rpl::variable<int> _footerHeight = 0;
|
|
|
|
|
|
|
|
rpl::event_stream<> _editMediaClicks;
|
|
|
|
rpl::event_stream<> _photoEditorOpens;
|
2021-07-20 18:42:05 +03:00
|
|
|
rpl::event_stream<> _previewRebuilds;
|
2021-07-09 14:59:48 +03:00
|
|
|
rpl::event_stream<int> _contentHeight;
|
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
};
|