tdesktop/Telegram/SourceFiles/boxes/send_files_box.h

163 lines
4.1 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2015-10-03 16:16:42 +03:00
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once
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"
namespace Ui {
class Checkbox;
class RoundButton;
class InputArea;
2017-12-19 20:57:42 +04:00
struct GroupMediaLayout;
} // namespace Ui
class SendFilesBox : public BoxContent {
public:
SendFilesBox(
QWidget*,
Storage::PreparedList &&list,
CompressConfirm compressed);
void setConfirmedCallback(
base::lambda<void(
Storage::PreparedList &&list,
bool compressed,
const QString &caption,
bool ctrlShiftEnter)> callback) {
_confirmedCallback = std::move(callback);
}
void setCancelledCallback(base::lambda<void()> callback) {
_cancelledCallback = std::move(callback);
}
2015-10-11 10:37:24 +02: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:
void prepareSingleFileLayout();
void prepareDocumentLayout();
void prepareGifPreview();
void clipCallback(Media::Clip::Notification notification);
2017-12-19 20:57:42 +04:00
void send(bool ctrlShiftEnter = false);
void captionResized();
void compressedChange();
void updateTitleText();
2015-10-11 10:37:24 +02:00
void updateBoxSize();
void updateControlsGeometry();
base::lambda<QString()> getSendButtonText() const;
2015-10-11 10:37:24 +02:00
QString _titleText;
2017-12-19 20:57:42 +04:00
Storage::PreparedList _list;
CompressConfirm _compressConfirm = CompressConfirm::None;
bool _animated = false;
QPixmap _preview;
int _previewLeft = 0;
int _previewWidth = 0;
int _previewHeight = 0;
Media::Clip::ReaderPointer _gifPreview;
QPixmap _fileThumb;
Text _nameText;
bool _fileIsAudio = false;
bool _fileIsImage = false;
QString _statusText;
int _statusWidth = 0;
base::lambda<void(
Storage::PreparedList &&list,
bool compressed,
const QString &caption,
bool ctrlShiftEnter)> _confirmedCallback;
base::lambda<void()> _cancelledCallback;
bool _confirmed = false;
object_ptr<Ui::InputArea> _caption = { nullptr };
object_ptr<Ui::Checkbox> _compressed = { nullptr };
QPointer<Ui::RoundButton> _send;
};
2017-12-19 20:57:42 +04:00
class SendAlbumBox : public BoxContent {
public:
2017-12-19 20:57:42 +04:00
SendAlbumBox(QWidget*, Storage::PreparedList &&list);
void setConfirmedCallback(
base::lambda<void(
Storage::PreparedList &&list,
const QString &caption,
bool ctrlShiftEnter)> callback) {
2017-12-19 20:57:42 +04:00
_confirmedCallback = std::move(callback);
}
void setCancelledCallback(base::lambda<void()> callback) {
_cancelledCallback = std::move(callback);
}
2017-12-19 20:57:42 +04:00
~SendAlbumBox();
protected:
void prepare() override;
void setInnerFocus() override;
void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
private:
struct Thumb;
void prepareThumbs();
Thumb prepareThumb(
const QImage &preview,
const Ui::GroupMediaLayout &layout) const;
void send(bool ctrlShiftEnter = false);
void captionResized();
void updateBoxSize();
void updateControlsGeometry();
Storage::PreparedList _list;
std::vector<Thumb> _thumbs;
int _thumbsHeight = 0;
base::lambda<void(Storage::PreparedList &&list, const QString &caption, bool ctrlShiftEnter)> _confirmedCallback;
base::lambda<void()> _cancelledCallback;
bool _confirmed = false;
object_ptr<Ui::InputArea> _caption = { nullptr };
};