tdesktop/Telegram/SourceFiles/data/data_photo.h

110 lines
2.2 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
#include "data/data_types.h"
class PhotoData {
public:
2018-07-13 16:49:46 +00:00
explicit PhotoData(const PhotoId &id);
PhotoData(
const PhotoId &id,
2018-07-13 16:49:46 +00:00
const uint64 &access,
const QByteArray &fileReference,
TimeId date,
const ImagePtr &thumb,
const ImagePtr &medium,
const ImagePtr &full);
2018-07-13 21:25:47 +00:00
void automaticLoad(
Data::FileOrigin origin,
const HistoryItem *item);
void automaticLoadSettingsChanged();
2018-07-13 21:25:47 +00:00
void download(Data::FileOrigin origin);
bool loaded() const;
bool loading() const;
bool displayLoading() const;
void cancel();
float64 progress() const;
int32 loadOffset() const;
bool uploading() const;
void setWaitingForAlbum();
bool waitingForAlbum() const;
void forget();
2018-07-13 21:25:47 +00:00
ImagePtr makeReplyPreview(Data::FileOrigin origin);
2018-07-13 16:49:46 +00:00
MTPInputPhoto mtpInput() const;
PhotoId id = 0;
uint64 access = 0;
QByteArray fileReference;
TimeId date = 0;
ImagePtr thumb, replyPreview;
ImagePtr medium;
ImagePtr full;
PeerData *peer = nullptr; // for chat and channel photos connection
// geo, caption
std::unique_ptr<Data::UploadState> uploadingData;
};
class PhotoClickHandler : public FileClickHandler {
public:
PhotoClickHandler(
not_null<PhotoData*> photo,
FullMsgId context = FullMsgId(),
PeerData *peer = nullptr)
: FileClickHandler(context)
, _photo(photo)
, _peer(peer) {
}
not_null<PhotoData*> photo() const {
return _photo;
}
PeerData *peer() const {
return _peer;
}
private:
not_null<PhotoData*> _photo;
PeerData *_peer = nullptr;
};
class PhotoOpenClickHandler : public PhotoClickHandler {
public:
using PhotoClickHandler::PhotoClickHandler;
protected:
void onClickImpl() const override;
};
class PhotoSaveClickHandler : public PhotoClickHandler {
public:
using PhotoClickHandler::PhotoClickHandler;
protected:
void onClickImpl() const override;
};
class PhotoCancelClickHandler : public PhotoClickHandler {
public:
using PhotoClickHandler::PhotoClickHandler;
protected:
void onClickImpl() const override;
};