2016-06-07 19:59:39 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-06-07 19:59:39 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-06-07 19:59:39 +00:00
|
|
|
*/
|
|
|
|
#include "dialogs/dialogs_row.h"
|
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
#include "ui/effects/ripple_animation.h"
|
2019-04-23 12:29:23 +00:00
|
|
|
#include "ui/text_options.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "dialogs/dialogs_entry.h"
|
2019-04-23 12:29:23 +00:00
|
|
|
#include "data/data_folder.h"
|
|
|
|
#include "history/history.h"
|
|
|
|
#include "lang/lang_keys.h"
|
2016-12-05 11:01:08 +00:00
|
|
|
#include "mainwidget.h"
|
2019-04-23 12:29:23 +00:00
|
|
|
#include "styles/style_dialogs.h"
|
2016-06-07 19:59:39 +00:00
|
|
|
|
|
|
|
namespace Dialogs {
|
2019-04-23 12:29:23 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
QString ComposeFolderListEntryText(not_null<Data::Folder*> folder) {
|
2019-05-08 08:50:39 +00:00
|
|
|
const auto &list = folder->lastHistories();
|
2019-04-23 12:29:23 +00:00
|
|
|
if (list.empty()) {
|
2019-05-08 08:50:39 +00:00
|
|
|
return QString();
|
2019-04-23 12:29:23 +00:00
|
|
|
}
|
2019-05-08 08:50:39 +00:00
|
|
|
|
2019-04-23 12:29:23 +00:00
|
|
|
const auto count = std::max(
|
|
|
|
int(list.size()),
|
2019-05-08 08:50:39 +00:00
|
|
|
folder->chatsListSize());
|
|
|
|
|
|
|
|
const auto throwAwayLastName = (list.size() > 1)
|
|
|
|
&& (count == list.size() + 1);
|
|
|
|
auto &&peers = ranges::view::all(
|
|
|
|
list
|
|
|
|
) | ranges::view::take(
|
|
|
|
list.size() - (throwAwayLastName ? 1 : 0)
|
2019-05-08 09:05:15 +00:00
|
|
|
);
|
|
|
|
const auto wrapName = [](not_null<History*> history) {
|
|
|
|
const auto name = TextUtilities::Clean(App::peerName(history->peer));
|
|
|
|
return (history->unreadCount() > 0)
|
|
|
|
? (textcmdStartSemibold()
|
|
|
|
+ textcmdLink(1, name)
|
|
|
|
+ textcmdStopSemibold())
|
|
|
|
: name;
|
|
|
|
};
|
2019-05-08 08:50:39 +00:00
|
|
|
const auto shown = int(peers.size());
|
|
|
|
const auto accumulated = [&] {
|
|
|
|
Expects(shown > 0);
|
|
|
|
|
|
|
|
auto i = peers.begin();
|
2019-05-08 09:05:15 +00:00
|
|
|
auto result = wrapName(*i);
|
2019-05-08 08:50:39 +00:00
|
|
|
for (++i; i != peers.end(); ++i) {
|
|
|
|
result = lng_archived_last_list(
|
|
|
|
lt_accumulated,
|
|
|
|
result,
|
|
|
|
lt_chat,
|
2019-05-08 09:05:15 +00:00
|
|
|
wrapName(*i));
|
2019-05-08 08:50:39 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}();
|
|
|
|
return (shown < count)
|
|
|
|
? lng_archived_last(lt_count, (count - shown), lt_chats, accumulated)
|
|
|
|
: accumulated;
|
2019-04-23 12:29:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2016-06-07 19:59:39 +00:00
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
RippleRow::RippleRow() = default;
|
|
|
|
RippleRow::~RippleRow() = default;
|
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void RippleRow::addRipple(QPoint origin, QSize size, Fn<void()> updateCallback) {
|
2016-12-05 11:01:08 +00:00
|
|
|
if (!_ripple) {
|
|
|
|
auto mask = Ui::RippleAnimation::rectMask(size);
|
2017-02-21 13:45:56 +00:00
|
|
|
_ripple = std::make_unique<Ui::RippleAnimation>(st::dialogsRipple, std::move(mask), std::move(updateCallback));
|
2016-12-05 11:01:08 +00:00
|
|
|
}
|
|
|
|
_ripple->add(origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RippleRow::stopLastRipple() {
|
|
|
|
if (_ripple) {
|
|
|
|
_ripple->lastStop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
void RippleRow::paintRipple(Painter &p, int x, int y, int outerWidth, const QColor *colorOverride) const {
|
2016-12-05 11:01:08 +00:00
|
|
|
if (_ripple) {
|
2019-04-02 09:13:30 +00:00
|
|
|
_ripple->paint(p, x, y, outerWidth, colorOverride);
|
2016-12-05 11:01:08 +00:00
|
|
|
if (_ripple->empty()) {
|
|
|
|
_ripple.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
uint64 Row::sortKey() const {
|
|
|
|
return _id.entry()->sortKeyInChatList();
|
|
|
|
}
|
|
|
|
|
2019-04-23 12:29:23 +00:00
|
|
|
void Row::validateListEntryCache() const {
|
|
|
|
const auto folder = _id.folder();
|
|
|
|
if (!folder) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto version = folder->chatListViewVersion();
|
|
|
|
if (_listEntryCacheVersion == version) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_listEntryCacheVersion = version;
|
|
|
|
_listEntryCache.setText(
|
|
|
|
st::dialogsTextStyle,
|
|
|
|
ComposeFolderListEntryText(folder),
|
|
|
|
Ui::DialogTextOptions());
|
|
|
|
}
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
FakeRow::FakeRow(Key searchInChat, not_null<HistoryItem*> item)
|
|
|
|
: _searchInChat(searchInChat)
|
2017-09-05 17:21:56 +00:00
|
|
|
, _item(item)
|
|
|
|
, _cache(st::dialogsTextWidthMin) {
|
2016-06-07 19:59:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Dialogs
|