tdesktop/Telegram/SourceFiles/boxes/edit_caption_box.h

150 lines
3.5 KiB
C
Raw Normal View History

/*
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 "boxes/abstract_box.h"
2019-03-26 21:14:51 +00:00
#include "storage/storage_media_prepare.h"
#include "ui/wrap/slide_wrap.h"
2019-11-18 09:28:14 +00:00
#include "mtproto/mtproto_rpc_sender.h"
namespace ChatHelpers {
class TabbedPanel;
} // namespace ChatHelpers
namespace Window {
class SessionController;
} // namespace Window
namespace Data {
class Media;
class DocumentMedia;
} // namespace Data
namespace Ui {
class InputField;
class EmojiButton;
class IconButton;
class Checkbox;
} // namespace Ui
2018-04-06 16:23:09 +00:00
namespace Window {
class SessionController;
2018-04-06 16:23:09 +00:00
} // namespace Window
namespace Media {
namespace Streaming {
class Instance;
class Document;
struct Update;
enum class Error;
struct Information;
} // namespace Streaming
} // namespace Media
2019-09-16 11:14:06 +00:00
class EditCaptionBox
2019-09-18 11:19:05 +00:00
: public Ui::BoxContent
2019-09-16 11:14:06 +00:00
, public RPCSender
, private base::Subscriber {
public:
EditCaptionBox(
QWidget*,
not_null<Window::SessionController*> controller,
not_null<HistoryItem*> item);
~EditCaptionBox();
protected:
void prepare() override;
void setInnerFocus() override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
private:
void updateBoxSize();
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();
void setupEmojiPanel();
void updateEmojiPanelGeometry();
void emojiFilterForGeometry(not_null<QEvent*> event);
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);
bool fileFromClipboard(not_null<const QMimeData*> data);
void updateEditPreview();
void updateEditMediaButton();
2019-03-26 21:14:51 +00:00
int errorTopSkip() const;
void createEditMediaButton();
inline QString getNewMediaPath() {
return _preparedList.files.empty()
? QString()
: _preparedList.files.front().path;
}
not_null<Window::SessionController*> _controller;
FullMsgId _msgId;
std::shared_ptr<Data::DocumentMedia> _documentMedia;
Image *_thumbnailImage = nullptr;
bool _thumbnailImageLoaded = false;
Fn<void()> _refreshThumbnail;
bool _animated = false;
bool _photo = false;
bool _doc = false;
QPixmap _thumb;
std::unique_ptr<::Media::Streaming::Instance> _streamed;
object_ptr<Ui::InputField> _field = { nullptr };
object_ptr<Ui::EmojiButton> _emojiToggle = { nullptr };
base::unique_qptr<ChatHelpers::TabbedPanel> _emojiPanel;
base::unique_qptr<QObject> _emojiFilter;
int _thumbx = 0;
int _thumbw = 0;
int _thumbh = 0;
2019-06-12 13:26:04 +00:00
Ui::Text::String _name;
QString _status;
bool _isAudio = false;
bool _isImage = false;
int _gifw = 0;
int _gifh = 0;
int _gifx = 0;
2019-03-26 21:14:51 +00:00
Storage::PreparedList _preparedList;
bool _previewCancelled = false;
mtpRequestId _saveRequestId = 0;
object_ptr<Ui::IconButton> _editMedia = nullptr;
Ui::SlideWrap<Ui::RpWidget> *_wayWrap = nullptr;
2019-03-24 12:39:19 +00:00
QString _newMediaPath;
bool _isAllowedEditMedia = false;
bool _isAlbum = false;
bool _asFile = false;
rpl::event_stream<> _editMediaClicks;
2019-03-24 12:39:19 +00:00
QString _error;
};