[Option][GUI] Compact chat list
This commit is contained in:
parent
c241938606
commit
374bc85dc7
10 changed files with 609 additions and 235 deletions
|
|
@ -33,6 +33,7 @@
|
||||||
"ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.",
|
"ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.",
|
||||||
"ktg_settings_emoji_outline": "Big emoji outline",
|
"ktg_settings_emoji_outline": "Big emoji outline",
|
||||||
"ktg_settings_always_show_scheduled": "Always show scheduled",
|
"ktg_settings_always_show_scheduled": "Always show scheduled",
|
||||||
|
"ktg_settings_chat_list_compact": "Compact chat list",
|
||||||
"ktg_fonts_title": "Fonts",
|
"ktg_fonts_title": "Fonts",
|
||||||
"ktg_settings_fonts": "Change application fonts",
|
"ktg_settings_fonts": "Change application fonts",
|
||||||
"ktg_fonts_reset": "Reset",
|
"ktg_fonts_reset": "Reset",
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/dialogs_inner_widget.h"
|
#include "dialogs/dialogs_inner_widget.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "dialogs/dialogs_indexed_list.h"
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
#include "dialogs/ui/dialogs_video_userpic.h"
|
#include "dialogs/ui/dialogs_video_userpic.h"
|
||||||
|
|
@ -72,6 +73,18 @@ base::options::toggle TabbedPanelShowOnClick({
|
||||||
"(Cmd+Click on macOS).",
|
"(Cmd+Click on macOS).",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inline int DialogsRowHeight() {
|
||||||
|
return (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsImportantBarHeight
|
||||||
|
: st::dialogsRowHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int DialogsPhotoSize() {
|
||||||
|
return (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsUnreadHeight
|
||||||
|
: st::dialogsPhotoSize);
|
||||||
|
}
|
||||||
|
|
||||||
int FixedOnTopDialogsCount(not_null<Dialogs::IndexedList*> list) {
|
int FixedOnTopDialogsCount(not_null<Dialogs::IndexedList*> list) {
|
||||||
auto result = 0;
|
auto result = 0;
|
||||||
for (const auto &row : *list) {
|
for (const auto &row : *list) {
|
||||||
|
|
@ -212,6 +225,12 @@ InnerWidget::InnerWidget(
|
||||||
refresh();
|
refresh();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
::Kotato::JsonSettings::Events(
|
||||||
|
"chat_list_lines"
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
refresh();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
session().changes().historyUpdates(
|
session().changes().historyUpdates(
|
||||||
Data::HistoryUpdate::Flag::IsPinned
|
Data::HistoryUpdate::Flag::IsPinned
|
||||||
| Data::HistoryUpdate::Flag::ChatOccupied
|
| Data::HistoryUpdate::Flag::ChatOccupied
|
||||||
|
|
@ -313,7 +332,10 @@ void InnerWidget::refreshWithCollapsedRows(bool toTop) {
|
||||||
? (*list->begin())->folder()
|
? (*list->begin())->folder()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const auto inMainMenu = session().settings().archiveInMainMenu();
|
const auto inMainMenu = session().settings().archiveInMainMenu();
|
||||||
if (archive && (session().settings().archiveCollapsed() || inMainMenu)) {
|
if (archive &&
|
||||||
|
(session().settings().archiveCollapsed()
|
||||||
|
|| inMainMenu
|
||||||
|
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)) {
|
||||||
if (_selected && _selected->folder() == archive) {
|
if (_selected && _selected->folder() == archive) {
|
||||||
_selected = nullptr;
|
_selected = nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +364,7 @@ void InnerWidget::refreshWithCollapsedRows(bool toTop) {
|
||||||
|
|
||||||
int InnerWidget::dialogsOffset() const {
|
int InnerWidget::dialogsOffset() const {
|
||||||
return _collapsedRows.size() * st::dialogsImportantBarHeight
|
return _collapsedRows.size() * st::dialogsImportantBarHeight
|
||||||
- _skipTopDialogs * st::dialogsRowHeight;
|
- _skipTopDialogs * DialogsRowHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::fixedOnTopCount() const {
|
int InnerWidget::fixedOnTopCount() const {
|
||||||
|
|
@ -358,7 +380,7 @@ int InnerWidget::fixedOnTopCount() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::pinnedOffset() const {
|
int InnerWidget::pinnedOffset() const {
|
||||||
return dialogsOffset() + fixedOnTopCount() * st::dialogsRowHeight;
|
return dialogsOffset() + fixedOnTopCount() * DialogsRowHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::filteredOffset() const {
|
int InnerWidget::filteredOffset() const {
|
||||||
|
|
@ -366,11 +388,11 @@ int InnerWidget::filteredOffset() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::peerSearchOffset() const {
|
int InnerWidget::peerSearchOffset() const {
|
||||||
return filteredOffset() + (_filterResults.size() * st::dialogsRowHeight) + st::searchedBarHeight;
|
return filteredOffset() + (_filterResults.size() * DialogsRowHeight()) + st::searchedBarHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::searchedOffset() const {
|
int InnerWidget::searchedOffset() const {
|
||||||
auto result = peerSearchOffset() + (_peerSearchResults.empty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight));
|
auto result = peerSearchOffset() + (_peerSearchResults.empty() ? 0 : ((_peerSearchResults.size() * DialogsRowHeight()) + st::searchedBarHeight));
|
||||||
if (_searchInChat) {
|
if (_searchInChat) {
|
||||||
result += searchInChatSkip();
|
result += searchInChatSkip();
|
||||||
}
|
}
|
||||||
|
|
@ -424,7 +446,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
const auto rows = shownDialogs();
|
const auto rows = shownDialogs();
|
||||||
const auto &list = rows->all();
|
const auto &list = rows->all();
|
||||||
const auto otherStart = std::max(int(rows->size()) - _skipTopDialogs, 0) * st::dialogsRowHeight;
|
const auto otherStart = std::max(int(rows->size()) - _skipTopDialogs, 0) * DialogsRowHeight();
|
||||||
const auto active = activeEntry.key;
|
const auto active = activeEntry.key;
|
||||||
const auto selected = _menuRow.key
|
const auto selected = _menuRow.key
|
||||||
? _menuRow.key
|
? _menuRow.key
|
||||||
|
|
@ -439,7 +461,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
const auto skip = dialogsOffset();
|
const auto skip = dialogsOffset();
|
||||||
auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty());
|
auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty());
|
||||||
if (reorderingPinned) {
|
if (reorderingPinned) {
|
||||||
dialogsClip = dialogsClip.marginsAdded(QMargins(0, st::dialogsRowHeight, 0, st::dialogsRowHeight));
|
dialogsClip = dialogsClip.marginsAdded(QMargins(0, DialogsRowHeight(), 0, DialogsRowHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto promoted = fixedOnTopCount();
|
const auto promoted = fixedOnTopCount();
|
||||||
|
|
@ -471,7 +493,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto i = list.cfind(dialogsClip.top() - skip, st::dialogsRowHeight);
|
auto i = list.cfind(dialogsClip.top() - skip, DialogsRowHeight());
|
||||||
while (i != list.cend() && (*i)->pos() < _skipTopDialogs) {
|
while (i != list.cend() && (*i)->pos() < _skipTopDialogs) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
@ -480,13 +502,13 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
// If we're reordering pinned chats we need to fill this area background first.
|
// If we're reordering pinned chats we need to fill this area background first.
|
||||||
if (reorderingPinned) {
|
if (reorderingPinned) {
|
||||||
p.fillRect(0, (promoted - _skipTopDialogs) * st::dialogsRowHeight, fullWidth, st::dialogsRowHeight * _pinnedRows.size(), st::dialogsBg);
|
p.fillRect(0, (promoted - _skipTopDialogs) * DialogsRowHeight(), fullWidth, DialogsRowHeight() * _pinnedRows.size(), st::dialogsBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.translate(0, (lastPaintedPos - _skipTopDialogs) * st::dialogsRowHeight);
|
p.translate(0, (lastPaintedPos - _skipTopDialogs) * DialogsRowHeight());
|
||||||
for (auto e = list.cend(); i != e; ++i) {
|
for (auto e = list.cend(); i != e; ++i) {
|
||||||
auto row = (*i);
|
auto row = (*i);
|
||||||
if ((lastPaintedPos - _skipTopDialogs) * st::dialogsRowHeight >= dialogsClip.top() - skip + dialogsClip.height()) {
|
if ((lastPaintedPos - _skipTopDialogs) * DialogsRowHeight() >= dialogsClip.top() - skip + dialogsClip.height()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +518,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
paintDialog(row);
|
paintDialog(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, DialogsRowHeight());
|
||||||
++lastPaintedPos;
|
++lastPaintedPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,9 +527,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
auto i = list.cfind(promoted + _aboveIndex, 1);
|
auto i = list.cfind(promoted + _aboveIndex, 1);
|
||||||
auto pos = (i == list.cend()) ? -1 : (*i)->pos();
|
auto pos = (i == list.cend()) ? -1 : (*i)->pos();
|
||||||
if (pos == promoted + _aboveIndex) {
|
if (pos == promoted + _aboveIndex) {
|
||||||
p.translate(0, (pos - lastPaintedPos) * st::dialogsRowHeight);
|
p.translate(0, (pos - lastPaintedPos) * DialogsRowHeight());
|
||||||
paintDialog(*i);
|
paintDialog(*i);
|
||||||
p.translate(0, (lastPaintedPos - pos) * st::dialogsRowHeight);
|
p.translate(0, (lastPaintedPos - pos) * DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -562,9 +584,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
if (!_filterResults.empty()) {
|
if (!_filterResults.empty()) {
|
||||||
auto skip = filteredOffset();
|
auto skip = filteredOffset();
|
||||||
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
auto from = floorclamp(r.y() - skip, DialogsRowHeight(), 0, _filterResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _filterResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, DialogsRowHeight(), 0, _filterResults.size());
|
||||||
p.translate(0, from * st::dialogsRowHeight);
|
p.translate(0, from * DialogsRowHeight());
|
||||||
if (from < _filterResults.size()) {
|
if (from < _filterResults.size()) {
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
const auto row = _filterResults[from];
|
const auto row = _filterResults[from];
|
||||||
|
|
@ -586,7 +608,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
selected,
|
selected,
|
||||||
ms,
|
ms,
|
||||||
videoPaused);
|
videoPaused);
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -599,9 +621,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.translate(0, st::searchedBarHeight);
|
p.translate(0, st::searchedBarHeight);
|
||||||
|
|
||||||
auto skip = peerSearchOffset();
|
auto skip = peerSearchOffset();
|
||||||
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
auto from = floorclamp(r.y() - skip, DialogsRowHeight(), 0, _peerSearchResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, DialogsRowHeight(), 0, _peerSearchResults.size());
|
||||||
p.translate(0, from * st::dialogsRowHeight);
|
p.translate(0, from * DialogsRowHeight());
|
||||||
if (from < _peerSearchResults.size()) {
|
if (from < _peerSearchResults.size()) {
|
||||||
const auto activePeer = activeEntry.key.peer();
|
const auto activePeer = activeEntry.key.peer();
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
|
|
@ -615,7 +637,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
? _peerSearchPressed
|
? _peerSearchPressed
|
||||||
: _peerSearchSelected));
|
: _peerSearchSelected));
|
||||||
paintPeerSearchResult(p, result.get(), fullWidth, active, selected);
|
paintPeerSearchResult(p, result.get(), fullWidth, active, selected);
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -658,9 +680,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.translate(0, st::searchedBarHeight);
|
p.translate(0, st::searchedBarHeight);
|
||||||
|
|
||||||
auto skip = searchedOffset();
|
auto skip = searchedOffset();
|
||||||
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _searchResults.size());
|
auto from = floorclamp(r.y() - skip, DialogsRowHeight(), 0, _searchResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _searchResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, DialogsRowHeight(), 0, _searchResults.size());
|
||||||
p.translate(0, from * st::dialogsRowHeight);
|
p.translate(0, from * DialogsRowHeight());
|
||||||
if (from < _searchResults.size()) {
|
if (from < _searchResults.size()) {
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
const auto &result = _searchResults[from];
|
const auto &result = _searchResults[from];
|
||||||
|
|
@ -678,7 +700,7 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
selected,
|
selected,
|
||||||
ms,
|
ms,
|
||||||
showUnreadInSearchResults);
|
showUnreadInSearchResults);
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -768,7 +790,7 @@ void InnerWidget::paintPeerSearchResult(
|
||||||
int fullWidth,
|
int fullWidth,
|
||||||
bool active,
|
bool active,
|
||||||
bool selected) const {
|
bool selected) const {
|
||||||
QRect fullRect(0, 0, fullWidth, st::dialogsRowHeight);
|
QRect fullRect(0, 0, fullWidth, DialogsRowHeight());
|
||||||
p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg));
|
p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg));
|
||||||
if (!active) {
|
if (!active) {
|
||||||
result->row.paintRipple(p, 0, 0, fullWidth);
|
result->row.paintRipple(p, 0, 0, fullWidth);
|
||||||
|
|
@ -776,11 +798,17 @@ void InnerWidget::paintPeerSearchResult(
|
||||||
|
|
||||||
auto peer = result->peer;
|
auto peer = result->peer;
|
||||||
auto userpicPeer = (peer->migrateTo() ? peer->migrateTo() : peer);
|
auto userpicPeer = (peer->migrateTo() ? peer->migrateTo() : peer);
|
||||||
userpicPeer->paintUserpicLeft(p, result->row.userpicView(), st::dialogsPadding.x(), st::dialogsPadding.y(), width(), st::dialogsPhotoSize);
|
userpicPeer->paintUserpicLeft(p, result->row.userpicView(), st::dialogsPadding.x(), st::dialogsPadding.y(), width(), DialogsPhotoSize());
|
||||||
|
|
||||||
auto nameleft = st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPhotoPadding;
|
auto nameleft = st::dialogsPadding.x() + DialogsPhotoSize() + st::dialogsPhotoPadding;
|
||||||
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
||||||
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
|
QRect rectForName(
|
||||||
|
nameleft,
|
||||||
|
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)
|
||||||
|
? st::dialogsPadding.y()
|
||||||
|
: st::dialogsPadding.y() + st::dialogsNameTop,
|
||||||
|
namewidth,
|
||||||
|
st::msgNameFont->height);
|
||||||
|
|
||||||
if (result->name.isEmpty()) {
|
if (result->name.isEmpty()) {
|
||||||
result->name.setText(
|
result->name.setText(
|
||||||
|
|
@ -819,29 +847,43 @@ void InnerWidget::paintPeerSearchResult(
|
||||||
badgeStyle);
|
badgeStyle);
|
||||||
rectForName.setWidth(rectForName.width() - badgeWidth);
|
rectForName.setWidth(rectForName.width() - badgeWidth);
|
||||||
|
|
||||||
QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height);
|
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
|
||||||
p.setFont(st::dialogsTextFont);
|
QString text = peer->name();
|
||||||
QString username = peer->userName();
|
p.setPen(active
|
||||||
if (!active && username.startsWith(_peerSearchQuery, Qt::CaseInsensitive)) {
|
? st::dialogsNameFgActive
|
||||||
auto first = '@' + username.mid(0, _peerSearchQuery.size());
|
: selected
|
||||||
auto second = username.mid(_peerSearchQuery.size());
|
? st::dialogsNameFgOver
|
||||||
auto w = st::dialogsTextFont->width(first);
|
: st::dialogsNameFg);
|
||||||
if (w >= tr.width()) {
|
p.setFont(st::dialogsTextFont);
|
||||||
p.setPen(st::dialogsTextFgService);
|
|
||||||
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided(first, tr.width()));
|
|
||||||
} else {
|
|
||||||
p.setPen(st::dialogsTextFgService);
|
|
||||||
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, first);
|
|
||||||
p.setPen(st::dialogsTextFg);
|
|
||||||
p.drawText(tr.left() + w, tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided(second, tr.width() - w));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.setPen(active ? st::dialogsTextFgActive : st::dialogsTextFgService);
|
|
||||||
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided('@' + username, tr.width()));
|
|
||||||
}
|
|
||||||
|
|
||||||
p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg);
|
Ui::Text::String textStr;
|
||||||
result->name.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
textStr.setText(st::dialogsTextStyle, text, Ui::NameTextOptions());
|
||||||
|
textStr.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||||
|
} else {
|
||||||
|
QRect tr(nameleft, st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip, namewidth, st::dialogsTextFont->height);
|
||||||
|
p.setFont(st::dialogsTextFont);
|
||||||
|
QString username = peer->userName();
|
||||||
|
if (!active && username.startsWith(_peerSearchQuery, Qt::CaseInsensitive)) {
|
||||||
|
auto first = '@' + username.mid(0, _peerSearchQuery.size());
|
||||||
|
auto second = username.mid(_peerSearchQuery.size());
|
||||||
|
auto w = st::dialogsTextFont->width(first);
|
||||||
|
if (w >= tr.width()) {
|
||||||
|
p.setPen(st::dialogsTextFgService);
|
||||||
|
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided(first, tr.width()));
|
||||||
|
} else {
|
||||||
|
p.setPen(st::dialogsTextFgService);
|
||||||
|
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, first);
|
||||||
|
p.setPen(st::dialogsTextFg);
|
||||||
|
p.drawText(tr.left() + w, tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided(second, tr.width() - w));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p.setPen(active ? st::dialogsTextFgActive : st::dialogsTextFgService);
|
||||||
|
p.drawText(tr.left(), tr.top() + st::dialogsTextFont->ascent, st::dialogsTextFont->elided('@' + username, tr.width()));
|
||||||
|
}
|
||||||
|
|
||||||
|
p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg);
|
||||||
|
result->name.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::paintSearchInChat(Painter &p) const {
|
void InnerWidget::paintSearchInChat(Painter &p) const {
|
||||||
|
|
@ -1003,7 +1045,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
: (mouseY >= offset)
|
: (mouseY >= offset)
|
||||||
? shownDialogs()->rowAtY(
|
? shownDialogs()->rowAtY(
|
||||||
mouseY - offset,
|
mouseY - offset,
|
||||||
st::dialogsRowHeight)
|
DialogsRowHeight())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (_selected != selected || _collapsedSelected != collapsedSelected) {
|
if (_selected != selected || _collapsedSelected != collapsedSelected) {
|
||||||
updateSelectedRow();
|
updateSelectedRow();
|
||||||
|
|
@ -1034,7 +1076,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
}
|
}
|
||||||
if (!_filterResults.empty()) {
|
if (!_filterResults.empty()) {
|
||||||
auto skip = filteredOffset();
|
auto skip = filteredOffset();
|
||||||
auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto filteredSelected = (mouseY >= skip) ? ((mouseY - skip) / DialogsRowHeight()) : -1;
|
||||||
if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) {
|
if (filteredSelected < 0 || filteredSelected >= _filterResults.size()) {
|
||||||
filteredSelected = -1;
|
filteredSelected = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1046,7 +1088,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.empty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
auto skip = peerSearchOffset();
|
auto skip = peerSearchOffset();
|
||||||
auto peerSearchSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto peerSearchSelected = (mouseY >= skip) ? ((mouseY - skip) / DialogsRowHeight()) : -1;
|
||||||
if (peerSearchSelected < 0 || peerSearchSelected >= _peerSearchResults.size()) {
|
if (peerSearchSelected < 0 || peerSearchSelected >= _peerSearchResults.size()) {
|
||||||
peerSearchSelected = -1;
|
peerSearchSelected = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1058,7 +1100,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
}
|
}
|
||||||
if (!_waitingForSearch && !_searchResults.empty()) {
|
if (!_waitingForSearch && !_searchResults.empty()) {
|
||||||
auto skip = searchedOffset();
|
auto skip = searchedOffset();
|
||||||
auto searchedSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto searchedSelected = (mouseY >= skip) ? ((mouseY - skip) / DialogsRowHeight()) : -1;
|
||||||
if (searchedSelected < 0 || searchedSelected >= _searchResults.size()) {
|
if (searchedSelected < 0 || searchedSelected >= _searchResults.size()) {
|
||||||
searchedSelected = -1;
|
searchedSelected = -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1092,7 +1134,7 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
});
|
});
|
||||||
} else if (_pressed) {
|
} else if (_pressed) {
|
||||||
auto row = _pressed;
|
auto row = _pressed;
|
||||||
row->addRipple(e->pos() - QPoint(0, dialogsOffset() + _pressed->pos() * st::dialogsRowHeight), QSize(width(), st::dialogsRowHeight), [this, row] {
|
row->addRipple(e->pos() - QPoint(0, dialogsOffset() + _pressed->pos() * DialogsRowHeight()), QSize(width(), DialogsRowHeight()), [this, row] {
|
||||||
if (!_pinnedShiftAnimation.animating()) {
|
if (!_pinnedShiftAnimation.animating()) {
|
||||||
row->entry()->updateChatListEntry();
|
row->entry()->updateChatListEntry();
|
||||||
}
|
}
|
||||||
|
|
@ -1108,19 +1150,19 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
const auto filterId = _filterId;
|
const auto filterId = _filterId;
|
||||||
row->addRipple(
|
row->addRipple(
|
||||||
e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight),
|
e->pos() - QPoint(0, filteredOffset() + _filteredPressed * st::dialogsRowHeight),
|
||||||
QSize(width(), st::dialogsRowHeight),
|
QSize(width(), DialogsRowHeight()),
|
||||||
[=] { repaintDialogRow(filterId, row); });
|
[=] { repaintDialogRow(filterId, row); });
|
||||||
} else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) {
|
} else if (base::in_range(_peerSearchPressed, 0, _peerSearchResults.size())) {
|
||||||
auto &result = _peerSearchResults[_peerSearchPressed];
|
auto &result = _peerSearchResults[_peerSearchPressed];
|
||||||
auto row = &result->row;
|
auto row = &result->row;
|
||||||
row->addRipple(
|
row->addRipple(
|
||||||
e->pos() - QPoint(0, peerSearchOffset() + _peerSearchPressed * st::dialogsRowHeight),
|
e->pos() - QPoint(0, peerSearchOffset() + _peerSearchPressed * DialogsRowHeight()),
|
||||||
QSize(width(), st::dialogsRowHeight),
|
QSize(width(), DialogsRowHeight()),
|
||||||
[this, peer = result->peer] { updateSearchResult(peer); });
|
[this, peer = result->peer] { updateSearchResult(peer); });
|
||||||
} else if (base::in_range(_searchedPressed, 0, _searchResults.size())) {
|
} else if (base::in_range(_searchedPressed, 0, _searchResults.size())) {
|
||||||
auto &row = _searchResults[_searchedPressed];
|
auto &row = _searchResults[_searchedPressed];
|
||||||
row->addRipple(e->pos() - QPoint(0, searchedOffset() + _searchedPressed * st::dialogsRowHeight), QSize(width(), st::dialogsRowHeight), [this, index = _searchedPressed] {
|
row->addRipple(e->pos() - QPoint(0, searchedOffset() + _searchedPressed * DialogsRowHeight()), QSize(width(), DialogsRowHeight()), [this, index = _searchedPressed] {
|
||||||
rtlupdate(0, searchedOffset() + index * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
rtlupdate(0, searchedOffset() + index * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (anim::Disabled()
|
if (anim::Disabled()
|
||||||
|
|
@ -1248,7 +1290,7 @@ bool InnerWidget::updateReorderPinned(QPoint localPosition) {
|
||||||
auto yaddWas = _pinnedRows[_draggingIndex].yadd.current();
|
auto yaddWas = _pinnedRows[_draggingIndex].yadd.current();
|
||||||
auto shift = 0;
|
auto shift = 0;
|
||||||
auto now = crl::now();
|
auto now = crl::now();
|
||||||
auto rowHeight = st::dialogsRowHeight;
|
auto rowHeight = DialogsRowHeight();
|
||||||
if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) {
|
if (_dragStart.y() > localPosition.y() && _draggingIndex > 0) {
|
||||||
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
||||||
|
|
||||||
|
|
@ -1328,11 +1370,11 @@ bool InnerWidget::pinnedShiftAnimationCallback(crl::time now) {
|
||||||
}
|
}
|
||||||
if (updateMin >= 0) {
|
if (updateMin >= 0) {
|
||||||
auto top = pinnedOffset();
|
auto top = pinnedOffset();
|
||||||
auto updateFrom = top + st::dialogsRowHeight * (updateMin - 1);
|
auto updateFrom = top + DialogsRowHeight() * (updateMin - 1);
|
||||||
auto updateHeight = st::dialogsRowHeight * (updateMax - updateMin + 3);
|
auto updateHeight = DialogsRowHeight() * (updateMax - updateMin + 3);
|
||||||
if (base::in_range(_aboveIndex, 0, _pinnedRows.size())) {
|
if (base::in_range(_aboveIndex, 0, _pinnedRows.size())) {
|
||||||
// Always include currently dragged chat in its current and old positions.
|
// Always include currently dragged chat in its current and old positions.
|
||||||
auto aboveRowBottom = top + (_aboveIndex + 1) * st::dialogsRowHeight;
|
auto aboveRowBottom = top + (_aboveIndex + 1) * DialogsRowHeight();
|
||||||
auto aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current());
|
auto aboveTopShift = qCeil(_pinnedRows[_aboveIndex].yadd.current());
|
||||||
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift);
|
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + _aboveTopShift);
|
||||||
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift);
|
accumulate_max(updateHeight, (aboveRowBottom - updateFrom) + aboveTopShift);
|
||||||
|
|
@ -1494,7 +1536,7 @@ void InnerWidget::handleChatListEntryRefreshes() {
|
||||||
) | rpl::filter([=](const Event &event) {
|
) | rpl::filter([=](const Event &event) {
|
||||||
return (event.filterId == _filterId);
|
return (event.filterId == _filterId);
|
||||||
}) | rpl::start_with_next([=](const Event &event) {
|
}) | rpl::start_with_next([=](const Event &event) {
|
||||||
const auto rowHeight = st::dialogsRowHeight;
|
const auto rowHeight = DialogsRowHeight();
|
||||||
const auto from = dialogsOffset() + event.moved.from * rowHeight;
|
const auto from = dialogsOffset() + event.moved.from * rowHeight;
|
||||||
const auto to = dialogsOffset() + event.moved.to * rowHeight;
|
const auto to = dialogsOffset() + event.moved.to * rowHeight;
|
||||||
const auto &key = event.key;
|
const auto &key = event.key;
|
||||||
|
|
@ -1555,7 +1597,7 @@ int InnerWidget::defaultRowTop(not_null<Row*> row) const {
|
||||||
if (base::in_range(position, 0, _pinnedRows.size())) {
|
if (base::in_range(position, 0, _pinnedRows.size())) {
|
||||||
top += qRound(_pinnedRows[position].yadd.current());
|
top += qRound(_pinnedRows[position].yadd.current());
|
||||||
}
|
}
|
||||||
return top + position * st::dialogsRowHeight;
|
return top + position * DialogsRowHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::repaintDialogRow(
|
void InnerWidget::repaintDialogRow(
|
||||||
|
|
@ -1566,7 +1608,7 @@ void InnerWidget::repaintDialogRow(
|
||||||
if (const auto folder = row->folder()) {
|
if (const auto folder = row->folder()) {
|
||||||
repaintCollapsedFolderRow(folder);
|
repaintCollapsedFolderRow(folder);
|
||||||
}
|
}
|
||||||
update(0, defaultRowTop(row), width(), st::dialogsRowHeight);
|
update(0, defaultRowTop(row), width(), DialogsRowHeight());
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
if (!filterId) {
|
if (!filterId) {
|
||||||
|
|
@ -1574,9 +1616,9 @@ void InnerWidget::repaintDialogRow(
|
||||||
if (_filterResults[i]->key() == row->key()) {
|
if (_filterResults[i]->key() == row->key()) {
|
||||||
update(
|
update(
|
||||||
0,
|
0,
|
||||||
filteredOffset() + i * st::dialogsRowHeight,
|
filteredOffset() + i * DialogsRowHeight(),
|
||||||
width(),
|
width(),
|
||||||
st::dialogsRowHeight);
|
DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1610,9 +1652,9 @@ void InnerWidget::updateSearchResult(not_null<PeerData*> peer) {
|
||||||
const auto index = (i - begin(_peerSearchResults));
|
const auto index = (i - begin(_peerSearchResults));
|
||||||
rtlupdate(
|
rtlupdate(
|
||||||
0,
|
0,
|
||||||
top + index * st::dialogsRowHeight,
|
top + index * DialogsRowHeight(),
|
||||||
width(),
|
width(),
|
||||||
st::dialogsRowHeight);
|
DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1622,7 +1664,7 @@ void InnerWidget::updateDialogRow(
|
||||||
QRect updateRect,
|
QRect updateRect,
|
||||||
UpdateRowSections sections) {
|
UpdateRowSections sections) {
|
||||||
if (updateRect.isEmpty()) {
|
if (updateRect.isEmpty()) {
|
||||||
updateRect = QRect(0, 0, width(), st::dialogsRowHeight);
|
updateRect = QRect(0, 0, width(), DialogsRowHeight());
|
||||||
}
|
}
|
||||||
if (IsServerMsgId(-row.fullId.msg)) {
|
if (IsServerMsgId(-row.fullId.msg)) {
|
||||||
if (const auto peer = row.key.peer()) {
|
if (const auto peer = row.key.peer()) {
|
||||||
|
|
@ -1654,7 +1696,7 @@ void InnerWidget::updateDialogRow(
|
||||||
if (base::in_range(position, 0, _pinnedRows.size())) {
|
if (base::in_range(position, 0, _pinnedRows.size())) {
|
||||||
top += qRound(_pinnedRows[position].yadd.current());
|
top += qRound(_pinnedRows[position].yadd.current());
|
||||||
}
|
}
|
||||||
updateRow(top + position * st::dialogsRowHeight);
|
updateRow(top + position * DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
|
|
@ -1664,7 +1706,7 @@ void InnerWidget::updateDialogRow(
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto result : _filterResults) {
|
for (const auto result : _filterResults) {
|
||||||
if (result->key() == row.key) {
|
if (result->key() == row.key) {
|
||||||
updateRow(add + index * st::dialogsRowHeight);
|
updateRow(add + index * DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
|
|
@ -1677,7 +1719,7 @@ void InnerWidget::updateDialogRow(
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto &result : _peerSearchResults) {
|
for (const auto &result : _peerSearchResults) {
|
||||||
if (result->peer == peer) {
|
if (result->peer == peer) {
|
||||||
updateRow(add + index * st::dialogsRowHeight);
|
updateRow(add + index * DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
|
|
@ -1690,7 +1732,7 @@ void InnerWidget::updateDialogRow(
|
||||||
auto index = 0;
|
auto index = 0;
|
||||||
for (const auto &result : _searchResults) {
|
for (const auto &result : _searchResults) {
|
||||||
if (isSearchResultActive(result.get(), row)) {
|
if (isSearchResultActive(result.get(), row)) {
|
||||||
updateRow(add + index * st::dialogsRowHeight);
|
updateRow(add + index * DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
|
|
@ -1715,9 +1757,9 @@ void InnerWidget::updateSelectedRow(Key key) {
|
||||||
if (base::in_range(position, 0, _pinnedRows.size())) {
|
if (base::in_range(position, 0, _pinnedRows.size())) {
|
||||||
top += qRound(_pinnedRows[position].yadd.current());
|
top += qRound(_pinnedRows[position].yadd.current());
|
||||||
}
|
}
|
||||||
update(0, top + position * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, top + position * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
} else if (_selected) {
|
} else if (_selected) {
|
||||||
update(0, dialogsOffset() + _selected->pos() * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, dialogsOffset() + _selected->pos() * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
} else if (_collapsedSelected >= 0) {
|
} else if (_collapsedSelected >= 0) {
|
||||||
update(0, _collapsedSelected * st::dialogsImportantBarHeight, width(), st::dialogsImportantBarHeight);
|
update(0, _collapsedSelected * st::dialogsImportantBarHeight, width(), st::dialogsImportantBarHeight);
|
||||||
}
|
}
|
||||||
|
|
@ -1725,18 +1767,18 @@ void InnerWidget::updateSelectedRow(Key key) {
|
||||||
if (key) {
|
if (key) {
|
||||||
for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) {
|
for (auto i = 0, l = int(_filterResults.size()); i != l; ++i) {
|
||||||
if (_filterResults[i]->key() == key) {
|
if (_filterResults[i]->key() == key) {
|
||||||
update(0, filteredOffset() + i * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, filteredOffset() + i * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_hashtagSelected >= 0) {
|
} else if (_hashtagSelected >= 0) {
|
||||||
update(0, _hashtagSelected * st::mentionHeight, width(), st::mentionHeight);
|
update(0, _hashtagSelected * st::mentionHeight, width(), st::mentionHeight);
|
||||||
} else if (_filteredSelected >= 0) {
|
} else if (_filteredSelected >= 0) {
|
||||||
update(0, filteredOffset() + _filteredSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, filteredOffset() + _filteredSelected * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
} else if (_peerSearchSelected >= 0) {
|
} else if (_peerSearchSelected >= 0) {
|
||||||
update(0, peerSearchOffset() + _peerSearchSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, peerSearchOffset() + _peerSearchSelected * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
} else if (_searchedSelected >= 0) {
|
} else if (_searchedSelected >= 0) {
|
||||||
update(0, searchedOffset() + _searchedSelected * st::dialogsRowHeight, width(), st::dialogsRowHeight);
|
update(0, searchedOffset() + _searchedSelected * DialogsRowHeight(), width(), DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2253,7 +2295,8 @@ bool InnerWidget::needCollapsedRowsRefresh() const {
|
||||||
const auto collapsedHasArchive = !_collapsedRows.empty()
|
const auto collapsedHasArchive = !_collapsedRows.empty()
|
||||||
&& (_collapsedRows.back()->folder != nullptr);
|
&& (_collapsedRows.back()->folder != nullptr);
|
||||||
const auto archiveIsCollapsed = (archive != nullptr)
|
const auto archiveIsCollapsed = (archive != nullptr)
|
||||||
&& session().settings().archiveCollapsed();
|
&& (session().settings().archiveCollapsed()
|
||||||
|
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1);
|
||||||
const auto archiveIsInMainMenu = (archive != nullptr)
|
const auto archiveIsInMainMenu = (archive != nullptr)
|
||||||
&& session().settings().archiveInMainMenu();
|
&& session().settings().archiveInMainMenu();
|
||||||
return archiveIsInMainMenu
|
return archiveIsInMainMenu
|
||||||
|
|
@ -2280,13 +2323,13 @@ void InnerWidget::refresh(bool toTop) {
|
||||||
if (list->empty()) {
|
if (list->empty()) {
|
||||||
h = st::dialogsEmptyHeight;
|
h = st::dialogsEmptyHeight;
|
||||||
} else {
|
} else {
|
||||||
h = dialogsOffset() + list->size() * st::dialogsRowHeight;
|
h = dialogsOffset() + list->size() * DialogsRowHeight();
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
if (_waitingForSearch) {
|
if (_waitingForSearch) {
|
||||||
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.empty() && !_searchInChat) ? -st::searchedBarHeight : 0);
|
h = searchedOffset() + (_searchResults.size() * DialogsRowHeight()) + ((_searchResults.empty() && !_searchInChat) ? -st::searchedBarHeight : 0);
|
||||||
} else {
|
} else {
|
||||||
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight);
|
h = searchedOffset() + (_searchResults.size() * DialogsRowHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resize(width(), h);
|
resize(width(), h);
|
||||||
|
|
@ -2517,7 +2560,7 @@ void InnerWidget::selectSkip(int32 direction) {
|
||||||
const auto fromY = (_collapsedSelected >= 0)
|
const auto fromY = (_collapsedSelected >= 0)
|
||||||
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
||||||
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight);
|
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight);
|
||||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
_mustScrollTo.fire({ fromY, fromY + DialogsRowHeight() });
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) {
|
if (_hashtagResults.empty() && _filterResults.empty() && _peerSearchResults.empty() && _searchResults.empty()) {
|
||||||
|
|
@ -2572,25 +2615,25 @@ void InnerWidget::selectSkip(int32 direction) {
|
||||||
});
|
});
|
||||||
} else if (base::in_range(_filteredSelected, 0, _filterResults.size())) {
|
} else if (base::in_range(_filteredSelected, 0, _filterResults.size())) {
|
||||||
_mustScrollTo.fire({
|
_mustScrollTo.fire({
|
||||||
filteredOffset() + _filteredSelected * st::dialogsRowHeight,
|
filteredOffset() + _filteredSelected * DialogsRowHeight(),
|
||||||
filteredOffset()
|
filteredOffset()
|
||||||
+ (_filteredSelected + 1) * st::dialogsRowHeight,
|
+ (_filteredSelected + 1) * DialogsRowHeight(),
|
||||||
});
|
});
|
||||||
} else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) {
|
} else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) {
|
||||||
_mustScrollTo.fire({
|
_mustScrollTo.fire({
|
||||||
peerSearchOffset()
|
peerSearchOffset()
|
||||||
+ _peerSearchSelected * st::dialogsRowHeight
|
+ _peerSearchSelected * DialogsRowHeight()
|
||||||
+ (_peerSearchSelected ? 0 : -st::searchedBarHeight),
|
+ (_peerSearchSelected ? 0 : -st::searchedBarHeight),
|
||||||
peerSearchOffset()
|
peerSearchOffset()
|
||||||
+ (_peerSearchSelected + 1) * st::dialogsRowHeight,
|
+ (_peerSearchSelected + 1) * DialogsRowHeight(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
_mustScrollTo.fire({
|
_mustScrollTo.fire({
|
||||||
searchedOffset()
|
searchedOffset()
|
||||||
+ _searchedSelected * st::dialogsRowHeight
|
+ _searchedSelected * DialogsRowHeight()
|
||||||
+ (_searchedSelected ? 0 : -st::searchedBarHeight),
|
+ (_searchedSelected ? 0 : -st::searchedBarHeight),
|
||||||
searchedOffset()
|
searchedOffset()
|
||||||
+ (_searchedSelected + 1) * st::dialogsRowHeight,
|
+ (_searchedSelected + 1) * DialogsRowHeight(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2601,33 +2644,33 @@ void InnerWidget::scrollToEntry(const RowDescriptor &entry) {
|
||||||
int32 fromY = -1;
|
int32 fromY = -1;
|
||||||
if (_state == WidgetState::Default) {
|
if (_state == WidgetState::Default) {
|
||||||
if (auto row = shownDialogs()->getRow(entry.key)) {
|
if (auto row = shownDialogs()->getRow(entry.key)) {
|
||||||
fromY = dialogsOffset() + row->pos() * st::dialogsRowHeight;
|
fromY = dialogsOffset() + row->pos() * DialogsRowHeight();
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
for (int32 i = 0, c = _searchResults.size(); i < c; ++i) {
|
for (int32 i = 0, c = _searchResults.size(); i < c; ++i) {
|
||||||
if (isSearchResultActive(_searchResults[i].get(), entry)) {
|
if (isSearchResultActive(_searchResults[i].get(), entry)) {
|
||||||
fromY = searchedOffset() + i * st::dialogsRowHeight;
|
fromY = searchedOffset() + i * DialogsRowHeight();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromY < 0) {
|
if (fromY < 0) {
|
||||||
for (auto i = 0, c = int(_filterResults.size()); i != c; ++i) {
|
for (auto i = 0, c = int(_filterResults.size()); i != c; ++i) {
|
||||||
if (_filterResults[i]->key() == entry.key) {
|
if (_filterResults[i]->key() == entry.key) {
|
||||||
fromY = filteredOffset() + (i * st::dialogsRowHeight);
|
fromY = filteredOffset() + (i * DialogsRowHeight());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromY >= 0) {
|
if (fromY >= 0) {
|
||||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
_mustScrollTo.fire({ fromY, fromY + DialogsRowHeight() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
|
void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
|
||||||
clearMouseSelection();
|
clearMouseSelection();
|
||||||
const auto list = shownDialogs();
|
const auto list = shownDialogs();
|
||||||
int toSkip = pixels / int(st::dialogsRowHeight);
|
int toSkip = pixels / int(DialogsRowHeight());
|
||||||
if (_state == WidgetState::Default) {
|
if (_state == WidgetState::Default) {
|
||||||
if (!_selected) {
|
if (!_selected) {
|
||||||
if (direction > 0 && list->size() > _skipTopDialogs) {
|
if (direction > 0 && list->size() > _skipTopDialogs) {
|
||||||
|
|
@ -2653,8 +2696,8 @@ void InnerWidget::selectSkipPage(int32 pixels, int32 direction) {
|
||||||
if (_collapsedSelected >= 0 || _selected) {
|
if (_collapsedSelected >= 0 || _selected) {
|
||||||
const auto fromY = (_collapsedSelected >= 0)
|
const auto fromY = (_collapsedSelected >= 0)
|
||||||
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
? (_collapsedSelected * st::dialogsImportantBarHeight)
|
||||||
: (dialogsOffset() + _selected->pos() * st::dialogsRowHeight);
|
: (dialogsOffset() + _selected->pos() * DialogsRowHeight());
|
||||||
_mustScrollTo.fire({ fromY, fromY + st::dialogsRowHeight });
|
_mustScrollTo.fire({ fromY, fromY + DialogsRowHeight() });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return selectSkip(direction * toSkip);
|
return selectSkip(direction * toSkip);
|
||||||
|
|
@ -2669,10 +2712,10 @@ void InnerWidget::loadPeerPhotos() {
|
||||||
auto yFrom = _visibleTop;
|
auto yFrom = _visibleTop;
|
||||||
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
|
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
|
||||||
if (_state == WidgetState::Default) {
|
if (_state == WidgetState::Default) {
|
||||||
auto otherStart = list->size() * st::dialogsRowHeight;
|
auto otherStart = list->size() * DialogsRowHeight();
|
||||||
if (yFrom < otherStart) {
|
if (yFrom < otherStart) {
|
||||||
for (auto i = list->cfind(yFrom, st::dialogsRowHeight), end = list->cend(); i != end; ++i) {
|
for (auto i = list->cfind(yFrom, DialogsRowHeight()), end = list->cend(); i != end; ++i) {
|
||||||
if (((*i)->pos() * st::dialogsRowHeight) >= yTo) {
|
if (((*i)->pos() * DialogsRowHeight()) >= yTo) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*i)->entry()->loadUserpic();
|
(*i)->entry()->loadUserpic();
|
||||||
|
|
@ -2683,10 +2726,10 @@ void InnerWidget::loadPeerPhotos() {
|
||||||
}
|
}
|
||||||
yTo -= otherStart;
|
yTo -= otherStart;
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
int32 from = (yFrom - filteredOffset()) / st::dialogsRowHeight;
|
int32 from = (yFrom - filteredOffset()) / DialogsRowHeight();
|
||||||
if (from < 0) from = 0;
|
if (from < 0) from = 0;
|
||||||
if (from < _filterResults.size()) {
|
if (from < _filterResults.size()) {
|
||||||
int32 to = (yTo / int32(st::dialogsRowHeight)) + 1;
|
int32 to = (yTo / int32(DialogsRowHeight())) + 1;
|
||||||
if (to > _filterResults.size()) to = _filterResults.size();
|
if (to > _filterResults.size()) to = _filterResults.size();
|
||||||
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
|
|
@ -2694,20 +2737,20 @@ void InnerWidget::loadPeerPhotos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
from = (yFrom > filteredOffset() + st::searchedBarHeight ? ((yFrom - filteredOffset() - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size();
|
from = (yFrom > filteredOffset() + st::searchedBarHeight ? ((yFrom - filteredOffset() - st::searchedBarHeight) / int32(DialogsRowHeight())) : 0) - _filterResults.size();
|
||||||
if (from < 0) from = 0;
|
if (from < 0) from = 0;
|
||||||
if (from < _peerSearchResults.size()) {
|
if (from < _peerSearchResults.size()) {
|
||||||
int32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() + 1;
|
int32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / int32(DialogsRowHeight())) : 0) - _filterResults.size() + 1;
|
||||||
if (to > _peerSearchResults.size()) to = _peerSearchResults.size();
|
if (to > _peerSearchResults.size()) to = _peerSearchResults.size();
|
||||||
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
_peerSearchResults[from]->peer->loadUserpic();
|
_peerSearchResults[from]->peer->loadUserpic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size();
|
from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(DialogsRowHeight())) : 0) - _filterResults.size() - _peerSearchResults.size();
|
||||||
if (from < 0) from = 0;
|
if (from < 0) from = 0;
|
||||||
if (from < _searchResults.size()) {
|
if (from < _searchResults.size()) {
|
||||||
int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1;
|
int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(DialogsRowHeight())) : 0) - _filterResults.size() - _peerSearchResults.size() + 1;
|
||||||
if (to > _searchResults.size()) to = _searchResults.size();
|
if (to > _searchResults.size()) to = _searchResults.size();
|
||||||
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
|
|
@ -3074,8 +3117,8 @@ void InnerWidget::updateDialogRowCornerStatus(not_null<History*> history) {
|
||||||
? st::dialogsOnlineBadgeSkip
|
? st::dialogsOnlineBadgeSkip
|
||||||
: st::dialogsCallBadgeSkip;
|
: st::dialogsCallBadgeSkip;
|
||||||
const auto updateRect = QRect(
|
const auto updateRect = QRect(
|
||||||
st::dialogsPhotoSize - skip.x() - size,
|
DialogsPhotoSize() - skip.x() - size,
|
||||||
st::dialogsPhotoSize - skip.y() - size,
|
DialogsPhotoSize() - skip.y() - size,
|
||||||
size,
|
size,
|
||||||
size
|
size
|
||||||
).marginsAdded(
|
).marginsAdded(
|
||||||
|
|
@ -3135,11 +3178,11 @@ void InnerWidget::updateRowCornerStatusShown(
|
||||||
[](not_null<Row*> row) { return row->history(); });
|
[](not_null<Row*> row) { return row->history(); });
|
||||||
const auto index = (i - begin(_filterResults));
|
const auto index = (i - begin(_filterResults));
|
||||||
const auto row = (i == end(_filterResults)) ? nullptr : i->get();
|
const auto row = (i == end(_filterResults)) ? nullptr : i->get();
|
||||||
return { row, filteredOffset() + index * st::dialogsRowHeight };
|
return { row, filteredOffset() + index * DialogsRowHeight() };
|
||||||
};
|
};
|
||||||
if (const auto &[row, top] = findRow(history); row != nullptr) {
|
if (const auto &[row, top] = findRow(history); row != nullptr) {
|
||||||
const auto visible = (top < _visibleBottom)
|
const auto visible = (top < _visibleBottom)
|
||||||
&& (top + st::dialogsRowHeight > _visibleTop);
|
&& (top + DialogsRowHeight() > _visibleTop);
|
||||||
row->updateCornerBadgeShown(
|
row->updateCornerBadgeShown(
|
||||||
history->peer,
|
history->peer,
|
||||||
visible ? Fn<void()>(crl::guard(this, repaint)) : nullptr);
|
visible ? Fn<void()>(crl::guard(this, repaint)) : nullptr);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/dialogs_row.h"
|
#include "dialogs/dialogs_row.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
@ -141,6 +142,28 @@ void BasicRow::paintUserpic(
|
||||||
paused);
|
paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasicRow::paintUserpic(
|
||||||
|
Painter &p,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
Ui::VideoUserpic *videoUserpic,
|
||||||
|
History *historyForCornerBadge,
|
||||||
|
crl::time now,
|
||||||
|
bool active,
|
||||||
|
int fullWidth,
|
||||||
|
int size,
|
||||||
|
bool paused) const {
|
||||||
|
PaintUserpic(
|
||||||
|
p,
|
||||||
|
peer,
|
||||||
|
videoUserpic,
|
||||||
|
_userpic,
|
||||||
|
st::dialogsPadding.x(),
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
fullWidth,
|
||||||
|
size,
|
||||||
|
paused);
|
||||||
|
}
|
||||||
|
|
||||||
Row::Row(Key key, int pos) : _id(key), _pos(pos) {
|
Row::Row(Key key, int pos) : _id(key), _pos(pos) {
|
||||||
if (const auto history = key.history()) {
|
if (const auto history = key.history()) {
|
||||||
updateCornerBadgeShown(history->peer);
|
updateCornerBadgeShown(history->peer);
|
||||||
|
|
@ -198,6 +221,9 @@ void Row::updateCornerBadgeShown(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> updateCallback) const {
|
Fn<void()> updateCallback) const {
|
||||||
const auto shown = [&] {
|
const auto shown = [&] {
|
||||||
|
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (const auto user = peer->asUser()) {
|
if (const auto user = peer->asUser()) {
|
||||||
return Data::IsUserOnline(user);
|
return Data::IsUserOnline(user);
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
|
|
@ -232,7 +258,9 @@ void Row::PaintCornerBadgeFrame(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
data->frame.width() / data->frame.devicePixelRatio(),
|
data->frame.width() / data->frame.devicePixelRatio(),
|
||||||
st::dialogsPhotoSize,
|
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsUnreadHeight
|
||||||
|
: st::dialogsPhotoSize),
|
||||||
paused);
|
paused);
|
||||||
|
|
||||||
PainterHighQualityEnabler hq(q);
|
PainterHighQualityEnabler hq(q);
|
||||||
|
|
@ -284,6 +312,9 @@ void Row::paintUserpic(
|
||||||
now,
|
now,
|
||||||
active,
|
active,
|
||||||
fullWidth,
|
fullWidth,
|
||||||
|
(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsUnreadHeight
|
||||||
|
: st::dialogsPhotoSize),
|
||||||
paused);
|
paused);
|
||||||
if (!historyForCornerBadge || !_cornerBadgeShown) {
|
if (!historyForCornerBadge || !_cornerBadgeShown) {
|
||||||
_cornerBadgeUserpic = nullptr;
|
_cornerBadgeUserpic = nullptr;
|
||||||
|
|
@ -292,9 +323,10 @@ void Row::paintUserpic(
|
||||||
}
|
}
|
||||||
ensureCornerBadgeUserpic();
|
ensureCornerBadgeUserpic();
|
||||||
if (_cornerBadgeUserpic->frame.isNull()) {
|
if (_cornerBadgeUserpic->frame.isNull()) {
|
||||||
_cornerBadgeUserpic->frame = QImage(
|
const auto frameSize = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
st::dialogsPhotoSize * cRetinaFactor(),
|
? st::dialogsUnreadHeight
|
||||||
st::dialogsPhotoSize * cRetinaFactor(),
|
: st::dialogsPhotoSize) * cRetinaFactor();
|
||||||
|
_cornerBadgeUserpic->frame = QImage(frameSize, frameSize,
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
_cornerBadgeUserpic->frame.setDevicePixelRatio(cRetinaFactor());
|
_cornerBadgeUserpic->frame.setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,17 @@ public:
|
||||||
int fullWidth,
|
int fullWidth,
|
||||||
bool paused) const;
|
bool paused) const;
|
||||||
|
|
||||||
|
virtual void paintUserpic(
|
||||||
|
Painter &p,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
Ui::VideoUserpic *videoUserpic,
|
||||||
|
History *historyForCornerBadge,
|
||||||
|
crl::time now,
|
||||||
|
bool active,
|
||||||
|
int fullWidth,
|
||||||
|
int size,
|
||||||
|
bool paused) const;
|
||||||
|
|
||||||
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
|
void addRipple(QPoint origin, QSize size, Fn<void()> updateCallback);
|
||||||
void stopLastRipple();
|
void stopLastRipple();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/dialogs_widget.h"
|
#include "dialogs/dialogs_widget.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "kotato/kotato_lang.h"
|
#include "kotato/kotato_lang.h"
|
||||||
#include "dialogs/dialogs_inner_widget.h"
|
#include "dialogs/dialogs_inner_widget.h"
|
||||||
#include "dialogs/dialogs_search_from_controllers.h"
|
#include "dialogs/dialogs_search_from_controllers.h"
|
||||||
|
|
@ -231,7 +232,9 @@ Widget::Widget(
|
||||||
const auto movedTo = data.ymax;
|
const auto movedTo = data.ymax;
|
||||||
const auto st = int32(_scroll->scrollTop());
|
const auto st = int32(_scroll->scrollTop());
|
||||||
if (st > movedTo && st < movedFrom) {
|
if (st > movedTo && st < movedFrom) {
|
||||||
_scroll->scrollToY(st + st::dialogsRowHeight);
|
_scroll->scrollToY(st + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsImportantBarHeight
|
||||||
|
: st::dialogsRowHeight));
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
_inner->searchMessages(
|
_inner->searchMessages(
|
||||||
|
|
@ -1670,7 +1673,7 @@ void Widget::updateControlsGeometry() {
|
||||||
_forwardCancel->moveToLeft(0, filterAreaTop);
|
_forwardCancel->moveToLeft(0, filterAreaTop);
|
||||||
filterAreaTop += st::dialogsForwardHeight;
|
filterAreaTop += st::dialogsForwardHeight;
|
||||||
}
|
}
|
||||||
auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x());
|
auto smallLayoutWidth = (st::dialogsPadding.x() + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) + st::dialogsPadding.x());
|
||||||
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
|
auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.;
|
||||||
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
|
auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x();
|
||||||
auto filterRight = (session().domain().local().hasLocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
|
auto filterRight = (session().domain().local().hasLocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "data/data_abstract_structure.h"
|
#include "data/data_abstract_structure.h"
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
|
@ -92,7 +93,8 @@ void PaintNarrowCounter(
|
||||||
bool selected,
|
bool selected,
|
||||||
bool active,
|
bool active,
|
||||||
bool unreadMuted,
|
bool unreadMuted,
|
||||||
bool mentionOrReactionMuted) {
|
bool mentionOrReactionMuted,
|
||||||
|
int lines = 2) {
|
||||||
auto skipBeforeMention = 0;
|
auto skipBeforeMention = 0;
|
||||||
if (displayUnreadCounter || displayUnreadMark) {
|
if (displayUnreadCounter || displayUnreadMark) {
|
||||||
const auto counter = (unreadCount > 0)
|
const auto counter = (unreadCount > 0)
|
||||||
|
|
@ -104,9 +106,11 @@ void PaintNarrowCounter(
|
||||||
: 3;
|
: 3;
|
||||||
const auto unreadRight = st::dialogsPadding.x()
|
const auto unreadRight = st::dialogsPadding.x()
|
||||||
+ st::dialogsPhotoSize;
|
+ st::dialogsPhotoSize;
|
||||||
const auto unreadTop = st::dialogsPadding.y()
|
const auto unreadTop = (lines == 1
|
||||||
+ st::dialogsPhotoSize
|
? st::dialogsPadding.y()
|
||||||
- st::dialogsUnreadHeight;
|
: st::dialogsPadding.y()
|
||||||
|
+ st::dialogsPhotoSize
|
||||||
|
- st::dialogsUnreadHeight);
|
||||||
|
|
||||||
UnreadBadgeStyle st;
|
UnreadBadgeStyle st;
|
||||||
st.active = active;
|
st.active = active;
|
||||||
|
|
@ -124,11 +128,15 @@ void PaintNarrowCounter(
|
||||||
if (displayMentionBadge || displayReactionBadge) {
|
if (displayMentionBadge || displayReactionBadge) {
|
||||||
const auto counter = QString();
|
const auto counter = QString();
|
||||||
const auto unreadRight = st::dialogsPadding.x()
|
const auto unreadRight = st::dialogsPadding.x()
|
||||||
+ st::dialogsPhotoSize
|
+ (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsUnreadHeight
|
||||||
|
: st::dialogsPhotoSize)
|
||||||
- skipBeforeMention;
|
- skipBeforeMention;
|
||||||
const auto unreadTop = st::dialogsPadding.y()
|
const auto unreadTop = (lines == 1
|
||||||
+ st::dialogsPhotoSize
|
? st::dialogsPadding.y()
|
||||||
- st::dialogsUnreadHeight;
|
: st::dialogsPadding.y()
|
||||||
|
+ st::dialogsPhotoSize
|
||||||
|
- st::dialogsUnreadHeight);
|
||||||
|
|
||||||
UnreadBadgeStyle st;
|
UnreadBadgeStyle st;
|
||||||
st.sizeId = displayMentionBadge
|
st.sizeId = displayMentionBadge
|
||||||
|
|
@ -302,6 +310,195 @@ enum class Flag {
|
||||||
};
|
};
|
||||||
inline constexpr bool is_flag_type(Flag) { return true; }
|
inline constexpr bool is_flag_type(Flag) { return true; }
|
||||||
|
|
||||||
|
template <typename PaintItemCallback, typename PaintCounterCallback>
|
||||||
|
void paintOneLineRow(
|
||||||
|
Painter &p,
|
||||||
|
not_null<const BasicRow*> row,
|
||||||
|
not_null<Entry*> entry,
|
||||||
|
Dialogs::Key chat,
|
||||||
|
VideoUserpic *videoUserpic,
|
||||||
|
FilterId filterId,
|
||||||
|
PeerData *from,
|
||||||
|
const Ui::Text::String &fromName,
|
||||||
|
const HiddenSenderInfo *hiddenSenderInfo,
|
||||||
|
HistoryItem *item,
|
||||||
|
const Data::Draft *draft,
|
||||||
|
QDateTime date,
|
||||||
|
int fullWidth,
|
||||||
|
base::flags<Flag> flags,
|
||||||
|
crl::time ms,
|
||||||
|
PaintItemCallback &&paintItemCallback,
|
||||||
|
PaintCounterCallback &&paintCounterCallback) {
|
||||||
|
const auto supportMode = entry->session().supportMode();
|
||||||
|
if (supportMode) {
|
||||||
|
draft = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto active = (flags & Flag::Active);
|
||||||
|
auto selected = (flags & Flag::Selected);
|
||||||
|
auto fullRect = QRect(0, 0, fullWidth, st::dialogsImportantBarHeight);
|
||||||
|
auto bg = active
|
||||||
|
? st::dialogsBgActive
|
||||||
|
: (selected
|
||||||
|
? st::dialogsBgOver
|
||||||
|
: st::dialogsBg);
|
||||||
|
auto ripple = active
|
||||||
|
? st::dialogsRippleBgActive
|
||||||
|
: st::dialogsRippleBg;
|
||||||
|
p.fillRect(fullRect, bg);
|
||||||
|
row->paintRipple(p, 0, 0, fullWidth, &ripple->c);
|
||||||
|
|
||||||
|
const auto history = chat.history();
|
||||||
|
|
||||||
|
if (flags & Flag::SavedMessages) {
|
||||||
|
Ui::EmptyUserpic::PaintSavedMessages(
|
||||||
|
p,
|
||||||
|
st::dialogsPadding.x(),
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
fullWidth,
|
||||||
|
st::dialogsUnreadHeight);
|
||||||
|
} else if (flags & Flag::RepliesMessages) {
|
||||||
|
Ui::EmptyUserpic::PaintRepliesMessages(
|
||||||
|
p,
|
||||||
|
st::dialogsPadding.x(),
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
fullWidth,
|
||||||
|
st::dialogsUnreadHeight);
|
||||||
|
} else if (from) {
|
||||||
|
row->paintUserpic(
|
||||||
|
p,
|
||||||
|
from,
|
||||||
|
videoUserpic,
|
||||||
|
(flags & Flag::AllowUserOnline) ? history : nullptr,
|
||||||
|
ms,
|
||||||
|
active,
|
||||||
|
fullWidth,
|
||||||
|
(flags & Flag::VideoPaused));
|
||||||
|
} else if (hiddenSenderInfo) {
|
||||||
|
hiddenSenderInfo->emptyUserpic.paint(
|
||||||
|
p,
|
||||||
|
st::dialogsPadding.x(),
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
fullWidth,
|
||||||
|
st::dialogsUnreadHeight);
|
||||||
|
} else {
|
||||||
|
entry->paintUserpicLeft(
|
||||||
|
p,
|
||||||
|
row->userpicView(),
|
||||||
|
st::dialogsPadding.x(),
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
fullWidth,
|
||||||
|
st::dialogsUnreadHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto nameleft = st::dialogsPadding.x() * 2 + st::dialogsUnreadHeight;
|
||||||
|
if (fullWidth <= nameleft) {
|
||||||
|
if (!draft && item && !item->isEmpty()) {
|
||||||
|
paintCounterCallback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
||||||
|
auto rectForName = QRect(
|
||||||
|
nameleft,
|
||||||
|
st::dialogsPadding.y(),
|
||||||
|
namewidth,
|
||||||
|
st::dialogsTextFont->height);
|
||||||
|
|
||||||
|
const auto promoted = (history && history->useTopPromotion())
|
||||||
|
&& !(flags & (Flag::SearchResult/* | Flag::FeedSearchResult*/)); // #feed
|
||||||
|
if (promoted) {
|
||||||
|
const auto text = tr::lng_proxy_sponsor(tr::now);
|
||||||
|
PaintRowTopRight(p, text, rectForName, active, selected);
|
||||||
|
} else if (from && !(flags & Flag::SearchResult/* | Flag::FeedSearchResult*/)) { // #feed
|
||||||
|
if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) {
|
||||||
|
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
|
||||||
|
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
|
||||||
|
}
|
||||||
|
//} else if (const auto feed = chat.feed()) { // #feed
|
||||||
|
// if (const auto feedTypeIcon = FeedTypeIcon(feed, active, selected)) {
|
||||||
|
// feedTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
|
||||||
|
// rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
if (!draft
|
||||||
|
&& !(supportMode
|
||||||
|
&& entry->session().supportHelper().isOccupiedBySomeone(history))
|
||||||
|
&& item
|
||||||
|
&& !item->isEmpty()) {
|
||||||
|
const auto nameWithoutCounterWidth = paintItemCallback(nameleft, (flags & Flag::SearchResult ? namewidth : rectForName.width()));
|
||||||
|
rectForName.setWidth(nameWithoutCounterWidth - st::dialogsPadding.x());
|
||||||
|
} else if (entry->isPinnedDialog(filterId) && (filterId || !entry->fixedOnTopIndex())) {
|
||||||
|
auto &icon = (active ? st::dialogsPinnedIconActive : (selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon));
|
||||||
|
icon.paint(p, fullWidth - st::dialogsPadding.x() - icon.width(), st::dialogsPadding.y(), fullWidth);
|
||||||
|
rectForName.setWidth(rectForName.width() - icon.width() - st::dialogsUnreadPadding);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
if (flags & (Flag::SavedMessages | Flag::RepliesMessages)) {
|
||||||
|
text = (flags & Flag::SavedMessages)
|
||||||
|
? tr::lng_saved_messages(tr::now)
|
||||||
|
: tr::lng_replies_messages(tr::now);
|
||||||
|
p.setPen(active
|
||||||
|
? st::dialogsNameFgActive
|
||||||
|
: selected
|
||||||
|
? st::dialogsNameFgOver
|
||||||
|
: st::dialogsNameFg);
|
||||||
|
} else if (from) {
|
||||||
|
if (!(flags & Flag::SearchResult)) {
|
||||||
|
const auto badgeStyle = PeerBadgeStyle{
|
||||||
|
(active
|
||||||
|
? &st::dialogsVerifiedIconActive
|
||||||
|
: selected
|
||||||
|
? &st::dialogsVerifiedIconOver
|
||||||
|
: &st::dialogsVerifiedIcon),
|
||||||
|
(active
|
||||||
|
? &st::dialogsPremiumIconActive
|
||||||
|
: selected
|
||||||
|
? &st::dialogsPremiumIconOver
|
||||||
|
: &st::dialogsPremiumIcon),
|
||||||
|
(active
|
||||||
|
? &st::dialogsScamFgActive
|
||||||
|
: selected
|
||||||
|
? &st::dialogsScamFgOver
|
||||||
|
: &st::dialogsScamFg) };
|
||||||
|
const auto badgeWidth = Ui::DrawPeerBadgeGetWidth(
|
||||||
|
from,
|
||||||
|
p,
|
||||||
|
rectForName,
|
||||||
|
fromName.maxWidth(),
|
||||||
|
fullWidth,
|
||||||
|
badgeStyle);
|
||||||
|
rectForName.setWidth(rectForName.width() - badgeWidth);
|
||||||
|
|
||||||
|
text = fromName.toString();
|
||||||
|
p.setPen(active
|
||||||
|
? st::dialogsNameFgActive
|
||||||
|
: selected
|
||||||
|
? st::dialogsNameFgOver
|
||||||
|
: st::dialogsNameFg);
|
||||||
|
p.setFont(st::dialogsTextFont);
|
||||||
|
}
|
||||||
|
} else if (hiddenSenderInfo) {
|
||||||
|
text = hiddenSenderInfo->nameText().toString();
|
||||||
|
} else {
|
||||||
|
text = entry->chatListName();
|
||||||
|
const auto nameFg = active
|
||||||
|
? st::dialogsNameFgActive
|
||||||
|
: (selected
|
||||||
|
? st::dialogsArchiveFgOver
|
||||||
|
: st::dialogsArchiveFg);
|
||||||
|
p.setPen(nameFg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(from && (flags & Flag::SearchResult))) {
|
||||||
|
auto textStr = Ui::Text::String{ st::dialogsTextStyle, text, Ui::NameTextOptions() };
|
||||||
|
textStr.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename PaintItemCallback, typename PaintCounterCallback>
|
template <typename PaintItemCallback, typename PaintCounterCallback>
|
||||||
void paintRow(
|
void paintRow(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
|
|
@ -855,6 +1052,11 @@ void RowPainter::paint(
|
||||||
const auto mentionOrReactionMuted = (entry->folder() != nullptr)
|
const auto mentionOrReactionMuted = (entry->folder() != nullptr)
|
||||||
|| (!displayMentionBadge && unreadMuted);
|
|| (!displayMentionBadge && unreadMuted);
|
||||||
const auto displayUnreadCounter = [&] {
|
const auto displayUnreadCounter = [&] {
|
||||||
|
if (fullWidth < st::columnMinimalWidthLeft
|
||||||
|
&& ::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (displayMentionBadge
|
if (displayMentionBadge
|
||||||
&& unreadCount == 1
|
&& unreadCount == 1
|
||||||
&& item
|
&& item
|
||||||
|
|
@ -888,9 +1090,12 @@ void RowPainter::paint(
|
||||||
| (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0))
|
| (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0))
|
||||||
| (paused ? Flag::VideoPaused : Flag(0));
|
| (paused ? Flag::VideoPaused : Flag(0));
|
||||||
const auto paintItemCallback = [&](int nameleft, int namewidth) {
|
const auto paintItemCallback = [&](int nameleft, int namewidth) {
|
||||||
const auto texttop = st::dialogsPadding.y()
|
const auto texttop = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
+ st::msgNameFont->height
|
? st::dialogsPadding.y()
|
||||||
+ st::dialogsSkip;
|
: st::dialogsPadding.y()
|
||||||
|
+ st::msgNameFont->height
|
||||||
|
+ st::dialogsSkip);
|
||||||
|
|
||||||
const auto availableWidth = PaintWideCounter(
|
const auto availableWidth = PaintWideCounter(
|
||||||
p,
|
p,
|
||||||
texttop,
|
texttop,
|
||||||
|
|
@ -906,37 +1111,42 @@ void RowPainter::paint(
|
||||||
selected,
|
selected,
|
||||||
unreadMuted,
|
unreadMuted,
|
||||||
mentionOrReactionMuted);
|
mentionOrReactionMuted);
|
||||||
const auto &color = active
|
if (flags & Flag::SearchResult
|
||||||
? st::dialogsTextFgServiceActive
|
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") > 1) {
|
||||||
: (selected
|
const auto &color = active
|
||||||
? st::dialogsTextFgServiceOver
|
? st::dialogsTextFgServiceActive
|
||||||
: st::dialogsTextFgService);
|
: (selected
|
||||||
const auto itemRect = QRect(
|
? st::dialogsTextFgServiceOver
|
||||||
nameleft,
|
: st::dialogsTextFgService);
|
||||||
texttop,
|
const auto itemRect = QRect(
|
||||||
availableWidth,
|
nameleft,
|
||||||
st::dialogsTextFont->height);
|
texttop,
|
||||||
const auto actionWasPainted = ShowSendActionInDialogs(history)
|
availableWidth,
|
||||||
? history->sendActionPainter()->paint(
|
st::dialogsTextFont->height);
|
||||||
p,
|
const auto actionWasPainted = ShowSendActionInDialogs(history)
|
||||||
itemRect.x(),
|
? history->sendActionPainter()->paint(
|
||||||
itemRect.y(),
|
p,
|
||||||
itemRect.width(),
|
itemRect.x(),
|
||||||
fullWidth,
|
itemRect.y(),
|
||||||
color,
|
itemRect.width(),
|
||||||
ms)
|
fullWidth,
|
||||||
: false;
|
color,
|
||||||
if (const auto folder = row->folder()) {
|
ms)
|
||||||
PaintListEntryText(p, itemRect, active, selected, row);
|
: false;
|
||||||
} else if (history && !actionWasPainted) {
|
if (const auto folder = row->folder()) {
|
||||||
history->lastItemDialogsView.paint(
|
PaintListEntryText(p, itemRect, active, selected, row);
|
||||||
p,
|
} else if (history && !actionWasPainted) {
|
||||||
item,
|
history->lastItemDialogsView.paint(
|
||||||
itemRect,
|
p,
|
||||||
active,
|
item,
|
||||||
selected,
|
itemRect,
|
||||||
{});
|
active,
|
||||||
|
selected,
|
||||||
|
{});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return availableWidth;
|
||||||
};
|
};
|
||||||
const auto paintCounterCallback = [&] {
|
const auto paintCounterCallback = [&] {
|
||||||
PaintNarrowCounter(
|
PaintNarrowCounter(
|
||||||
|
|
@ -949,26 +1159,48 @@ void RowPainter::paint(
|
||||||
selected,
|
selected,
|
||||||
active,
|
active,
|
||||||
unreadMuted,
|
unreadMuted,
|
||||||
mentionOrReactionMuted);
|
mentionOrReactionMuted,
|
||||||
|
::Kotato::JsonSettings::GetInt("chat_list_lines"));
|
||||||
};
|
};
|
||||||
paintRow(
|
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
|
||||||
p,
|
paintOneLineRow(
|
||||||
row,
|
p,
|
||||||
entry,
|
row,
|
||||||
row->key(),
|
entry,
|
||||||
videoUserpic,
|
row->key(),
|
||||||
filterId,
|
videoUserpic,
|
||||||
from,
|
filterId,
|
||||||
entry->chatListNameText(),
|
from,
|
||||||
nullptr,
|
entry->chatListNameText(),
|
||||||
item,
|
nullptr,
|
||||||
cloudDraft,
|
item,
|
||||||
displayDate,
|
cloudDraft,
|
||||||
fullWidth,
|
displayDate,
|
||||||
flags,
|
fullWidth,
|
||||||
ms,
|
flags,
|
||||||
paintItemCallback,
|
ms,
|
||||||
paintCounterCallback);
|
paintItemCallback,
|
||||||
|
paintCounterCallback);
|
||||||
|
} else {
|
||||||
|
paintRow(
|
||||||
|
p,
|
||||||
|
row,
|
||||||
|
entry,
|
||||||
|
row->key(),
|
||||||
|
videoUserpic,
|
||||||
|
filterId,
|
||||||
|
from,
|
||||||
|
entry->chatListNameText(),
|
||||||
|
nullptr,
|
||||||
|
item,
|
||||||
|
cloudDraft,
|
||||||
|
displayDate,
|
||||||
|
fullWidth,
|
||||||
|
flags,
|
||||||
|
ms,
|
||||||
|
paintItemCallback,
|
||||||
|
paintCounterCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RowPainter::paint(
|
void RowPainter::paint(
|
||||||
|
|
@ -1030,11 +1262,21 @@ void RowPainter::paint(
|
||||||
&& !displayMentionBadge
|
&& !displayMentionBadge
|
||||||
&& unreadMark;
|
&& unreadMark;
|
||||||
const auto displayPinnedIcon = false;
|
const auto displayPinnedIcon = false;
|
||||||
|
const auto showSavedMessages = history->peer->isSelf()
|
||||||
|
&& !row->searchInChat();
|
||||||
|
const auto showRepliesMessages = history->peer->isRepliesChat()
|
||||||
|
&& !row->searchInChat();
|
||||||
|
const auto flags = (active ? Flag::Active : Flag(0))
|
||||||
|
| (selected ? Flag::Selected : Flag(0))
|
||||||
|
| Flag::SearchResult
|
||||||
|
| (showSavedMessages ? Flag::SavedMessages : Flag(0))
|
||||||
|
| (showRepliesMessages ? Flag::RepliesMessages : Flag(0));
|
||||||
const auto paintItemCallback = [&](int nameleft, int namewidth) {
|
const auto paintItemCallback = [&](int nameleft, int namewidth) {
|
||||||
const auto texttop = st::dialogsPadding.y()
|
const auto texttop = (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
+ st::msgNameFont->height
|
? st::dialogsPadding.y()
|
||||||
+ st::dialogsSkip;
|
: st::dialogsPadding.y()
|
||||||
|
+ st::msgNameFont->height
|
||||||
|
+ st::dialogsSkip);
|
||||||
const auto availableWidth = PaintWideCounter(
|
const auto availableWidth = PaintWideCounter(
|
||||||
p,
|
p,
|
||||||
texttop,
|
texttop,
|
||||||
|
|
@ -1051,18 +1293,23 @@ void RowPainter::paint(
|
||||||
unreadMuted,
|
unreadMuted,
|
||||||
mentionOrReactionMuted);
|
mentionOrReactionMuted);
|
||||||
|
|
||||||
const auto itemRect = QRect(
|
if (flags & Flag::SearchResult
|
||||||
nameleft,
|
|| ::Kotato::JsonSettings::GetInt("chat_list_lines") > 1) {
|
||||||
texttop,
|
const auto itemRect = QRect(
|
||||||
availableWidth,
|
nameleft,
|
||||||
st::dialogsTextFont->height);
|
texttop,
|
||||||
row->itemView().paint(
|
availableWidth,
|
||||||
p,
|
st::dialogsTextFont->height);
|
||||||
item,
|
row->itemView().paint(
|
||||||
itemRect,
|
p,
|
||||||
active,
|
item,
|
||||||
selected,
|
itemRect,
|
||||||
previewOptions);
|
active,
|
||||||
|
selected,
|
||||||
|
previewOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
return availableWidth;
|
||||||
};
|
};
|
||||||
const auto paintCounterCallback = [&] {
|
const auto paintCounterCallback = [&] {
|
||||||
PaintNarrowCounter(
|
PaintNarrowCounter(
|
||||||
|
|
@ -1075,35 +1322,48 @@ void RowPainter::paint(
|
||||||
selected,
|
selected,
|
||||||
active,
|
active,
|
||||||
unreadMuted,
|
unreadMuted,
|
||||||
mentionOrReactionMuted);
|
mentionOrReactionMuted,
|
||||||
|
::Kotato::JsonSettings::GetInt("chat_list_lines"));
|
||||||
};
|
};
|
||||||
const auto showSavedMessages = history->peer->isSelf()
|
if (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1) {
|
||||||
&& !row->searchInChat();
|
paintOneLineRow(
|
||||||
const auto showRepliesMessages = history->peer->isRepliesChat()
|
p,
|
||||||
&& !row->searchInChat();
|
row,
|
||||||
const auto flags = (active ? Flag::Active : Flag(0))
|
history,
|
||||||
| (selected ? Flag::Selected : Flag(0))
|
history,
|
||||||
| Flag::SearchResult
|
nullptr,
|
||||||
| (showSavedMessages ? Flag::SavedMessages : Flag(0))
|
FilterId(),
|
||||||
| (showRepliesMessages ? Flag::RepliesMessages : Flag(0));
|
from,
|
||||||
paintRow(
|
row->name(),
|
||||||
p,
|
hiddenSenderInfo,
|
||||||
row,
|
item,
|
||||||
history,
|
cloudDraft,
|
||||||
history,
|
ItemDateTime(item),
|
||||||
nullptr,
|
fullWidth,
|
||||||
FilterId(),
|
flags,
|
||||||
from,
|
ms,
|
||||||
row->name(),
|
paintItemCallback,
|
||||||
hiddenSenderInfo,
|
paintCounterCallback);
|
||||||
item,
|
} else {
|
||||||
cloudDraft,
|
paintRow(
|
||||||
ItemDateTime(item),
|
p,
|
||||||
fullWidth,
|
row,
|
||||||
flags,
|
history,
|
||||||
ms,
|
history,
|
||||||
paintItemCallback,
|
nullptr,
|
||||||
paintCounterCallback);
|
FilterId(),
|
||||||
|
from,
|
||||||
|
row->name(),
|
||||||
|
hiddenSenderInfo,
|
||||||
|
item,
|
||||||
|
cloudDraft,
|
||||||
|
ItemDateTime(item),
|
||||||
|
fullWidth,
|
||||||
|
flags,
|
||||||
|
ms,
|
||||||
|
paintItemCallback,
|
||||||
|
paintCounterCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect RowPainter::sendActionAnimationRect(
|
QRect RowPainter::sendActionAnimationRect(
|
||||||
|
|
@ -1113,7 +1373,9 @@ QRect RowPainter::sendActionAnimationRect(
|
||||||
int fullWidth,
|
int fullWidth,
|
||||||
bool textUpdated) {
|
bool textUpdated) {
|
||||||
const auto nameleft = st::dialogsPadding.x()
|
const auto nameleft = st::dialogsPadding.x()
|
||||||
+ st::dialogsPhotoSize
|
+ (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1
|
||||||
|
? st::dialogsUnreadHeight
|
||||||
|
: st::dialogsPhotoSize)
|
||||||
+ st::dialogsPhotoPadding;
|
+ st::dialogsPhotoPadding;
|
||||||
const auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
const auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
|
||||||
const auto texttop = st::dialogsPadding.y()
|
const auto texttop = st::dialogsPadding.y()
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,10 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
||||||
{ "scales", {
|
{ "scales", {
|
||||||
.type = SettingType::QJsonArraySetting,
|
.type = SettingType::QJsonArraySetting,
|
||||||
.limitHandler = ScalesLimit(), }},
|
.limitHandler = ScalesLimit(), }},
|
||||||
|
{ "chat_list_lines", {
|
||||||
|
.type = SettingType::IntSetting,
|
||||||
|
.defaultValue = 2,
|
||||||
|
.limitHandler = IntLimit(1, 2, 2), }},
|
||||||
};
|
};
|
||||||
|
|
||||||
using OldOptionKey = QString;
|
using OldOptionKey = QString;
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,20 @@ void SetupKotatoChats(
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
AddSubsectionTitle(container, rktr("ktg_settings_chats"));
|
AddSubsectionTitle(container, rktr("ktg_settings_chats"));
|
||||||
|
|
||||||
|
AddButton(
|
||||||
|
container,
|
||||||
|
rktr("ktg_settings_chat_list_compact"),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->toggleOn(
|
||||||
|
rpl::single(::Kotato::JsonSettings::GetInt("chat_list_lines") == 1)
|
||||||
|
)->toggledValue(
|
||||||
|
) | rpl::filter([](bool enabled) {
|
||||||
|
return (enabled != (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1));
|
||||||
|
}) | rpl::start_with_next([](bool enabled) {
|
||||||
|
::Kotato::JsonSettings::Set("chat_list_lines", enabled ? 1 : 2);
|
||||||
|
::Kotato::JsonSettings::Write();
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
rktr("ktg_settings_always_show_scheduled"),
|
rktr("ktg_settings_always_show_scheduled"),
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "api/api_chat_participants.h"
|
#include "api/api_chat_participants.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
|
@ -911,14 +912,16 @@ void Filler::fillArchiveActions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto controller = _controller;
|
const auto controller = _controller;
|
||||||
const auto hidden = controller->session().settings().archiveCollapsed();
|
if (::Kotato::JsonSettings::GetInt("chat_list_lines") != 1) {
|
||||||
const auto text = hidden
|
const auto hidden = controller->session().settings().archiveCollapsed();
|
||||||
? tr::lng_context_archive_expand(tr::now)
|
const auto text = hidden
|
||||||
: tr::lng_context_archive_collapse(tr::now);
|
? tr::lng_context_archive_expand(tr::now)
|
||||||
_addAction(text, [=] {
|
: tr::lng_context_archive_collapse(tr::now);
|
||||||
controller->session().settings().setArchiveCollapsed(!hidden);
|
_addAction(text, [=] {
|
||||||
controller->session().saveSettingsDelayed();
|
controller->session().settings().setArchiveCollapsed(!hidden);
|
||||||
}, hidden ? &st::menuIconExpand : &st::menuIconCollapse);
|
controller->session().saveSettingsDelayed();
|
||||||
|
}, hidden ? &st::menuIconExpand : &st::menuIconCollapse);
|
||||||
|
}
|
||||||
|
|
||||||
_addAction(tr::lng_context_archive_to_menu(tr::now), [=] {
|
_addAction(tr::lng_context_archive_to_menu(tr::now), [=] {
|
||||||
Ui::Toast::Show(
|
Ui::Toast::Show(
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_settings.h"
|
||||||
#include "boxes/add_contact_box.h"
|
#include "boxes/add_contact_box.h"
|
||||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||||
#include "boxes/peers/edit_peer_info_box.h"
|
#include "boxes/peers/edit_peer_info_box.h"
|
||||||
|
|
@ -1035,7 +1036,7 @@ void SessionController::floatPlayerAreaUpdated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int SessionController::dialogsSmallColumnWidth() const {
|
int SessionController::dialogsSmallColumnWidth() const {
|
||||||
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
return st::dialogsPadding.x() + (::Kotato::JsonSettings::GetInt("chat_list_lines") == 1 ? st::dialogsUnreadHeight : st::dialogsPhotoSize) + st::dialogsPadding.x();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SessionController::minimalThreeColumnWidth() const {
|
int SessionController::minimalThreeColumnWidth() const {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue