| 178 | } |
| 179 | |
| 180 | void CodeInput::setDigitsCountMax(int digitsCount) { |
| 181 | _digitsCountMax = digitsCount; |
| 182 | |
| 183 | _digits.clear(); |
| 184 | _currentIndex = 0; |
| 185 | |
| 186 | constexpr auto kWidthRatio = 0.8; |
| 187 | const auto digitWidth = st::introCodeDigitHeight * kWidthRatio; |
| 188 | const auto padding = Margins(st::introCodeDigitSkip); |
| 189 | resize( |
| 190 | padding.left() |
| 191 | + digitWidth * digitsCount |
| 192 | + st::introCodeDigitSkip * (digitsCount - 1) |
| 193 | + padding.right(), |
| 194 | st::introCodeDigitHeight); |
| 195 | setNaturalWidth(width()); |
| 196 | |
| 197 | for (auto i = 0; i < digitsCount; i++) { |
| 198 | const auto widget = Ui::CreateChild<CodeDigit>(this); |
| 199 | widget->setPointerCursor(false); |
| 200 | widget->setClickedCallback([=] { unfocusAll(_currentIndex = i); }); |
| 201 | widget->resize(digitWidth, st::introCodeDigitHeight); |
| 202 | widget->moveToLeft( |
| 203 | padding.left() + (digitWidth + st::introCodeDigitSkip) * i, |
| 204 | 0); |
| 205 | _digits.emplace_back(widget); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | void CodeInput::setCode(QString code) { |
| 210 | using namespace TextUtilities; |
no test coverage detected