2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00: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 13:16:42 +00: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 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
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"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-28 09:20:24 +00:00
|
|
|
namespace Ui {
|
|
|
|
class Checkbox;
|
2016-11-11 13:46:04 +00:00
|
|
|
class RoundButton;
|
2016-11-15 11:56:49 +00:00
|
|
|
class InputArea;
|
2017-12-05 08:43:18 +00:00
|
|
|
class EmptyUserpic;
|
2016-10-28 09:20:24 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class SendFilesBox : public BoxContent {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-03-10 14:14:10 +00:00
|
|
|
SendFilesBox(QWidget*, QImage image, CompressConfirm compressed);
|
2016-12-13 17:07:56 +00:00
|
|
|
SendFilesBox(QWidget*, const QStringList &files, CompressConfirm compressed);
|
|
|
|
SendFilesBox(QWidget*, const QString &phone, const QString &firstname, const QString &lastname);
|
2016-11-28 15:45:07 +00:00
|
|
|
|
2017-03-10 14:14:10 +00:00
|
|
|
void setConfirmedCallback(base::lambda<void(const QStringList &files, const QImage &image, std::unique_ptr<FileLoadTask::MediaInformation> information, bool compressed, const QString &caption, bool ctrlShiftEnter)> callback) {
|
2017-02-21 13:45:56 +00:00
|
|
|
_confirmedCallback = std::move(callback);
|
2016-11-28 15:45:07 +00:00
|
|
|
}
|
2017-02-26 11:32:13 +00:00
|
|
|
void setCancelledCallback(base::lambda<void()> callback) {
|
2017-02-21 13:45:56 +00:00
|
|
|
_cancelledCallback = std::move(callback);
|
2016-11-28 15:45:07 +00:00
|
|
|
}
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2017-12-05 08:43:18 +00:00
|
|
|
~SendFilesBox();
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-04-02 10:33:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
private slots:
|
|
|
|
void onCompressedChange();
|
|
|
|
void onSend(bool ctrlShiftEnter = false);
|
|
|
|
void onCaptionResized();
|
2016-12-20 13:03:51 +00:00
|
|
|
void onClose() {
|
|
|
|
closeBox();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-10 14:14:10 +00:00
|
|
|
void prepareSingleFileLayout();
|
|
|
|
void prepareDocumentLayout();
|
|
|
|
void tryToReadSingleFile();
|
2017-03-10 14:43:26 +00:00
|
|
|
void prepareGifPreview();
|
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
2017-03-10 14:14:10 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
void updateTitleText();
|
2015-10-11 08:37:24 +00:00
|
|
|
void updateBoxSize();
|
2016-11-28 15:45:07 +00:00
|
|
|
void updateControlsGeometry();
|
2017-05-30 15:21:05 +00:00
|
|
|
base::lambda<QString()> getSendButtonText() const;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
QString _titleText;
|
|
|
|
QStringList _files;
|
2017-03-10 14:14:10 +00:00
|
|
|
QImage _image;
|
|
|
|
std::unique_ptr<FileLoadTask::MediaInformation> _information;
|
2015-12-19 14:37:28 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
CompressConfirm _compressConfirm = CompressConfirm::None;
|
|
|
|
bool _animated = false;
|
2015-12-19 14:37:28 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
QPixmap _preview;
|
|
|
|
int _previewLeft = 0;
|
|
|
|
int _previewWidth = 0;
|
|
|
|
int _previewHeight = 0;
|
2017-03-10 14:43:26 +00:00
|
|
|
Media::Clip::ReaderPointer _gifPreview;
|
2016-10-28 09:20:24 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
QPixmap _fileThumb;
|
|
|
|
Text _nameText;
|
2017-03-10 14:14:10 +00:00
|
|
|
bool _fileIsAudio = false;
|
2016-11-28 15:45:07 +00:00
|
|
|
bool _fileIsImage = false;
|
|
|
|
QString _statusText;
|
|
|
|
int _statusWidth = 0;
|
2015-12-19 14:37:28 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
QString _contactPhone;
|
|
|
|
QString _contactFirstName;
|
|
|
|
QString _contactLastName;
|
2017-12-05 08:43:18 +00:00
|
|
|
std::unique_ptr<Ui::EmptyUserpic> _contactPhotoEmpty;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-03-10 14:14:10 +00:00
|
|
|
base::lambda<void(const QStringList &files, const QImage &image, std::unique_ptr<FileLoadTask::MediaInformation> information, bool compressed, const QString &caption, bool ctrlShiftEnter)> _confirmedCallback;
|
2016-11-28 15:45:07 +00:00
|
|
|
base::lambda<void()> _cancelledCallback;
|
|
|
|
bool _confirmed = false;
|
2015-12-19 14:37:28 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InputArea> _caption = { nullptr };
|
|
|
|
object_ptr<Ui::Checkbox> _compressed = { nullptr };
|
2014-08-22 14:55:23 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
QPointer<Ui::RoundButton> _send;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2016-02-21 12:30:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class EditCaptionBox : public BoxContent, public RPCSender {
|
2016-02-21 12:30:16 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-04-02 10:25:54 +00:00
|
|
|
EditCaptionBox(QWidget*, HistoryMedia *media, FullMsgId msgId);
|
2016-02-23 14:31:06 +00:00
|
|
|
|
2016-02-21 12:30:16 +00:00
|
|
|
public slots:
|
|
|
|
void onCaptionResized();
|
|
|
|
void onSave(bool ctrlShiftEnter = false);
|
2016-12-20 13:03:51 +00:00
|
|
|
void onClose() {
|
|
|
|
closeBox();
|
|
|
|
}
|
2016-02-21 12:30:16 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2016-02-21 12:30:16 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateBoxSize();
|
2017-03-10 14:43:26 +00:00
|
|
|
void prepareGifPreview(DocumentData *document);
|
|
|
|
void clipCallback(Media::Clip::Notification notification);
|
2016-02-21 12:30:16 +00:00
|
|
|
|
|
|
|
void saveDone(const MTPUpdates &updates);
|
|
|
|
bool saveFail(const RPCError &error);
|
|
|
|
|
2017-04-21 13:17:54 +00:00
|
|
|
int errorTopSkip() const;
|
|
|
|
|
2016-02-23 14:31:06 +00:00
|
|
|
FullMsgId _msgId;
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _animated = false;
|
|
|
|
bool _photo = false;
|
|
|
|
bool _doc = false;
|
2016-02-21 12:30:16 +00:00
|
|
|
|
|
|
|
QPixmap _thumb;
|
2017-03-10 14:43:26 +00:00
|
|
|
Media::Clip::ReaderPointer _gifPreview;
|
2016-02-21 12:30:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InputArea> _field = { nullptr };
|
2016-02-21 12:30:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
int _thumbx = 0;
|
|
|
|
int _thumby = 0;
|
|
|
|
int _thumbw = 0;
|
|
|
|
int _thumbh = 0;
|
2016-02-21 12:30:16 +00:00
|
|
|
Text _name;
|
|
|
|
QString _status;
|
2016-12-13 17:07:56 +00:00
|
|
|
int _statusw = 0;
|
2017-03-10 14:14:10 +00:00
|
|
|
bool _isAudio = false;
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _isImage = false;
|
2016-02-21 12:30:16 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _previewCancelled = false;
|
|
|
|
mtpRequestId _saveRequestId = 0;
|
2016-02-21 12:30:16 +00:00
|
|
|
|
|
|
|
QString _error;
|
|
|
|
|
|
|
|
};
|