mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Remove HistoryMediaType type-tag.
This commit is contained in:
parent
6d08394adc
commit
3e22ada889
19 changed files with 24 additions and 154 deletions
|
@ -1014,47 +1014,13 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
_menu->addAction(lang(lng_context_copy_selected), [this] { copySelectedText(); });
|
||||
} else {
|
||||
if (item && !isUponSelected) {
|
||||
auto mediaHasTextForCopy = false;
|
||||
if (auto media = view->media()) {
|
||||
mediaHasTextForCopy = media->hasTextForCopy();
|
||||
if (media->type() == MediaTypeWebPage && static_cast<HistoryWebPage*>(media)->attach()) {
|
||||
media = static_cast<HistoryWebPage*>(media)->attach();
|
||||
}
|
||||
if (media->type() == MediaTypeSticker) {
|
||||
if (const auto document = media->getDocument()) {
|
||||
if (document->sticker() && document->sticker()->set.type() != mtpc_inputStickerSetEmpty) {
|
||||
_menu->addAction(lang(document->isStickerSetInstalled() ? lng_context_pack_info : lng_context_pack_add), [=] {
|
||||
showStickerPackInfo(document);
|
||||
});
|
||||
}
|
||||
_menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
|
||||
saveDocumentToFile(document);
|
||||
}));
|
||||
}
|
||||
} else if (media->type() == MediaTypeGif && !link) {
|
||||
if (auto document = media->getDocument()) {
|
||||
if (document->loading()) {
|
||||
_menu->addAction(lang(lng_context_cancel_download), [=] {
|
||||
cancelContextDownload(document);
|
||||
});
|
||||
} else {
|
||||
if (document->isGifv()) {
|
||||
if (!cAutoPlayGif()) {
|
||||
_menu->addAction(lang(lng_context_open_gif), [=] {
|
||||
openContextGif(itemId);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
||||
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
|
||||
showContextInFolder(document);
|
||||
});
|
||||
}
|
||||
_menu->addAction(lang(lng_context_save_file), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
|
||||
saveDocumentToFile(document);
|
||||
}));
|
||||
}
|
||||
}
|
||||
const auto media = view->media();
|
||||
const auto mediaHasTextForCopy = media && media->hasTextForCopy();
|
||||
if (const auto document = media ? media->getDocument() : nullptr) {
|
||||
if (document->sticker()) {
|
||||
_menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
|
||||
saveDocumentToFile(document);
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (msg && !link && (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
|
|
|
@ -1629,29 +1629,13 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
} else {
|
||||
addItemActions(item);
|
||||
if (item && !isUponSelected) {
|
||||
auto mediaHasTextForCopy = false;
|
||||
if (auto media = (view ? view->media() : nullptr)) {
|
||||
mediaHasTextForCopy = media->hasTextForCopy();
|
||||
if (media->type() == MediaTypeWebPage && static_cast<HistoryWebPage*>(media)->attach()) {
|
||||
media = static_cast<HistoryWebPage*>(media)->attach();
|
||||
}
|
||||
if (media->type() == MediaTypeSticker) {
|
||||
if (auto document = media->getDocument()) {
|
||||
if (document->sticker() && document->sticker()->set.type() != mtpc_inputStickerSetEmpty) {
|
||||
_menu->addAction(lang(document->isStickerSetInstalled() ? lng_context_pack_info : lng_context_pack_add), [=] {
|
||||
showStickerPackInfo(document);
|
||||
});
|
||||
_menu->addAction(lang(Stickers::IsFaved(document) ? lng_faved_stickers_remove : lng_faved_stickers_add), [=] {
|
||||
Auth().api().toggleFavedSticker(
|
||||
document,
|
||||
itemId,
|
||||
!Stickers::IsFaved(document));
|
||||
});
|
||||
}
|
||||
_menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
}
|
||||
const auto media = (view ? view->media() : nullptr);
|
||||
const auto mediaHasTextForCopy = media && media->hasTextForCopy();
|
||||
if (const auto document = media ? media->getDocument() : nullptr) {
|
||||
if (document->sticker()) {
|
||||
_menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
|
||||
saveDocumentToFile(itemId, document);
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (msg && view && !link && (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
|
|
|
@ -37,25 +37,6 @@ enum class MediaInBubbleState {
|
|||
Bottom,
|
||||
};
|
||||
|
||||
enum HistoryMediaType : char {
|
||||
MediaTypePhoto,
|
||||
MediaTypeVideo,
|
||||
MediaTypeContact,
|
||||
MediaTypeCall,
|
||||
MediaTypeFile,
|
||||
MediaTypeGif,
|
||||
MediaTypeSticker,
|
||||
MediaTypeLocation,
|
||||
MediaTypeWebPage,
|
||||
MediaTypeMusicFile,
|
||||
MediaTypeVoiceFile,
|
||||
MediaTypeGame,
|
||||
MediaTypeInvoice,
|
||||
MediaTypeGrouped,
|
||||
|
||||
MediaTypeCount
|
||||
};
|
||||
|
||||
class HistoryMedia : public HistoryView::Object {
|
||||
public:
|
||||
using Element = HistoryView::Element;
|
||||
|
@ -66,8 +47,6 @@ public:
|
|||
HistoryMedia(not_null<Element*> parent) : _parent(parent) {
|
||||
}
|
||||
|
||||
virtual HistoryMediaType type() const = 0;
|
||||
|
||||
virtual TextWithEntities selectedText(TextSelection selection) const {
|
||||
return TextWithEntities();
|
||||
}
|
||||
|
|
|
@ -20,10 +20,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<Data::Call*> call);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeCall;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@ public:
|
|||
const QString &phone);
|
||||
~HistoryContact();
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeContact;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -51,14 +51,6 @@ HistoryDocument::HistoryDocument(
|
|||
}
|
||||
}
|
||||
|
||||
HistoryMediaType HistoryDocument::type() const {
|
||||
return _data->isVoiceMessage()
|
||||
? MediaTypeVoiceFile
|
||||
: (_data->isSong()
|
||||
? MediaTypeMusicFile
|
||||
: MediaTypeFile);
|
||||
}
|
||||
|
||||
float64 HistoryDocument::dataProgress() const {
|
||||
return _data->progress();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
HistoryMediaType type() const override;
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
void updatePressed(QPoint point) override;
|
||||
|
|
|
@ -18,10 +18,6 @@ public:
|
|||
not_null<GameData*> data,
|
||||
const TextWithEntities &consumed);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeGame;
|
||||
}
|
||||
|
||||
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
|
|
|
@ -29,10 +29,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeGif;
|
||||
}
|
||||
|
||||
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
|
|
|
@ -26,10 +26,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
const std::vector<not_null<HistoryItem*>> &items);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeGrouped;
|
||||
}
|
||||
|
||||
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
||||
|
||||
void draw(
|
||||
|
|
|
@ -19,10 +19,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<Data::Invoice*> invoice);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeInvoice;
|
||||
}
|
||||
|
||||
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
||||
|
||||
MsgId getReceiptMsgId() const {
|
||||
|
|
|
@ -20,10 +20,6 @@ public:
|
|||
const QString &title = QString(),
|
||||
const QString &description = QString());
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeLocation;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -21,10 +21,6 @@ public:
|
|||
not_null<PhotoData*> photo,
|
||||
int width);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypePhoto;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &clip, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeSticker;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -16,10 +16,6 @@ public:
|
|||
not_null<HistoryItem*> realParent,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeVideo;
|
||||
}
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
TextState textState(QPoint point, StateRequest request) const override;
|
||||
|
||||
|
|
|
@ -477,7 +477,9 @@ void HistoryWebPage::draw(Painter &p, const QRect &r, TextSelection selection, T
|
|||
auto pixheight = _attach->height();
|
||||
|
||||
if (_data->type == WebPageType::Video
|
||||
&& _attach->type() == MediaTypePhoto) {
|
||||
&& _collage.empty()
|
||||
&& _data->photo
|
||||
&& !_data->document) {
|
||||
if (_attach->isReadyForOpen()) {
|
||||
if (_data->siteName == qstr("YouTube")) {
|
||||
st::youtubeIcon.paint(p, (pixwidth - st::youtubeIcon.width()) / 2, (pixheight - st::youtubeIcon.height()) / 2, width());
|
||||
|
|
|
@ -19,10 +19,6 @@ public:
|
|||
not_null<Element*> parent,
|
||||
not_null<WebPageData*> data);
|
||||
|
||||
HistoryMediaType type() const override {
|
||||
return MediaTypeWebPage;
|
||||
}
|
||||
|
||||
void refreshParentId(not_null<HistoryItem*> realParent) override;
|
||||
|
||||
void draw(Painter &p, const QRect &r, TextSelection selection, TimeMs ms) const override;
|
||||
|
|
|
@ -479,18 +479,10 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
AddToggleGroupingAction(result, linkPeer->peer());
|
||||
}
|
||||
} else if (!request.overSelection && view && !hasSelection) {
|
||||
auto media = view->media();
|
||||
const auto media = view->media();
|
||||
const auto mediaHasTextForCopy = media && media->hasTextForCopy();
|
||||
if (media) {
|
||||
if (media->type() == MediaTypeWebPage
|
||||
&& static_cast<HistoryWebPage*>(media)->attach()) {
|
||||
media = static_cast<HistoryWebPage*>(media)->attach();
|
||||
}
|
||||
if (media->type() == MediaTypeSticker) {
|
||||
if (const auto document = media->getDocument()) {
|
||||
AddDocumentActions(result, document, view->data()->fullId());
|
||||
}
|
||||
}
|
||||
if (const auto document = media ? media->getDocument() : nullptr) {
|
||||
AddDocumentActions(result, document, view->data()->fullId());
|
||||
}
|
||||
if (!link && (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
const auto asGroup = (request.pointState != PointState::GroupPart);
|
||||
|
|
|
@ -7,10 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "history/view/history_view_list_widget.h"
|
||||
|
||||
#include "history/media/history_media.h"
|
||||
#include "history/history_message.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_text.h"
|
||||
#include "history/media/history_media.h"
|
||||
#include "history/media/history_media_sticker.h"
|
||||
#include "history/view/history_view_context_menu.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
#include "history/view/history_view_message.h"
|
||||
|
@ -880,8 +881,8 @@ bool ListWidget::requiredToStartDragging(
|
|||
not_null<Element*> view) const {
|
||||
if (_mouseCursorState == CursorState::Date) {
|
||||
return true;
|
||||
} else if (const auto media = view->media()) {
|
||||
return media->type() == MediaTypeSticker;
|
||||
} else if (dynamic_cast<HistorySticker*>(view->media()) != nullptr) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue