mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Move photo data to Data::PhotoMedia.
This commit is contained in:
@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_photo_media.h"
|
||||
#include "data/data_document_media.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
@@ -370,18 +371,23 @@ void GifsListWidget::selectInlineResult(int row, int column) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto ctrl = (QGuiApplication::keyboardModifiers()
|
||||
== Qt::ControlModifier);
|
||||
auto item = _rows[row].items[column];
|
||||
if (const auto photo = item->getPhoto()) {
|
||||
if (photo->thumbnail()->loaded()) {
|
||||
using Data::PhotoSize;
|
||||
const auto media = photo->activeMediaView();
|
||||
if (ctrl
|
||||
|| (media && media->image(PhotoSize::Thumbnail))
|
||||
|| (media && media->image(PhotoSize::Large))) {
|
||||
_photoChosen.fire_copy(photo);
|
||||
} else if (!photo->thumbnail()->loading()) {
|
||||
photo->thumbnail()->loadEvenCancelled(Data::FileOrigin());
|
||||
} else if (!photo->loading(PhotoSize::Thumbnail)) {
|
||||
photo->load(PhotoSize::Thumbnail, Data::FileOrigin());
|
||||
}
|
||||
} else if (const auto document = item->getDocument()) {
|
||||
const auto media = document->activeMediaView();
|
||||
const auto preview = Data::VideoPreviewState(media.get());
|
||||
if ((media && preview.loaded())
|
||||
|| QGuiApplication::keyboardModifiers() == Qt::ControlModifier) {
|
||||
if (ctrl || (media && preview.loaded())) {
|
||||
_fileChosen.fire_copy(document);
|
||||
} else if (!preview.usingThumbnail()) {
|
||||
if (preview.loading()) {
|
||||
@@ -551,11 +557,13 @@ void GifsListWidget::clearInlineRows(bool resultsDeleted) {
|
||||
_rows.clear();
|
||||
}
|
||||
|
||||
GifsListWidget::LayoutItem *GifsListWidget::layoutPrepareSavedGif(DocumentData *doc, int32 position) {
|
||||
auto it = _gifLayouts.find(doc);
|
||||
GifsListWidget::LayoutItem *GifsListWidget::layoutPrepareSavedGif(
|
||||
not_null<DocumentData*> document,
|
||||
int32 position) {
|
||||
auto it = _gifLayouts.find(document);
|
||||
if (it == _gifLayouts.cend()) {
|
||||
if (auto layout = LayoutItem::createLayoutGif(this, doc)) {
|
||||
it = _gifLayouts.emplace(doc, std::move(layout)).first;
|
||||
if (auto layout = LayoutItem::createLayoutGif(this, document)) {
|
||||
it = _gifLayouts.emplace(document, std::move(layout)).first;
|
||||
it->second->initDimensions();
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -567,7 +575,9 @@ GifsListWidget::LayoutItem *GifsListWidget::layoutPrepareSavedGif(DocumentData *
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
GifsListWidget::LayoutItem *GifsListWidget::layoutPrepareInlineResult(InlineResult *result, int32 position) {
|
||||
GifsListWidget::LayoutItem *GifsListWidget::layoutPrepareInlineResult(
|
||||
not_null<InlineResult*> result,
|
||||
int32 position) {
|
||||
auto it = _inlineLayouts.find(result);
|
||||
if (it == _inlineLayouts.cend()) {
|
||||
if (auto layout = LayoutItem::createLayout(this, result, _inlineWithThumb)) {
|
||||
|
@@ -134,11 +134,19 @@ private:
|
||||
QVector<Row> _rows;
|
||||
void clearInlineRows(bool resultsDeleted);
|
||||
|
||||
std::map<DocumentData*, std::unique_ptr<LayoutItem>> _gifLayouts;
|
||||
LayoutItem *layoutPrepareSavedGif(DocumentData *doc, int32 position);
|
||||
std::map<
|
||||
not_null<DocumentData*>,
|
||||
std::unique_ptr<LayoutItem>> _gifLayouts;
|
||||
LayoutItem *layoutPrepareSavedGif(
|
||||
not_null<DocumentData*> document,
|
||||
int32 position);
|
||||
|
||||
std::map<InlineResult*, std::unique_ptr<LayoutItem>> _inlineLayouts;
|
||||
LayoutItem *layoutPrepareInlineResult(InlineResult *result, int32 position);
|
||||
std::map<
|
||||
not_null<InlineResult*>,
|
||||
std::unique_ptr<LayoutItem>> _inlineLayouts;
|
||||
LayoutItem *layoutPrepareInlineResult(
|
||||
not_null<InlineResult*> result,
|
||||
int32 position);
|
||||
|
||||
bool inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, Row &row, int32 &sumWidth);
|
||||
bool inlineRowFinalize(Row &row, int32 &sumWidth, bool force = false);
|
||||
|
@@ -128,11 +128,6 @@ public:
|
||||
QImage takeLoaded() override;
|
||||
void unload() override;
|
||||
|
||||
void automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
const HistoryItem *item) override;
|
||||
void automaticLoadSettingsChanged() override;
|
||||
|
||||
bool loading() override;
|
||||
bool displayLoading() override;
|
||||
void cancel() override;
|
||||
@@ -222,14 +217,6 @@ void ImageSource::unload() {
|
||||
_data = QImage();
|
||||
}
|
||||
|
||||
void ImageSource::automaticLoad(
|
||||
Data::FileOrigin origin,
|
||||
const HistoryItem *item) {
|
||||
}
|
||||
|
||||
void ImageSource::automaticLoadSettingsChanged() {
|
||||
}
|
||||
|
||||
bool ImageSource::loading() {
|
||||
return _data.isNull() && _bytes.isEmpty();
|
||||
}
|
||||
|
Reference in New Issue
Block a user