/* This file is part of Telegram Desktop, the official desktop version of Telegram messaging app, see https://telegram.org Telegram Desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #include "info/profile/info_profile_members.h" #include #include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_values.h" #include "info/profile/info_profile_icon.h" #include "info/profile/info_profile_values.h" #include "info/profile/info_profile_button.h" #include "info/profile/info_profile_members_controllers.h" #include "info/info_content_widget.h" #include "info/info_controller.h" #include "info/info_memento.h" #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/scroll_area.h" #include "ui/wrap/padding_wrap.h" #include "ui/search_field_controller.h" #include "styles/style_boxes.h" #include "styles/style_info.h" #include "lang/lang_keys.h" #include "boxes/confirm_box.h" #include "boxes/peer_list_controllers.h" #include "window/window_controller.h" namespace Info { namespace Profile { namespace { constexpr auto kEnableSearchMembersAfterCount = 20; } // namespace Members::Members( QWidget *parent, not_null controller, not_null peer) : RpWidget(parent) , _controller(controller) , _peer(peer) , _listController(CreateMembersController(controller->window(), _peer)) { setupHeader(); setupList(); setContent(_list.data()); _listController->setDelegate(static_cast(this)); _controller->searchFieldController()->queryValue() | rpl::start_with_next([this](QString &&query) { peerListScrollToTop(); content()->searchQueryChanged(std::move(query)); }, lifetime()); } int Members::desiredHeight() const { auto desired = _header ? _header->height() : 0; auto count = [this] { if (auto chat = _peer->asChat()) { return chat->count; } else if (auto channel = _peer->asChannel()) { return channel->membersCount(); } return 0; }(); desired += qMax(count, _list->fullRowsCount()) * st::infoMembersList.item.height; return qMax(height(), desired); } rpl::producer Members::onlineCountValue() const { return _listController->onlineCountValue(); } std::unique_ptr Members::saveState() { auto result = std::make_unique(); result->list = _listController->saveState(); //if (_searchShown) { // result->search = _searchField->getLastText(); //} return result; } void Members::restoreState(std::unique_ptr state) { if (!state) { return; } _listController->restoreState(std::move(state->list)); updateSearchEnabledByContent(); //if (!_controller->searchFieldController()->query().isEmpty()) { // if (!_searchShown) { // toggleSearch(anim::type::instant); // } //} else if (_searchShown) { // toggleSearch(anim::type::instant); //} } void Members::setupHeader() { if (_controller->section().type() == Section::Type::Members) { return; } _header = object_ptr( this, st::infoMembersHeader); auto parent = _header.data(); _openMembers = Ui::CreateChild