mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-01 03:50:43 +00:00
Adapt share voice chat link box styles.
This commit is contained in:
parent
16e1c740ce
commit
c587335ae1
@ -215,17 +215,23 @@ localStorageLimitMargin: margins(22px, 5px, 20px, 10px);
|
||||
shareRowsTop: 12px;
|
||||
shareRowHeight: 108px;
|
||||
sharePhotoTop: 6px;
|
||||
sharePhotoCheckbox: RoundImageCheckbox(defaultPeerListCheckbox) {
|
||||
imageRadius: 28px;
|
||||
imageSmallRadius: 24px;
|
||||
shareBoxListItem: PeerListItem(defaultPeerListItem) {
|
||||
nameStyle: TextStyle(defaultTextStyle) {
|
||||
font: font(11px);
|
||||
linkFont: font(11px);
|
||||
linkFontOver: font(11px);
|
||||
}
|
||||
nameFg: windowFg;
|
||||
nameFgChecked: windowActiveTextFg;
|
||||
checkbox: RoundImageCheckbox(defaultPeerListCheckbox) {
|
||||
imageRadius: 28px;
|
||||
imageSmallRadius: 24px;
|
||||
}
|
||||
}
|
||||
shareNameStyle: TextStyle(defaultTextStyle) {
|
||||
font: font(11px);
|
||||
linkFont: font(11px);
|
||||
linkFontOver: font(11px);
|
||||
shareBoxList: PeerList(defaultPeerList) {
|
||||
bg: boxBg;
|
||||
item: shareBoxListItem;
|
||||
}
|
||||
shareNameFg: windowFg;
|
||||
shareNameActiveFg: windowActiveTextFg;
|
||||
shareNameTop: 6px;
|
||||
shareColumnSkip: 6px;
|
||||
shareActivateDuration: 150;
|
||||
|
@ -44,10 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
class ShareBox::Inner final : public Ui::RpWidget, private base::Subscriber {
|
||||
public:
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
ShareBox::FilterCallback &&filterCallback);
|
||||
Inner(QWidget *parent, const Descriptor &descriptor);
|
||||
|
||||
void setPeerSelectedChangedCallback(
|
||||
Fn<void(PeerData *peer, bool selected)> callback);
|
||||
@ -84,7 +81,10 @@ protected:
|
||||
|
||||
private:
|
||||
struct Chat {
|
||||
Chat(PeerData *peer, Fn<void()> updateCallback);
|
||||
Chat(
|
||||
PeerData *peer,
|
||||
const style::PeerListItem &st,
|
||||
Fn<void()> updateCallback);
|
||||
|
||||
PeerData *peer;
|
||||
Ui::RoundImageCheckbox checkbox;
|
||||
@ -121,7 +121,8 @@ private:
|
||||
|
||||
void refresh();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const Descriptor &_descriptor;
|
||||
const style::PeerList &_st;
|
||||
|
||||
float64 _columnSkip = 0.;
|
||||
float64 _rowWidthReal = 0.;
|
||||
@ -133,7 +134,6 @@ private:
|
||||
int _active = -1;
|
||||
int _upon = -1;
|
||||
|
||||
ShareBox::FilterCallback _filterCallback;
|
||||
std::unique_ptr<Dialogs::IndexedList> _chatsIndexed;
|
||||
QString _filter;
|
||||
std::vector<not_null<Dialogs::Row*>> _filtered;
|
||||
@ -158,13 +158,17 @@ ShareBox::ShareBox(QWidget*, Descriptor &&descriptor)
|
||||
, _api(&_descriptor.session->mtp())
|
||||
, _select(
|
||||
this,
|
||||
st::defaultMultiSelect,
|
||||
(_descriptor.stMultiSelect
|
||||
? *_descriptor.stMultiSelect
|
||||
: st::defaultMultiSelect),
|
||||
tr::lng_participant_filter())
|
||||
, _comment(
|
||||
this,
|
||||
object_ptr<Ui::InputField>(
|
||||
this,
|
||||
st::shareComment,
|
||||
(_descriptor.stComment
|
||||
? *_descriptor.stComment
|
||||
: st::shareComment),
|
||||
Ui::InputField::Mode::MultiLine,
|
||||
tr::lng_photos_comment()),
|
||||
st::shareCommentPadding)
|
||||
@ -235,10 +239,7 @@ void ShareBox::prepare() {
|
||||
setTitle(tr::lng_share_title());
|
||||
|
||||
_inner = setInnerWidget(
|
||||
object_ptr<Inner>(
|
||||
this,
|
||||
_descriptor.session,
|
||||
std::move(_descriptor.filterCallback)),
|
||||
object_ptr<Inner>(this, _descriptor),
|
||||
getTopScrollSkip(),
|
||||
getBottomScrollSkip());
|
||||
|
||||
@ -541,13 +542,10 @@ void ShareBox::scrollAnimationCallback() {
|
||||
//scrollArea()->scrollToY(scrollTop);
|
||||
}
|
||||
|
||||
ShareBox::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
ShareBox::FilterCallback &&filterCallback)
|
||||
ShareBox::Inner::Inner(QWidget *parent, const Descriptor &descriptor)
|
||||
: RpWidget(parent)
|
||||
, _session(session)
|
||||
, _filterCallback(std::move(filterCallback))
|
||||
, _descriptor(descriptor)
|
||||
, _st(_descriptor.st ? *_descriptor.st : st::shareBoxList)
|
||||
, _chatsIndexed(
|
||||
std::make_unique<Dialogs::IndexedList>(
|
||||
Dialogs::SortMode::Add)) {
|
||||
@ -555,44 +553,44 @@ ShareBox::Inner::Inner(
|
||||
_rowHeight = st::shareRowHeight;
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
const auto self = session->user();
|
||||
if (_filterCallback(self)) {
|
||||
const auto self = _descriptor.session->user();
|
||||
if (_descriptor.filterCallback(self)) {
|
||||
_chatsIndexed->addToEnd(self->owner().history(self));
|
||||
}
|
||||
const auto addList = [&](not_null<Dialogs::IndexedList*> list) {
|
||||
for (const auto row : list->all()) {
|
||||
if (const auto history = row->history()) {
|
||||
if (!history->peer->isSelf()
|
||||
&& _filterCallback(history->peer)) {
|
||||
&& _descriptor.filterCallback(history->peer)) {
|
||||
_chatsIndexed->addToEnd(history);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
addList(_session->data().chatsList()->indexed());
|
||||
addList(_descriptor.session->data().chatsList()->indexed());
|
||||
const auto id = Data::Folder::kId;
|
||||
if (const auto folder = _session->data().folderLoaded(id)) {
|
||||
if (const auto folder = _descriptor.session->data().folderLoaded(id)) {
|
||||
addList(folder->chatsList()->indexed());
|
||||
}
|
||||
addList(_session->data().contactsNoChatsList());
|
||||
addList(_descriptor.session->data().contactsNoChatsList());
|
||||
|
||||
_filter = qsl("a");
|
||||
updateFilter();
|
||||
|
||||
_session->changes().peerUpdates(
|
||||
_descriptor.session->changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::Photo
|
||||
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||
updateChat(update.peer);
|
||||
}, lifetime());
|
||||
|
||||
_session->changes().realtimeNameUpdates(
|
||||
_descriptor.session->changes().realtimeNameUpdates(
|
||||
) | rpl::start_with_next([=](const Data::NameUpdate &update) {
|
||||
_chatsIndexed->peerNameChanged(
|
||||
update.peer,
|
||||
update.oldFirstLetters);
|
||||
}, lifetime());
|
||||
|
||||
_session->downloaderTaskFinished(
|
||||
_descriptor.session->downloaderTaskFinished(
|
||||
) | rpl::start_with_next([=] {
|
||||
update();
|
||||
}, lifetime());
|
||||
@ -661,7 +659,7 @@ void ShareBox::Inner::updateChatName(
|
||||
: peer->isRepliesChat()
|
||||
? tr::lng_replies_messages(tr::now)
|
||||
: peer->name;
|
||||
chat->name.setText(st::shareNameStyle, text, Ui::NameTextOptions());
|
||||
chat->name.setText(_st.item.nameStyle, text, Ui::NameTextOptions());
|
||||
}
|
||||
|
||||
void ShareBox::Inner::repaintChatAtIndex(int index) {
|
||||
@ -784,7 +782,7 @@ auto ShareBox::Inner::getChat(not_null<Dialogs::Row*> row)
|
||||
}
|
||||
const auto [i, ok] = _dataMap.emplace(
|
||||
peer,
|
||||
std::make_unique<Chat>(peer, [=] { repaintChat(peer); }));
|
||||
std::make_unique<Chat>(peer, _st.item, [=] { repaintChat(peer); }));
|
||||
updateChatName(i->second.get(), peer);
|
||||
row->attached = i->second.get();
|
||||
return i->second.get();
|
||||
@ -815,23 +813,26 @@ void ShareBox::Inner::paintChat(
|
||||
auto y = _rowsTop + (index / _columnCount) * _rowHeight;
|
||||
|
||||
auto outerWidth = width();
|
||||
auto photoLeft = (_rowWidth - (st::sharePhotoCheckbox.imageRadius * 2)) / 2;
|
||||
auto photoLeft = (_rowWidth - (_st.item.checkbox.imageRadius * 2)) / 2;
|
||||
auto photoTop = st::sharePhotoTop;
|
||||
chat->checkbox.paint(p, x + photoLeft, y + photoTop, outerWidth);
|
||||
|
||||
auto nameActive = chat->nameActive.value((index == _active) ? 1. : 0.);
|
||||
p.setPen(anim::pen(st::shareNameFg, st::shareNameActiveFg, nameActive));
|
||||
p.setPen(anim::pen(_st.item.nameFg, _st.item.nameFgChecked, nameActive));
|
||||
|
||||
auto nameWidth = (_rowWidth - st::shareColumnSkip);
|
||||
auto nameLeft = st::shareColumnSkip / 2;
|
||||
auto nameTop = photoTop + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop;
|
||||
auto nameTop = photoTop + _st.item.checkbox.imageRadius * 2 + st::shareNameTop;
|
||||
chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true);
|
||||
}
|
||||
|
||||
ShareBox::Inner::Chat::Chat(PeerData *peer, Fn<void()> updateCallback)
|
||||
ShareBox::Inner::Chat::Chat(
|
||||
PeerData *peer,
|
||||
const style::PeerListItem &st,
|
||||
Fn<void()> updateCallback)
|
||||
: peer(peer)
|
||||
, checkbox(st::sharePhotoCheckbox, updateCallback, PaintUserpicCallback(peer, true))
|
||||
, name(st::sharePhotoCheckbox.imageRadius * 2) {
|
||||
, checkbox(st.checkbox, updateCallback, PaintUserpicCallback(peer, true))
|
||||
, name(st.checkbox.imageRadius * 2) {
|
||||
}
|
||||
|
||||
void ShareBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
@ -839,7 +840,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
|
||||
auto r = e->rect();
|
||||
p.setClipRect(r);
|
||||
p.fillRect(r, st::boxBg);
|
||||
p.fillRect(r, _st.bg);
|
||||
auto yFrom = r.y(), yTo = r.y() + r.height();
|
||||
auto rowFrom = yFrom / _rowHeight;
|
||||
auto rowTo = (yTo + _rowHeight - 1) / _rowHeight;
|
||||
@ -857,7 +858,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
} else {
|
||||
p.setFont(st::noContactsFont);
|
||||
p.setPen(st::noContactsColor);
|
||||
p.setPen(_st.about.textFg);
|
||||
p.drawText(
|
||||
rect().marginsRemoved(st::boxPadding),
|
||||
tr::lng_bot_no_chats(tr::now),
|
||||
@ -868,7 +869,7 @@ void ShareBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
&& _byUsernameFiltered.empty()
|
||||
&& !_searching) {
|
||||
p.setFont(st::noContactsFont);
|
||||
p.setPen(st::noContactsColor);
|
||||
p.setPen(_st.about.textFg);
|
||||
p.drawText(
|
||||
rect().marginsRemoved(st::boxPadding),
|
||||
tr::lng_bot_chats_not_found(tr::now),
|
||||
@ -924,7 +925,7 @@ void ShareBox::Inner::updateUpon(const QPoint &pos) {
|
||||
auto left = _rowsLeft + qFloor(column * _rowWidthReal) + st::shareColumnSkip / 2;
|
||||
auto top = _rowsTop + row * _rowHeight + st::sharePhotoTop;
|
||||
auto xupon = (x >= left) && (x < left + (_rowWidth - st::shareColumnSkip));
|
||||
auto yupon = (y >= top) && (y < top + st::sharePhotoCheckbox.imageRadius * 2 + st::shareNameTop + st::shareNameStyle.font->height * 2);
|
||||
auto yupon = (y >= top) && (y < top + _st.item.checkbox.imageRadius * 2 + st::shareNameTop + _st.item.nameStyle.font->height * 2);
|
||||
auto upon = (xupon && yupon) ? (row * _columnCount + column) : -1;
|
||||
if (upon >= displayedChatsCount()) {
|
||||
upon = -1;
|
||||
@ -944,8 +945,8 @@ void ShareBox::Inner::selectActive() {
|
||||
}
|
||||
|
||||
void ShareBox::Inner::resizeEvent(QResizeEvent *e) {
|
||||
_columnSkip = (width() - _columnCount * st::sharePhotoCheckbox.imageRadius * 2) / float64(_columnCount + 1);
|
||||
_rowWidthReal = st::sharePhotoCheckbox.imageRadius * 2 + _columnSkip;
|
||||
_columnSkip = (width() - _columnCount * _st.item.checkbox.imageRadius * 2) / float64(_columnCount + 1);
|
||||
_rowWidthReal = _st.item.checkbox.imageRadius * 2 + _columnSkip;
|
||||
_rowsLeft = qFloor(_columnSkip / 2);
|
||||
_rowWidth = qFloor(_rowWidthReal);
|
||||
update();
|
||||
@ -1051,9 +1052,10 @@ void ShareBox::Inner::peopleReceived(
|
||||
d_byUsernameFiltered.reserve(already + my.size() + people.size());
|
||||
const auto feedList = [&](const QVector<MTPPeer> &list) {
|
||||
for (const auto &data : list) {
|
||||
if (const auto peer = _session->data().peerLoaded(peerFromMTP(data))) {
|
||||
const auto history = _session->data().historyLoaded(peer);
|
||||
if (!_filterCallback(peer)) {
|
||||
if (const auto peer = _descriptor.session->data().peerLoaded(
|
||||
peerFromMTP(data))) {
|
||||
const auto history = _descriptor.session->data().historyLoaded(peer);
|
||||
if (!_descriptor.filterCallback(peer)) {
|
||||
continue;
|
||||
} else if (history && _chatsIndexed->getRow(history)) {
|
||||
continue;
|
||||
@ -1063,6 +1065,7 @@ void ShareBox::Inner::peopleReceived(
|
||||
_byUsernameFiltered.push_back(peer);
|
||||
d_byUsernameFiltered.push_back(std::make_unique<Chat>(
|
||||
peer,
|
||||
_st.item,
|
||||
[=] { repaintChat(peer); }));
|
||||
updateChatName(d_byUsernameFiltered.back().get(), peer);
|
||||
}
|
||||
|
@ -14,6 +14,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/round_checkbox.h"
|
||||
#include "mtproto/sender.h"
|
||||
|
||||
namespace style {
|
||||
struct MultiSelect;
|
||||
struct InputField;
|
||||
struct PeerList;
|
||||
} // namespace style
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
@ -69,6 +75,9 @@ public:
|
||||
Fn<void(not_null<Ui::InputField*>)> initSpellchecker;
|
||||
Fn<void(not_null<Ui::InputField*>)> initEditLink;
|
||||
object_ptr<Ui::RpWidget> bottomWidget = { nullptr };
|
||||
const style::MultiSelect *stMultiSelect = nullptr;
|
||||
const style::InputField *stComment = nullptr;
|
||||
const style::PeerList *st = nullptr;
|
||||
};
|
||||
ShareBox(QWidget*, Descriptor &&descriptor);
|
||||
|
||||
|
@ -557,7 +557,6 @@ groupCallMultiSelect: MultiSelect(defaultMultiSelect) {
|
||||
ripple: groupCallRipple;
|
||||
}
|
||||
}
|
||||
|
||||
groupCallField: InputField(defaultInputField) {
|
||||
textMargins: margins(2px, 7px, 2px, 0px);
|
||||
|
||||
@ -578,6 +577,22 @@ groupCallField: InputField(defaultInputField) {
|
||||
|
||||
menu: groupCallPopupMenu;
|
||||
}
|
||||
groupCallShareBoxComment: InputField(groupCallField) {
|
||||
textMargins: margins(8px, 8px, 8px, 6px);
|
||||
heightMin: 36px;
|
||||
heightMax: 72px;
|
||||
placeholderMargins: margins(2px, 0px, 2px, 0px);
|
||||
border: 0px;
|
||||
borderActive: 0px;
|
||||
}
|
||||
groupCallShareBoxList: PeerList(groupCallMembersList) {
|
||||
item: PeerListItem(groupCallMembersListItem) {
|
||||
checkbox: RoundImageCheckbox(groupCallMembersListCheckbox) {
|
||||
imageRadius: 28px;
|
||||
imageSmallRadius: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
groupCallMembersTop: 51px;
|
||||
groupCallTitleTop: 8px;
|
||||
@ -913,6 +928,8 @@ groupCallStatusSpeakerArcsAnimation: ArcsAnimation(groupCallSpeakerArcsAnimation
|
||||
startHeight: 1px;
|
||||
}
|
||||
|
||||
groupCallShareMutedMargin: margins(16px, 16px, 16px, 8px);
|
||||
|
||||
callTopBarMuteCrossLine: CrossLineAnimation {
|
||||
fg: callBarFg;
|
||||
icon: icon {{ "calls/call_record_active", callBarFg }};
|
||||
|
@ -105,8 +105,9 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||
object_ptr<Ui::Checkbox>(
|
||||
nullptr,
|
||||
tr::lng_group_call_share_listener(tr::now),
|
||||
true),
|
||||
style::margins(16, 16, 16, 16));// #TODO calls style
|
||||
true,
|
||||
st::groupCallCheckbox),
|
||||
st::groupCallShareMutedMargin);
|
||||
const auto listenerCheckbox = bottom->entity();
|
||||
const auto currentLink = [=] {
|
||||
return listenerCheckbox->checked() ? linkListener : linkSpeaker;
|
||||
@ -186,7 +187,10 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||
.copyCallback = std::move(copyCallback),
|
||||
.submitCallback = std::move(submitCallback),
|
||||
.filterCallback = std::move(filterCallback),
|
||||
.bottomWidget = std::move(bottom) });
|
||||
.bottomWidget = std::move(bottom),
|
||||
.stMultiSelect = &st::groupCallMultiSelect,
|
||||
.stComment = &st::groupCallShareBoxComment,
|
||||
.stItem = &st::groupCallShareBoxList });
|
||||
*box = result.data();
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user