mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Made creation of title with userpic more generic.
This commit is contained in:
parent
fd2d12d6b1
commit
71f83b5993
3 changed files with 48 additions and 29 deletions
|
@ -757,38 +757,22 @@ void DeleteChatBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
|||
return base::EventFilterResult::Continue;
|
||||
});
|
||||
|
||||
const auto line = container->add(object_ptr<Ui::RpWidget>(container));
|
||||
const auto &st = st::mainMenuUserpic;
|
||||
line->resize(line->width(), st.size.height());
|
||||
|
||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||
line,
|
||||
container,
|
||||
peer,
|
||||
st);
|
||||
st::mainMenuUserpic);
|
||||
userpic->showSavedMessagesOnSelf(true);
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
line,
|
||||
peer->isSelf()
|
||||
? tr::lng_saved_messages() | Ui::Text::ToBold()
|
||||
: maybeUser
|
||||
? tr::lng_profile_delete_conversation() | Ui::Text::ToBold()
|
||||
: rpl::single(Ui::Text::Bold(peer->name())) | rpl::type_erased(),
|
||||
box->getDelegate()->style().title);
|
||||
line->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
userpic->moveToLeft(st::boxRowPadding.left(), 0);
|
||||
const auto skip = st::defaultBoxCheckbox.textPosition.x();
|
||||
label->resizeToWidth(width
|
||||
- rect::right(userpic)
|
||||
- skip
|
||||
- st::boxRowPadding.right());
|
||||
label->moveToLeft(
|
||||
rect::right(userpic) + skip,
|
||||
((userpic->height() - label->height()) / 2));
|
||||
}, label->lifetime());
|
||||
|
||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
Ui::IconWithTitle(
|
||||
container,
|
||||
userpic,
|
||||
Ui::CreateChild<Ui::FlatLabel>(
|
||||
container,
|
||||
peer->isSelf()
|
||||
? tr::lng_saved_messages() | Ui::Text::ToBold()
|
||||
: maybeUser
|
||||
? tr::lng_profile_delete_conversation() | Ui::Text::ToBold()
|
||||
: rpl::single(peer->name()) | Ui::Text::ToBold(),
|
||||
box->getDelegate()->style().title));
|
||||
|
||||
Ui::AddSkip(container);
|
||||
Ui::AddSkip(container);
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/boxes/confirm_box.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
|
@ -100,4 +101,33 @@ object_ptr<Ui::GenericBox> MakeConfirmBox(ConfirmBoxArgs &&args) {
|
|||
return Box(ConfirmBox, std::move(args));
|
||||
}
|
||||
|
||||
void IconWithTitle(
|
||||
not_null<VerticalLayout*> container,
|
||||
not_null<RpWidget*> icon,
|
||||
not_null<RpWidget*> title) {
|
||||
const auto line = container->add(
|
||||
object_ptr<RpWidget>(container),
|
||||
st::boxRowPadding);
|
||||
icon->setParent(line);
|
||||
title->setParent(line);
|
||||
|
||||
icon->heightValue(
|
||||
) | rpl::start_with_next([=](int height) {
|
||||
line->resize(line->width(), height);
|
||||
}, icon->lifetime());
|
||||
|
||||
line->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
icon->moveToLeft(0, 0);
|
||||
const auto skip = st::defaultBoxCheckbox.textPosition.x();
|
||||
title->resizeToWidth(width - rect::right(icon) - skip);
|
||||
title->moveToLeft(
|
||||
rect::right(icon) + skip,
|
||||
((icon->height() - title->height()) / 2));
|
||||
}, title->lifetime());
|
||||
|
||||
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
title->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -60,4 +60,9 @@ inline void InformBox(not_null<GenericBox*> box, ConfirmBoxArgs &&args) {
|
|||
return MakeInformBox({ .text = std::move(text) });
|
||||
}
|
||||
|
||||
void IconWithTitle(
|
||||
not_null<VerticalLayout*> container,
|
||||
not_null<RpWidget*> icon,
|
||||
not_null<RpWidget*> title);
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue