mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
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>(
|
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||||
line,
|
container,
|
||||||
peer,
|
peer,
|
||||||
st);
|
st::mainMenuUserpic);
|
||||||
userpic->showSavedMessagesOnSelf(true);
|
userpic->showSavedMessagesOnSelf(true);
|
||||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
Ui::IconWithTitle(
|
||||||
line,
|
container,
|
||||||
peer->isSelf()
|
userpic,
|
||||||
? tr::lng_saved_messages() | Ui::Text::ToBold()
|
Ui::CreateChild<Ui::FlatLabel>(
|
||||||
: maybeUser
|
container,
|
||||||
? tr::lng_profile_delete_conversation() | Ui::Text::ToBold()
|
peer->isSelf()
|
||||||
: rpl::single(Ui::Text::Bold(peer->name())) | rpl::type_erased(),
|
? tr::lng_saved_messages() | Ui::Text::ToBold()
|
||||||
box->getDelegate()->style().title);
|
: maybeUser
|
||||||
line->widthValue(
|
? tr::lng_profile_delete_conversation() | Ui::Text::ToBold()
|
||||||
) | rpl::start_with_next([=](int width) {
|
: rpl::single(peer->name()) | Ui::Text::ToBold(),
|
||||||
userpic->moveToLeft(st::boxRowPadding.left(), 0);
|
box->getDelegate()->style().title));
|
||||||
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::AddSkip(container);
|
Ui::AddSkip(container);
|
||||||
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 "ui/boxes/confirm_box.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/rect.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
|
||||||
|
@ -100,4 +101,33 @@ object_ptr<Ui::GenericBox> MakeConfirmBox(ConfirmBoxArgs &&args) {
|
||||||
return Box(ConfirmBox, std::move(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
|
} // namespace Ui
|
||||||
|
|
|
@ -60,4 +60,9 @@ inline void InformBox(not_null<GenericBox*> box, ConfirmBoxArgs &&args) {
|
||||||
return MakeInformBox({ .text = std::move(text) });
|
return MakeInformBox({ .text = std::move(text) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IconWithTitle(
|
||||||
|
not_null<VerticalLayout*> container,
|
||||||
|
not_null<RpWidget*> icon,
|
||||||
|
not_null<RpWidget*> title);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Add table
Reference in a new issue