1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*
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_file_origin.h"
#include "ui/basic_click_handlers.h"
class DocumentData;
class HistoryItem;
class PhotoData;
class FileClickHandler : public LeftButtonClickHandler {
public:
FileClickHandler(FullMsgId context);
void setMessageId(FullMsgId context);
[[nodiscard]] FullMsgId context() const;
private:
FullMsgId _context;
};
class DocumentClickHandler : public FileClickHandler {
public:
DocumentClickHandler(
not_null<DocumentData*> document,
FullMsgId context = FullMsgId());
QString tooltip() const override;
[[nodiscard]] not_null<DocumentData*> document() const;
private:
const not_null<DocumentData*> _document;
};
class DocumentSaveClickHandler : public DocumentClickHandler {
public:
enum class Mode {
ToCacheOrFile,
ToFile,
ToNewFile,
};
using DocumentClickHandler::DocumentClickHandler;
static void Save(
Data::FileOrigin origin,
not_null<DocumentData*> document,
Mode mode = Mode::ToCacheOrFile);
static void SaveAndTrack(
FullMsgId itemId,
not_null<DocumentData*> document,
Mode mode = Mode::ToCacheOrFile);
protected:
void onClickImpl() const override;
};
class DocumentOpenClickHandler : public DocumentClickHandler {
public:
DocumentOpenClickHandler(
not_null<DocumentData*> document,
Fn<void(FullMsgId)> &&callback,
FullMsgId context = FullMsgId());
protected:
void onClickImpl() const override;
private:
const Fn<void(FullMsgId)> _handler;
};
class DocumentCancelClickHandler : public DocumentClickHandler {
public:
DocumentCancelClickHandler(
not_null<DocumentData*> document,
Fn<void(FullMsgId)> &&callback,
FullMsgId context = FullMsgId());
protected:
void onClickImpl() const override;
private:
const Fn<void(FullMsgId)> _handler;
};
class DocumentOpenWithClickHandler : public DocumentClickHandler {
public:
using DocumentClickHandler::DocumentClickHandler;
static void Open(
Data::FileOrigin origin,
not_null<DocumentData*> document);
protected:
void onClickImpl() const override;
};
class VoiceSeekClickHandler : public DocumentOpenClickHandler {
public:
using DocumentOpenClickHandler::DocumentOpenClickHandler;
protected:
void onClickImpl() const override {
}
};
class DocumentWrappedClickHandler : public DocumentClickHandler {
public:
DocumentWrappedClickHandler(
ClickHandlerPtr wrapped,
not_null<DocumentData*> document,
FullMsgId context = FullMsgId());
protected:
void onClickImpl() const override;
private:
ClickHandlerPtr _wrapped;
};
class PhotoClickHandler : public FileClickHandler {
public:
PhotoClickHandler(
not_null<PhotoData*> photo,
FullMsgId context = FullMsgId(),
PeerData *peer = nullptr);
[[nodiscard]] not_null<PhotoData*> photo() const;
[[nodiscard]] PeerData *peer() const;
private:
const not_null<PhotoData*> _photo;
PeerData * const _peer = nullptr;
};
class PhotoOpenClickHandler : public PhotoClickHandler {
public:
PhotoOpenClickHandler(
not_null<PhotoData*> photo,
Fn<void(FullMsgId)> &&callback,
FullMsgId context = FullMsgId());
protected:
void onClickImpl() const override;
private:
const Fn<void(FullMsgId)> _handler;
};
class PhotoSaveClickHandler : public PhotoClickHandler {
public:
using PhotoClickHandler::PhotoClickHandler;
protected:
void onClickImpl() const override;
};
class PhotoCancelClickHandler : public PhotoClickHandler {
public:
PhotoCancelClickHandler(
not_null<PhotoData*> photo,
Fn<void(FullMsgId)> &&callback,
FullMsgId context = FullMsgId());
protected:
void onClickImpl() const override;
private:
const Fn<void(FullMsgId)> _handler;
};
|