2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

boxes finished

This commit is contained in:
John Preston
2015-10-14 13:51:37 +02:00
parent ed707c8f0e
commit 8172b82ed4
15 changed files with 163 additions and 84 deletions

View File

@@ -135,12 +135,12 @@ void AddContactBox::resizeEvent(QResizeEvent *e) {
_phone.resize(_first.width(), _last.height());
if (_invertOrder) {
_last.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top());
_first.moveToLeft(_last.x(), _last.y() + _last.height() + st::contactSkip);
_phone.moveToLeft(_first.x(), _first.y() + _first.height() + st::contactPhoneSkip);
_first.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last.y() + _last.height() + st::contactSkip);
_phone.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first.y() + _first.height() + st::contactPhoneSkip);
} else {
_first.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), st::boxTitleHeight + st::contactPadding.top());
_last.moveToLeft(_first.x(), _first.y() + _first.height() + st::contactSkip);
_phone.moveToLeft(_last.x(), _last.y() + _last.height() + st::contactPhoneSkip);
_last.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _first.y() + _first.height() + st::contactSkip);
_phone.moveToLeft(st::boxPadding.left() + st::contactPadding.left(), _last.y() + _last.height() + st::contactPhoneSkip);
}
_save.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _save.height());
@@ -165,7 +165,9 @@ void AddContactBox::onSubmit() {
void AddContactBox::onSave() {
if (_addRequest) return;
QString firstName = _first.getLastText().trimmed(), lastName = _last.getLastText().trimmed(), phone = _phone.getLastText().trimmed();
QString firstName = prepareSentText(_first.getLastText());
QString lastName = prepareSentText(_last.getLastText());
QString phone = _phone.getLastText().trimmed();
if (firstName.isEmpty() && lastName.isEmpty()) {
if (_invertOrder) {
_last.setFocus();
@@ -318,11 +320,11 @@ void NewGroupBox::paintEvent(QPaintEvent *e) {
p.setPen(st::newGroupAboutFg->p);
QRect aboutGroup = myrtlrect(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _group.y() + _group.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight);
_aboutGroup.draw(p, aboutGroup.x(), aboutGroup.y(), aboutGroup.width());
QRect aboutGroup(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _group.y() + _group.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight);
_aboutGroup.drawLeft(p, aboutGroup.x(), aboutGroup.y(), aboutGroup.width(), width());
QRect aboutChannel = myrtlrect(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _channel.y() + _channel.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight);
_aboutChannel.draw(p, aboutChannel.x(), aboutChannel.y(), aboutChannel.width());
QRect aboutChannel(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _channel.y() + _channel.height() + st::lineWidth, _aboutGroupWidth, _aboutGroupHeight);
_aboutChannel.drawLeft(p, aboutChannel.x(), aboutChannel.y(), aboutChannel.width(), width());
}
void NewGroupBox::resizeEvent(QResizeEvent *e) {
@@ -489,7 +491,7 @@ void GroupInfoBox::onNameSubmit() {
void GroupInfoBox::onNext() {
if (_creationRequestId) return;
QString title = _title.getLastText().trimmed();
QString title = prepareSentText(_title.getLastText());
if (title.isEmpty()) {
_title.setFocus();
_title.showError();
@@ -498,7 +500,7 @@ void GroupInfoBox::onNext() {
if (_creating == CreatingGroupGroup) {
App::wnd()->replaceLayer(new ContactsBox(title, _photoBig));
} else {
_creationRequestId = MTP::send(MTPchannels_CreateChannel(MTP_int(MTPmessages_CreateChannel_flag_broadcast), MTP_string(title), MTP_string(_description.getLastText().trimmed()), MTP_vector<MTPInputUser>(0)), rpcDone(&GroupInfoBox::creationDone), rpcFail(&GroupInfoBox::creationFail));
_creationRequestId = MTP::send(MTPchannels_CreateChannel(MTP_int(MTPmessages_CreateChannel_flag_broadcast), MTP_string(title), MTP_string(prepareSentText(_description.getLastText())), MTP_vector<MTPInputUser>(0)), rpcDone(&GroupInfoBox::creationDone), rpcFail(&GroupInfoBox::creationFail));
}
}
@@ -689,14 +691,14 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) {
p.setPen(st::newGroupAboutFg);
QRect aboutPublic = myrtlrect(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _public.y() + _public.height(), _aboutPublicWidth, _aboutPublicHeight);
_aboutPublic.draw(p, aboutPublic.x(), aboutPublic.y(), aboutPublic.width());
QRect aboutPublic(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _public.y() + _public.height(), _aboutPublicWidth, _aboutPublicHeight);
_aboutPublic.drawLeft(p, aboutPublic.x(), aboutPublic.y(), aboutPublic.width(), width());
QRect aboutPrivate = myrtlrect(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _private.y() + _private.height(), _aboutPublicWidth, _aboutPublicHeight);
_aboutPrivate.draw(p, aboutPrivate.x(), aboutPrivate.y(), aboutPrivate.width());
QRect aboutPrivate(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _private.y() + _private.height(), _aboutPublicWidth, _aboutPublicHeight);
_aboutPrivate.drawLeft(p, aboutPrivate.x(), aboutPrivate.y(), aboutPrivate.width(), width());
//QRect aboutComments = myrtlrect(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _comments.y() + _comments.height(), _aboutPublicWidth, _aboutPublicHeight);
//_aboutComments.draw(p, aboutComments.x(), aboutComments.y(), aboutComments.width());
//QRect aboutComments(st::boxPadding.left() + st::newGroupPadding.left() + st::defaultRadiobutton.textPosition.x(), _comments.y() + _comments.height(), _aboutPublicWidth, _aboutPublicHeight);
//_aboutComments.drawLeft(p, aboutComments.x(), aboutComments.y(), aboutComments.width(), width());
p.setPen(st::black);
p.setFont(st::newGroupLinkFont);
@@ -1078,7 +1080,7 @@ void EditNameTitleBox::resizeEvent(QResizeEvent *e) {
void EditNameTitleBox::onSave() {
if (_requestId) return;
QString first = _first.getLastText().trimmed(), last = _last.getLastText().trimmed();
QString first = prepareSentText(_first.getLastText()), last = prepareSentText(_last.getLastText());
if (first.isEmpty() && last.isEmpty()) {
if (_invertOrder) {
_last.setFocus();
@@ -1169,7 +1171,7 @@ _saveTitleRequestId(0), _saveDescriptionRequestId(0) {
updateMaxHeight();
connect(&_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
connect(&_description, SIGNAL(submitted(bool)), this, SLOT(onNext()));
connect(&_description, SIGNAL(submitted(bool)), this, SLOT(onSave()));
connect(&_description, SIGNAL(cancelled()), this, SLOT(onClose()));
connect(&_save, SIGNAL(clicked()), this, SLOT(onSave()));
@@ -1251,7 +1253,7 @@ void EditChannelBox::resizeEvent(QResizeEvent *e) {
void EditChannelBox::onSave() {
if (_saveTitleRequestId || _saveDescriptionRequestId) return;
QString title = _title.getLastText().trimmed(), description = _description.getLastText().trimmed();
QString title = prepareSentText(_title.getLastText()), description = prepareSentText(_description.getLastText());
if (title.isEmpty()) {
_title.setFocus();
_title.showError();

View File

@@ -121,7 +121,7 @@ void ConfirmBox::updateHover() {
QPoint m(mapFromGlobal(_lastMousePos));
bool wasMy = (_myLink == textlnkOver());
textstyleSet(&st::boxTextStyle);
_myLink = _text.link(m.x() - st::boxPadding.left(), m.y() - st::boxPadding.top(), _textWidth, (_text.maxWidth() < width()) ? style::al_center : style::al_left);
_myLink = _text.linkLeft(m.x() - st::boxPadding.left(), m.y() - st::boxPadding.top(), _textWidth, width(), (_text.maxWidth() < width()) ? style::al_center : style::al_left);
textstyleRestore();
if (_myLink != textlnkOver()) {
if (wasMy || _myLink || rect().contains(m)) {
@@ -165,7 +165,7 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
// draw box title / text
p.setPen(st::black->p);
textstyleSet(&st::boxTextStyle);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, style::al_left);
_text.drawLeftElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, width(), 16, style::al_left);
textstyleRestore();
}
@@ -259,7 +259,7 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
// draw box title / text
p.setPen(st::black->p);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, style::al_left);
_text.drawLeftElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, width(), 16, style::al_left);
QTextOption option(style::al_left);
option.setWrapMode(QTextOption::WrapAnywhere);

View File

@@ -341,7 +341,7 @@ void ContactsInner::paintDialog(Painter &p, PeerData *peer, ContactData *data, b
namew -= st::verifiedCheck.pxWidth() + st::verifiedCheckPos.x();
p.drawSpriteLeft(namex + qMin(data->name.maxWidth(), namew) + st::verifiedCheckPos.x(), st::contactsPadding.top() + st::contactsNameTop + st::verifiedCheckPos.y(), width(), st::verifiedCheck);
}
data->name.drawElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew);
data->name.drawLeftElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew, width());
if (_chat || (_creating != CreatingGroupNone && (!_channel || _channelFilter != MembersFilterAdmins))) {
if (sel || data->check) {
@@ -1641,7 +1641,7 @@ void MembersInner::paintDialog(Painter &p, PeerData *peer, MemberData *data, boo
namew -= st::verifiedCheck.pxWidth() + st::verifiedCheckPos.x();
p.drawSpriteLeft(namex + qMin(data->name.maxWidth(), namew) + st::verifiedCheckPos.x(), st::contactsPadding.top() + st::contactsNameTop + st::verifiedCheckPos.y(), width(), st::verifiedCheck);
}
data->name.drawElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew);
data->name.drawLeftElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew, width());
if (data->canKick) {
p.setFont((kickSel ? st::linkOverFont : st::linkFont)->f);

View File

@@ -35,7 +35,7 @@ PasscodeBox::PasscodeBox(bool turningOff) : AbstractBox(st::boxWidth)
, _hasRecovery(false)
, _skipEmailWarning(false)
, _aboutHeight(0)
, _about(st::boxWidth - st::boxPadding.left() - st::boxPadding.right())
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
, _saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::defaultBoxButton)
, _cancelButton(this, lang(lng_cancel), st::cancelBoxButton)
, _oldPasscode(this, st::defaultInputField, lang(lng_passcode_enter_old))
@@ -58,7 +58,7 @@ PasscodeBox::PasscodeBox(const QByteArray &newSalt, const QByteArray &curSalt, b
, _hasRecovery(hasRecovery)
, _skipEmailWarning(false)
, _aboutHeight(0)
, _about(st::boxWidth - st::boxPadding.left() - st::boxPadding.right())
, _about(st::boxWidth - st::boxPadding.left() * 1.5)
, _saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::defaultBoxButton)
, _cancelButton(this, lang(lng_cancel), st::cancelBoxButton)
, _oldPasscode(this, st::defaultInputField, lang(lng_cloud_password_enter_old))
@@ -79,7 +79,7 @@ void PasscodeBox::init() {
textstyleSet(&st::usernameTextStyle);
_about.setRichText(st::normalFont, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() - st::boxPadding.right());
_aboutHeight = _about.countHeight(st::boxWidth - st::boxPadding.left() * 1.5);
textstyleRestore();
if (_turningOff) {
_oldPasscode.show();
@@ -213,29 +213,29 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
textstyleSet(&st::usernameTextStyle);
int32 w = width() - st::boxPadding.left() - st::boxPadding.right();
int32 w = st::boxWidth - st::boxPadding.left() * 1.5;
int32 abouty = (_passwordHint.isHidden() ? (_reenterPasscode.isHidden() ? (_oldPasscode.y() + (_hasRecovery && !_hintText.isEmpty() ? st::passcodeSkip : 0)) : _reenterPasscode.y()) + st::passcodeSkip : _passwordHint.y() + st::contactSkip) + _oldPasscode.height();
p.setPen(st::black);
_about.draw(p, st::boxPadding.left(), abouty, w);
_about.drawLeft(p, st::boxPadding.left(), abouty, w, width());
if (!_hintText.isEmpty() && _oldError.isEmpty()) {
p.setPen(st::black->p);
_hintText.drawElided(p, st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height() + ((st::passcodeSkip - st::normalFont->height) / 2), w, 1, style::al_topleft);
_hintText.drawLeftElided(p, st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height() + ((st::passcodeSkip - st::normalFont->height) / 2), w, width(), 1, style::al_topleft);
}
if (!_oldError.isEmpty()) {
p.setPen(st::setErrColor->p);
p.drawText(QRect(st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height(), width() - st::boxPadding.left() - st::boxPadding.right(), st::passcodeSkip), _oldError, style::al_left);
p.drawText(QRect(st::boxPadding.left(), _oldPasscode.y() + _oldPasscode.height(), w, st::passcodeSkip), _oldError, style::al_left);
}
if (!_newError.isEmpty()) {
p.setPen(st::setErrColor->p);
p.drawText(QRect(st::boxPadding.left(), _reenterPasscode.y() + _reenterPasscode.height(), width() - st::boxPadding.left() - st::boxPadding.right(), st::passcodeSkip), _newError, style::al_left);
p.drawText(QRect(st::boxPadding.left(), _reenterPasscode.y() + _reenterPasscode.height(), w, st::passcodeSkip), _newError, style::al_left);
}
if (!_emailError.isEmpty()) {
p.setPen(st::setErrColor->p);
p.drawText(QRect(st::boxPadding.left(), _recoverEmail.y() + _recoverEmail.height(), width() - st::boxPadding.left() - st::boxPadding.right(), st::passcodeSkip), _emailError, style::al_left);
p.drawText(QRect(st::boxPadding.left(), _recoverEmail.y() + _recoverEmail.height(), w, st::passcodeSkip), _emailError, style::al_left);
}
textstyleRestore();
@@ -243,7 +243,7 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
void PasscodeBox::resizeEvent(QResizeEvent *e) {
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
int32 w = width() - st::boxPadding.left() - st::boxPadding.right();
int32 w = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
_oldPasscode.resize(w, _oldPasscode.height());
_oldPasscode.moveToLeft(st::boxPadding.left(), st::boxTitleHeight + st::passcodePadding.top());
_newPasscode.resize(w, _newPasscode.height());
@@ -498,7 +498,7 @@ bool PasscodeBox::recoverStartFail(const RPCError &error) {
RecoverBox::RecoverBox(const QString &pattern) : AbstractBox(st::boxWidth)
, _submitRequest(0)
, _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() - st::boxPadding.right()))
, _pattern(st::normalFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWidth - st::boxPadding.left() * 1.5))
, _saveButton(this, lang(lng_passcode_submit), st::defaultBoxButton)
, _cancelButton(this, lang(lng_cancel), st::cancelBoxButton)
, _recoverCode(this, st::defaultInputField, lang(lng_signin_code)) {
@@ -537,7 +537,7 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
p.setFont(st::normalFont);
p.setPen(st::black);
int32 w = width() - st::boxPadding.left() - st::boxPadding.right();
int32 w = st::boxWidth - st::boxPadding.left() * 1.5;
p.drawText(QRect(st::boxPadding.left(), _recoverCode.y() - st::passcodeSkip - st::passcodePadding.top(), w, st::passcodePadding.top() + st::passcodeSkip), _pattern, style::al_left);
if (!_error.isEmpty()) {
@@ -547,7 +547,8 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
}
void RecoverBox::resizeEvent(QResizeEvent *e) {
_recoverCode.setGeometry(st::boxPadding.left(), st::boxTitleHeight + st::passcodePadding.top() + st::passcodeSkip, width() - st::boxPadding.left() - st::boxPadding.right(), _recoverCode.height());
_recoverCode.resize(st::boxWidth - st::boxPadding.left() - st::boxPadding.right(), _recoverCode.height());
_recoverCode.moveToLeft(st::boxPadding.left(), st::boxTitleHeight + st::passcodePadding.top() + st::passcodeSkip);
_saveButton.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton.height());
_cancelButton.moveToRight(st::boxButtonPadding.right() + _saveButton.width() + st::boxButtonPadding.left(), _saveButton.y());

View File

@@ -267,7 +267,7 @@ void PhotoSendBox::onSend(bool ctrlShiftEnter) {
}
if (_compressed.isHidden() || _compressed.checked()) {
_img->ctrlShiftEnter = ctrlShiftEnter;
_img->caption = _caption.isHidden() ? QString() : _caption.getLastText();
_img->caption = _caption.isHidden() ? QString() : prepareSentText(_caption.getLastText());
if (App::main()) App::main()->confirmSendImage(*_img);
} else {
if (App::main()) App::main()->confirmSendImageUncompressed(ctrlShiftEnter, _replyTo);

View File

@@ -102,8 +102,8 @@ void UsernameBox::paintEvent(QPaintEvent *e) {
}
p.setPen(st::black);
textstyleSet(&st::usernameTextStyle);
int32 availw = st::boxWidth - st::usernamePadding.left(), h = _about.countHeight(availw);
_about.draw(p, st::usernamePadding.left(), _username.y() + _username.height() + st::usernameSkip, availw);
int32 availw = st::boxWidth - st::usernamePadding.left() - st::usernamePadding.right(), h = _about.countHeight(availw);
_about.drawLeft(p, st::usernamePadding.left(), _username.y() + _username.height() + st::usernameSkip, availw, width());
textstyleRestore();
int32 linky = _username.y() + _username.height() + st::usernameSkip + h + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2);
@@ -121,7 +121,7 @@ void UsernameBox::resizeEvent(QResizeEvent *e) {
_username.moveToLeft(st::usernamePadding.left(), st::boxTitleHeight + st::usernamePadding.top());
textstyleSet(&st::usernameTextStyle);
int32 availw = st::boxWidth - st::usernamePadding.left(), h = _about.countHeight(availw);
int32 availw = st::boxWidth - st::usernamePadding.left() - st::usernamePadding.right(), h = _about.countHeight(availw);
textstyleRestore();
int32 linky = _username.y() + _username.height() + st::usernameSkip + h + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2);
_link.moveToLeft(st::usernamePadding.left(), linky + st::usernameTextStyle.lineHeight + ((st::usernameTextStyle.lineHeight - st::boxTextFont->height) / 2));