mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show nice short info box from viewers dropdown.
This commit is contained in:
parent
a2bf0fc511
commit
e41fc69513
11 changed files with 103 additions and 32 deletions
|
@ -24,6 +24,11 @@ UserpicButton {
|
||||||
uploadIcon: icon;
|
uploadIcon: icon;
|
||||||
uploadIconPosition: point;
|
uploadIconPosition: point;
|
||||||
}
|
}
|
||||||
|
ShortInfoBox {
|
||||||
|
label: FlatLabel;
|
||||||
|
labeled: FlatLabel;
|
||||||
|
labeledOneLine: FlatLabel;
|
||||||
|
}
|
||||||
|
|
||||||
countryRowHeight: 36px;
|
countryRowHeight: 36px;
|
||||||
countryRowNameFont: semiboldFont;
|
countryRowNameFont: semiboldFont;
|
||||||
|
@ -961,3 +966,26 @@ ringtonesBoxSkip: 7px;
|
||||||
gradientButtonGlareDuration: 700;
|
gradientButtonGlareDuration: 700;
|
||||||
gradientButtonGlareTimeout: 2000;
|
gradientButtonGlareTimeout: 2000;
|
||||||
gradientButtonGlareWidth: 100px;
|
gradientButtonGlareWidth: 100px;
|
||||||
|
|
||||||
|
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
||||||
|
maxHeight: 20px;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
lineHeight: 19px;
|
||||||
|
}
|
||||||
|
margin: margins(5px, 5px, 5px, 5px);
|
||||||
|
}
|
||||||
|
infoLabelSkip: 2px;
|
||||||
|
infoLabeled: FlatLabel(infoLabeledOneLine) {
|
||||||
|
minWidth: 180px;
|
||||||
|
maxHeight: 0px;
|
||||||
|
margin: margins(5px, 5px, 5px, 5px);
|
||||||
|
}
|
||||||
|
infoLabel: FlatLabel(infoLabeled) {
|
||||||
|
textFg: windowSubTextFg;
|
||||||
|
}
|
||||||
|
|
||||||
|
shortInfoBox: ShortInfoBox {
|
||||||
|
label: infoLabel;
|
||||||
|
labeled: infoLabeled;
|
||||||
|
labeledOneLine: infoLabeledOneLine;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/streaming/media_streaming_player.h"
|
#include "media/streaming/media_streaming_player.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
|
||||||
|
@ -614,8 +615,10 @@ PeerShortInfoBox::PeerShortInfoBox(
|
||||||
rpl::producer<PeerShortInfoFields> fields,
|
rpl::producer<PeerShortInfoFields> fields,
|
||||||
rpl::producer<QString> status,
|
rpl::producer<QString> status,
|
||||||
rpl::producer<PeerShortInfoUserpic> userpic,
|
rpl::producer<PeerShortInfoUserpic> userpic,
|
||||||
Fn<bool()> videoPaused)
|
Fn<bool()> videoPaused,
|
||||||
: _type(type)
|
const style::ShortInfoBox *stOverride)
|
||||||
|
: _st(stOverride ? *stOverride : st::shortInfoBox)
|
||||||
|
, _type(type)
|
||||||
, _fields(std::move(fields))
|
, _fields(std::move(fields))
|
||||||
, _topRoundBackground(this)
|
, _topRoundBackground(this)
|
||||||
, _scroll(this, st::shortInfoScroll)
|
, _scroll(this, st::shortInfoScroll)
|
||||||
|
@ -691,11 +694,12 @@ void PeerShortInfoBox::prepareRows() {
|
||||||
auto addInfoLineGeneric = [&](
|
auto addInfoLineGeneric = [&](
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<QString> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
const style::FlatLabel &textSt) {
|
||||||
auto line = CreateTextWithLabel(
|
auto line = CreateTextWithLabel(
|
||||||
_rows,
|
_rows,
|
||||||
rpl::duplicate(label) | Ui::Text::ToWithEntities(),
|
rpl::duplicate(label) | Ui::Text::ToWithEntities(),
|
||||||
rpl::duplicate(text),
|
rpl::duplicate(text),
|
||||||
|
_st.label,
|
||||||
textSt,
|
textSt,
|
||||||
st::shortInfoLabeledPadding);
|
st::shortInfoLabeledPadding);
|
||||||
_rows->add(object_ptr<Ui::OverrideMargins>(
|
_rows->add(object_ptr<Ui::OverrideMargins>(
|
||||||
|
@ -715,7 +719,7 @@ void PeerShortInfoBox::prepareRows() {
|
||||||
auto addInfoLine = [&](
|
auto addInfoLine = [&](
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<QString> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
const style::FlatLabel &textSt) {
|
||||||
return addInfoLineGeneric(
|
return addInfoLineGeneric(
|
||||||
std::move(label),
|
std::move(label),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
@ -728,7 +732,7 @@ void PeerShortInfoBox::prepareRows() {
|
||||||
auto result = addInfoLine(
|
auto result = addInfoLine(
|
||||||
std::move(label),
|
std::move(label),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
st::infoLabeledOneLine);
|
_st.labeledOneLine);
|
||||||
result->setDoubleClickSelectsParagraph(true);
|
result->setDoubleClickSelectsParagraph(true);
|
||||||
result->setContextCopyText(contextCopyText);
|
result->setContextCopyText(contextCopyText);
|
||||||
return result;
|
return result;
|
||||||
|
@ -744,7 +748,7 @@ void PeerShortInfoBox::prepareRows() {
|
||||||
auto label = _fields.current().isBio
|
auto label = _fields.current().isBio
|
||||||
? tr::lng_info_bio_label()
|
? tr::lng_info_bio_label()
|
||||||
: tr::lng_info_about_label();
|
: tr::lng_info_about_label();
|
||||||
addInfoLine(std::move(label), aboutValue());
|
addInfoLine(std::move(label), aboutValue(), _st.labeled);
|
||||||
addInfoOneLine(
|
addInfoOneLine(
|
||||||
tr::lng_info_username_label(),
|
tr::lng_info_username_label(),
|
||||||
usernameValue() | Ui::Text::ToWithEntities(),
|
usernameValue() | Ui::Text::ToWithEntities(),
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
struct ShortInfoCover;
|
struct ShortInfoCover;
|
||||||
|
struct ShortInfoBox;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
namespace Media::Streaming {
|
namespace Media::Streaming {
|
||||||
|
@ -144,7 +145,8 @@ public:
|
||||||
rpl::producer<PeerShortInfoFields> fields,
|
rpl::producer<PeerShortInfoFields> fields,
|
||||||
rpl::producer<QString> status,
|
rpl::producer<QString> status,
|
||||||
rpl::producer<PeerShortInfoUserpic> userpic,
|
rpl::producer<PeerShortInfoUserpic> userpic,
|
||||||
Fn<bool()> videoPaused);
|
Fn<bool()> videoPaused,
|
||||||
|
const style::ShortInfoBox *stOverride);
|
||||||
~PeerShortInfoBox();
|
~PeerShortInfoBox();
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> openRequests() const;
|
[[nodiscard]] rpl::producer<> openRequests() const;
|
||||||
|
@ -166,6 +168,7 @@ private:
|
||||||
[[nodiscard]] rpl::producer<QString> usernameValue() const;
|
[[nodiscard]] rpl::producer<QString> usernameValue() const;
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> aboutValue() const;
|
[[nodiscard]] rpl::producer<TextWithEntities> aboutValue() const;
|
||||||
|
|
||||||
|
const style::ShortInfoBox &_st;
|
||||||
const PeerShortInfoType _type = PeerShortInfoType::User;
|
const PeerShortInfoType _type = PeerShortInfoType::User;
|
||||||
|
|
||||||
rpl::variable<PeerShortInfoFields> _fields;
|
rpl::variable<PeerShortInfoFields> _fields;
|
||||||
|
|
|
@ -420,7 +420,8 @@ bool ProcessCurrent(
|
||||||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> open,
|
Fn<void()> open,
|
||||||
Fn<bool()> videoPaused) {
|
Fn<bool()> videoPaused,
|
||||||
|
const style::ShortInfoBox *stOverride) {
|
||||||
const auto type = peer->isUser()
|
const auto type = peer->isUser()
|
||||||
? PeerShortInfoType::User
|
? PeerShortInfoType::User
|
||||||
: peer->isBroadcast()
|
: peer->isBroadcast()
|
||||||
|
@ -432,7 +433,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
FieldsValue(peer),
|
FieldsValue(peer),
|
||||||
StatusValue(peer),
|
StatusValue(peer),
|
||||||
std::move(userpic.value),
|
std::move(userpic.value),
|
||||||
std::move(videoPaused));
|
std::move(videoPaused),
|
||||||
|
stOverride);
|
||||||
|
|
||||||
result->openRequests(
|
result->openRequests(
|
||||||
) | rpl::start_with_next(open, result->lifetime());
|
) | rpl::start_with_next(open, result->lifetime());
|
||||||
|
@ -445,7 +447,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
|
|
||||||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<Window::SessionNavigation*> navigation) {
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
const style::ShortInfoBox *stOverride) {
|
||||||
const auto open = [=] { navigation->showPeerHistory(peer); };
|
const auto open = [=] { navigation->showPeerHistory(peer); };
|
||||||
const auto videoIsPaused = [=] {
|
const auto videoIsPaused = [=] {
|
||||||
return navigation->parentController()->isGifPausedAtLeastFor(
|
return navigation->parentController()->isGifPausedAtLeastFor(
|
||||||
|
@ -454,7 +457,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
return PrepareShortInfoBox(
|
return PrepareShortInfoBox(
|
||||||
peer,
|
peer,
|
||||||
open,
|
open,
|
||||||
videoIsPaused);
|
videoIsPaused,
|
||||||
|
stOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> PrepareShortInfoStatus(not_null<PeerData*> peer) {
|
rpl::producer<QString> PrepareShortInfoStatus(not_null<PeerData*> peer) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ class PeerData;
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
struct ShortInfoCover;
|
struct ShortInfoCover;
|
||||||
|
struct ShortInfoBox;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -33,11 +34,13 @@ struct PreparedShortInfoUserpic {
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> open,
|
Fn<void()> open,
|
||||||
Fn<bool()> videoPaused);
|
Fn<bool()> videoPaused,
|
||||||
|
const style::ShortInfoBox *stOverride = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<Window::SessionNavigation*> navigation);
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
const style::ShortInfoBox *stOverride = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<QString> PrepareShortInfoStatus(
|
[[nodiscard]] rpl::producer<QString> PrepareShortInfoStatus(
|
||||||
not_null<PeerData*> peer);
|
not_null<PeerData*> peer);
|
||||||
|
|
|
@ -389,22 +389,6 @@ infoNotificationsIconPosition: point(20px, 5px);
|
||||||
infoSharedMediaButtonIconPosition: point(20px, 3px);
|
infoSharedMediaButtonIconPosition: point(20px, 3px);
|
||||||
infoGroupMembersIconPosition: point(20px, 10px);
|
infoGroupMembersIconPosition: point(20px, 10px);
|
||||||
infoChannelMembersIconPosition: point(20px, 19px);
|
infoChannelMembersIconPosition: point(20px, 19px);
|
||||||
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
|
||||||
maxHeight: 20px;
|
|
||||||
style: TextStyle(defaultTextStyle) {
|
|
||||||
lineHeight: 19px;
|
|
||||||
}
|
|
||||||
margin: margins(5px, 5px, 5px, 5px);
|
|
||||||
}
|
|
||||||
infoLabelSkip: 2px;
|
|
||||||
infoLabeled: FlatLabel(infoLabeledOneLine) {
|
|
||||||
minWidth: 180px;
|
|
||||||
maxHeight: 0px;
|
|
||||||
margin: margins(5px, 5px, 5px, 5px);
|
|
||||||
}
|
|
||||||
infoLabel: FlatLabel(infoLabeled) {
|
|
||||||
textFg: windowSubTextFg;
|
|
||||||
}
|
|
||||||
|
|
||||||
infoBlockHeaderLabel: FlatLabel(infoProfileStatus) {
|
infoBlockHeaderLabel: FlatLabel(infoProfileStatus) {
|
||||||
textFg: windowBoldFg;
|
textFg: windowBoldFg;
|
||||||
|
|
|
@ -350,6 +350,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
result,
|
result,
|
||||||
v::text::take_marked(std::move(label)),
|
v::text::take_marked(std::move(label)),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
st::infoLabel,
|
||||||
textSt,
|
textSt,
|
||||||
padding);
|
padding);
|
||||||
tracker.track(result->add(std::move(line.wrap)));
|
tracker.track(result->add(std::move(line.wrap)));
|
||||||
|
|
|
@ -22,6 +22,7 @@ TextWithLabel CreateTextWithLabel(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<TextWithEntities> &&label,
|
rpl::producer<TextWithEntities> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
|
const style::FlatLabel &labelSt,
|
||||||
const style::FlatLabel &textSt,
|
const style::FlatLabel &textSt,
|
||||||
const style::margins &padding) {
|
const style::margins &padding) {
|
||||||
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
@ -58,7 +59,7 @@ TextWithLabel CreateTextWithLabel(
|
||||||
) | rpl::after_next([=] {
|
) | rpl::after_next([=] {
|
||||||
layout->resizeToWidth(layout->widthNoMargins());
|
layout->resizeToWidth(layout->widthNoMargins());
|
||||||
}),
|
}),
|
||||||
st::infoLabel));
|
labelSt));
|
||||||
result->finishAnimating();
|
result->finishAnimating();
|
||||||
return { std::move(result), labeled, subtext };
|
return { std::move(result), labeled, subtext };
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ TextWithLabel CreateTextWithLabel(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<TextWithEntities> &&label,
|
rpl::producer<TextWithEntities> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
|
const style::FlatLabel &labelSt,
|
||||||
const style::FlatLabel &textSt,
|
const style::FlatLabel &textSt,
|
||||||
const style::margins &padding);
|
const style::margins &padding);
|
||||||
|
|
||||||
|
|
|
@ -8,17 +8,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/stories/media_stories_recent_views.h"
|
#include "media/stories/media_stories_recent_views.h"
|
||||||
|
|
||||||
#include "api/api_who_reacted.h" // FormatReadDate.
|
#include "api/api_who_reacted.h" // FormatReadDate.
|
||||||
|
#include "boxes/peers/prepare_short_info_box.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_stories.h"
|
#include "data/data_stories.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "media/stories/media_stories_controller.h"
|
#include "media/stories/media_stories_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/chat/group_call_userpics.h"
|
#include "ui/chat/group_call_userpics.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
|
||||||
#include "ui/controls/who_reacted_context_action.h"
|
#include "ui/controls/who_reacted_context_action.h"
|
||||||
|
#include "ui/layers/box_content.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/userpic_view.h"
|
#include "ui/userpic_view.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_media_view.h"
|
#include "styles/style_media_view.h"
|
||||||
|
|
||||||
|
@ -324,8 +329,27 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
||||||
|
|
||||||
const auto peer = entry.peer;
|
const auto peer = entry.peer;
|
||||||
const auto date = Api::FormatReadDate(entry.date, now);
|
const auto date = Api::FormatReadDate(entry.date, now);
|
||||||
|
const auto show = _controller->uiShow();
|
||||||
const auto prepare = [&](Ui::PeerUserpicView &view) {
|
const auto prepare = [&](Ui::PeerUserpicView &view) {
|
||||||
const auto size = st::storiesWhoViewed.photoSize;
|
const auto size = st::storiesWhoViewed.photoSize;
|
||||||
|
auto callback = [=] {
|
||||||
|
const auto open = [=] {
|
||||||
|
if (const auto window = Core::App().windowFor(peer)) {
|
||||||
|
window->invokeForSessionController(
|
||||||
|
&peer->session().account(),
|
||||||
|
peer,
|
||||||
|
[&](not_null<Window::SessionController*> controller) {
|
||||||
|
Core::App().hideMediaView();
|
||||||
|
controller->showPeerHistory(peer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
show->show(PrepareShortInfoBox(
|
||||||
|
peer,
|
||||||
|
open,
|
||||||
|
[] { return false; },
|
||||||
|
&st::storiesShortInfoBox));
|
||||||
|
};
|
||||||
auto userpic = peer->generateUserpicImage(
|
auto userpic = peer->generateUserpicImage(
|
||||||
view,
|
view,
|
||||||
size * style::DevicePixelRatio());
|
size * style::DevicePixelRatio());
|
||||||
|
@ -334,7 +358,7 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
||||||
.text = peer->name(),
|
.text = peer->name(),
|
||||||
.date = date,
|
.date = date,
|
||||||
.userpic = std::move(userpic),
|
.userpic = std::move(userpic),
|
||||||
.callback = [] {},
|
.callback = std::move(callback),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (_menuPlaceholderCount > 0) {
|
if (_menuPlaceholderCount > 0) {
|
||||||
|
|
|
@ -793,3 +793,21 @@ storiesUnsupportedLabel: FlatLabel(defaultFlatLabel) {
|
||||||
align: align(top);
|
align: align(top);
|
||||||
}
|
}
|
||||||
storiesUnsupportedUpdate: themePreviewApplyButton;
|
storiesUnsupportedUpdate: themePreviewApplyButton;
|
||||||
|
storiesShortInfoBox: ShortInfoBox(shortInfoBox) {
|
||||||
|
label: FlatLabel(infoLabel) {
|
||||||
|
textFg: storiesComposeGrayText;
|
||||||
|
palette: TextPalette(mediaviewTextPalette) {
|
||||||
|
linkFg: mediaviewTextLinkFg;
|
||||||
|
monoFg: storiesComposeGrayText;
|
||||||
|
spoilerFg: storiesComposeGrayText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
labeled: FlatLabel(infoLabeled) {
|
||||||
|
textFg: mediaviewCaptionFg;
|
||||||
|
palette: mediaviewTextPalette;
|
||||||
|
}
|
||||||
|
labeledOneLine: FlatLabel(infoLabeledOneLine) {
|
||||||
|
textFg: mediaviewCaptionFg;
|
||||||
|
palette: mediaviewTextPalette;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue