void InnerWidget::createBlocks() { auto user = _peer->asUser(); auto chat = _peer->asChat(); auto channel = _peer->asChannel(); auto megagroup = _peer->isMegagroup() ? channel : nullptr; if (user || channel || megagroup) { _blocks.push_back({ new InfoWidget(this, _peer), BlockSide::Right }); } _blocks.push_back({ new SettingsWidget(this, _peer), BlockSide::Right }); if (chat || channel || megagroup) { _blocks.push_back({ new InviteLinkWidget(this, _peer), BlockSide::Right }); } _blocks.push_back({ new SharedMediaWidget(this, _peer), BlockSide::Right }); if (channel && !megagroup) { _blocks.push_back({ new ChannelMembersWidget(this, _peer), BlockSide::Right }); } _blocks.push_back({ new ActionsWidget(this, _peer), BlockSide::Right }); if (chat || megagroup) { auto membersWidget = new MembersWidget(this, _peer); connect(membersWidget, SIGNAL(onlineCountUpdated(int)), _cover, SLOT(onOnlineCountUpdated(int))); _cover->onOnlineCountUpdated(membersWidget->onlineCount()); _blocks.push_back({ membersWidget, BlockSide::Left }); } for_const (auto &blockData, _blocks) { connect(blockData.block, SIGNAL(heightUpdated()), this, SLOT(onBlockHeightUpdated())); }
void InnerDropdown::setOwnedWidget(TWidget *widget) { connect(widget, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated())); auto container = _scroll->setOwnedWidget(object_ptr<Container>(_scroll, widget, _st)); container->resizeToWidth(_scroll->width()); container->moveToLeft(0, 0); container->show(); widget->show(); }
void InnerDropdown::setOwnedWidget(ScrolledWidget *widget) { auto container = new internal::Container(_scroll, widget, _st); connect(container, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated())); _scroll->setOwnedWidget(container); container->resizeToWidth(_scroll->width()); container->moveToLeft(0, 0); container->show(); widget->show(); }
QPointer<TWidget> InnerDropdown::doSetOwnedWidget(object_ptr<TWidget> widget) { auto result = QPointer<TWidget>(widget); connect(widget, SIGNAL(heightUpdated()), this, SLOT(onWidgetHeightUpdated())); auto container = _scroll->setOwnedWidget(object_ptr<Container>(_scroll, std::move(widget), _st)); container->resizeToWidth(_scroll->width()); container->moveToLeft(0, 0); container->show(); result->show(); return result; }
void Container::onHeightUpdate() { int newHeight = _st.scrollPadding.top() + _st.scrollPadding.bottom(); if (auto child = static_cast<ScrolledWidget*>(children().front())) { newHeight += child->height(); } if (newHeight != height()) { resize(width(), newHeight); emit heightUpdated(); } }
Widget::Widget() : LayerWidget() , _scroll(this, st::setScroll) , _inner(this) , _fixedBar(this) , _fixedBarShadow1(this, st::settingsFixedBarShadowBg1) , _fixedBarShadow2(this, st::settingsFixedBarShadowBg2) { _scroll->setOwnedWidget(_inner); setAttribute(Qt::WA_OpaquePaintEvent); _fixedBar->move(0, 0); _fixedBarShadow1->move(0, _fixedBar->y() + st::settingsFixedBarHeight); _fixedBarShadow2->move(0, _fixedBarShadow1->y() + st::lineWidth); _scroll->move(0, st::settingsFixedBarHeight); connect(_inner, SIGNAL(heightUpdated()), this, SLOT(onInnerHeightUpdated())); }
Container::Container(QWidget *parent, ScrolledWidget *child, const style::InnerDropdown &st) : ScrolledWidget(parent), _st(st) { child->setParent(this); child->moveToLeft(_st.scrollPadding.left(), _st.scrollPadding.top()); connect(child, SIGNAL(heightUpdated()), this, SLOT(onHeightUpdate())); }