2014-05-30 12:53:19 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 13:47:38 +03:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 22:31:31 +04:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#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"
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2016-10-28 12:20:24 +03:00
|
|
|
namespace Ui {
|
|
|
|
class Checkbox;
|
2016-11-11 16:46:04 +03:00
|
|
|
class RoundButton;
|
2016-11-15 14:56:49 +03:00
|
|
|
class InputArea;
|
2017-12-19 20:57:42 +04:00
|
|
|
struct GroupMediaLayout;
|
2016-10-28 12:20:24 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
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*,
|
|
|
|
Storage::PreparedList &&list,
|
|
|
|
CompressConfirm compressed);
|
|
|
|
|
|
|
|
void setConfirmedCallback(
|
|
|
|
base::lambda<void(
|
|
|
|
Storage::PreparedList &&list,
|
|
|
|
bool compressed,
|
|
|
|
const QString &caption,
|
|
|
|
bool ctrlShiftEnter)> callback) {
|
2017-02-21 16:45:56 +03:00
|
|
|
_confirmedCallback = std::move(callback);
|
2016-11-28 18:45:07 +03:00
|
|
|
}
|
2017-02-26 14:32:13 +03:00
|
|
|
void setCancelledCallback(base::lambda<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-03-10 17:14:10 +03:00
|
|
|
void prepareSingleFileLayout();
|
|
|
|
void prepareDocumentLayout();
|
2017-03-10 17:43:26 +03:00
|
|
|
void prepareGifPreview();
|
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
2017-03-10 17:14:10 +03:00
|
|
|
|
2017-12-19 20:57:42 +04:00
|
|
|
void send(bool ctrlShiftEnter = false);
|
|
|
|
void captionResized();
|
|
|
|
void compressedChange();
|
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
void updateTitleText();
|
2015-10-11 10:37:24 +02:00
|
|
|
void updateBoxSize();
|
2016-11-28 18:45:07 +03:00
|
|
|
void updateControlsGeometry();
|
2017-05-30 18:21:05 +03:00
|
|
|
base::lambda<QString()> getSendButtonText() const;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
QString _titleText;
|
2017-12-19 20:57:42 +04:00
|
|
|
Storage::PreparedList _list;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
CompressConfirm _compressConfirm = CompressConfirm::None;
|
|
|
|
bool _animated = false;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
QPixmap _preview;
|
|
|
|
int _previewLeft = 0;
|
|
|
|
int _previewWidth = 0;
|
|
|
|
int _previewHeight = 0;
|
2017-03-10 17:43:26 +03:00
|
|
|
Media::Clip::ReaderPointer _gifPreview;
|
2016-10-28 12:20:24 +03:00
|
|
|
|
2016-11-28 18:45:07 +03:00
|
|
|
QPixmap _fileThumb;
|
|
|
|
Text _nameText;
|
2017-03-10 17:14:10 +03:00
|
|
|
bool _fileIsAudio = false;
|
2016-11-28 18:45:07 +03:00
|
|
|
bool _fileIsImage = false;
|
|
|
|
QString _statusText;
|
|
|
|
int _statusWidth = 0;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2017-12-21 20:15:37 +04:00
|
|
|
base::lambda<void(
|
|
|
|
Storage::PreparedList &&list,
|
|
|
|
bool compressed,
|
|
|
|
const QString &caption,
|
|
|
|
bool ctrlShiftEnter)> _confirmedCallback;
|
2016-11-28 18:45:07 +03:00
|
|
|
base::lambda<void()> _cancelledCallback;
|
|
|
|
bool _confirmed = false;
|
2015-12-19 17:37:28 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::InputArea> _caption = { nullptr };
|
|
|
|
object_ptr<Ui::Checkbox> _compressed = { nullptr };
|
2014-08-22 18:55:23 +04:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
QPointer<Ui::RoundButton> _send;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
|
|
|
};
|
2016-02-21 15:30:16 +03:00
|
|
|
|
2017-12-19 20:57:42 +04:00
|
|
|
class SendAlbumBox : public BoxContent {
|
2016-02-21 15:30:16 +03:00
|
|
|
public:
|
2017-12-19 20:57:42 +04:00
|
|
|
SendAlbumBox(QWidget*, Storage::PreparedList &&list);
|
2016-02-23 17:31:06 +03:00
|
|
|
|
2017-12-21 20:15:37 +04:00
|
|
|
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);
|
2016-12-20 16:03:51 +03:00
|
|
|
}
|
2016-02-21 15:30:16 +03:00
|
|
|
|
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 };
|
|
|
|
|
|
|
|
};
|