init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
83
Telegram/SourceFiles/dialogs/ui/chat_search_empty.cpp
Normal file
83
Telegram/SourceFiles/dialogs/ui/chat_search_empty.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "dialogs/ui/chat_search_empty.h"
|
||||
|
||||
#include "base/object_ptr.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
SearchEmpty::SearchEmpty(
|
||||
QWidget *parent,
|
||||
Icon icon,
|
||||
rpl::producer<TextWithEntities> text)
|
||||
: RpWidget(parent) {
|
||||
setup(icon, std::move(text));
|
||||
}
|
||||
|
||||
void SearchEmpty::setMinimalHeight(int minimalHeight) {
|
||||
const auto minimal = st::recentPeersEmptyHeightMin;
|
||||
resize(width(), std::max(minimalHeight, minimal));
|
||||
}
|
||||
|
||||
void SearchEmpty::setup(Icon icon, rpl::producer<TextWithEntities> text) {
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
this,
|
||||
std::move(text),
|
||||
st::defaultPeerListAbout);
|
||||
const auto size = st::recentPeersEmptySize;
|
||||
const auto animation = [&] {
|
||||
switch (icon) {
|
||||
case Icon::Search: return u"search"_q;
|
||||
case Icon::NoResults: return u"noresults"_q;
|
||||
}
|
||||
Unexpected("Icon in SearchEmpty::setup.");
|
||||
}();
|
||||
const auto [widget, animate] = Settings::CreateLottieIcon(
|
||||
this,
|
||||
{
|
||||
.name = animation,
|
||||
.sizeOverride = { size, size },
|
||||
},
|
||||
st::recentPeersEmptyMargin);
|
||||
const auto animated = widget.data();
|
||||
|
||||
sizeValue() | rpl::on_next([=](QSize size) {
|
||||
const auto padding = st::recentPeersEmptyMargin;
|
||||
const auto paddings = padding.left() + padding.right();
|
||||
label->resizeToWidth(size.width() - paddings);
|
||||
const auto x = (size.width() - animated->width()) / 2;
|
||||
const auto y = (size.height() - animated->height()) / 3;
|
||||
const auto top = y + animated->height() + st::recentPeersEmptySkip;
|
||||
const auto sub = std::max(top + label->height() - size.height(), 0);
|
||||
animated->move(x, y - sub);
|
||||
label->move((size.width() - label->width()) / 2, top - sub);
|
||||
}, lifetime());
|
||||
|
||||
label->setClickHandlerFilter([=](
|
||||
const ClickHandlerPtr &handler,
|
||||
Qt::MouseButton) {
|
||||
_handlerActivated.fire_copy(handler);
|
||||
return false;
|
||||
});
|
||||
|
||||
_animate = [animate] {
|
||||
animate(anim::repeat::once);
|
||||
};
|
||||
}
|
||||
|
||||
void SearchEmpty::animate() {
|
||||
if (const auto onstack = _animate) {
|
||||
onstack();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Dialogs
|
||||
Reference in New Issue
Block a user