2017-12-22 05:16:23 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-12-22 05:16:23 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-12-22 05:16:23 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "boxes/abstract_box.h"
|
2019-03-26 21:14:51 +00:00
|
|
|
#include "storage/storage_media_prepare.h"
|
2019-03-27 10:44:57 +00:00
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2017-12-22 05:16:23 +00:00
|
|
|
|
2020-05-29 14:08:18 +00:00
|
|
|
class Image;
|
|
|
|
|
2018-11-22 12:48:50 +00:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class TabbedPanel;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2018-05-26 14:58:21 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-05-26 14:58:21 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2018-01-14 16:02:25 +00:00
|
|
|
namespace Data {
|
|
|
|
class Media;
|
2020-05-25 14:16:04 +00:00
|
|
|
class PhotoMedia;
|
2020-04-09 12:27:53 +00:00
|
|
|
class DocumentMedia;
|
2018-01-14 16:02:25 +00:00
|
|
|
} // namespace Data
|
2018-01-13 12:45:11 +00:00
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
namespace Ui {
|
2018-05-20 17:42:30 +00:00
|
|
|
class InputField;
|
2018-11-22 12:48:50 +00:00
|
|
|
class EmojiButton;
|
2019-04-04 16:31:34 +00:00
|
|
|
class IconButton;
|
2019-03-27 10:44:57 +00:00
|
|
|
class Checkbox;
|
2017-12-22 05:16:23 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-04-06 16:23:09 +00:00
|
|
|
namespace Window {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2018-04-06 16:23:09 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2020-05-20 11:04:56 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Streaming {
|
|
|
|
class Instance;
|
|
|
|
class Document;
|
|
|
|
struct Update;
|
|
|
|
enum class Error;
|
|
|
|
struct Information;
|
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class EditCaptionBox final : public Ui::BoxContent, private base::Subscriber {
|
2017-12-22 05:16:23 +00:00
|
|
|
public:
|
2018-05-26 14:58:21 +00:00
|
|
|
EditCaptionBox(
|
|
|
|
QWidget*,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2018-05-26 14:58:21 +00:00
|
|
|
not_null<HistoryItem*> item);
|
2020-05-20 11:04:56 +00:00
|
|
|
~EditCaptionBox();
|
2017-12-22 05:16:23 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2019-03-30 08:53:28 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2017-12-22 05:16:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateBoxSize();
|
2020-05-20 11:04:56 +00:00
|
|
|
void prepareStreamedPreview();
|
|
|
|
void checkStreamedIsStarted();
|
|
|
|
void setupStreamedPreview(
|
|
|
|
std::shared_ptr<::Media::Streaming::Document> shared);
|
|
|
|
void handleStreamingUpdate(::Media::Streaming::Update &&update);
|
|
|
|
void handleStreamingError(::Media::Streaming::Error &&error);
|
|
|
|
void streamingReady(::Media::Streaming::Information &&info);
|
|
|
|
void startStreamedPlayer();
|
2017-12-22 05:16:23 +00:00
|
|
|
|
2018-11-22 12:48:50 +00:00
|
|
|
void setupEmojiPanel();
|
|
|
|
void updateEmojiPanelGeometry();
|
2019-09-05 10:51:36 +00:00
|
|
|
void emojiFilterForGeometry(not_null<QEvent*> event);
|
2018-11-22 12:48:50 +00:00
|
|
|
|
2020-06-13 13:08:55 +00:00
|
|
|
void setupDragArea();
|
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
void save();
|
|
|
|
void captionResized();
|
|
|
|
|
2019-03-26 21:14:51 +00:00
|
|
|
void setName(QString nameString, qint64 size);
|
2019-04-01 19:09:14 +00:00
|
|
|
bool fileFromClipboard(not_null<const QMimeData*> data);
|
|
|
|
void updateEditPreview();
|
2019-04-04 16:31:34 +00:00
|
|
|
void updateEditMediaButton();
|
2019-03-26 21:14:51 +00:00
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
int errorTopSkip() const;
|
|
|
|
|
2019-03-29 10:51:19 +00:00
|
|
|
void createEditMediaButton();
|
|
|
|
|
2019-04-02 10:38:53 +00:00
|
|
|
inline QString getNewMediaPath() {
|
|
|
|
return _preparedList.files.empty()
|
|
|
|
? QString()
|
|
|
|
: _preparedList.files.front().path;
|
|
|
|
}
|
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
const not_null<Window::SessionController*> _controller;
|
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
FullMsgId _msgId;
|
2020-05-25 14:16:04 +00:00
|
|
|
std::shared_ptr<Data::PhotoMedia> _photoMedia;
|
2020-04-15 14:06:34 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> _documentMedia;
|
2018-08-02 14:31:54 +00:00
|
|
|
bool _thumbnailImageLoaded = false;
|
|
|
|
Fn<void()> _refreshThumbnail;
|
2017-12-22 05:16:23 +00:00
|
|
|
bool _animated = false;
|
|
|
|
bool _photo = false;
|
|
|
|
bool _doc = false;
|
|
|
|
|
|
|
|
QPixmap _thumb;
|
2020-05-20 11:04:56 +00:00
|
|
|
std::unique_ptr<::Media::Streaming::Instance> _streamed;
|
2017-12-22 05:16:23 +00:00
|
|
|
|
2018-05-20 17:42:30 +00:00
|
|
|
object_ptr<Ui::InputField> _field = { nullptr };
|
2018-11-22 12:48:50 +00:00
|
|
|
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
|
|
|
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
|
|
|
base::unique_qptr<QObject> _emojiFilter;
|
2017-12-22 05:16:23 +00:00
|
|
|
|
|
|
|
int _thumbx = 0;
|
|
|
|
int _thumbw = 0;
|
|
|
|
int _thumbh = 0;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _name;
|
2017-12-22 05:16:23 +00:00
|
|
|
QString _status;
|
|
|
|
bool _isAudio = false;
|
|
|
|
bool _isImage = false;
|
|
|
|
|
2019-03-21 12:17:18 +00:00
|
|
|
int _gifw = 0;
|
|
|
|
int _gifh = 0;
|
|
|
|
int _gifx = 0;
|
|
|
|
|
2019-03-26 21:14:51 +00:00
|
|
|
Storage::PreparedList _preparedList;
|
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
mtpRequestId _saveRequestId = 0;
|
|
|
|
|
2019-04-04 16:31:34 +00:00
|
|
|
object_ptr<Ui::IconButton> _editMedia = nullptr;
|
2019-03-27 10:44:57 +00:00
|
|
|
Ui::SlideWrap<Ui::RpWidget> *_wayWrap = nullptr;
|
2019-03-24 12:39:19 +00:00
|
|
|
QString _newMediaPath;
|
2019-03-29 10:51:19 +00:00
|
|
|
bool _isAllowedEditMedia = false;
|
2019-04-02 10:38:53 +00:00
|
|
|
bool _isAlbum = false;
|
2019-04-04 16:31:34 +00:00
|
|
|
bool _asFile = false;
|
2019-03-30 08:53:28 +00:00
|
|
|
rpl::event_stream<> _editMediaClicks;
|
2019-03-24 12:39:19 +00:00
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
QString _error;
|
|
|
|
|
|
|
|
};
|