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"
|
2019-03-27 00:14:51 +03:00
|
|
|
#include "storage/storage_media_prepare.h"
|
2019-03-27 13:44:57 +03:00
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2019-09-13 09:06:02 +03:00
|
|
|
#include "media/clip/media_clip_reader.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 {
|
|
|
|
class Media;
|
|
|
|
} // namespace Data
|
2018-01-13 15:45:11 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
namespace Ui {
|
2018-05-20 20:42:30 +03:00
|
|
|
class InputField;
|
2018-11-22 16:48:50 +04:00
|
|
|
class EmojiButton;
|
2019-04-04 19:31:34 +03:00
|
|
|
class IconButton;
|
2019-03-27 13:44:57 +03:00
|
|
|
class Checkbox;
|
2017-12-22 09:16:23 +04:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-04-06 20:23:09 +04:00
|
|
|
namespace Window {
|
2019-06-06 13:21:40 +03:00
|
|
|
class SessionController;
|
2018-04-06 20:23:09 +04:00
|
|
|
} // namespace Window
|
|
|
|
|
2019-09-16 14:14:06 +03:00
|
|
|
class EditCaptionBox
|
2019-09-18 14:19:05 +03:00
|
|
|
: public Ui::BoxContent
|
2019-09-16 14:14:06 +03:00
|
|
|
, public RPCSender
|
|
|
|
, private base::Subscriber {
|
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);
|
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:
|
|
|
|
void updateBoxSize();
|
2019-03-27 09:28:18 +03:00
|
|
|
void prepareGifPreview(DocumentData* document = nullptr);
|
2017-12-22 09:16:23 +04:00
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
|
|
|
|
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
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
void save();
|
|
|
|
void captionResized();
|
|
|
|
|
|
|
|
void saveDone(const MTPUpdates &updates);
|
|
|
|
bool saveFail(const RPCError &error);
|
|
|
|
|
2019-03-27 00:14:51 +03:00
|
|
|
void setName(QString nameString, qint64 size);
|
2019-04-01 22:09:14 +03:00
|
|
|
bool fileFromClipboard(not_null<const QMimeData*> data);
|
|
|
|
void updateEditPreview();
|
2019-04-04 19:31:34 +03:00
|
|
|
void updateEditMediaButton();
|
2019-03-27 00:14:51 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
int errorTopSkip() const;
|
|
|
|
|
2019-03-29 13:51:19 +03:00
|
|
|
void createEditMediaButton();
|
|
|
|
|
2019-04-02 13:38:53 +03:00
|
|
|
inline QString getNewMediaPath() {
|
|
|
|
return _preparedList.files.empty()
|
|
|
|
? QString()
|
|
|
|
: _preparedList.files.front().path;
|
|
|
|
}
|
|
|
|
|
2019-06-06 13:21:40 +03:00
|
|
|
not_null<Window::SessionController*> _controller;
|
2017-12-22 09:16:23 +04:00
|
|
|
FullMsgId _msgId;
|
2019-01-25 18:37:28 +04:00
|
|
|
Image *_thumbnailImage = nullptr;
|
2018-08-02 17:31:54 +03:00
|
|
|
bool _thumbnailImageLoaded = false;
|
|
|
|
Fn<void()> _refreshThumbnail;
|
2017-12-22 09:16:23 +04:00
|
|
|
bool _animated = false;
|
|
|
|
bool _photo = false;
|
|
|
|
bool _doc = false;
|
|
|
|
|
|
|
|
QPixmap _thumb;
|
|
|
|
Media::Clip::ReaderPointer _gifPreview;
|
|
|
|
|
2018-05-20 20:42:30 +03:00
|
|
|
object_ptr<Ui::InputField> _field = { nullptr };
|
2018-11-22 16:48:50 +04:00
|
|
|
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
|
|
|
|
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
|
|
|
|
base::unique_qptr<QObject> _emojiFilter;
|
2017-12-22 09:16:23 +04:00
|
|
|
|
|
|
|
int _thumbx = 0;
|
|
|
|
int _thumbw = 0;
|
|
|
|
int _thumbh = 0;
|
2019-06-12 15:26:04 +02:00
|
|
|
Ui::Text::String _name;
|
2017-12-22 09:16:23 +04:00
|
|
|
QString _status;
|
|
|
|
bool _isAudio = false;
|
|
|
|
bool _isImage = false;
|
|
|
|
|
2019-03-21 15:17:18 +03:00
|
|
|
int _gifw = 0;
|
|
|
|
int _gifh = 0;
|
|
|
|
int _gifx = 0;
|
|
|
|
|
2019-03-27 00:14:51 +03:00
|
|
|
Storage::PreparedList _preparedList;
|
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
bool _previewCancelled = false;
|
|
|
|
mtpRequestId _saveRequestId = 0;
|
|
|
|
|
2019-04-04 19:31:34 +03:00
|
|
|
object_ptr<Ui::IconButton> _editMedia = nullptr;
|
2019-03-27 13:44:57 +03:00
|
|
|
Ui::SlideWrap<Ui::RpWidget> *_wayWrap = nullptr;
|
2019-03-24 15:39:19 +03:00
|
|
|
QString _newMediaPath;
|
2019-03-29 13:51:19 +03:00
|
|
|
bool _isAllowedEditMedia = false;
|
2019-04-02 13:38:53 +03:00
|
|
|
bool _isAlbum = false;
|
2019-04-04 19:31:34 +03:00
|
|
|
bool _asFile = false;
|
2019-03-30 11:53:28 +03:00
|
|
|
rpl::event_stream<> _editMediaClicks;
|
2019-03-24 15:39:19 +03:00
|
|
|
|
2017-12-22 09:16:23 +04:00
|
|
|
QString _error;
|
|
|
|
|
|
|
|
};
|