mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Open profile on header click.
This commit is contained in:
parent
ac534780cc
commit
fcc15dd52d
4 changed files with 38 additions and 25 deletions
|
@ -10,7 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/timer.h"
|
||||
#include "base/power_save_blocker.h"
|
||||
#include "base/qt_signal_producer.h"
|
||||
#include "boxes/peers/prepare_short_info_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "core/application.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "data/data_changes.h"
|
||||
|
@ -45,6 +47,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
#include "ui/round_rect.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_media_view.h"
|
||||
|
@ -1388,4 +1392,23 @@ void ReportRequested(
|
|||
}));
|
||||
}
|
||||
|
||||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(not_null<PeerData*> peer) {
|
||||
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);
|
||||
});
|
||||
}
|
||||
};
|
||||
return ::PrepareShortInfoBox(
|
||||
peer,
|
||||
open,
|
||||
[] { return false; },
|
||||
&st::storiesShortInfoBox);
|
||||
}
|
||||
|
||||
} // namespace Media::Stories
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/object_ptr.h"
|
||||
#include "data/data_stories.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
||||
|
@ -36,6 +37,7 @@ namespace Ui {
|
|||
class RpWidget;
|
||||
struct MessageSendingAnimationFrom;
|
||||
class EmojiFlyAnimation;
|
||||
class BoxContent;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui::Toast {
|
||||
|
@ -269,5 +271,7 @@ void ReportRequested(
|
|||
std::shared_ptr<Main::SessionShow> show,
|
||||
FullStoryId id,
|
||||
const style::ReportBox *stOverride = nullptr);
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
} // namespace Media::Stories
|
||||
|
|
|
@ -8,10 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/stories/media_stories_header.h"
|
||||
|
||||
#include "base/unixtime.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "data/data_user.h"
|
||||
#include "media/stories/media_stories_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/controls/userpic_button.h"
|
||||
#include "ui/layers/box_content.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/painter.h"
|
||||
|
@ -92,13 +94,16 @@ void Header::show(HeaderData data) {
|
|||
if (userChanged) {
|
||||
_date = nullptr;
|
||||
const auto parent = _controller->wrap();
|
||||
auto widget = std::make_unique<Ui::RpWidget>(parent);
|
||||
auto widget = std::make_unique<Ui::AbstractButton>(parent);
|
||||
const auto raw = widget.get();
|
||||
raw->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
raw->setClickedCallback([=] {
|
||||
_controller->uiShow()->show(PrepareShortInfoBox(_data->user));
|
||||
});
|
||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||
raw,
|
||||
data.user,
|
||||
st::storiesHeaderPhoto);
|
||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
userpic->show();
|
||||
userpic->move(
|
||||
st::storiesHeaderMargin.left(),
|
||||
|
@ -107,6 +112,7 @@ void Header::show(HeaderData data) {
|
|||
raw,
|
||||
data.user->firstName,
|
||||
st::storiesHeaderName);
|
||||
name->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
name->setOpacity(kNameOpacity);
|
||||
name->move(st::storiesHeaderNamePosition);
|
||||
raw->show();
|
||||
|
@ -122,6 +128,7 @@ void Header::show(HeaderData data) {
|
|||
_widget.get(),
|
||||
std::move(timestamp.text),
|
||||
st::storiesHeaderDate);
|
||||
_date->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
_date->setOpacity(kDateOpacity);
|
||||
_date->show();
|
||||
_date->move(st::storiesHeaderDatePosition);
|
||||
|
|
|
@ -8,8 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/stories/media_stories_recent_views.h"
|
||||
|
||||
#include "api/api_who_reacted.h" // FormatReadDate.
|
||||
#include "boxes/peers/prepare_short_info_box.h"
|
||||
#include "core/application.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_stories.h"
|
||||
#include "main/main_session.h"
|
||||
|
@ -22,8 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/painter.h"
|
||||
#include "ui/rp_widget.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_media_view.h"
|
||||
|
||||
|
@ -332,24 +329,6 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
|||
const auto show = _controller->uiShow();
|
||||
const auto prepare = [&](Ui::PeerUserpicView &view) {
|
||||
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(
|
||||
view,
|
||||
size * style::DevicePixelRatio());
|
||||
|
@ -358,7 +337,7 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
|||
.text = peer->name(),
|
||||
.date = date,
|
||||
.userpic = std::move(userpic),
|
||||
.callback = std::move(callback),
|
||||
.callback = [=] { show->show(PrepareShortInfoBox(peer)); },
|
||||
};
|
||||
};
|
||||
if (_menuPlaceholderCount > 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue