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"
|
2019-03-30 08:53:28 +00:00
|
|
|
#include <rpl/event_stream.h>
|
2017-12-22 05:16:23 +00:00
|
|
|
|
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;
|
|
|
|
} // 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
|
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
class EditCaptionBox : public BoxContent, public RPCSender {
|
|
|
|
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);
|
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();
|
2019-03-27 06:28:18 +00:00
|
|
|
void prepareGifPreview(DocumentData* document = nullptr);
|
2017-12-22 05:16:23 +00:00
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
|
|
|
|
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
|
|
|
|
2017-12-22 05:16:23 +00:00
|
|
|
void save();
|
|
|
|
void captionResized();
|
|
|
|
|
|
|
|
void saveDone(const MTPUpdates &updates);
|
|
|
|
bool saveFail(const RPCError &error);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> _controller;
|
2017-12-22 05:16:23 +00:00
|
|
|
FullMsgId _msgId;
|
2019-01-25 14:37:28 +00:00
|
|
|
Image *_thumbnailImage = nullptr;
|
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;
|
|
|
|
Media::Clip::ReaderPointer _gifPreview;
|
|
|
|
|
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
|
|
|
bool _previewCancelled = false;
|
|
|
|
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;
|
|
|
|
|
|
|
|
};
|