"Fossies" - the Fresh Open Source Software Archive 
Member "tdesktop-4.8.3/Telegram/SourceFiles/passport/passport_form_row.cpp" (1 Jun 2023, 2348 Bytes) of package /linux/misc/tdesktop-4.8.3.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "passport_form_row.cpp" see the
Fossies "Dox" file reference documentation.
1 /*
2 This file is part of Telegram Desktop,
3 the official desktop application for the Telegram messaging service.
4
5 For license and copyright information please follow this link:
6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
7 */
8 #include "passport/passport_form_row.h"
9
10 #include "ui/wrap/fade_wrap.h"
11 #include "ui/text_options.h"
12 #include "styles/style_boxes.h"
13 #include "styles/style_passport.h"
14
15 namespace Passport {
16
17 FormRow::FormRow(
18 QWidget *parent,
19 const QString &title,
20 const QString &description)
21 : RippleButton(parent, st::passportRowRipple)
22 , _title(
23 st::semiboldTextStyle,
24 title,
25 Ui::NameTextOptions(),
26 st::boxWideWidth / 2)
27 , _description(
28 st::defaultTextStyle,
29 description,
30 Ui::NameTextOptions(),
31 st::boxWideWidth / 2) {
32 }
33
34 void FormRow::setReady(bool ready) {
35 _ready = ready;
36 resizeToWidth(width());
37 update();
38 }
39
40 int FormRow::resizeGetHeight(int newWidth) {
41 const auto availableWidth = countAvailableWidth(newWidth);
42 _titleHeight = _title.countHeight(availableWidth);
43 _descriptionHeight = _description.countHeight(availableWidth);
44 const auto result = st::passportRowPadding.top()
45 + _titleHeight
46 + st::passportRowSkip
47 + _descriptionHeight
48 + st::passportRowPadding.bottom();
49 return result;
50 }
51
52 int FormRow::countAvailableWidth(int newWidth) const {
53 return newWidth
54 - st::passportRowPadding.left()
55 - st::passportRowPadding.right()
56 - (_ready ? st::passportRowReadyIcon : st::passportRowEmptyIcon).width();
57 }
58
59 int FormRow::countAvailableWidth() const {
60 return countAvailableWidth(width());
61 }
62
63 void FormRow::paintEvent(QPaintEvent *e) {
64 Painter p(this);
65
66 const auto ms = getms();
67 paintRipple(p, 0, 0, ms);
68
69 const auto left = st::passportRowPadding.left();
70 const auto availableWidth = countAvailableWidth();
71 auto top = st::passportRowPadding.top();
72
73 p.setPen(st::passportRowTitleFg);
74 _title.drawLeft(p, left, top, availableWidth, width());
75 top += _titleHeight + st::passportRowSkip;
76
77 p.setPen(st::passportRowDescriptionFg);
78 _description.drawLeft(p, left, top, availableWidth, width());
79 top += _descriptionHeight + st::passportRowPadding.bottom();
80
81 const auto &icon = _ready
82 ? st::passportRowReadyIcon
83 : st::passportRowEmptyIcon;
84 icon.paint(
85 p,
86 width() - st::passportRowPadding.right() - icon.width(),
87 (height() - icon.height()) / 2,
88 width());
89 }
90
91 } // namespace Passport