2021-06-17 23:28:09 +00:00
|
|
|
/*
|
|
|
|
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:
|
2021-06-18 06:39:59 +00:00
|
|
|
FileClickHandler(FullMsgId context);
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
void setMessageId(FullMsgId context);
|
|
|
|
|
|
|
|
[[nodiscard]] FullMsgId context() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
FullMsgId _context;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentClickHandler : public FileClickHandler {
|
|
|
|
public:
|
|
|
|
DocumentClickHandler(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
FullMsgId context = FullMsgId());
|
|
|
|
|
2022-10-04 16:03:57 +00:00
|
|
|
QString tooltip() const override;
|
|
|
|
|
2021-06-17 23:28:09 +00:00
|
|
|
[[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,
|
2023-08-18 17:25:25 +00:00
|
|
|
Mode mode = Mode::ToCacheOrFile,
|
|
|
|
Fn<void()> started = nullptr);
|
2022-02-27 13:32:36 +00:00
|
|
|
static void SaveAndTrack(
|
|
|
|
FullMsgId itemId,
|
|
|
|
not_null<DocumentData*> document,
|
2023-08-18 17:25:25 +00:00
|
|
|
Mode mode = Mode::ToCacheOrFile,
|
|
|
|
Fn<void()> started = nullptr);
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentOpenClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
|
|
|
DocumentOpenClickHandler(
|
|
|
|
not_null<DocumentData*> document,
|
2021-06-18 04:22:47 +00:00
|
|
|
Fn<void(FullMsgId)> &&callback,
|
|
|
|
FullMsgId context = FullMsgId());
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
private:
|
2021-06-18 04:22:47 +00:00
|
|
|
const Fn<void(FullMsgId)> _handler;
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DocumentCancelClickHandler : public DocumentClickHandler {
|
|
|
|
public:
|
2021-06-18 06:20:49 +00:00
|
|
|
DocumentCancelClickHandler(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
Fn<void(FullMsgId)> &&callback,
|
|
|
|
FullMsgId context = FullMsgId());
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
2021-06-18 06:20:49 +00:00
|
|
|
private:
|
|
|
|
const Fn<void(FullMsgId)> _handler;
|
|
|
|
|
2021-06-17 23:28:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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:
|
2021-06-18 04:22:47 +00:00
|
|
|
PhotoOpenClickHandler(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
Fn<void(FullMsgId)> &&callback,
|
|
|
|
FullMsgId context = FullMsgId());
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
private:
|
2021-06-18 04:22:47 +00:00
|
|
|
const Fn<void(FullMsgId)> _handler;
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhotoSaveClickHandler : public PhotoClickHandler {
|
|
|
|
public:
|
|
|
|
using PhotoClickHandler::PhotoClickHandler;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhotoCancelClickHandler : public PhotoClickHandler {
|
|
|
|
public:
|
2021-06-18 06:20:49 +00:00
|
|
|
PhotoCancelClickHandler(
|
|
|
|
not_null<PhotoData*> photo,
|
|
|
|
Fn<void(FullMsgId)> &&callback,
|
|
|
|
FullMsgId context = FullMsgId());
|
2021-06-17 23:28:09 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onClickImpl() const override;
|
|
|
|
|
2021-06-18 06:20:49 +00:00
|
|
|
private:
|
|
|
|
const Fn<void(FullMsgId)> _handler;
|
|
|
|
|
2021-06-17 23:28:09 +00:00
|
|
|
};
|