/* 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/info_profile_inner_widget.h" #include #include "boxes/abstract_box.h" #include "mainwidget.h" #include "info/info_profile_widget.h" #include "info/info_profile_lines.h" #include "window/window_controller.h" #include "lang/lang_keys.h" #include "styles/style_info.h" #include "ui/widgets/buttons.h" #include "ui/widgets/checkbox.h" namespace Info { namespace Profile { InnerWidget::InnerWidget( QWidget *parent, not_null controller, not_null peer) : RpWidget(parent) , _controller(controller) , _peer(peer) , _content(this) { setupContent(); } void InnerWidget::setupContent() { auto hideDetails = (_peer->isChat() || _peer->isMegagroup()); auto cover = _content->add(object_ptr(this, _peer)); if (hideDetails) { auto hiddenDetailsContent = setupDetailsContent(_content); auto hiddenDetails = _content->add(object_ptr>( this, std::move(hiddenDetailsContent))); cover->setHasToggle(true); cover->toggled() | rpl::on_next([=](bool expanded) { hiddenDetails->toggleAnimated(expanded); }) | rpl::start(_lifetime); hiddenDetails->hideFast(); } else { _content->add(setupDetailsContent(_content)); } _content->add(object_ptr(this)); _content->heightValue() | rpl::on_next([this](int height) { TWidget::resizeToWidth(width()); }) | rpl::start(_lifetime); } object_ptr InnerWidget::setupDetailsContent( RpWidget *parent) const { auto result = object_ptr(parent); result->add(object_ptr(result)); auto skipPadding = QMargins(0, 0, 0, st::infoProfileSkip); result->add(object_ptr>(result, skipPadding)); result->add(setupInfoLines(result)); result->add(setupMuteToggle(result)); if (auto user = _peer->asUser()) { setupMainUserButtons(result, user); } result->add(object_ptr>(result, skipPadding)); return result; } object_ptr InnerWidget::setupMuteToggle( RpWidget *parent) const { auto result = object_ptr(parent); auto button = result->add(object_ptr