diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 74d6278af..6e3a27a87 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -1579,7 +1579,7 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) { } } -void HistoryInner::recountHeight() { +void HistoryInner::recountHistoryGeometry() { int visibleHeight = _scroll->height(); int oldHistoryPaddingTop = qMax(visibleHeight - historyHeight() - st::historyPaddingBottom, 0); if (_botAbout && !_botAbout->info->text.isEmpty()) { diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index 0836f4513..b2bb2069b 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -47,7 +47,7 @@ public: void touchScrollUpdated(const QPoint &screenPos); QPoint mapPointToItem(QPoint p, HistoryItem *item); - void recountHeight(); + void recountHistoryGeometry(); void updateSize(); void repaintItem(const HistoryItem *item); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index c0d93e99a..0c12be8a9 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4785,7 +4785,7 @@ int HistoryWidget::countAutomaticScrollTop() { void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const ScrollChange &change) { if (!_history || (initial && _historyInited) || (!initial && !_historyInited)) return; if (_firstLoadRequest || _a_show.animating()) { - return; // scrollTopMax etc are not working after recountHeight() + return; // scrollTopMax etc are not working after recountHistoryGeometry() } auto newScrollHeight = height() - _topBar->height(); @@ -4868,7 +4868,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S } void HistoryWidget::updateListSize() { - _list->recountHeight(); + _list->recountHistoryGeometry(); auto washidden = _scroll->isHidden(); if (washidden) { _scroll->show(); diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 482f7e911..2dc5a4062 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -173,9 +173,15 @@ infoIconMembers: icon {{ "info_members", infoIconFg }}; infoIconNotifications: icon {{ "info_notifications", infoIconFg }}; infoIconActions: icon {{ "info_actions", infoIconFg }}; infoIconMediaPhoto: icon {{ "info_media_photo", infoIconFg }}; +infoIconMediaAudio: icon {{ "info_media_audio", infoIconFg }}; +infoIconMediaLink: icon {{ "info_media_link", infoIconFg }}; +infoIconMediaGroup: icon {{ "info_common_groups", infoIconFg }}; +infoIconMediaVoice: icon {{ "info_media_voice", infoIconFg }}; +infoIconMediaRound: icon {{ "info_media_round", infoIconFg }}; infoInformationIconPosition: point(25px, 12px); infoNotificationsIconPosition: point(20px, 5px); infoSharedMediaIconPosition: point(20px, 24px); +infoSharedMediaButtonIconPosition: point(20px, 3px); infoIconPosition: point(20px, 15px); infoLabeledOneLine: FlatLabel(defaultFlatLabel) { diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp index 131bc6b1a..38b4abbba 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.cpp +++ b/Telegram/SourceFiles/info/info_layer_widget.cpp @@ -57,6 +57,7 @@ LayerWidget::LayerWidget( void LayerWidget::setupHeightConsumers() { _content->desiredHeightValue() | rpl::start_with_next([this](int height) { + if (!_content) return; accumulate_max(_desiredHeight, height); resizeToWidth(width()); _content->forceContentRepaint(); diff --git a/Telegram/SourceFiles/info/media/info_media_buttons.h b/Telegram/SourceFiles/info/media/info_media_buttons.h new file mode 100644 index 000000000..b03488512 --- /dev/null +++ b/Telegram/SourceFiles/info/media/info_media_buttons.h @@ -0,0 +1,129 @@ +/* +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 +*/ +#pragma once + +#include +#include +#include "lang/lang_keys.h" +#include "storage/storage_shared_media.h" +#include "info/info_memento.h" +#include "info/profile/info_profile_button.h" +#include "info/profile/info_profile_values.h" +#include "ui/wrap/slide_wrap.h" +#include "ui/wrap/vertical_layout.h" +#include "window/window_controller.h" +#include "styles/style_info.h" + +namespace Info { +namespace Media { + +using Type = Storage::SharedMediaType; + +inline auto MediaTextPhrase(Type type) { + switch (type) { + case Type::Photo: return lng_profile_photos; + case Type::Video: return lng_profile_videos; + case Type::File: return lng_profile_files; + case Type::MusicFile: return lng_profile_songs; + case Type::Link: return lng_profile_shared_links; + case Type::VoiceFile: return lng_profile_audios; + case Type::RoundFile: return lng_profile_rounds; + } + Unexpected("Type in setupSharedMedia()"); +}; + +inline auto MediaText(Type type) { + return [phrase = MediaTextPhrase(type)](int count) { + return phrase(lt_count, count); + }; +} + +template +inline auto AddCountedButton( + Ui::VerticalLayout *parent, + Count &&count, + Text &&textFromCount, + Ui::MultiSlideTracker &tracker) { + using namespace rpl::mappers; + + using Button = Profile::Button; + auto forked = std::move(count) + | start_spawning(parent->lifetime()); + auto text = rpl::duplicate(forked) + | rpl::map([textFromCount](int count) { + return (count > 0) + ? textFromCount(count) + : QString(); + }); + auto button = parent->add(object_ptr>( + parent, + object_ptr