mirror of https://github.com/procxx/kepka.git
Simplify media overview layouts.
This commit is contained in:
parent
053eace154
commit
58f82620e0
|
@ -689,7 +689,7 @@ void DocumentData::loadThumbnail(Data::FileOrigin origin) {
|
||||||
_thumbnailLoader = nullptr;
|
_thumbnailLoader = nullptr;
|
||||||
_flags |= Flag::ThumbnailFailed;
|
_flags |= Flag::ThumbnailFailed;
|
||||||
}, [=] {
|
}, [=] {
|
||||||
if (!_thumbnailLoader->cancelled()) {
|
if (_thumbnailLoader && !_thumbnailLoader->cancelled()) {
|
||||||
if (auto image = _thumbnailLoader->imageData(); image.isNull()) {
|
if (auto image = _thumbnailLoader->imageData(); image.isNull()) {
|
||||||
_flags |= Flag::ThumbnailFailed;
|
_flags |= Flag::ThumbnailFailed;
|
||||||
} else if (const auto active = activeMediaView()) {
|
} else if (const auto active = activeMediaView()) {
|
||||||
|
@ -697,7 +697,7 @@ void DocumentData::loadThumbnail(Data::FileOrigin origin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_thumbnailLoader = nullptr;
|
_thumbnailLoader = nullptr;
|
||||||
}) | rpl::release();
|
}, _thumbnailLoader->lifetime());
|
||||||
|
|
||||||
_thumbnailLoader->start();
|
_thumbnailLoader->start();
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ void DocumentData::finishLoad() {
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
destroyLoader();
|
destroyLoader();
|
||||||
});
|
});
|
||||||
if (_loader->cancelled()) {
|
if (!_loader || _loader->cancelled()) {
|
||||||
_flags |= Flag::DownloadCancelled;
|
_flags |= Flag::DownloadCancelled;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1004,7 @@ void DocumentData::handleLoaderUpdates() {
|
||||||
) | rpl::start_with_next_error_done([=] {
|
) | rpl::start_with_next_error_done([=] {
|
||||||
_owner->documentLoadProgress(this);
|
_owner->documentLoadProgress(this);
|
||||||
}, [=](bool started) {
|
}, [=](bool started) {
|
||||||
if (started) {
|
if (started && _loader) {
|
||||||
const auto origin = _loader->fileOrigin();
|
const auto origin = _loader->fileOrigin();
|
||||||
const auto failedFileName = _loader->fileName();
|
const auto failedFileName = _loader->fileName();
|
||||||
const auto retry = [=] {
|
const auto retry = [=] {
|
||||||
|
@ -1035,7 +1035,7 @@ void DocumentData::handleLoaderUpdates() {
|
||||||
}, [=] {
|
}, [=] {
|
||||||
finishLoad();
|
finishLoad();
|
||||||
_owner->documentLoadDone(this);
|
_owner->documentLoadDone(this);
|
||||||
}) | rpl::release();
|
}, _loader->lifetime());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,11 +140,6 @@ void Checkbox::startAnimation() {
|
||||||
_pression.start(_updateCallback, showPressed ? 0. : 1., showPressed ? 1. : 0., st::overviewCheck.duration);
|
_pression.start(_updateCallback, showPressed ? 0. : 1., showPressed ? 1. : 0., st::overviewCheck.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgId AbstractItem::msgId() const {
|
|
||||||
auto item = getItem();
|
|
||||||
return item ? item->id : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemBase::ItemBase(
|
ItemBase::ItemBase(
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
not_null<HistoryItem*> parent)
|
not_null<HistoryItem*> parent)
|
||||||
|
@ -295,25 +290,6 @@ void StatusText::setSize(int newSize) {
|
||||||
_size = newSize;
|
_size = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date::Date(const QDate &date, bool month)
|
|
||||||
: _date(date)
|
|
||||||
, _text(month ? langMonthFull(date) : langDayOfMonthFull(date)) {
|
|
||||||
AddComponents(Info::Bit());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Date::initDimensions() {
|
|
||||||
_maxw = st::normalFont->width(_text);
|
|
||||||
_minh = st::linksDateMargin.top() + st::normalFont->height + st::linksDateMargin.bottom() + st::linksBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Date::paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) {
|
|
||||||
if (clip.intersects(QRect(0, st::linksDateMargin.top(), _width, st::normalFont->height))) {
|
|
||||||
p.setPen(st::linksDateColor);
|
|
||||||
p.setFont(st::semiboldFont);
|
|
||||||
p.drawTextLeft(0, st::linksDateMargin.top(), _width, _text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Photo::Photo(
|
Photo::Photo(
|
||||||
not_null<Delegate*> delegate,
|
not_null<Delegate*> delegate,
|
||||||
not_null<HistoryItem*> parent,
|
not_null<HistoryItem*> parent,
|
||||||
|
|
|
@ -37,35 +37,17 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AbstractItem : public LayoutItemBase {
|
class ItemBase : public LayoutItemBase {
|
||||||
public:
|
|
||||||
virtual void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) = 0;
|
|
||||||
|
|
||||||
virtual ItemBase *toMediaItem() {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
virtual const ItemBase *toMediaItem() const {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual HistoryItem *getItem() const {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
virtual DocumentData *getDocument() const {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
MsgId msgId() const;
|
|
||||||
|
|
||||||
virtual void invalidateCache() {
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class ItemBase : public AbstractItem {
|
|
||||||
public:
|
public:
|
||||||
ItemBase(not_null<Delegate*> delegate, not_null<HistoryItem*> parent);
|
ItemBase(not_null<Delegate*> delegate, not_null<HistoryItem*> parent);
|
||||||
~ItemBase();
|
~ItemBase();
|
||||||
|
|
||||||
|
virtual void paint(
|
||||||
|
Painter &p,
|
||||||
|
const QRect &clip,
|
||||||
|
TextSelection selection,
|
||||||
|
const PaintContext *context) = 0;
|
||||||
|
|
||||||
QDateTime dateTime() const;
|
QDateTime dateTime() const;
|
||||||
|
|
||||||
void setPosition(int position) {
|
void setPosition(int position) {
|
||||||
|
@ -75,20 +57,14 @@ public:
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemBase *toMediaItem() final override {
|
HistoryItem *getItem() const {
|
||||||
return this;
|
|
||||||
}
|
|
||||||
const ItemBase *toMediaItem() const final override {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
HistoryItem *getItem() const final override {
|
|
||||||
return _parent;
|
return _parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
|
||||||
void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
|
void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
|
||||||
|
|
||||||
void invalidateCache() override;
|
void invalidateCache();
|
||||||
|
|
||||||
virtual void clearHeavyPart() {
|
virtual void clearHeavyPart() {
|
||||||
}
|
}
|
||||||
|
@ -194,19 +170,6 @@ struct Info : public RuntimeComponent<Info, LayoutItemBase> {
|
||||||
int top = 0;
|
int top = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Date : public AbstractItem {
|
|
||||||
public:
|
|
||||||
Date(const QDate &date, bool month);
|
|
||||||
|
|
||||||
void initDimensions() override;
|
|
||||||
void paint(Painter &p, const QRect &clip, TextSelection selection, const PaintContext *context) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QDate _date;
|
|
||||||
QString _text;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class Photo final : public ItemBase {
|
class Photo final : public ItemBase {
|
||||||
public:
|
public:
|
||||||
Photo(
|
Photo(
|
||||||
|
@ -321,10 +284,6 @@ public:
|
||||||
QPoint point,
|
QPoint point,
|
||||||
StateRequest request) const override;
|
StateRequest request) const override;
|
||||||
|
|
||||||
DocumentData *getDocument() const override {
|
|
||||||
return _data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float64 dataProgress() const override;
|
float64 dataProgress() const override;
|
||||||
bool dataFinished() const override;
|
bool dataFinished() const override;
|
||||||
|
|
|
@ -1745,7 +1745,7 @@ void FormController::loadFile(File &file) {
|
||||||
fileLoadFail(key);
|
fileLoadFail(key);
|
||||||
}, [=] {
|
}, [=] {
|
||||||
fileLoadDone(key, loader->bytes());
|
fileLoadDone(key, loader->bytes());
|
||||||
}) | rpl::release();
|
}, loader->lifetime());
|
||||||
loader->start();
|
loader->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,10 @@ public:
|
||||||
return _updates.events();
|
return _updates.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::lifetime &lifetime() {
|
||||||
|
return _lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum class LocalStatus {
|
enum class LocalStatus {
|
||||||
NotTried,
|
NotTried,
|
||||||
|
@ -138,7 +142,6 @@ protected:
|
||||||
[[nodiscard]] QByteArray readLoadedPartBack(int offset, int size);
|
[[nodiscard]] QByteArray readLoadedPartBack(int offset, int size);
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Main::Session*> _session;
|
||||||
rpl::event_stream<rpl::empty_value, bool> _updates;
|
|
||||||
|
|
||||||
bool _autoLoading = false;
|
bool _autoLoading = false;
|
||||||
uint8 _cacheTag = 0;
|
uint8 _cacheTag = 0;
|
||||||
|
@ -163,6 +166,9 @@ protected:
|
||||||
mutable QByteArray _imageFormat;
|
mutable QByteArray _imageFormat;
|
||||||
mutable QImage _imageData;
|
mutable QImage _imageData;
|
||||||
|
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
rpl::event_stream<rpl::empty_value, bool> _updates;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] std::unique_ptr<FileLoader> CreateFileLoader(
|
[[nodiscard]] std::unique_ptr<FileLoader> CreateFileLoader(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit df918b9d3e2cce729cf21de5c69a01a847e7107c
|
Subproject commit 88ae67c59ab791084f43163d4484c9874003ac42
|
Loading…
Reference in New Issue