MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / createRowView

Method createRowView

Telegram/SourceFiles/ui/search_field_controller.cpp:23–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23auto SearchFieldController::createRowView(
24 QWidget *parent,
25 const style::SearchFieldRow &st) -> RowView {
26 auto result = base::make_unique_q<Ui::FixedHeightWidget>(
27 parent,
28 st.height);
29 auto wrap = result.get();
30
31 auto field = createField(wrap, st.field).release();
32 field->show();
33
34 auto cancel = CreateChild<Ui::CrossButton>(
35 wrap,
36 st.fieldCancel);
37 cancel->addClickHandler([=] {
38 field->setText(QString());
39 });
40 queryValue(
41 ) | rpl::map([](const QString &value) {
42 return !value.isEmpty();
43 }) | rpl::on_next([cancel](bool shown) {
44 cancel->toggle(shown, anim::type::normal);
45 cancel->setAccessibleName(tr::lng_sr_clear_search(tr::now));
46 }, cancel->lifetime());
47 cancel->finishAnimating();
48
49 auto shadow = CreateChild<Ui::PlainShadow>(wrap);
50 shadow->show();
51
52 wrap->widthValue(
53 ) | rpl::on_next([=, &st](int newWidth) {
54 auto availableWidth = newWidth
55 - st.fieldIconSkip
56 - st.fieldCancelSkip;
57 field->setGeometryToLeft(
58 st.padding.left() + st.fieldIconSkip,
59 st.padding.top(),
60 availableWidth,
61 field->height());
62 cancel->moveToRight(0, 0);
63 shadow->setGeometry(
64 0,
65 st.height - st::lineWidth,
66 newWidth,
67 st::lineWidth);
68 }, wrap->lifetime());
69 wrap->paintRequest(
70 ) | rpl::on_next([=, &st] {
71 auto p = QPainter(wrap);
72 st.fieldIcon.paint(
73 p,
74 st.padding.left(),
75 st.padding.top(),
76 wrap->width());
77 }, wrap->lifetime());
78
79 _view.release();
80 _view.reset(wrap);

Callers 3

createPinnedToTopMethod · 0.80
createPinnedToTopMethod · 0.80
refreshSearchFieldMethod · 0.80

Calls 15

QStringClass · 0.50
QPainterClass · 0.50
getMethod · 0.45
releaseMethod · 0.45
showMethod · 0.45
setTextMethod · 0.45
isEmptyMethod · 0.45
toggleMethod · 0.45
finishAnimatingMethod · 0.45
widthValueMethod · 0.45
topMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected