@@ -26,6 +26,7 @@ For license and copyright information please follow this link:
2626#include " ui/widgets/labels.h"
2727#include " ui/wrap/fade_wrap.h"
2828#include " ui/painter.h"
29+ #include " ui/rect.h"
2930#include " passport/passport_encryption.h"
3031#include " passport/passport_panel_edit_contact.h"
3132#include " settings/settings_privacy_security.h"
@@ -171,8 +172,9 @@ PasscodeBox::PasscodeBox(
171172 bool turningOff)
172173: _session(session)
173174, _api(&_session->mtp ())
175+ , _textWidth(st::boxWidth - st::boxPadding.left() * 1.5)
174176, _turningOff(turningOff)
175- , _about(st::boxWidth - st::boxPadding.left() * 1.5 )
177+ , _about(_textWidth )
176178, _oldPasscode(this , st::defaultInputField, tr::lng_passcode_enter_old())
177179, _newPasscode(
178180 this ,
@@ -193,10 +195,11 @@ PasscodeBox::PasscodeBox(
193195 const CloudFields &fields)
194196: _session(session)
195197, _api(mtp)
198+ , _textWidth(st::boxWidth - st::boxPadding.left() * 1.5)
196199, _turningOff(fields.turningOff)
197200, _cloudPwd(true )
198201, _cloudFields(fields)
199- , _about(st::boxWidth - st::boxPadding.left() * 1.5 )
202+ , _about(_textWidth )
200203, _oldPasscode(this , st::defaultInputField, tr::lng_cloud_password_enter_old())
201204, _newPasscode(
202205 this ,
@@ -274,7 +277,7 @@ void PasscodeBox::prepare() {
274277 : _cloudPwd
275278 ? tr::lng_cloud_password_about (tr::now)
276279 : tr::lng_passcode_about (tr::now)));
277- _aboutHeight = _about.countHeight (st::boxWidth - st::boxPadding. left () * 1.5 );
280+ _aboutHeight = _about.countHeight (_textWidth );
278281 const auto onlyCheck = onlyCheckCurrent ();
279282 if (onlyCheck) {
280283 _oldPasscode->show ();
@@ -382,28 +385,27 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
382385
383386 Painter p (this );
384387
385- int32 w = st::boxWidth - st::boxPadding.left () * 1.5 ;
386388 int32 abouty = (_passwordHint->isHidden () ? ((_reenterPasscode->isHidden () ? (_oldPasscode->y () + (_showRecoverLink && !_hintText.isEmpty () ? st::passcodeTextLine : 0 )) : _reenterPasscode->y ()) + st::passcodeSkip) : _passwordHint->y ()) + _oldPasscode->height () + st::passcodeLittleSkip + st::passcodeAboutSkip;
387389 p.setPen (st::boxTextFg);
388- _about.drawLeft (p, st::boxPadding.left (), abouty, w , width ());
390+ _about.drawLeft (p, st::boxPadding.left (), abouty, _textWidth , width ());
389391
390392 if (!_hintText.isEmpty () && _oldError.isEmpty ()) {
391- _hintText.drawLeftElided (p, st::boxPadding.left (), _oldPasscode->y () + _oldPasscode->height () + ((st::passcodeTextLine - st::normalFont->height ) / 2 ), w , width (), 1 , style::al_topleft);
393+ _hintText.drawLeftElided (p, st::boxPadding.left (), _oldPasscode->y () + _oldPasscode->height () + ((st::passcodeTextLine - st::normalFont->height ) / 2 ), _textWidth , width (), 1 , style::al_topleft);
392394 }
393395
394396 if (!_oldError.isEmpty ()) {
395397 p.setPen (st::boxTextFgError);
396- p.drawText (QRect (st::boxPadding.left (), _oldPasscode->y () + _oldPasscode->height (), w , st::passcodeTextLine), _oldError, style::al_left);
398+ p.drawText (QRect (st::boxPadding.left (), _oldPasscode->y () + _oldPasscode->height (), _textWidth , st::passcodeTextLine), _oldError, style::al_left);
397399 }
398400
399401 if (!_newError.isEmpty ()) {
400402 p.setPen (st::boxTextFgError);
401- p.drawText (QRect (st::boxPadding.left (), _reenterPasscode->y () + _reenterPasscode->height (), w , st::passcodeTextLine), _newError, style::al_left);
403+ p.drawText (QRect (st::boxPadding.left (), _reenterPasscode->y () + _reenterPasscode->height (), _textWidth , st::passcodeTextLine), _newError, style::al_left);
402404 }
403405
404406 if (!_emailError.isEmpty ()) {
405407 p.setPen (st::boxTextFgError);
406- p.drawText (QRect (st::boxPadding.left (), _recoverEmail->y () + _recoverEmail->height (), w , st::passcodeTextLine), _emailError, style::al_left);
408+ p.drawText (QRect (st::boxPadding.left (), _recoverEmail->y () + _recoverEmail->height (), _textWidth , st::passcodeTextLine), _emailError, style::al_left);
407409 }
408410}
409411
@@ -1141,11 +1143,21 @@ RecoverBox::RecoverBox(
11411143 Fn<void ()> closeParent)
11421144: _session(session)
11431145, _api(mtp)
1144- , _pattern (st::normalFont-> elided (tr::lng_signin_recover_hint(tr::now, lt_recover_email, pattern), st:: boxWidth - st::boxPadding.left() * 1.5) )
1146+ , _textWidth (st::boxWidth - st::boxPadding.left() * 1.5)
11451147, _cloudFields(fields)
11461148, _recoverCode(this , st::defaultInputField, tr::lng_signin_code())
11471149, _noEmailAccess(this , tr::lng_signin_try_password(tr::now))
1150+ , _patternLabel(
1151+ this ,
1152+ tr::lng_signin_recover_hint (
1153+ lt_recover_email,
1154+ rpl::single (Ui::Text::WrapEmailPattern(pattern)),
1155+ Ui::Text::WithEntities),
1156+ st::termsContent,
1157+ st::defaultPopupMenu,
1158+ [=](Fn<void ()> update) { return CommonTextContext{ std::move (update) }; })
11481159, _closeParent(std::move(closeParent)) {
1160+ _patternLabel->setAttribute (Qt::WA_TransparentForMouseEvents);
11491161 if (_cloudFields.pendingResetDate != 0 || !session) {
11501162 _noEmailAccess.destroy ();
11511163 } else {
@@ -1176,19 +1188,24 @@ rpl::producer<> RecoverBox::recoveryExpired() const {
11761188 return _recoveryExpired.events ();
11771189}
11781190
1179- void RecoverBox::prepare () {
1180- setTitle (tr::lng_signin_recover_title ());
1181-
1182- addButton (tr::lng_passcode_submit (), [=] { submit (); });
1183- addButton (tr::lng_cancel (), [=] { closeBox (); });
1184-
1191+ void RecoverBox::updateHeight () {
11851192 setDimensions (
11861193 st::boxWidth,
11871194 (st::passcodePadding.top ()
11881195 + st::passcodePadding.bottom ()
11891196 + st::passcodeTextLine
11901197 + _recoverCode->height ()
1198+ + _patternLabel->height ()
11911199 + st::passcodeTextLine));
1200+ }
1201+
1202+ void RecoverBox::prepare () {
1203+ setTitle (tr::lng_signin_recover_title ());
1204+
1205+ addButton (tr::lng_passcode_submit (), [=] { submit (); });
1206+ addButton (tr::lng_cancel (), [=] { closeBox (); });
1207+
1208+ updateHeight ();
11921209
11931210 _recoverCode->changes (
11941211 ) | rpl::start_with_next ([=] {
@@ -1205,23 +1222,42 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
12051222
12061223 p.setFont (st::normalFont);
12071224 p.setPen (st::boxTextFg);
1208- int32 w = st::boxWidth - st::boxPadding.left () * 1.5 ;
1209- p.drawText (QRect (st::boxPadding.left (), _recoverCode->y () - st::passcodeTextLine - st::passcodePadding.top (), w, st::passcodePadding.top () + st::passcodeTextLine), _pattern, style::al_left);
12101225
12111226 if (!_error.isEmpty ()) {
12121227 p.setPen (st::boxTextFgError);
1213- p.drawText (QRect (st::boxPadding.left (), _recoverCode->y () + _recoverCode->height (), w, st::passcodeTextLine), _error, style::al_left);
1228+ p.drawText (
1229+ QRect (
1230+ st::boxPadding.left (),
1231+ _recoverCode->y () + _recoverCode->height (),
1232+ _textWidth,
1233+ st::passcodeTextLine),
1234+ _error,
1235+ style::al_left);
12141236 }
12151237}
12161238
12171239void RecoverBox::resizeEvent (QResizeEvent *e) {
12181240 BoxContent::resizeEvent (e);
12191241
1220- _recoverCode->resize (st::boxWidth - st::boxPadding.left () - st::boxPadding.right (), _recoverCode->height ());
1221- _recoverCode->moveToLeft (st::boxPadding.left (), st::passcodePadding.top () + st::passcodePadding.bottom () + st::passcodeTextLine);
1242+ _patternLabel->resizeToWidth (_textWidth);
1243+ _patternLabel->moveToLeft (
1244+ st::boxPadding.left (),
1245+ st::passcodePadding.top ());
1246+
1247+ _recoverCode->resize (
1248+ st::boxWidth - st::boxPadding.left () - st::boxPadding.right (),
1249+ _recoverCode->height ());
1250+ _recoverCode->moveToLeft (
1251+ st::boxPadding.left (),
1252+ rect::m::sum::v (st::passcodePadding) + _patternLabel->height ());
12221253 if (_noEmailAccess) {
1223- _noEmailAccess->moveToLeft (st::boxPadding.left (), _recoverCode->y () + _recoverCode->height () + (st::passcodeTextLine - _noEmailAccess->height ()) / 2 );
1254+ _noEmailAccess->moveToLeft (
1255+ st::boxPadding.left (),
1256+ rect::bottom (_recoverCode)
1257+ + (st::passcodeTextLine - _noEmailAccess->height ()) / 2 );
12241258 }
1259+
1260+ updateHeight ();
12251261}
12261262
12271263void RecoverBox::setInnerFocus () {
0 commit comments