mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Implement dice media display.
This commit is contained in:
@@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/view/media/history_view_web_page.h"
|
||||
#include "history/view/media/history_view_poll.h"
|
||||
#include "history/view/media/history_view_theme_document.h"
|
||||
#include "history/view/media/history_view_dice.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/image/image_source.h"
|
||||
#include "ui/text_options.h"
|
||||
@@ -1325,4 +1326,49 @@ std::unique_ptr<HistoryView::Media> MediaPoll::createView(
|
||||
return std::make_unique<HistoryView::Poll>(message, _poll);
|
||||
}
|
||||
|
||||
MediaDice::MediaDice(not_null<HistoryItem*> parent, int value)
|
||||
: Media(parent)
|
||||
, _value(value) {
|
||||
}
|
||||
|
||||
std::unique_ptr<Media> MediaDice::clone(not_null<HistoryItem*> parent) {
|
||||
return std::make_unique<MediaDice>(parent, _value);
|
||||
}
|
||||
|
||||
int MediaDice::diceValue() const {
|
||||
return _value;
|
||||
}
|
||||
|
||||
QString MediaDice::notificationText() const {
|
||||
return QString::fromUtf8("\xF0\x9F\x8E\xB2");
|
||||
}
|
||||
|
||||
QString MediaDice::pinnedTextSubstring() const {
|
||||
return QChar(171) + notificationText() + QChar(187);
|
||||
}
|
||||
|
||||
TextForMimeData MediaDice::clipboardText() const {
|
||||
return { notificationText() };
|
||||
}
|
||||
|
||||
bool MediaDice::updateInlineResultMedia(const MTPMessageMedia &media) {
|
||||
return updateSentMedia(media);
|
||||
}
|
||||
|
||||
bool MediaDice::updateSentMedia(const MTPMessageMedia &media) {
|
||||
if (media.type() != mtpc_messageMediaDice) {
|
||||
return false;
|
||||
}
|
||||
_value = media.c_messageMediaDice().vvalue().v;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Media> MediaDice::createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) {
|
||||
return std::make_unique<HistoryView::UnwrappedMedia>(
|
||||
message,
|
||||
std::make_unique<HistoryView::Dice>(message, _value));
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
@@ -118,7 +118,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaPhoto : public Media {
|
||||
class MediaPhoto final : public Media {
|
||||
public:
|
||||
MediaPhoto(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -158,7 +158,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaFile : public Media {
|
||||
class MediaFile final : public Media {
|
||||
public:
|
||||
MediaFile(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -195,7 +195,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaContact : public Media {
|
||||
class MediaContact final : public Media {
|
||||
public:
|
||||
MediaContact(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -223,7 +223,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaLocation : public Media {
|
||||
class MediaLocation final : public Media {
|
||||
public:
|
||||
MediaLocation(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -255,7 +255,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaCall : public Media {
|
||||
class MediaCall final : public Media {
|
||||
public:
|
||||
MediaCall(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -284,7 +284,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaWebPage : public Media {
|
||||
class MediaWebPage final : public Media {
|
||||
public:
|
||||
MediaWebPage(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -316,7 +316,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaGame : public Media {
|
||||
class MediaGame final : public Media {
|
||||
public:
|
||||
MediaGame(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaInvoice : public Media {
|
||||
class MediaInvoice final : public Media {
|
||||
public:
|
||||
MediaInvoice(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -378,7 +378,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaPoll : public Media {
|
||||
class MediaPoll final : public Media {
|
||||
public:
|
||||
MediaPoll(
|
||||
not_null<HistoryItem*> parent,
|
||||
@@ -405,6 +405,28 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class MediaDice final : public Media {
|
||||
public:
|
||||
MediaDice(not_null<HistoryItem*> parent, int value);
|
||||
|
||||
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
|
||||
|
||||
int diceValue() const;
|
||||
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
std::unique_ptr<HistoryView::Media> createView(
|
||||
not_null<HistoryView::Element*> message,
|
||||
not_null<HistoryItem*> realParent) override;
|
||||
|
||||
private:
|
||||
int _value = 0;
|
||||
|
||||
};
|
||||
|
||||
TextForMimeData WithCaptionClipboardText(
|
||||
const QString &attachType,
|
||||
TextForMimeData &&caption);
|
||||
|
Reference in New Issue
Block a user