2014-05-30 12:53:19 +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.
|
2014-05-30 12:53:19 +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
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-22 21:42:33 +04:00
|
|
|
#include <rpl/variable.h>
|
2017-04-06 17:38:10 +03:00
|
|
|
#include "boxes/abstract_box.h"
|
2017-03-04 13:23:56 +03:00
|
|
|
#include "storage/localimageloader.h"
|
2017-12-19 20:57:42 +04:00
|
|
|
#include "storage/storage_media_prepare.h"
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2018-05-26 17:58:21 +03:00
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
} // namespace Window
|
|
|
|
|
2018-11-22 16:48:50 +04:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class TabbedPanel;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2016-10-28 12:20:24 +03:00
|
|
|
namespace Ui {
|
2017-12-22 21:42:33 +04:00
|
|
|
template <typename Enum>
|
|
|
|
class Radioenum;
|
|
|
|
template <typename Enum>
|
|
|
|
class RadioenumGroup;
|
2016-11-11 16:46:04 +03:00
|
|
|
class RoundButton;
|
2018-05-20 20:42:30 +03:00
|
|
|
class InputField;
|
2017-12-19 20:57:42 +04:00
|
|
|
struct GroupMediaLayout;
|
2018-11-22 16:48:50 +04:00
|
|
|
class EmojiButton;
|
2016-10-28 12:20:24 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-04-06 20:23:09 +04:00
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
} // namespace Window
|
|
|
|
|
2017-12-25 14:13:27 +03:00
|
|
|
enum class SendFilesWay {
|
|
|
|
Album,
|
|
|
|
Photos,
|
|
|
|
Files,
|
|
|
|
};
|
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
class SendFilesBox : public BoxContent {
|
2014-05-30 12:53:19 +04:00
|
|
|
public:
|
2017-12-21 20:15:37 +04:00
|
|
|
SendFilesBox(
|
|
|
|
QWidget*,
|
2018-05-26 17:58:21 +03:00
|
|
|
not_null<Window::Controller*> controller,
|
2017-12-21 20:15:37 +04:00
|
|
|
Storage::PreparedList &&list,
|
2018-05-24 17:57:41 +03:00
|
|
|
const TextWithTags &caption,
|
2017-12-21 20:15:37 +04:00
|
|
|
CompressConfirm compressed);
|
|
|
|
|
|
|
|
void setConfirmedCallback(
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(
|
2017-12-21 20:15:37 +04:00
|
|
|
Storage::PreparedList &&list,
|
2017-12-25 14:13:27 +03:00
|
|
|
SendFilesWay way,
|
2018-05-24 16:03:21 +03:00
|
|
|
TextWithTags &&caption,
|
2017-12-21 20:15:37 +04:00
|
|
|
bool ctrlShiftEnter)> callback) {
|
2017-02-21 16:45:56 +03:00
|
|
|
_confirmedCallback = std::move(callback);
|
2016-11-28 18:45:07 +03:00
|
|
|
}
|
2018-06-04 18:35:11 +03:00
|
|
|
void setCancelledCallback(Fn<void()> callback) {
|
2017-02-21 16:45:56 +03:00
|
|
|
_cancelledCallback = std::move(callback);
|
2016-11-28 18:45:07 +03:00
|
|
|
}
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2017-12-05 12:43:18 +04:00
|
|
|
~SendFilesBox();
|
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-08-16 19:53:10 +03:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-04-02 13:33:19 +03:00
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
private:
|
2017-12-22 21:42:33 +04:00
|
|
|
class AlbumPreview;
|
|
|
|
|
|
|
|
void initSendWay();
|
|
|
|
void initPreview(rpl::producer<int> desiredPreviewHeight);
|
|
|
|
|
|
|
|
void setupControls();
|
|
|
|
void setupSendWayControls();
|
|
|
|
void setupCaption();
|
|
|
|
void setupShadows(
|
|
|
|
not_null<Ui::ScrollArea*> wrap,
|
|
|
|
not_null<AlbumPreview*> content);
|
|
|
|
|
2018-11-22 16:48:50 +04:00
|
|
|
void setupEmojiPanel();
|
|
|
|
void updateEmojiPanelGeometry();
|
|
|
|
bool emojiFilter(not_null<QEvent*> event);
|
|
|
|
|
2017-12-30 00:06:43 +03:00
|
|
|
void refreshAlbumMediaCount();
|
2017-12-29 20:02:23 +03:00
|
|
|
void preparePreview();
|
2017-12-22 21:42:33 +04:00
|
|
|
void prepareSingleFilePreview();
|
|
|
|
void prepareAlbumPreview();
|
2017-12-25 22:26:08 +03:00
|
|
|
void applyAlbumOrder();
|
2017-03-10 17:14:10 +03:00
|
|
|
|
2017-12-19 20:57:42 +04:00
|
|
|
void send(bool ctrlShiftEnter = false);
|
|
|
|
void captionResized();
|
|
|
|
|
2017-12-22 21:42:33 +04:00
|
|
|
void setupTitleText();
|
2015-10-11 10:37:24 +02:00
|
|
|
void updateBoxSize();
|
2016-11-28 18:45:07 +03:00
|
|
|
void updateControlsGeometry();
|
2018-12-26 10:47:03 +04:00
|
|
|
void updateCaptionPlaceholder();
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2017-12-29 20:02:23 +03:00
|
|
|
bool canAddFiles(not_null<const QMimeData*> data) const;
|
2018-03-10 00:09:12 +03:00
|
|
|
bool canAddUrls(const QList<QUrl> &urls) const;
|
2017-12-29 20:02:23 +03:00
|
|
|
bool addFiles(not_null<const QMimeData*> data);
|
|
|
|
|
2018-05-26 17:58:21 +03:00
|
|
|
not_null<Window::Controller*> _controller;
|
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
QString _titleText;
|
2017-12-22 21:42:33 +04:00
|
|
|
int _titleHeight = 0;
|
|
|
|
|
2017-12-19 20:57:42 +04:00
|
|
|
Storage::PreparedList _list;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2017-12-30 00:06:43 +03:00
|
|
|
CompressConfirm _compressConfirmInitial = CompressConfirm::None;
|
2016-11-28 18:45:07 +03:00
|
|
|
CompressConfirm _compressConfirm = CompressConfirm::None;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(
|
2017-12-21 20:15:37 +04:00
|
|
|
Storage::PreparedList &&list,
|
2017-12-25 14:13:27 +03:00
|
|
|
SendFilesWay way,
|
2018-05-24 16:03:21 +03:00
|
|
|
TextWithTags &&caption,
|
2017-12-21 20:15:37 +04:00
|
|
|
bool ctrlShiftEnter)> _confirmedCallback;
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void()> _cancelledCallback;
|
2016-11-28 18:45:07 +03:00
|
|
|
bool _confirmed = false;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2018-05-20 20:42:30 +03:00
|
|
|
object_ptr<Ui::InputField> _caption = { 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-25 14:13:27 +03:00
|
|
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendAlbum = { nullptr };
|
|
|
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendPhotos = { nullptr };
|
|
|
|
object_ptr<Ui::Radioenum<SendFilesWay>> _sendFiles = { nullptr };
|
|
|
|
std::shared_ptr<Ui::RadioenumGroup<SendFilesWay>> _sendWay;
|
2016-02-21 15:30:16 +03:00
|
|
|
|
2017-12-22 21:42:33 +04:00
|
|
|
rpl::variable<int> _footerHeight = 0;
|
2017-12-19 20:57:42 +04:00
|
|
|
|
2017-12-22 21:42:33 +04:00
|
|
|
QWidget *_preview = nullptr;
|
|
|
|
AlbumPreview *_albumPreview = nullptr;
|
|
|
|
int _albumVideosCount = 0;
|
|
|
|
int _albumPhotosCount = 0;
|
2017-12-19 20:57:42 +04:00
|
|
|
|
2017-12-22 21:42:33 +04:00
|
|
|
QPointer<Ui::RoundButton> _send;
|
2017-12-19 20:57:42 +04:00
|
|
|
|
|
|
|
};
|