tdesktop/Telegram/SourceFiles/boxes/send_files_box.h

130 lines
3.1 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
2017-12-22 17:42:33 +00:00
#include <rpl/variable.h>
2017-04-06 14:38:10 +00:00
#include "boxes/abstract_box.h"
2017-03-04 10:23:56 +00:00
#include "storage/localimageloader.h"
2017-12-19 16:57:42 +00:00
#include "storage/storage_media_prepare.h"
namespace Window {
class Controller;
} // namespace Window
namespace Ui {
2017-12-22 17:42:33 +00:00
template <typename Enum>
class Radioenum;
template <typename Enum>
class RadioenumGroup;
class RoundButton;
class InputField;
2017-12-19 16:57:42 +00:00
struct GroupMediaLayout;
} // namespace Ui
enum class SendFilesWay {
Album,
Photos,
Files,
};
class SendFilesBox : public BoxContent {
public:
SendFilesBox(
QWidget*,
not_null<Window::Controller*> controller,
Storage::PreparedList &&list,
const TextWithTags &caption,
CompressConfirm compressed);
void setConfirmedCallback(
base::lambda<void(
Storage::PreparedList &&list,
SendFilesWay way,
TextWithTags &&caption,
bool ctrlShiftEnter)> callback) {
_confirmedCallback = std::move(callback);
}
void setCancelledCallback(base::lambda<void()> callback) {
_cancelledCallback = std::move(callback);
}
2015-10-11 08:37:24 +00:00
~SendFilesBox();
protected:
void prepare() override;
void setInnerFocus() override;
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:
2017-12-22 17:42:33 +00: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);
void refreshAlbumMediaCount();
void preparePreview();
2017-12-22 17:42:33 +00:00
void prepareSingleFilePreview();
void prepareAlbumPreview();
void applyAlbumOrder();
2017-12-19 16:57:42 +00:00
void send(bool ctrlShiftEnter = false);
void captionResized();
2017-12-22 17:42:33 +00:00
void setupTitleText();
2015-10-11 08:37:24 +00:00
void updateBoxSize();
void updateControlsGeometry();
2015-10-11 08:37:24 +00:00
bool canAddFiles(not_null<const QMimeData*> data) const;
bool canAddUrls(const QList<QUrl> &urls) const;
bool addFiles(not_null<const QMimeData*> data);
not_null<Window::Controller*> _controller;
QString _titleText;
2017-12-22 17:42:33 +00:00
int _titleHeight = 0;
2017-12-19 16:57:42 +00:00
Storage::PreparedList _list;
CompressConfirm _compressConfirmInitial = CompressConfirm::None;
CompressConfirm _compressConfirm = CompressConfirm::None;
base::lambda<void(
Storage::PreparedList &&list,
SendFilesWay way,
TextWithTags &&caption,
bool ctrlShiftEnter)> _confirmedCallback;
base::lambda<void()> _cancelledCallback;
bool _confirmed = false;
object_ptr<Ui::InputField> _caption = { nullptr };
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;
2017-12-22 17:42:33 +00:00
rpl::variable<int> _footerHeight = 0;
2017-12-19 16:57:42 +00:00
2017-12-22 17:42:33 +00:00
QWidget *_preview = nullptr;
AlbumPreview *_albumPreview = nullptr;
int _albumVideosCount = 0;
int _albumPhotosCount = 0;
2017-12-19 16:57:42 +00:00
2017-12-22 17:42:33 +00:00
QPointer<Ui::RoundButton> _send;
2017-12-19 16:57:42 +00:00
};