Closed beta 10019014: New input fields design and animations.

This commit is contained in:
John Preston 2016-12-09 21:56:01 +03:00
parent 2d48cde27a
commit 90234cb7a0
51 changed files with 1068 additions and 940 deletions

View file

@ -394,15 +394,6 @@ radialPeriod: 3000;
radialFg: #ffffff; radialFg: #ffffff;
radialBg: #00000056; radialBg: #00000056;
downloadPathSkip: 10px;
usernamePadding: margins(23px, 22px, 21px, 12px);
usernameSkip: 49px;
usernameTextStyle: TextStyle(defaultTextStyle) {
lineHeight: 20px;
}
usernameDefaultFg: #777777;
youtubeIcon: icon { youtubeIcon: icon {
{ "media_youtube_play_bg", #e83131c8 }, { "media_youtube_play_bg", #e83131c8 },
{ "media_youtube_play", #ffffff, point(24px, 12px) }, { "media_youtube_play", #ffffff, point(24px, 12px) },

View file

@ -154,6 +154,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_phone_notreg" = "If you don't have a Telegram account yet,\nplease [b]sign up[/b] with {link_start}Android / iPhone{link_end} or {signup_start}here{signup_end}"; "lng_phone_notreg" = "If you don't have a Telegram account yet,\nplease [b]sign up[/b] with {link_start}Android / iPhone{link_end} or {signup_start}here{signup_end}";
"lng_country_code" = "Country Code"; "lng_country_code" = "Country Code";
"lng_bad_country_code" = "Invalid Country Code"; "lng_bad_country_code" = "Invalid Country Code";
"lng_country_fake_ph" = "Your country";
"lng_country_ph" = "Search"; "lng_country_ph" = "Search";
"lng_country_done" = "Done"; "lng_country_done" = "Done";
"lng_country_none" = "Country not found"; "lng_country_none" = "Country not found";
@ -351,6 +352,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_passcode_wrong" = "Wrong passcode"; "lng_passcode_wrong" = "Wrong passcode";
"lng_passcode_is_same" = "Passcode was not changed"; "lng_passcode_is_same" = "Passcode was not changed";
"lng_passcode_enter" = "Enter your local passcode"; "lng_passcode_enter" = "Enter your local passcode";
"lng_passcode_ph" = "Your passcode";
"lng_passcode_submit" = "Submit"; "lng_passcode_submit" = "Submit";
"lng_passcode_logout" = "Log out"; "lng_passcode_logout" = "Log out";
"lng_passcode_need_unblock" = "You need to unlock me first."; "lng_passcode_need_unblock" = "You need to unlock me first.";

View file

@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,19,13 FILEVERSION 0,10,19,14
PRODUCTVERSION 0,10,19,13 PRODUCTVERSION 0,10,19,14
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.10.19.13" VALUE "FileVersion", "0.10.19.14"
VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.19.13" VALUE "ProductVersion", "0.10.19.14"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,10,19,13 FILEVERSION 0,10,19,14
PRODUCTVERSION 0,10,19,13 PRODUCTVERSION 0,10,19,14
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -43,10 +43,10 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileDescription", "Telegram Updater" VALUE "FileDescription", "Telegram Updater"
VALUE "FileVersion", "0.10.19.13" VALUE "FileVersion", "0.10.19.14"
VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.10.19.13" VALUE "ProductVersion", "0.10.19.14"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -239,9 +239,7 @@ void AddContactBox::onRetry() {
_retry->hide(); _retry->hide();
resizeEvent(0); resizeEvent(0);
_first->setText(QString()); _first->setText(QString());
_first->updatePlaceholder();
_last->setText(QString()); _last->setText(QString());
_last->updatePlaceholder();
_phone->clearText(); _phone->clearText();
_phone->setDisabled(false); _phone->setDisabled(false);
_first->setFocus(); _first->setFocus();
@ -274,13 +272,11 @@ GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : Ab
connect(_next, SIGNAL(clicked()), this, SLOT(onNext())); connect(_next, SIGNAL(clicked()), this, SLOT(onNext()));
connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
_photo->setClickedCallback([this] { _photo->setClickedCallback(App::LambdaDelayed(st::defaultActiveButton.ripple.hideDuration, this, [this] {
App::CallDelayed(st::defaultActiveButton.ripple.hideDuration, base::lambda_guarded(this, [this] {
auto imgExtensions = cImgExtensions(); auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); _setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
})); }));
});
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
notifyFileQueryUpdated(update); notifyFileQueryUpdated(update);
}); });
@ -433,7 +429,7 @@ SetupChannelBox::SetupChannelBox(ChannelData *channel, bool existing) : Abstract
, _aboutPublicWidth(width() - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultBoxCheckbox.textPosition.x()) , _aboutPublicWidth(width() - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultBoxCheckbox.textPosition.x())
, _aboutPublic(st::normalFont, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth) , _aboutPublic(st::normalFont, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth)
, _aboutPrivate(st::normalFont, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth) , _aboutPrivate(st::normalFont, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth)
, _link(this, st::defaultInputField, QString(), channel->username, true) , _link(this, st::setupChannelLink, QString(), channel->username, true)
, _linkOver(false) , _linkOver(false)
, _save(this, lang(lng_settings_save), st::defaultBoxButton) , _save(this, lang(lng_settings_save), st::defaultBoxButton)
, _skip(this, lang(existing ? lng_cancel : lng_create_group_skip), st::cancelBoxButton) { , _skip(this, lang(existing ? lng_cancel : lng_create_group_skip), st::cancelBoxButton) {

View file

@ -97,6 +97,7 @@ boxLinkButton: LinkButton {
} }
boxOptionListPadding: margins(2px, 20px, 2px, 2px); boxOptionListPadding: margins(2px, 20px, 2px, 2px);
boxOptionInputSkip: 6px;
boxVerticalMargin: 10px; boxVerticalMargin: 10px;
boxWidth: 320px; boxWidth: 320px;
@ -146,7 +147,7 @@ boxPhotoTitleFont: font(16px semibold);
boxPhotoTitlePosition: point(28px, 26px); boxPhotoTitlePosition: point(28px, 26px);
boxPhotoPadding: margins(28px, 28px, 28px, 0px); boxPhotoPadding: margins(28px, 28px, 28px, 0px);
boxPhotoCompressedSkip: 20px; boxPhotoCompressedSkip: 20px;
boxPhotoCaptionSkip: 22px; boxPhotoCaptionSkip: 8px;
boxPhotoTextFg: #808080; boxPhotoTextFg: #808080;
cropPointSize: 10px; cropPointSize: 10px;
@ -202,7 +203,7 @@ aboutRevokePublicLabel: FlatLabel(defaultFlatLabel) {
contactUserIcon: icon {{ "add_contact_user", #999999 }}; contactUserIcon: icon {{ "add_contact_user", #999999 }};
contactPhoneIcon: icon {{ "add_contact_phone", #999999 }}; contactPhoneIcon: icon {{ "add_contact_phone", #999999 }};
contactIconTop: 10px; contactIconTop: 28px;
contactsAddIconAbove: icon {{ "contacts_add", activeButtonFg, point(18px, 18px) }}; contactsAddIconAbove: icon {{ "contacts_add", activeButtonFg, point(18px, 18px) }};
contactsAdd: TwoIconButton { contactsAdd: TwoIconButton {
@ -222,8 +223,8 @@ contactsAdd: TwoIconButton {
} }
contactsAddPosition: point(14px, 8px); contactsAddPosition: point(14px, 8px);
contactPadding: margins(49px, 22px, 0px, 6px); contactPadding: margins(49px, 2px, 0px, 6px);
contactSkip: 13px; contactSkip: 6px;
contactPhoneSkip: 30px; contactPhoneSkip: 30px;
contactsPhotoSize: 42px; contactsPhotoSize: 42px;
@ -283,13 +284,16 @@ contactsMultiSelect: MultiSelect {
placeholderFg: #999999; placeholderFg: #999999;
placeholderFgActive: #aaaaaa; placeholderFgActive: #aaaaaa;
placeholderFgError: #aaaaaa;
placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderMargins: margins(2px, 0px, 2px, 0px);
placeholderScale: 0.;
placeholderFont: normalFont;
border: 0px; border: 0px;
borderActive: 0px; borderActive: 0px;
borderError: 0px; borderError: 0px;
height: 32px; heightMin: 32px;
font: normalFont; font: normalFont;
} }
@ -406,20 +410,23 @@ sessionTerminateAllButton: LinkButton(boxLinkButton) {
passcodeHeaderFont: font(19px); passcodeHeaderFont: font(19px);
passcodeHeaderHeight: 80px; passcodeHeaderHeight: 80px;
passcodeInput: introPhone; passcodeInput: InputField(introPhone) {
textMargins: margins(1px, 27px, 1px, 6px);
}
passcodeSubmit: RoundButton(introNextButton) { passcodeSubmit: RoundButton(introNextButton) {
width: 225px; width: 225px;
} }
passcodeSubmitSkip: 40px; passcodeSubmitSkip: 40px;
passcodePadding: margins(0px, 22px, 0px, 3px); passcodePadding: margins(0px, 6px, 0px, 13px);
passcodeSkip: 31px; passcodeTextLine: 28px;
passcodeSkip: 21px;
newGroupAboutFg: #808080; newGroupAboutFg: #808080;
newGroupPadding: margins(4px, 6px, 4px, 3px); newGroupPadding: margins(4px, 6px, 4px, 3px);
newGroupSkip: 17px; newGroupSkip: 27px;
newGroupInfoPadding: margins(0px, -4px, 0px, 1px); newGroupInfoPadding: margins(0px, -4px, 0px, 1px);
newGroupLinkPadding: margins(4px, 27px, 4px, 12px); newGroupLinkPadding: margins(4px, 27px, 4px, 21px);
newGroupLinkTop: 3px; newGroupLinkTop: 3px;
newGroupLinkFont: font(16px); newGroupLinkFont: font(16px);
@ -428,12 +435,17 @@ newGroupPhotoIcon: icon {{ "new_chat_photo", #ffffff }};
newGroupPhotoIconPosition: point(23px, 25px); newGroupPhotoIconPosition: point(23px, 25px);
newGroupPhotoDuration: 150; newGroupPhotoDuration: 150;
newGroupNamePosition: point(27px, 20px); newGroupNamePosition: point(27px, 5px);
newGroupDescriptionPadding: margins(0px, 23px, 0px, 14px); newGroupDescriptionPadding: margins(0px, 13px, 0px, 4px);
newGroupDescription: InputArea(defaultInputArea) { newGroupDescription: InputField(defaultInputField) {
textMargins: margins(1px, 6px, 1px, 4px); textMargins: margins(1px, 26px, 1px, 4px);
heightMax: 115px; heightMax: 135px;
}
setupChannelLink: InputField(defaultInputField) {
textMargins: margins(0px, 6px, 0px, 4px);
heightMin: 32px;
} }
newGroupPublicLinkPadding: margins(0px, 20px, 0px, 5px); newGroupPublicLinkPadding: margins(0px, 20px, 0px, 5px);
@ -463,14 +475,14 @@ aboutTextStyle: TextStyle(defaultTextStyle) {
lineHeight: 22px; lineHeight: 22px;
} }
editTextArea: InputArea(defaultInputArea) { editTextArea: InputField(defaultInputField) {
textMargins: margins(1px, 6px, 1px, 4px); textMargins: margins(1px, 26px, 1px, 4px);
heightMax: 256px; heightMax: 276px;
} }
confirmCaptionArea: InputArea(defaultInputArea) { confirmCaptionArea: InputField(defaultInputField) {
textMargins: margins(1px, 6px, 1px, 4px); textMargins: margins(1px, 26px, 1px, 4px);
heightMax: 56px; heightMax: 78px;
} }
confirmBg: windowBgOver; confirmBg: windowBgOver;
confirmMaxHeight: 245px; confirmMaxHeight: 245px;
@ -501,3 +513,12 @@ backgroundScroll: FlatScroll(boxScroll) {
deltat: 10px; deltat: 10px;
deltab: 0px; deltab: 0px;
} }
usernamePadding: margins(23px, 6px, 21px, 12px);
usernameSkip: 49px;
usernameTextStyle: TextStyle(defaultTextStyle) {
lineHeight: 20px;
}
usernameDefaultFg: #777777;
downloadPathSkip: 10px;

View file

@ -61,7 +61,7 @@ ConnectionBox::ConnectionBox() : AbstractBox(st::boxWidth, lang(lng_connection_h
void ConnectionBox::updateControlsVisibility() { void ConnectionBox::updateControlsVisibility() {
int32 h = titleHeight() + st::boxOptionListPadding.top() + _autoRadio->heightNoMargins() + st::boxOptionListPadding.top() + _httpProxyRadio->heightNoMargins() + st::boxOptionListPadding.top() + _tcpProxyRadio->heightNoMargins() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6->heightNoMargins() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom(); int32 h = titleHeight() + st::boxOptionListPadding.top() + _autoRadio->heightNoMargins() + st::boxOptionListPadding.top() + _httpProxyRadio->heightNoMargins() + st::boxOptionListPadding.top() + _tcpProxyRadio->heightNoMargins() + st::boxOptionListPadding.top() + st::connectionIPv6Skip + _tryIPv6->heightNoMargins() + st::boxOptionListPadding.bottom() + st::boxPadding.bottom() + st::boxButtonPadding.top() + _save->height() + st::boxButtonPadding.bottom();
if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) { if (_httpProxyRadio->checked() || _tcpProxyRadio->checked()) {
h += 2 * st::boxOptionListPadding.top() + 2 * _hostInput->height(); h += 2 * st::boxOptionInputSkip + 2 * _hostInput->height();
_hostInput->show(); _hostInput->show();
_portInput->show(); _portInput->show();
_userInput->show(); _userInput->show();
@ -89,19 +89,19 @@ void ConnectionBox::resizeEvent(QResizeEvent *e) {
int32 inputy = 0; int32 inputy = 0;
if (_httpProxyRadio->checked()) { if (_httpProxyRadio->checked()) {
inputy = _httpProxyRadio->bottomNoMargins() + st::boxOptionListPadding.top(); inputy = _httpProxyRadio->bottomNoMargins() + st::boxOptionInputSkip;
_tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionListPadding.top() + 2 * _hostInput->height() + st::boxOptionListPadding.top()); _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), inputy + st::boxOptionInputSkip + 2 * _hostInput->height() + st::boxOptionListPadding.top());
} else { } else {
_tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio->bottomNoMargins() + st::boxOptionListPadding.top()); _tcpProxyRadio->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left(), _httpProxyRadio->bottomNoMargins() + st::boxOptionListPadding.top());
if (_tcpProxyRadio->checked()) { if (_tcpProxyRadio->checked()) {
inputy = _tcpProxyRadio->bottomNoMargins() + st::boxOptionListPadding.top(); inputy = _tcpProxyRadio->bottomNoMargins() + st::boxOptionInputSkip;
} }
} }
if (inputy) { if (inputy) {
_hostInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), inputy); _hostInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), inputy);
_portInput->moveToRight(st::boxPadding.right(), inputy); _portInput->moveToRight(st::boxPadding.right(), inputy);
_userInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput->y() + _hostInput->height() + st::boxOptionListPadding.top()); _userInput->moveToLeft(st::boxPadding.left() + st::boxOptionListPadding.left() + st::defaultBoxCheckbox.textPosition.x() - st::defaultInputField.textMargins.left(), _hostInput->y() + _hostInput->height() + st::boxOptionInputSkip);
_passwordInput->moveToRight(st::boxPadding.right(), _userInput->y()); _passwordInput->moveToRight(st::boxPadding.right(), _userInput->y());
} }
@ -120,7 +120,6 @@ void ConnectionBox::onChange() {
_hostInput->setFocus(); _hostInput->setFocus();
if (_httpProxyRadio->checked() && !_portInput->getLastText().toInt()) { if (_httpProxyRadio->checked() && !_portInput->getLastText().toInt()) {
_portInput->setText(qsl("80")); _portInput->setText(qsl("80"));
_portInput->updatePlaceholder();
} }
} }
update(); update();

View file

@ -75,13 +75,13 @@ void PasscodeBox::init() {
if (_turningOff) { if (_turningOff) {
_oldPasscode->show(); _oldPasscode->show();
setTitleText(lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove)); setTitleText(lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove));
setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom()); setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeTextLine + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeTextLine : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
} else { } else {
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : Global::LocalPasscode(); bool has = _cloudPwd ? (!_curSalt.isEmpty()) : Global::LocalPasscode();
if (has) { if (has) {
_oldPasscode->show(); _oldPasscode->show();
setTitleText(lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change)); setTitleText(lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change));
setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0) + _newPasscode->height() + st::contactSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::contactSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom()); setMaxHeight(titleHeight() + st::passcodePadding.top() + _oldPasscode->height() + st::passcodeTextLine + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeTextLine : 0) + _newPasscode->height() + st::contactSkip + _reenterPasscode->height() + st::passcodeSkip + (_cloudPwd ? _passwordHint->height() + st::contactSkip : 0) + _aboutHeight + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
} else { } else {
_oldPasscode->hide(); _oldPasscode->hide();
setTitleText(lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create)); setTitleText(lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create));
@ -160,27 +160,27 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
textstyleSet(&st::usernameTextStyle); textstyleSet(&st::usernameTextStyle);
int32 w = st::boxWidth - st::boxPadding.left() * 1.5; 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(); int32 abouty = (_passwordHint->isHidden() ? (_reenterPasscode->isHidden() ? (_oldPasscode->y() + (_hasRecovery && !_hintText.isEmpty() ? st::passcodeTextLine : 0)) : _reenterPasscode->y()) + st::passcodeSkip : _passwordHint->y() + st::contactSkip) + _oldPasscode->height() + st::passcodePadding.bottom();
p.setPen(st::boxTextFg); p.setPen(st::boxTextFg);
_about.drawLeft(p, st::boxPadding.left(), abouty, w, width()); _about.drawLeft(p, st::boxPadding.left(), abouty, w, width());
if (!_hintText.isEmpty() && _oldError.isEmpty()) { if (!_hintText.isEmpty() && _oldError.isEmpty()) {
_hintText.drawLeftElided(p, st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height() + ((st::passcodeSkip - st::normalFont->height) / 2), w, width(), 1, style::al_topleft); _hintText.drawLeftElided(p, st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height() + ((st::passcodeTextLine - st::normalFont->height) / 2), w, width(), 1, style::al_topleft);
} }
if (!_oldError.isEmpty()) { if (!_oldError.isEmpty()) {
p.setPen(st::boxTextFgError); p.setPen(st::boxTextFgError);
p.drawText(QRect(st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height(), w, st::passcodeSkip), _oldError, style::al_left); p.drawText(QRect(st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height(), w, st::passcodeTextLine), _oldError, style::al_left);
} }
if (!_newError.isEmpty()) { if (!_newError.isEmpty()) {
p.setPen(st::boxTextFgError); p.setPen(st::boxTextFgError);
p.drawText(QRect(st::boxPadding.left(), _reenterPasscode->y() + _reenterPasscode->height(), w, st::passcodeSkip), _newError, style::al_left); p.drawText(QRect(st::boxPadding.left(), _reenterPasscode->y() + _reenterPasscode->height(), w, st::passcodeTextLine), _newError, style::al_left);
} }
if (!_emailError.isEmpty()) { if (!_emailError.isEmpty()) {
p.setPen(st::boxTextFgError); p.setPen(st::boxTextFgError);
p.drawText(QRect(st::boxPadding.left(), _recoverEmail->y() + _recoverEmail->height(), w, st::passcodeSkip), _emailError, style::al_left); p.drawText(QRect(st::boxPadding.left(), _recoverEmail->y() + _recoverEmail->height(), w, st::passcodeTextLine), _emailError, style::al_left);
} }
textstyleRestore(); textstyleRestore();
@ -192,7 +192,7 @@ void PasscodeBox::resizeEvent(QResizeEvent *e) {
_oldPasscode->resize(w, _oldPasscode->height()); _oldPasscode->resize(w, _oldPasscode->height());
_oldPasscode->moveToLeft(st::boxPadding.left(), titleHeight() + st::passcodePadding.top()); _oldPasscode->moveToLeft(st::boxPadding.left(), titleHeight() + st::passcodePadding.top());
_newPasscode->resize(w, _newPasscode->height()); _newPasscode->resize(w, _newPasscode->height());
_newPasscode->moveToLeft(st::boxPadding.left(), _oldPasscode->y() + ((_turningOff || has) ? (_oldPasscode->height() + st::passcodeSkip + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeSkip : 0)) : 0)); _newPasscode->moveToLeft(st::boxPadding.left(), _oldPasscode->y() + ((_turningOff || has) ? (_oldPasscode->height() + st::passcodeTextLine + ((_hasRecovery && !_hintText.isEmpty()) ? st::passcodeTextLine : 0)) : 0));
_reenterPasscode->resize(w, _reenterPasscode->height()); _reenterPasscode->resize(w, _reenterPasscode->height());
_reenterPasscode->moveToLeft(st::boxPadding.left(), _newPasscode->y() + _newPasscode->height() + st::contactSkip); _reenterPasscode->moveToLeft(st::boxPadding.left(), _newPasscode->y() + _newPasscode->height() + st::contactSkip);
_passwordHint->resize(w, _passwordHint->height()); _passwordHint->resize(w, _passwordHint->height());
@ -201,7 +201,7 @@ void PasscodeBox::resizeEvent(QResizeEvent *e) {
_recoverEmail->moveToLeft(st::boxPadding.left(), _passwordHint->y() + _passwordHint->height() + st::contactSkip + _aboutHeight + st::contactSkip); _recoverEmail->moveToLeft(st::boxPadding.left(), _passwordHint->y() + _passwordHint->height() + st::contactSkip + _aboutHeight + st::contactSkip);
if (!_recover->isHidden()) { if (!_recover->isHidden()) {
_recover->moveToLeft(st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height() + (_hintText.isEmpty() ? ((st::passcodeSkip - _recover->height()) / 2) : st::passcodeSkip)); _recover->moveToLeft(st::boxPadding.left(), _oldPasscode->y() + _oldPasscode->height() + (_hintText.isEmpty() ? ((st::passcodeTextLine - _recover->height()) / 2) : st::passcodeTextLine));
} }
_saveButton->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton->height()); _saveButton->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton->height());
@ -455,7 +455,7 @@ RecoverBox::RecoverBox(const QString &pattern) : AbstractBox(st::boxWidth, lang(
, _recoverCode(this, st::defaultInputField, lang(lng_signin_code)) { , _recoverCode(this, st::defaultInputField, lang(lng_signin_code)) {
setBlockTitle(true); setBlockTitle(true);
setMaxHeight(titleHeight() + st::passcodePadding.top() + st::passcodeSkip + _recoverCode->height() + st::passcodeSkip + st::passcodePadding.bottom() + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom()); setMaxHeight(titleHeight() + st::passcodePadding.top() + st::passcodePadding.bottom() + st::passcodeTextLine + _recoverCode->height() + st::passcodeTextLine + st::boxButtonPadding.top() + _saveButton->height() + st::boxButtonPadding.bottom());
connect(_saveButton, SIGNAL(clicked()), this, SLOT(onSubmit())); connect(_saveButton, SIGNAL(clicked()), this, SLOT(onSubmit()));
connect(_cancelButton, SIGNAL(clicked()), this, SLOT(onClose())); connect(_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
@ -474,17 +474,17 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.setPen(st::boxTextFg); p.setPen(st::boxTextFg);
int32 w = st::boxWidth - st::boxPadding.left() * 1.5; 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); p.drawText(QRect(st::boxPadding.left(), _recoverCode->y() - st::passcodeTextLine - st::passcodePadding.top(), w, st::passcodePadding.top() + st::passcodeTextLine), _pattern, style::al_left);
if (!_error.isEmpty()) { if (!_error.isEmpty()) {
p.setPen(st::boxTextFgError); p.setPen(st::boxTextFgError);
p.drawText(QRect(st::boxPadding.left(), _recoverCode->y() + _recoverCode->height(), w, st::passcodeSkip), _error, style::al_left); p.drawText(QRect(st::boxPadding.left(), _recoverCode->y() + _recoverCode->height(), w, st::passcodeTextLine), _error, style::al_left);
} }
} }
void RecoverBox::resizeEvent(QResizeEvent *e) { void RecoverBox::resizeEvent(QResizeEvent *e) {
_recoverCode->resize(st::boxWidth - 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(), titleHeight() + st::passcodePadding.top() + st::passcodeSkip); _recoverCode->moveToLeft(st::boxPadding.left(), titleHeight() + st::passcodePadding.top() + st::passcodePadding.bottom() + st::passcodeTextLine);
_saveButton->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton->height()); _saveButton->moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _saveButton->height());
_cancelButton->moveToRight(st::boxButtonPadding.right() + _saveButton->width() + st::boxButtonPadding.left(), _saveButton->y()); _cancelButton->moveToRight(st::boxButtonPadding.right() + _saveButton->width() + st::boxButtonPadding.left(), _saveButton->y());

View file

@ -71,7 +71,7 @@ void ReportBox::onChange() {
if (!_reasonOtherText) { if (!_reasonOtherText) {
_reasonOtherText.create(this, st::profileReportReasonOther, lang(lng_report_reason_description)); _reasonOtherText.create(this, st::profileReportReasonOther, lang(lng_report_reason_description));
_reasonOtherText->show(); _reasonOtherText->show();
_reasonOtherText->setCtrlEnterSubmit(Ui::CtrlEnterSubmitBoth); _reasonOtherText->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both);
_reasonOtherText->setMaxLength(MaxPhotoCaption); _reasonOtherText->setMaxLength(MaxPhotoCaption);
_reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height()); _reasonOtherText->resize(width() - (st::boxPadding.left() + st::boxOptionListPadding.left() + st::boxPadding.right()), _reasonOtherText->height());

View file

@ -157,7 +157,7 @@ void SendFilesBox::setup() {
} }
if (_caption) { if (_caption) {
_caption->setMaxLength(MaxPhotoCaption); _caption->setMaxLength(MaxPhotoCaption);
_caption->setCtrlEnterSubmit(Ui::CtrlEnterSubmitBoth); _caption->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both);
connect(_caption, SIGNAL(resized()), this, SLOT(onCaptionResized())); connect(_caption, SIGNAL(resized()), this, SLOT(onCaptionResized()));
connect(_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool))); connect(_caption, SIGNAL(submitted(bool)), this, SLOT(onSend(bool)));
connect(_caption, SIGNAL(cancelled()), this, SLOT(onClose())); connect(_caption, SIGNAL(cancelled()), this, SLOT(onClose()));
@ -484,13 +484,13 @@ EditCaptionBox::EditCaptionBox(HistoryItem *msg) : AbstractBox(st::boxWideWidth)
if (_animated || _photo || _doc) { if (_animated || _photo || _doc) {
_field.create(this, st::confirmCaptionArea, lang(lng_photo_caption), caption); _field.create(this, st::confirmCaptionArea, lang(lng_photo_caption), caption);
_field->setMaxLength(MaxPhotoCaption); _field->setMaxLength(MaxPhotoCaption);
_field->setCtrlEnterSubmit(Ui::CtrlEnterSubmitBoth); _field->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both);
} else { } else {
auto original = msg->originalText(); auto original = msg->originalText();
QString text = textApplyEntities(original.text, original.entities); QString text = textApplyEntities(original.text, original.entities);
_field.create(this, st::editTextArea, lang(lng_photo_caption), text); _field.create(this, st::editTextArea, lang(lng_photo_caption), text);
// _field->setMaxLength(MaxMessageSize); // entities can make text in input field larger but still valid // _field->setMaxLength(MaxMessageSize); // entities can make text in input field larger but still valid
_field->setCtrlEnterSubmit(cCtrlEnter() ? Ui::CtrlEnterSubmitCtrlEnter : Ui::CtrlEnterSubmitEnter); _field->setCtrlEnterSubmit(cCtrlEnter() ? Ui::CtrlEnterSubmit::CtrlEnter : Ui::CtrlEnterSubmit::Enter);
} }
updateBoxSize(); updateBoxSize();
connect(_field, SIGNAL(submitted(bool)), this, SLOT(onSave(bool))); connect(_field, SIGNAL(submitted(bool)), this, SLOT(onSave(bool)));

View file

@ -29,13 +29,12 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
UsernameBox::UsernameBox() : AbstractBox(st::boxWidth, lang(lng_username_title)), UsernameBox::UsernameBox() : AbstractBox(st::boxWidth, lang(lng_username_title))
_save(this, lang(lng_settings_save), st::defaultBoxButton), , _save(this, lang(lng_settings_save), st::defaultBoxButton)
_cancel(this, lang(lng_cancel), st::cancelBoxButton), , _cancel(this, lang(lng_cancel), st::cancelBoxButton)
_username(this, st::defaultInputField, qsl("@username"), App::self()->username, false), , _username(this, st::defaultInputField, qsl("@username"), App::self()->username, false)
_link(this, QString(), st::boxLinkButton), , _link(this, QString(), st::boxLinkButton)
_saveRequestId(0), _checkRequestId(0), , _about(st::boxWidth - st::usernamePadding.left()) {
_about(st::boxWidth - st::usernamePadding.left()) {
setBlockTitle(true); setBlockTitle(true);
_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available); _goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);

View file

@ -63,7 +63,8 @@ private:
ChildWidget<Ui::UsernameInput> _username; ChildWidget<Ui::UsernameInput> _username;
ChildWidget<Ui::LinkButton> _link; ChildWidget<Ui::LinkButton> _link;
mtpRequestId _saveRequestId, _checkRequestId; mtpRequestId _saveRequestId = 0;
mtpRequestId _checkRequestId = 0;
QString _sentUsername, _checkUsername, _errorText, _goodText, _copiedTextLink; QString _sentUsername, _checkUsername, _errorText, _goodText, _copiedTextLink;
Text _about; Text _about;

View file

@ -424,11 +424,17 @@ public:
using return_type = typename lambda_type<Lambda>::return_type; using return_type = typename lambda_type<Lambda>::return_type;
template <typename ...PointersAndLambda> template <typename ...PointersAndLambda>
lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) { inline lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
}
inline lambda_guard_data(const lambda_guard_data &other) : _lambda(other._lambda) {
for (auto i = 0; i != N; ++i) {
_pointers[i] = other._pointers[i];
}
} }
template <typename ...Args> template <typename ...Args>
inline return_type operator()(Args... args) const { inline return_type operator()(Args&&... args) const {
for (int i = 0; i != N; ++i) { for (int i = 0; i != N; ++i) {
if (!_pointers[i]) { if (!_pointers[i]) {
return return_type(); return return_type();
@ -458,17 +464,44 @@ public:
using return_type = typename lambda_type<Lambda>::return_type; using return_type = typename lambda_type<Lambda>::return_type;
template <typename ...PointersAndLambda> template <typename ...PointersAndLambda>
lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std_::make_unique<lambda_guard_data<N, Lambda>>(std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) { inline lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std_::make_unique<lambda_guard_data<N, Lambda>>(std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
static_assert(sizeof...(PointersAndLambda) == N + 1, "Wrong argument count!"); static_assert(sizeof...(PointersAndLambda) == N + 1, "Wrong argument count!");
} }
inline lambda_guard(const lambda_guard &&other) : _data(std_::move(other._data)) {
}
inline lambda_guard(lambda_guard &&other) : _data(std_::move(other._data)) {
}
inline lambda_guard &operator=(const lambda_guard &&other) {
_data = std_::move(other._data);
return *this;
}
inline lambda_guard &operator=(lambda_guard &&other) {
_data = std_::move(other._data);
return *this;
}
template <typename ...Args> template <typename ...Args>
inline return_type operator()(Args... args) const { inline return_type operator()(Args&&... args) const {
return (*_data)(std_::forward<Args>(args)...); return (*_data)(std_::forward<Args>(args)...);
} }
bool isNull() const {
return !_data;
}
lambda_guard clone() const {
return lambda_guard(*this);
}
private: private:
std_::unique_ptr<lambda_guard_data<N, Lambda>> _data; inline lambda_guard(const lambda_guard &other) : _data(std_::make_unique<lambda_guard_data<N, Lambda>>(static_cast<const lambda_guard_data<N, Lambda> &>(*other._data))) {
}
mutable std_::unique_ptr<lambda_guard_data<N, Lambda>> _data;
}; };

View file

@ -335,7 +335,8 @@ TimeMs getms(bool checked) {
return ((msCount - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0LL); return ((msCount - _msStart) * _msFreq) + (checked ? _msAddToMsStart : 0LL);
#else #else
timespec ts; timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { auto res = clock_gettime(CLOCK_MONOTONIC, &ts);
if (res != 0) {
LOG(("Bad clock_gettime result: %1").arg(res)); LOG(("Bad clock_gettime result: %1").arg(res));
return 0; return 0;
} }

View file

@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "core/utils.h" #include "core/utils.h"
#define BETA_VERSION_MACRO (10019013ULL) #define BETA_VERSION_MACRO (10019014ULL)
constexpr int AppVersion = 10020; constexpr int AppVersion = 10020;
constexpr str_const AppVersionStr = "0.10.20"; constexpr str_const AppVersionStr = "0.10.20";

View file

@ -37,11 +37,14 @@ Q_DECLARE_METATYPE(Qt::MouseButton);
Q_DECLARE_METATYPE(Ui::ShowWay); Q_DECLARE_METATYPE(Ui::ShowWay);
namespace App { namespace App {
namespace internal {
void CallDelayed(int duration, base::lambda<void()> &&lambda) { void CallDelayed(int duration, base::lambda<void()> &&lambda) {
QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std_::move(lambda)), SLOT(action())); QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std_::move(lambda)), SLOT(action()));
} }
} // namespace internal
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) {
if (auto m = main()) { if (auto m = main()) {
m->sendBotCommand(peer, bot, cmd, replyTo); m->sendBotCommand(peer, bot, cmd, replyTo);

View file

@ -32,9 +32,31 @@ class ItemBase;
} // namespace InlineBots } // namespace InlineBots
namespace App { namespace App {
namespace internal {
void CallDelayed(int duration, base::lambda<void()> &&lambda); void CallDelayed(int duration, base::lambda<void()> &&lambda);
} // namespace internal
template <int N, typename Lambda>
inline void CallDelayed(int duration, base::internal::lambda_guard<N, Lambda> &&guarded) {
return internal::CallDelayed(duration, [guarded = std_::move(guarded)] { guarded(); });
}
template <typename Pointer, typename ...PointersAndLambda>
inline void CallDelayed(int duration, Pointer &&qobject, PointersAndLambda&&... qobjectsAndLambda) {
auto guarded = base::lambda_guarded(std_::forward<Pointer>(qobject), std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
return CallDelayed(duration, std_::move(guarded));
}
template <typename ...PointersAndLambda>
inline base::lambda<void()> LambdaDelayed(int duration, PointersAndLambda&&... qobjectsAndLambda) {
auto guarded = base::lambda_guarded(std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
return [guarded = std_::move(guarded), duration] {
CallDelayed(duration, guarded.clone());
};
}
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo = 0); void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo = 0);
bool insertBotCommand(const QString &cmd, bool specialGif = false); bool insertBotCommand(const QString &cmd, bool specialGif = false);
void activateBotCommand(const HistoryItem *msg, int row, int col); void activateBotCommand(const HistoryItem *msg, int row, int col);

View file

@ -80,6 +80,25 @@ membersInnerDropdown: InnerDropdown(defaultInnerDropdown) {
scrollMargin: margins(0px, 5px, 0px, 5px); scrollMargin: margins(0px, 5px, 0px, 5px);
scrollPadding: margins(0px, 3px, 8px, 3px); scrollPadding: margins(0px, 3px, 8px, 3px);
} }
membersInnerItem: ProfilePeerListItem {
button: OutlineButton {
outlineWidth: 0px;
textBg: windowBg;
textBgOver: windowBgOver;
textFg: windowSubTextFg;
textFgOver: windowSubTextFgOver;
font: normalFont;
padding: margins(11px, 5px, 11px, 5px);
ripple: defaultRippleAnimation;
}
statusFg: windowSubTextFg;
statusFgOver: windowSubTextFgOver;
statusFgActive: windowActiveTextFg;
}
historyFileOutImage: icon {{ "history_file_image", msgOutBg }}; historyFileOutImage: icon {{ "history_file_image", msgOutBg }};
historyFileOutImageSelected: icon {{ "history_file_image", msgOutBgSelected }}; historyFileOutImageSelected: icon {{ "history_file_image", msgOutBgSelected }};

View file

@ -25,6 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
#include "styles/style_window.h" #include "styles/style_window.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_profile.h"
#include "boxes/confirmbox.h" #include "boxes/confirmbox.h"
#include "boxes/send_files_box.h" #include "boxes/send_files_box.h"
#include "boxes/sharebox.h" #include "boxes/sharebox.h"
@ -129,6 +130,11 @@ HistoryInner::HistoryInner(HistoryWidget *historyWidget, Ui::ScrollArea *scroll,
_touchSelectTimer.setSingleShot(true); _touchSelectTimer.setSingleShot(true);
connect(&_touchSelectTimer, SIGNAL(timeout()), this, SLOT(onTouchSelect())); connect(&_touchSelectTimer, SIGNAL(timeout()), this, SLOT(onTouchSelect()));
auto tmp = App::LambdaDelayed(200, this, [this] {
int a = 0;
});
tmp();
setAttribute(Qt::WA_AcceptTouchEvents); setAttribute(Qt::WA_AcceptTouchEvents);
connect(&_touchScrollTimer, SIGNAL(timeout()), this, SLOT(onTouchScrollTimer())); connect(&_touchScrollTimer, SIGNAL(timeout()), this, SLOT(onTouchScrollTimer()));
@ -1233,19 +1239,24 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
} }
if (lnkPhoto) { if (lnkPhoto) {
_menu->addAction(lang(lng_context_save_image), this, SLOT(saveContextImage()))->setEnabled(true); _menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, photo = lnkPhoto->photo()] {
savePhotoToFile(photo);
}))->setEnabled(true);
_menu->addAction(lang(lng_context_copy_image), this, SLOT(copyContextImage()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_image), this, SLOT(copyContextImage()))->setEnabled(true);
} else { } else {
if (lnkDocument && lnkDocument->document()->loading()) { auto document = lnkDocument->document();
if (document->loading()) {
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true); _menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
} else { } else {
if (lnkDocument && lnkDocument->document()->loaded() && lnkDocument->document()->isGifv()) { if (document->loaded() && document->isGifv()) {
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true); _menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
} }
if (lnkDocument && !lnkDocument->document()->filepath(DocumentData::FilePathResolveChecked).isEmpty()) { if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true); _menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true);
} }
_menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsAudio ? lng_context_save_audio : (lnkIsSong ? lng_context_save_audio_file : lng_context_save_file))), this, SLOT(saveContextFile()))->setEnabled(true); _menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsAudio ? lng_context_save_audio : (lnkIsSong ? lng_context_save_audio_file : lng_context_save_file))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
saveDocumentToFile(document);
}))->setEnabled(true);
} }
} }
if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) { if (item && item->hasDirectLink() && isUponSelected != 2 && isUponSelected != -2) {
@ -1304,32 +1315,35 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
} }
if (item && !isUponSelected) { if (item && !isUponSelected) {
bool mediaHasTextForCopy = false; auto mediaHasTextForCopy = false;
if (HistoryMedia *media = (msg ? msg->getMedia() : nullptr)) { if (auto media = (msg ? msg->getMedia() : nullptr)) {
mediaHasTextForCopy = media->hasTextForCopy(); mediaHasTextForCopy = media->hasTextForCopy();
if (media->type() == MediaTypeWebPage && static_cast<HistoryWebPage*>(media)->attach()) { if (media->type() == MediaTypeWebPage && static_cast<HistoryWebPage*>(media)->attach()) {
media = static_cast<HistoryWebPage*>(media)->attach(); media = static_cast<HistoryWebPage*>(media)->attach();
} }
if (media->type() == MediaTypeSticker) { if (media->type() == MediaTypeSticker) {
DocumentData *doc = media->getDocument(); if (auto document = media->getDocument()) {
if (doc && doc->sticker() && doc->sticker()->set.type() != mtpc_inputStickerSetEmpty) { if (document->sticker() && document->sticker()->set.type() != mtpc_inputStickerSetEmpty) {
_menu->addAction(lang(doc->sticker()->setInstalled() ? lng_context_pack_info : lng_context_pack_add), _widget, SLOT(onStickerPackInfo())); _menu->addAction(lang(document->sticker()->setInstalled() ? lng_context_pack_info : lng_context_pack_add), _widget, SLOT(onStickerPackInfo()));
}
_menu->addAction(lang(lng_context_save_image), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
saveDocumentToFile(document);
}))->setEnabled(true);
} }
_menu->addAction(lang(lng_context_save_image), this, SLOT(saveContextFile()))->setEnabled(true);
} else if (media->type() == MediaTypeGif && !_contextMenuLnk) { } else if (media->type() == MediaTypeGif && !_contextMenuLnk) {
DocumentData *doc = media->getDocument(); if (auto document = media->getDocument()) {
if (doc) { if (document->loading()) {
if (doc->loading()) {
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true); _menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
} else { } else {
if (doc->isGifv()) { if (document->isGifv()) {
_menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true); _menu->addAction(lang(lng_context_save_gif), this, SLOT(saveContextGif()))->setEnabled(true);
} }
if (!doc->filepath(DocumentData::FilePathResolveChecked).isEmpty()) { if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true); _menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true);
} }
_menu->addAction(lang(lng_context_save_file), this, SLOT(saveContextFile()))->setEnabled(true); _menu->addAction(lang(lng_context_save_file), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
saveDocumentToFile(document);
}))->setEnabled(true);
} }
} }
} }
@ -1401,11 +1415,7 @@ void HistoryInner::copyContextUrl() {
} }
} }
void HistoryInner::saveContextImage() { void HistoryInner::savePhotoToFile(PhotoData *photo) {
PhotoClickHandler *lnk = dynamic_cast<PhotoClickHandler*>(_contextMenuLnk.data());
if (!lnk) return;
PhotoData *photo = lnk->photo();
if (!photo || !photo->date || !photo->loaded()) return; if (!photo || !photo->date || !photo->loaded()) return;
QString file; QString file;
@ -1455,30 +1465,22 @@ void HistoryInner::showContextInFolder() {
} }
} }
void HistoryInner::saveContextFile() { void HistoryInner::saveDocumentToFile(DocumentData *document) {
if (DocumentClickHandler *lnkDocument = dynamic_cast<DocumentClickHandler*>(_contextMenuLnk.data())) { DocumentSaveClickHandler::doSave(document, true);
DocumentSaveClickHandler::doSave(lnkDocument->document(), true);
} else if (HistoryItem *item = App::contextItem()) {
if (HistoryMedia *media = item->getMedia()) {
if (DocumentData *doc = media->getDocument()) {
DocumentSaveClickHandler::doSave(doc, true);
}
}
}
} }
void HistoryInner::saveContextGif() { void HistoryInner::saveContextGif() {
if (HistoryItem *item = App::contextItem()) { if (auto item = App::contextItem()) {
if (HistoryMedia *media = item->getMedia()) { if (auto media = item->getMedia()) {
if (DocumentData *doc = media->getDocument()) { if (auto document = media->getDocument()) {
_widget->saveGif(doc); _widget->saveGif(document);
} }
} }
} }
} }
void HistoryInner::copyContextText() { void HistoryInner::copyContextText() {
HistoryItem *item = App::contextItem(); auto item = App::contextItem();
if (!item || (item->getMedia() && item->getMedia()->type() == MediaTypeSticker)) { if (!item || (item->getMedia() && item->getMedia()->type() == MediaTypeSticker)) {
return; return;
} }
@ -3089,11 +3091,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
connect(audioCapture(), SIGNAL(done(QByteArray,VoiceWaveform,qint32)), this, SLOT(onRecordDone(QByteArray,VoiceWaveform,qint32))); connect(audioCapture(), SIGNAL(done(QByteArray,VoiceWaveform,qint32)), this, SLOT(onRecordDone(QByteArray,VoiceWaveform,qint32)));
} }
_attachToggle->setClickedCallback([this] { _attachToggle->setClickedCallback(App::LambdaDelayed(st::historyAttach.ripple.hideDuration, this, [this] {
App::CallDelayed(st::historyAttach.ripple.hideDuration, base::lambda_guarded(this, [this] {
chooseAttach(); chooseAttach();
})); }));
});
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
notifyFileQueryUpdated(update); notifyFileQueryUpdated(update);
}); });
@ -6235,7 +6235,7 @@ void HistoryWidget::setMembersShowAreaActive(bool active) {
void HistoryWidget::onMembersDropdownShow() { void HistoryWidget::onMembersDropdownShow() {
if (!_membersDropdown) { if (!_membersDropdown) {
_membersDropdown.create(this, st::membersInnerDropdown); _membersDropdown.create(this, st::membersInnerDropdown);
_membersDropdown->setOwnedWidget(new Profile::GroupMembersWidget(_membersDropdown, _peer, Profile::GroupMembersWidget::TitleVisibility::Hidden)); _membersDropdown->setOwnedWidget(new Profile::GroupMembersWidget(_membersDropdown, _peer, Profile::GroupMembersWidget::TitleVisibility::Hidden, st::membersInnerItem));
_membersDropdown->resizeToWidth(st::membersInnerWidth); _membersDropdown->resizeToWidth(st::membersInnerWidth);
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax()); _membersDropdown->setMaxHeight(countMembersDropdownHeightMax());

View file

@ -139,11 +139,9 @@ public slots:
void onParentGeometryChanged(); void onParentGeometryChanged();
void copyContextUrl(); void copyContextUrl();
void saveContextImage();
void copyContextImage(); void copyContextImage();
void cancelContextDownload(); void cancelContextDownload();
void showContextInFolder(); void showContextInFolder();
void saveContextFile();
void saveContextGif(); void saveContextGif();
void copyContextText(); void copyContextText();
void copySelectedText(); void copySelectedText();
@ -159,6 +157,8 @@ private slots:
private: private:
void itemRemoved(HistoryItem *item); void itemRemoved(HistoryItem *item);
void savePhotoToFile(PhotoData *photo);
void saveDocumentToFile(DocumentData *document);
void touchResetSpeed(); void touchResetSpeed();
void touchUpdateSpeed(); void touchUpdateSpeed();

View file

@ -51,7 +51,7 @@ introCoverTitle: FlatLabel(defaultFlatLabel) {
textFg: introTitleFg; textFg: introTitleFg;
align: align(center); align: align(center);
} }
introCoverTitleTop: 126px; introCoverTitleTop: 136px;
introCoverDescription: FlatLabel(defaultFlatLabel) { introCoverDescription: FlatLabel(defaultFlatLabel) {
font: font(15px); font: font(15px);
textFg: introDescriptionFg; textFg: introDescriptionFg;
@ -60,12 +60,12 @@ introCoverDescription: FlatLabel(defaultFlatLabel) {
introCoverDescriptionTextStyle: TextStyle(defaultTextStyle) { introCoverDescriptionTextStyle: TextStyle(defaultTextStyle) {
lineHeight: 24px; lineHeight: 24px;
} }
introCoverDescriptionTop: 164px; introCoverDescriptionTop: 174px;
introTitle: FlatLabel(defaultFlatLabel) { introTitle: FlatLabel(defaultFlatLabel) {
font: font(17px semibold); font: font(17px semibold);
textFg: introTitleFg; textFg: introTitleFg;
} }
introTitleTop: 11px; introTitleTop: 1px;
introDescription: FlatLabel(defaultFlatLabel) { introDescription: FlatLabel(defaultFlatLabel) {
font: normalFont; font: normalFont;
textFg: introDescriptionFg; textFg: introDescriptionFg;
@ -73,18 +73,18 @@ introDescription: FlatLabel(defaultFlatLabel) {
introDescriptionTextStyle: TextStyle(defaultTextStyle) { introDescriptionTextStyle: TextStyle(defaultTextStyle) {
lineHeight: 20px; lineHeight: 20px;
} }
introDescriptionTop: 44px; introDescriptionTop: 34px;
introLink: defaultLinkButton; introLink: defaultLinkButton;
introPlaneWidth: 48px; introPlaneWidth: 48px;
introPlaneHeight: 38px; introPlaneHeight: 38px;
introHeight: 396px; introHeight: 406px;
introStepTopMin: 86px; introStepTopMin: 76px;
introStepWidth: 380px; introStepWidth: 380px;
introStepHeight: 256px; introStepHeight: 266px;
introStepHeightAdd: 30px; introStepHeightAdd: 30px;
introStepHeightFull: 580px; introStepHeightFull: 590px;
introSlideDuration: 200; introSlideDuration: 200;
introCoverDuration: 300; introCoverDuration: 300;
@ -96,30 +96,28 @@ introNextButton: RoundButton(defaultActiveButton) {
font: font(17px semibold); font: font(17px semibold);
} }
introStepFieldTop: 116px; introStepFieldTop: 96px;
introPhoneTop: 16px; introPhoneTop: 6px;
introLinkTop: 21px; introLinkTop: 24px;
introCountry: InputField(defaultInputField) { introCountry: InputField(defaultInputField) {
textMargins: margins(3px, 7px, 3px, 6px); textMargins: margins(3px, 27px, 3px, 6px);
font: font(16px); font: font(16px);
width: 300px; width: 300px;
height: 41px; heightMin: 61px;
} }
introCountryCode: InputField(introCountry) { introCountryCode: InputField(introCountry) {
width: 64px; width: 64px;
height: 41px;
textAlign: align(top); textAlign: align(top);
} }
introPhone: InputField(introCountry) { introPhone: InputField(introCountry) {
textMargins: margins(12px, 7px, 12px, 6px); textMargins: margins(12px, 27px, 12px, 6px);
width: 225px; width: 225px;
height: 41px;
} }
introCode: introCountry; introCode: introCountry;
introName: introCountry; introName: introCountry;
introPassword: introCountry; introPassword: introCountry;
introPasswordTop: 94px; introPasswordTop: 74px;
introPasswordHintTop: 146px; introPasswordHintTop: 151px;
introPasswordHint: FlatLabel(introDescription) { introPasswordHint: FlatLabel(introDescription) {
textFg: windowFg; textFg: windowFg;
@ -138,12 +136,12 @@ introResetButton: RoundButton(defaultLightButton) {
introResetBottom: 20px; introResetBottom: 20px;
introCountryIcon: icon {{ "intro_country_dropdown", menuIconFg }}; introCountryIcon: icon {{ "intro_country_dropdown", menuIconFg }};
introCountryIconPosition: point(8px, 17px); introCountryIconPosition: point(8px, 37px);
introSelectDelta: 30px; introSelectDelta: 30px;
introErrorTop: 225px; introErrorTop: 235px;
introErrorBelowLinkTop: 213px; introErrorBelowLinkTop: 220px;
introErrorDuration: 200; introErrorDuration: 200;
introError: introDescription; introError: introDescription;

View file

@ -71,7 +71,7 @@ void CodeInput::correctValue(const QString &was, int wasCursor, QString &now, in
if (newText != now) { if (newText != now) {
now = newText; now = newText;
setText(now); setText(now);
updatePlaceholder(); startPlaceholderAnimation();
} }
if (newPos != nowCursor) { if (newPos != nowCursor) {
nowCursor = newPos; nowCursor = newPos;
@ -176,7 +176,6 @@ void CodeWidget::finished() {
cancelled(); cancelled();
_sentCode.clear(); _sentCode.clear();
_code->setText(QString()); _code->setText(QString());
_code->setDisabled(false);
} }
void CodeWidget::cancelled() { void CodeWidget::cancelled() {
@ -190,18 +189,14 @@ void CodeWidget::stopCheck() {
} }
void CodeWidget::onCheckRequest() { void CodeWidget::onCheckRequest() {
int32 status = MTP::state(_sentRequest); auto status = MTP::state(_sentRequest);
if (status < 0) { if (status < 0) {
int32 leftms = -status; auto leftms = -status;
if (leftms >= 1000) { if (leftms >= 1000) {
if (_sentRequest) { if (_sentRequest) {
MTP::cancel(base::take(_sentRequest)); MTP::cancel(base::take(_sentRequest));
_sentCode.clear(); _sentCode.clear();
} }
if (!_code->isEnabled()) {
_code->setDisabled(false);
_code->setFocus();
}
} }
} }
if (!_sentRequest && status == MTP::RequestSent) { if (!_sentRequest && status == MTP::RequestSent) {
@ -212,7 +207,6 @@ void CodeWidget::onCheckRequest() {
void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) { void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
_code->setDisabled(false);
auto &d = result.c_auth_authorization(); auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf? if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showCodeError(lang(lng_server_error)); showCodeError(lang(lng_server_error));
@ -226,7 +220,6 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) { if (MTP::isFloodError(error)) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
_code->setDisabled(false);
showCodeError(lang(lng_flood_error)); showCodeError(lang(lng_flood_error));
return true; return true;
} }
@ -234,8 +227,7 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
_code->setDisabled(false); auto &err = error.type();
const QString &err = error.type();
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error
goBack(); goBack();
return true; return true;
@ -248,7 +240,6 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
return true; return true;
} else if (err == qstr("SESSION_PASSWORD_NEEDED")) { } else if (err == qstr("SESSION_PASSWORD_NEEDED")) {
getData()->code = _sentCode; getData()->code = _sentCode;
_code->setDisabled(false);
_checkRequest->start(1000); _checkRequest->start(1000);
_sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&CodeWidget::gotPassword), rpcFail(&CodeWidget::codeSubmitFail)); _sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&CodeWidget::gotPassword), rpcFail(&CodeWidget::codeSubmitFail));
return true; return true;
@ -298,7 +289,6 @@ void CodeWidget::callDone(const MTPauth_SentCode &v) {
void CodeWidget::gotPassword(const MTPaccount_Password &result) { void CodeWidget::gotPassword(const MTPaccount_Password &result) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
_code->setDisabled(false);
switch (result.type()) { switch (result.type()) {
case mtpc_account_noPassword: { // should not happen case mtpc_account_noPassword: { // should not happen
_code->setFocus(); _code->setFocus();
@ -317,9 +307,6 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
void CodeWidget::submit() { void CodeWidget::submit() {
if (_sentRequest) return; if (_sentRequest) return;
_code->setDisabled(true);
setFocus();
hideError(); hideError();
_checkRequest->start(1000); _checkRequest->start(1000);

View file

@ -114,20 +114,6 @@ void PhoneWidget::onInputChange() {
hidePhoneError(); hidePhoneError();
} }
void PhoneWidget::disableAll() {
_phone->setDisabled(true);
_country->setDisabled(true);
_code->setDisabled(true);
setFocus();
}
void PhoneWidget::enableAll(bool failed) {
_phone->setDisabled(false);
_country->setDisabled(false);
_code->setDisabled(false);
if (failed) _phone->setFocus();
}
void PhoneWidget::submit() { void PhoneWidget::submit() {
if (_sentRequest || isHidden()) return; if (_sentRequest || isHidden()) return;
@ -137,7 +123,6 @@ void PhoneWidget::submit() {
return; return;
} }
disableAll();
hidePhoneError(); hidePhoneError();
_checkRequest->start(1000); _checkRequest->start(1000);
@ -151,12 +136,11 @@ void PhoneWidget::stopCheck() {
} }
void PhoneWidget::onCheckRequest() { void PhoneWidget::onCheckRequest() {
int32 status = MTP::state(_sentRequest); auto status = MTP::state(_sentRequest);
if (status < 0) { if (status < 0) {
int32 leftms = -status; auto leftms = -status;
if (leftms >= 1000) { if (leftms >= 1000) {
MTP::cancel(base::take(_sentRequest)); MTP::cancel(base::take(_sentRequest));
if (!_phone->isEnabled()) enableAll(true);
} }
} }
if (!_sentRequest && status == MTP::RequestSent) { if (!_sentRequest && status == MTP::RequestSent) {
@ -169,7 +153,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
auto &d = result.c_auth_checkedPhone(); auto &d = result.c_auth_checkedPhone();
if (mtpIsTrue(d.vphone_registered)) { if (mtpIsTrue(d.vphone_registered)) {
disableAll();
hidePhoneError(); hidePhoneError();
_checkRequest->start(1000); _checkRequest->start(1000);
@ -178,7 +161,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
_sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(flags), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail)); _sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(flags), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail));
} else { } else {
showSignup(); showSignup();
enableAll(true);
_sentRequest = 0; _sentRequest = 0;
} }
} }
@ -186,7 +168,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) { void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
enableAll(true);
if (result.type() != mtpc_auth_sentCode) { if (result.type() != mtpc_auth_sentCode) {
showPhoneError(lang(lng_server_error)); showPhoneError(lang(lng_server_error));
@ -209,7 +190,6 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
} }
void PhoneWidget::toSignUp() { void PhoneWidget::toSignUp() {
disableAll();
hideError(); // Hide error, but leave the signup label visible. hideError(); // Hide error, but leave the signup label visible.
_checkRequest->start(1000); _checkRequest->start(1000);
@ -223,17 +203,15 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
showPhoneError(lang(lng_flood_error)); showPhoneError(lang(lng_flood_error));
enableAll(true);
return true; return true;
} }
if (MTP::isDefaultHandledError(error)) return false; if (MTP::isDefaultHandledError(error)) return false;
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
const QString &err = error.type(); auto &err = error.type();
if (err == qstr("PHONE_NUMBER_INVALID")) { // show error if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
showPhoneError(lang(lng_bad_phone)); showPhoneError(lang(lng_bad_phone));
enableAll(true);
return true; return true;
} }
if (cDebug()) { // internal server error if (cDebug()) { // internal server error
@ -241,7 +219,6 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
} else { } else {
showPhoneError(lang(lng_server_error)); showPhoneError(lang(lng_server_error));
} }
enableAll(true);
return false; return false;
} }
@ -271,7 +248,6 @@ void PhoneWidget::finished() {
rpcClear(); rpcClear();
cancelled(); cancelled();
enableAll(true);
} }
void PhoneWidget::cancelled() { void PhoneWidget::cancelled() {

View file

@ -68,8 +68,6 @@ private:
void toSignUp(); void toSignUp();
QString fullNumber() const; QString fullNumber() const;
void disableAll();
void enableAll(bool failed);
void stopCheck(); void stopCheck();
void showPhoneError(const QString &text); void showPhoneError(const QString &text);

View file

@ -102,16 +102,11 @@ void PwdCheckWidget::stopCheck() {
} }
void PwdCheckWidget::onCheckRequest() { void PwdCheckWidget::onCheckRequest() {
int32 status = MTP::state(_sentRequest); auto status = MTP::state(_sentRequest);
if (status < 0) { if (status < 0) {
int32 leftms = -status; auto leftms = -status;
if (leftms >= 1000) { if (leftms >= 1000) {
MTP::cancel(base::take(_sentRequest)); MTP::cancel(base::take(_sentRequest));
if (!_pwdField->isEnabled()) {
_pwdField->setDisabled(false);
_codeField->setDisabled(false);
activate();
}
} }
} }
if (!_sentRequest && status == MTP::RequestSent) { if (!_sentRequest && status == MTP::RequestSent) {
@ -125,8 +120,6 @@ void PwdCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorization &re
if (recover) { if (recover) {
cSetPasswordRecovered(true); cSetPasswordRecovered(true);
} }
_pwdField->setDisabled(false);
_codeField->setDisabled(false);
auto &d = result.c_auth_authorization(); auto &d = result.c_auth_authorization();
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf? if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showError(lang(lng_server_error)); showError(lang(lng_server_error));
@ -139,9 +132,7 @@ bool PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) { if (MTP::isFloodError(error)) {
_sentRequest = 0; _sentRequest = 0;
stopCheck(); stopCheck();
_codeField->setDisabled(false);
showError(lang(lng_flood_error)); showError(lang(lng_flood_error));
_pwdField->setDisabled(false);
_pwdField->showError(); _pwdField->showError();
return true; return true;
} }
@ -149,9 +140,7 @@ bool PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
_sentRequest = 0; _sentRequest = 0;
stopCheck(); stopCheck();
_pwdField->setDisabled(false); auto &err = error.type();
_codeField->setDisabled(false);
const QString &err = error.type();
if (err == qstr("PASSWORD_HASH_INVALID")) { if (err == qstr("PASSWORD_HASH_INVALID")) {
showError(lang(lng_signin_bad_password)); showError(lang(lng_signin_bad_password));
_pwdField->selectAll(); _pwdField->selectAll();
@ -179,8 +168,6 @@ bool PwdCheckWidget::codeSubmitFail(const RPCError &error) {
_sentRequest = 0; _sentRequest = 0;
stopCheck(); stopCheck();
_pwdField->setDisabled(false);
_codeField->setDisabled(false);
const QString &err = error.type(); const QString &err = error.type();
if (err == qstr("PASSWORD_EMPTY")) { if (err == qstr("PASSWORD_EMPTY")) {
goBack(); goBack();
@ -214,8 +201,6 @@ void PwdCheckWidget::recoverStarted(const MTPauth_PasswordRecovery &result) {
bool PwdCheckWidget::recoverStartFail(const RPCError &error) { bool PwdCheckWidget::recoverStartFail(const RPCError &error) {
stopCheck(); stopCheck();
_pwdField->setDisabled(false);
_codeField->setDisabled(false);
_pwdField->show(); _pwdField->show();
_pwdHint->show(); _pwdHint->show();
_codeField->hide(); _codeField->hide();
@ -283,7 +268,6 @@ void PwdCheckWidget::onInputChange() {
void PwdCheckWidget::submit() { void PwdCheckWidget::submit() {
if (_sentRequest) return; if (_sentRequest) return;
if (_pwdField->isHidden()) { if (_pwdField->isHidden()) {
if (!_codeField->isEnabled()) return;
auto code = _codeField->getLastText().trimmed(); auto code = _codeField->getLastText().trimmed();
if (code.isEmpty()) { if (code.isEmpty()) {
_codeField->showError(); _codeField->showError();
@ -292,11 +276,6 @@ void PwdCheckWidget::submit() {
_sentRequest = MTP::send(MTPauth_RecoverPassword(MTP_string(code)), rpcDone(&PwdCheckWidget::pwdSubmitDone, true), rpcFail(&PwdCheckWidget::codeSubmitFail)); _sentRequest = MTP::send(MTPauth_RecoverPassword(MTP_string(code)), rpcDone(&PwdCheckWidget::pwdSubmitDone, true), rpcFail(&PwdCheckWidget::codeSubmitFail));
} else { } else {
if (!_pwdField->isEnabled()) return;
_pwdField->setDisabled(true);
setFocus();
hideError(); hideError();
QByteArray pwdData = _salt + _pwdField->getLastText().toUtf8() + _salt, pwdHash(32, Qt::Uninitialized); QByteArray pwdData = _salt + _pwdField->getLastText().toUtf8() + _salt, pwdHash(32, Qt::Uninitialized);

View file

@ -42,13 +42,11 @@ SignupWidget::SignupWidget(QWidget *parent, Widget::Data *data) : Step(parent, d
, _checkRequest(this) { , _checkRequest(this) {
connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest())); connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
_photo->setClickedCallback([this] { _photo->setClickedCallback(App::LambdaDelayed(st::defaultActiveButton.ripple.hideDuration, this, [this] {
App::CallDelayed(st::defaultActiveButton.ripple.hideDuration, base::lambda_guarded(this, [this] {
auto imgExtensions = cImgExtensions(); auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
_readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); _readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
})); }));
});
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
notifyFileQueryUpdated(update); notifyFileQueryUpdated(update);
}); });
@ -96,7 +94,7 @@ void SignupWidget::resizeEvent(QResizeEvent *e) {
_photo->moveToLeft(photoRight - _photo->width(), photoTop); _photo->moveToLeft(photoRight - _photo->width(), photoTop);
auto firstTop = contentTop() + st::introStepFieldTop; auto firstTop = contentTop() + st::introStepFieldTop;
auto secondTop = firstTop + st::introName.height + st::introPhoneTop; auto secondTop = firstTop + st::introName.heightMin + st::introPhoneTop;
if (_invertOrder) { if (_invertOrder) {
_last->moveToLeft(contentLeft(), firstTop); _last->moveToLeft(contentLeft(), firstTop);
_first->moveToLeft(contentLeft(), secondTop); _first->moveToLeft(contentLeft(), secondTop);
@ -131,20 +129,11 @@ void SignupWidget::stopCheck() {
} }
void SignupWidget::onCheckRequest() { void SignupWidget::onCheckRequest() {
int32 status = MTP::state(_sentRequest); auto status = MTP::state(_sentRequest);
if (status < 0) { if (status < 0) {
int32 leftms = -status; auto leftms = -status;
if (leftms >= 1000) { if (leftms >= 1000) {
MTP::cancel(base::take(_sentRequest)); MTP::cancel(base::take(_sentRequest));
if (!_first->isEnabled()) {
_first->setDisabled(false);
_last->setDisabled(false);
if (_invertOrder) {
_first->setFocus();
} else {
_last->setFocus();
}
}
} }
} }
if (!_sentRequest && status == MTP::RequestSent) { if (!_sentRequest && status == MTP::RequestSent) {
@ -159,9 +148,7 @@ void SignupWidget::onPhotoReady(const QImage &img) {
void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) { void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
stopCheck(); stopCheck();
_first->setDisabled(false); auto &d = result.c_auth_authorization();
_last->setDisabled(false);
const auto &d(result.c_auth_authorization());
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf? if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showError(lang(lng_server_error)); showError(lang(lng_server_error));
return; return;
@ -172,8 +159,6 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
bool SignupWidget::nameSubmitFail(const RPCError &error) { bool SignupWidget::nameSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) { if (MTP::isFloodError(error)) {
stopCheck(); stopCheck();
_first->setDisabled(false);
_last->setDisabled(false);
showError(lang(lng_flood_error)); showError(lang(lng_flood_error));
if (_invertOrder) { if (_invertOrder) {
_first->setFocus(); _first->setFocus();
@ -185,9 +170,7 @@ bool SignupWidget::nameSubmitFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false; if (MTP::isDefaultHandledError(error)) return false;
stopCheck(); stopCheck();
_first->setDisabled(false); auto &err = error.type();
_last->setDisabled(false);
const QString &err = error.type();
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED") || if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED") ||
err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID") || err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID") ||
err == qstr("PHONE_NUMBER_OCCUPIED")) { err == qstr("PHONE_NUMBER_OCCUPIED")) {
@ -220,6 +203,7 @@ void SignupWidget::onInputChange() {
} }
void SignupWidget::submit() { void SignupWidget::submit() {
if (_sentRequest) return;
if (_invertOrder) { if (_invertOrder) {
if ((_last->hasFocus() || _last->getLastText().trimmed().length()) && !_first->getLastText().trimmed().length()) { if ((_last->hasFocus() || _last->getLastText().trimmed().length()) && !_first->getLastText().trimmed().length()) {
_first->setFocus(); _first->setFocus();
@ -237,11 +221,6 @@ void SignupWidget::submit() {
return; return;
} }
} }
if (!_first->isEnabled()) return;
_first->setDisabled(true);
_last->setDisabled(true);
setFocus();
showError(QString()); showError(QString());

View file

@ -311,6 +311,7 @@ void LayerStackWidget::setCacheImages() {
setFocus(); setFocus();
} }
if (_mainMenu) { if (_mainMenu) {
setAttribute(Qt::WA_OpaquePaintEvent, false);
hideChildren(); hideChildren();
bodyCache = myGrab(App::wnd()->bodyWidget()); bodyCache = myGrab(App::wnd()->bodyWidget());
showChildren(); showChildren();

View file

@ -50,27 +50,23 @@ TextParseOptions _documentNameOptions = {
} // namespace } // namespace
void ItemBase::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { void ItemBase::clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) {
App::hoveredLinkItem(active ? _parent : nullptr); App::hoveredLinkItem(active ? _parent : nullptr);
Ui::repaintHistoryItem(_parent); Ui::repaintHistoryItem(_parent);
} }
void ItemBase::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { void ItemBase::clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) {
App::pressedLinkItem(pressed ? _parent : nullptr); App::pressedLinkItem(pressed ? _parent : nullptr);
Ui::repaintHistoryItem(_parent); Ui::repaintHistoryItem(_parent);
} }
void RadialProgressItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { void RadialProgressItem::clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) {
if (p == _openl || p == _savel || p == _cancell) { ItemBase::clickHandlerActiveChanged(action, active);
if (action == _openl || action == _savel || action == _cancell) {
if (iconAnimated()) { if (iconAnimated()) {
_a_iconOver.start([this] { Ui::repaintHistoryItem(_parent); }, active ? 0. : 1., active ? 1. : 0., st::msgFileOverDuration); _a_iconOver.start([this] { Ui::repaintHistoryItem(_parent); }, active ? 0. : 1., active ? 1. : 0., st::msgFileOverDuration);
} }
} }
ItemBase::clickHandlerActiveChanged(p, active);
}
void RadialProgressItem::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
ItemBase::clickHandlerPressedChanged(p, pressed);
} }
void RadialProgressItem::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) { void RadialProgressItem::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) {
@ -274,12 +270,14 @@ void Photo::getState(ClickHandlerPtr &link, HistoryCursorState &cursor, int x, i
} }
void Photo::clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) { void Photo::clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) {
ItemBase::clickHandlerActiveChanged(action, active);
if (_check) { if (_check) {
_check->setActive(active); _check->setActive(active);
} }
} }
void Photo::clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) { void Photo::clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) {
ItemBase::clickHandlerPressedChanged(action, pressed);
if (_check) { if (_check) {
_check->setPressed(pressed); _check->setPressed(pressed);
} }

View file

@ -76,8 +76,8 @@ public:
return _parent; return _parent;
} }
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override; void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) override;
protected: protected:
HistoryItem *_parent; HistoryItem *_parent;
@ -90,8 +90,7 @@ public:
} }
RadialProgressItem(const RadialProgressItem &other) = delete; RadialProgressItem(const RadialProgressItem &other) = delete;
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override; void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) override;
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool active) override;
~RadialProgressItem(); ~RadialProgressItem();

View file

@ -1195,13 +1195,17 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
if (lnkPhoto) { if (lnkPhoto) {
} else { } else {
if (lnkDocument && lnkDocument->document()->loading()) { if (auto document = lnkDocument->document()) {
if (document->loading()) {
_menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true); _menu->addAction(lang(lng_context_cancel_download), this, SLOT(cancelContextDownload()))->setEnabled(true);
} else { } else {
if (lnkDocument && !lnkDocument->document()->filepath(DocumentData::FilePathResolveChecked).isEmpty()) { if (document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true); _menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), this, SLOT(showContextInFolder()))->setEnabled(true);
} }
_menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsAudio ? lng_context_save_audio : (lnkIsSong ? lng_context_save_audio_file : lng_context_save_file))), this, SLOT(saveContextFile()))->setEnabled(true); _menu->addAction(lang(lnkIsVideo ? lng_context_save_video : (lnkIsAudio ? lng_context_save_audio : (lnkIsSong ? lng_context_save_audio_file : lng_context_save_file))), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [this, document] {
saveDocumentToFile(document);
}))->setEnabled(true);
}
} }
} }
if (isUponSelected > 1) { if (isUponSelected > 1) {
@ -1418,30 +1422,27 @@ void OverviewInner::cancelContextDownload() {
} }
void OverviewInner::showContextInFolder() { void OverviewInner::showContextInFolder() {
if (DocumentClickHandler *lnkDocument = dynamic_cast<DocumentClickHandler*>(_contextMenuLnk.data())) { if (auto lnkDocument = dynamic_cast<DocumentClickHandler*>(_contextMenuLnk.data())) {
QString filepath = lnkDocument->document()->filepath(DocumentData::FilePathResolveChecked); auto filepath = lnkDocument->document()->filepath(DocumentData::FilePathResolveChecked);
if (!filepath.isEmpty()) { if (!filepath.isEmpty()) {
psShowInFolder(filepath); psShowInFolder(filepath);
} }
} }
} }
void OverviewInner::saveContextFile() { void OverviewInner::saveDocumentToFile(DocumentData *document) {
DocumentClickHandler *lnkDocument = dynamic_cast<DocumentClickHandler*>(_contextMenuLnk.data()); DocumentSaveClickHandler::doSave(document, true);
if (lnkDocument) DocumentSaveClickHandler::doSave(lnkDocument->document(), true);
} }
bool OverviewInner::onSearchMessages(bool searchCache) { bool OverviewInner::onSearchMessages(bool searchCache) {
_searchTimer.stop(); _searchTimer.stop();
QString q = _search->text().trimmed(); auto q = _search->text().trimmed();
if (q.isEmpty()) { if (q.isEmpty()) {
if (_searchRequest) { MTP::cancel(base::take(_searchRequest));
_searchRequest = 0;
}
return true; return true;
} }
if (searchCache) { if (searchCache) {
SearchCache::const_iterator i = _searchCache.constFind(q); auto i = _searchCache.constFind(q);
if (i != _searchCache.cend()) { if (i != _searchCache.cend()) {
_searchQuery = q; _searchQuery = q;
_searchFull = _searchFullMigrated = false; _searchFull = _searchFullMigrated = false;

View file

@ -107,7 +107,6 @@ public slots:
void copyContextUrl(); void copyContextUrl();
void cancelContextDownload(); void cancelContextDownload();
void showContextInFolder(); void showContextInFolder();
void saveContextFile();
void goToMessage(); void goToMessage();
void deleteMessage(); void deleteMessage();
@ -128,6 +127,8 @@ public slots:
void onNeedSearchMessages(); void onNeedSearchMessages();
private: private:
void saveDocumentToFile(DocumentData *document);
void itemRemoved(HistoryItem *item); void itemRemoved(HistoryItem *item);
MsgId complexMsgId(const HistoryItem *item) const; MsgId complexMsgId(const HistoryItem *item) const;

View file

@ -32,7 +32,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "window/window_slide_animation.h" #include "window/window_slide_animation.h"
PasscodeWidget::PasscodeWidget(QWidget *parent) : TWidget(parent) PasscodeWidget::PasscodeWidget(QWidget *parent) : TWidget(parent)
, _passcode(this, st::passcodeInput) , _passcode(this, st::passcodeInput, lang(lng_passcode_ph))
, _submit(this, lang(lng_passcode_submit), st::passcodeSubmit) , _submit(this, lang(lng_passcode_submit), st::passcodeSubmit)
, _logout(this, lang(lng_passcode_logout)) { , _logout(this, lang(lng_passcode_logout)) {
connect(_passcode, SIGNAL(changed()), this, SLOT(onChanged())); connect(_passcode, SIGNAL(changed()), this, SLOT(onChanged()));
@ -42,7 +42,6 @@ PasscodeWidget::PasscodeWidget(QWidget *parent) : TWidget(parent)
_logout->setClickedCallback([] { App::wnd()->onLogout(); }); _logout->setClickedCallback([] { App::wnd()->onLogout(); });
show(); show();
_passcode->setFocus();
} }
void PasscodeWidget::onSubmit() { void PasscodeWidget::onSubmit() {
@ -110,6 +109,8 @@ void PasscodeWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
_a_show.finish(); _a_show.finish();
showAll(); showAll();
setFocus();
_passcode->finishAnimations();
(_showBack ? _cacheUnder : _cacheOver) = myGrab(this); (_showBack ? _cacheUnder : _cacheOver) = myGrab(this);
hideAll(); hideAll();

View file

@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
using "basic.style"; using "basic.style";
using "basic_types.style"; using "basic_types.style";
using "ui/widgets/widgets.style";
using "window/window.style"; using "window/window.style";
profileBg: windowBg; profileBg: windowBg;
@ -115,6 +116,12 @@ profileInviteLinkText: FlatLabel(profileBlockTextPart) {
profileLimitReachedSkip: 6px; profileLimitReachedSkip: 6px;
profileMemberItem: ProfilePeerListItem {
button: defaultLeftOutlineButton;
statusFg: windowSubTextFg;
statusFgOver: #7c99b2;
statusFgActive: windowActiveTextFg;
}
profileMemberHeight: 58px; profileMemberHeight: 58px;
profileMemberPaddingLeft: 16px; profileMemberPaddingLeft: 16px;
profileMemberPhotoSize: 46px; profileMemberPhotoSize: 46px;
@ -122,9 +129,6 @@ profileMemberPhotoPosition: point(12px, 6px);
profileMemberNamePosition: point(68px, 11px); profileMemberNamePosition: point(68px, 11px);
profileMemberNameFg: #222222; profileMemberNameFg: #222222;
profileMemberStatusPosition: point(68px, 31px); profileMemberStatusPosition: point(68px, 31px);
profileMemberStatusFg: windowSubTextFg;
profileMemberStatusFgOver: #7c99b2;
profileMemberStatusFgActive: windowActiveTextFg;
profileMemberAdminIcon: icon {{ "profile_admin_star", windowBgActive, point(4px, 3px) }}; profileMemberAdminIcon: icon {{ "profile_admin_star", windowBgActive, point(4px, 3px) }};
profileLimitReachedLabel: FlatLabel(defaultFlatLabel) { profileLimitReachedLabel: FlatLabel(defaultFlatLabel) {
width: 180px; width: 180px;
@ -134,9 +138,9 @@ profileLimitReachedStyle: TextStyle(defaultTextStyle) {
lineHeight: 19px; lineHeight: 19px;
} }
profileReportReasonOther: InputArea(defaultInputArea) { profileReportReasonOther: InputField(defaultInputField) {
textMargins: margins(1px, 6px, 1px, 4px); textMargins: margins(1px, 26px, 1px, 4px);
heightMax: 115px; heightMax: 135px;
} }
profileVerifiedCheckShift: -3px; profileVerifiedCheckShift: -3px;

View file

@ -32,10 +32,11 @@ namespace Profile {
using UpdateFlag = Notify::PeerUpdate::Flag; using UpdateFlag = Notify::PeerUpdate::Flag;
GroupMembersWidget::GroupMembersWidget(QWidget *parent, PeerData *peer, TitleVisibility titleVisibility) GroupMembersWidget::GroupMembersWidget(QWidget *parent, PeerData *peer, TitleVisibility titleVisibility, const style::ProfilePeerListItem &st)
: PeerListWidget(parent : PeerListWidget(parent
, peer , peer
, (titleVisibility == TitleVisibility::Visible) ? lang(lng_profile_participants_section) : QString() , (titleVisibility == TitleVisibility::Visible) ? lang(lng_profile_participants_section) : QString()
, st
, lang(lng_profile_kick)) { , lang(lng_profile_kick)) {
_updateOnlineTimer.setSingleShot(true); _updateOnlineTimer.setSingleShot(true);
connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay())); connect(&_updateOnlineTimer, SIGNAL(timeout()), this, SLOT(onUpdateOnlineDisplay()));

View file

@ -41,7 +41,7 @@ public:
Visible, Visible,
Hidden, Hidden,
}; };
GroupMembersWidget(QWidget *parent, PeerData *peer, TitleVisibility titleVisibility = TitleVisibility::Visible); GroupMembersWidget(QWidget *parent, PeerData *peer, TitleVisibility titleVisibility = TitleVisibility::Visible, const style::ProfilePeerListItem &st = st::profileMemberItem);
int onlineCount() const { int onlineCount() const {
return _onlineCount; return _onlineCount;

View file

@ -32,8 +32,9 @@ PeerListWidget::Item::Item(PeerData *peer) : peer(peer) {
PeerListWidget::Item::~Item() = default; PeerListWidget::Item::~Item() = default;
PeerListWidget::PeerListWidget(QWidget *parent, PeerData *peer, const QString &title, const QString &removeText) PeerListWidget::PeerListWidget(QWidget *parent, PeerData *peer, const QString &title, const style::ProfilePeerListItem &st, const QString &removeText)
: BlockWidget(parent, peer, title) : BlockWidget(parent, peer, title)
, _st(st)
, _removeText(removeText) , _removeText(removeText)
, _removeWidth(st::normalFont->width(_removeText)) { , _removeWidth(st::normalFont->width(_removeText)) {
setMouseTracking(true); setMouseTracking(true);
@ -88,7 +89,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
paintOutlinedRect(p, x, y, memberRowWidth, st::profileMemberHeight); paintOutlinedRect(p, x, y, memberRowWidth, st::profileMemberHeight);
} }
if (auto &ripple = item->ripple) { if (auto &ripple = item->ripple) {
ripple->paint(p, x + st::defaultLeftOutlineButton.outlineWidth, y, width(), ms); ripple->paint(p, x + _st.button.outlineWidth, y, width(), ms);
if (ripple->empty()) { if (ripple->empty()) {
ripple.reset(); ripple.reset();
} }
@ -118,18 +119,20 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
item->name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width()); item->name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
if (item->statusHasOnlineColor) { if (item->statusHasOnlineColor) {
p.setPen(st::profileMemberStatusFgActive); p.setPen(_st.statusFgActive);
} else { } else {
p.setPen(selected ? st::profileMemberStatusFgOver : st::profileMemberStatusFg); p.setPen(selected ? _st.statusFgOver : _st.statusFg);
} }
p.setFont(st::normalFont); p.setFont(st::normalFont);
p.drawTextLeft(x + st::profileMemberStatusPosition.x(), y + st::profileMemberStatusPosition.y(), width(), item->statusText); p.drawTextLeft(x + st::profileMemberStatusPosition.x(), y + st::profileMemberStatusPosition.y(), width(), item->statusText);
} }
void PeerListWidget::paintOutlinedRect(Painter &p, int x, int y, int w, int h) const { void PeerListWidget::paintOutlinedRect(Painter &p, int x, int y, int w, int h) const {
int outlineWidth = st::defaultLeftOutlineButton.outlineWidth; auto outlineWidth = _st.button.outlineWidth;
p.fillRect(rtlrect(x, y, outlineWidth, h, width()), st::defaultLeftOutlineButton.outlineFgOver); if (outlineWidth) {
p.fillRect(rtlrect(x + outlineWidth, y, w - outlineWidth, h, width()), st::defaultLeftOutlineButton.textBgOver); p.fillRect(rtlrect(x, y, outlineWidth, h, width()), _st.button.outlineFgOver);
}
p.fillRect(rtlrect(x + outlineWidth, y, w - outlineWidth, h, width()), _st.button.textBgOver);
} }
void PeerListWidget::mouseMoveEvent(QMouseEvent *e) { void PeerListWidget::mouseMoveEvent(QMouseEvent *e) {
@ -147,12 +150,12 @@ void PeerListWidget::mousePressEvent(QMouseEvent *e) {
auto item = _items[_pressed]; auto item = _items[_pressed];
if (!item->ripple) { if (!item->ripple) {
auto memberRowWidth = rowWidth(); auto memberRowWidth = rowWidth();
auto mask = Ui::RippleAnimation::rectMask(QSize(memberRowWidth - st::defaultLeftOutlineButton.outlineWidth, st::profileMemberHeight)); auto mask = Ui::RippleAnimation::rectMask(QSize(memberRowWidth - _st.button.outlineWidth, st::profileMemberHeight));
item->ripple = std_::make_unique<Ui::RippleAnimation>(st::defaultLeftOutlineButton.ripple, std_::move(mask), [this, index = _pressed] { item->ripple = std_::make_unique<Ui::RippleAnimation>(_st.button.ripple, std_::move(mask), [this, index = _pressed] {
repaintRow(index); repaintRow(index);
}); });
} }
auto left = getListLeft() + st::defaultLeftOutlineButton.outlineWidth; auto left = getListLeft() + _st.button.outlineWidth;
auto top = getListTop() + st::profileMemberHeight * _pressed; auto top = getListTop() + st::profileMemberHeight * _pressed;
item->ripple->add(e->pos() - QPoint(left, top)); item->ripple->add(e->pos() - QPoint(left, top));
} }

View file

@ -21,6 +21,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "profile/profile_block_widget.h" #include "profile/profile_block_widget.h"
#include "styles/style_profile.h"
namespace Ui { namespace Ui {
class RippleAnimation; class RippleAnimation;
@ -34,7 +35,7 @@ namespace Profile {
class PeerListWidget : public BlockWidget { class PeerListWidget : public BlockWidget {
public: public:
PeerListWidget(QWidget *parent, PeerData *peer, const QString &title, const QString &removeText = QString()); PeerListWidget(QWidget *parent, PeerData *peer, const QString &title, const style::ProfilePeerListItem &st = st::profileMemberItem, const QString &removeText = QString());
void setVisibleTopBottom(int visibleTop, int visibleBottom) override; void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
@ -123,6 +124,8 @@ private:
void paintItem(Painter &p, int x, int y, Item *item, bool selected, bool selectedRemove, TimeMs ms); void paintItem(Painter &p, int x, int y, Item *item, bool selected, bool selectedRemove, TimeMs ms);
const style::ProfilePeerListItem &_st;
base::lambda<void()> _preloadMoreCallback; base::lambda<void()> _preloadMoreCallback;
base::lambda<void(PeerData*)> _selectedCallback; base::lambda<void(PeerData*)> _selectedCallback;
base::lambda<void(PeerData*)> _removedCallback; base::lambda<void(PeerData*)> _removedCallback;

View file

@ -486,10 +486,12 @@ void CoverWidget::onShareContact() {
} }
void CoverWidget::onSetPhoto() { void CoverWidget::onSetPhoto() {
App::CallDelayed(st::profilePrimaryButton.ripple.hideDuration, this, [this] {
QStringList imgExtensions(cImgExtensions()); QStringList imgExtensions(cImgExtensions());
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter()); QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter());
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); _setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
});
} }
void CoverWidget::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update) { void CoverWidget::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update) {

View file

@ -50,7 +50,7 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent,
_name->setSelectable(true); _name->setSelectable(true);
_name->setContextCopyText(lang(lng_profile_copy_fullname)); _name->setContextCopyText(lang(lng_profile_copy_fullname));
connect(_setPhoto, SIGNAL(clicked()), this, SLOT(onSetPhoto())); _setPhoto->setClickedCallback(App::LambdaDelayed(st::settingsPrimaryButton.ripple.hideDuration, this, [this] { onSetPhoto(); }));
connect(_editName, SIGNAL(clicked()), this, SLOT(onEditName())); connect(_editName, SIGNAL(clicked()), this, SLOT(onEditName()));
connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName())); connect(_editNameInline, SIGNAL(clicked()), this, SLOT(onEditName()));

View file

@ -127,9 +127,7 @@ void ScaleWidget::onRestartNow() {
} }
void ScaleWidget::onCancel() { void ScaleWidget::onCancel() {
App::CallDelayed(st::boxDuration, base::lambda_guarded(this, [this] { App::CallDelayed(st::boxDuration, this, [this] { setScale(cRealScale()); });
setScale(cRealScale());
}));
} }
} // namespace Settings } // namespace Settings

View file

@ -1091,20 +1091,20 @@ void GifOpenClickHandler::onClickImpl() const {
void DocumentSaveClickHandler::doSave(DocumentData *data, bool forceSavingAs) { void DocumentSaveClickHandler::doSave(DocumentData *data, bool forceSavingAs) {
if (!data->date) return; if (!data->date) return;
QString filepath = data->filepath(DocumentData::FilePathResolveSaveFromDataSilent, forceSavingAs); auto filepath = data->filepath(DocumentData::FilePathResolveSaveFromDataSilent, forceSavingAs);
if (!filepath.isEmpty() && !forceSavingAs) { if (!filepath.isEmpty() && !forceSavingAs) {
QPoint pos(QCursor::pos()); auto pos = QCursor::pos();
if (!psShowOpenWithMenu(pos.x(), pos.y(), filepath)) { if (!psShowOpenWithMenu(pos.x(), pos.y(), filepath)) {
psOpenFile(filepath, true); psOpenFile(filepath, true);
} }
} else { } else {
QFileInfo fileinfo(filepath); auto fileinfo = QFileInfo(filepath);
QDir filedir(filepath.isEmpty() ? QDir() : fileinfo.dir()); auto filedir = filepath.isEmpty() ? QDir() : fileinfo.dir();
QString filename(filepath.isEmpty() ? QString() : fileinfo.fileName()); auto filename = filepath.isEmpty() ? QString() : fileinfo.fileName();
QString newfname = documentSaveFilename(data, forceSavingAs, filename, filedir); auto newfname = documentSaveFilename(data, forceSavingAs, filename, filedir);
if (!newfname.isEmpty()) { if (!newfname.isEmpty()) {
ActionOnLoad action = filename.isEmpty() ? ActionOnLoadNone : ActionOnLoadOpenWith; auto action = (filename.isEmpty() || forceSavingAs) ? ActionOnLoadNone : ActionOnLoadOpenWith;
FullMsgId actionMsgId = App::hoveredLinkItem() ? App::hoveredLinkItem()->fullId() : (App::contextItem() ? App::contextItem()->fullId() : FullMsgId()); auto actionMsgId = App::hoveredLinkItem() ? App::hoveredLinkItem()->fullId() : (App::contextItem() ? App::contextItem()->fullId() : FullMsgId());
data->save(newfname, action, actionMsgId); data->save(newfname, action, actionMsgId);
} }
} }

View file

@ -95,7 +95,16 @@ CountryInput::CountryInput(QWidget *parent, const style::InputField &st) : TWidg
, _st(st) , _st(st)
, _text(lang(lng_country_code)) { , _text(lang(lng_country_code)) {
initCountries(); initCountries();
resize(_st.width, _st.height); resize(_st.width, _st.heightMin);
auto availableWidth = width() - _st.textMargins.left() - _st.textMargins.right() - _st.placeholderMargins.left() - _st.placeholderMargins.right() - 1;
auto placeholderFont = _st.placeholderFont->f;
placeholderFont.setStyleStrategy(QFont::PreferMatch);
auto metrics = QFontMetrics(placeholderFont);
auto placeholder = QString();// metrics.elidedText(lang(lng_country_fake_ph), Qt::ElideRight, availableWidth);
if (!placeholder.isNull()) {
_placeholderPath.addText(0, QFontMetrics(placeholderFont).ascent(), placeholderFont, placeholder);
}
} }
void CountryInput::paintEvent(QPaintEvent *e) { void CountryInput::paintEvent(QPaintEvent *e) {
@ -106,7 +115,7 @@ void CountryInput::paintEvent(QPaintEvent *e) {
p.fillRect(r, _st.textBg); p.fillRect(r, _st.textBg);
} }
if (_st.border) { if (_st.border) {
p.fillRect(0, height() - _st.border, width(), _st.border, _st.borderFg->b); p.fillRect(0, height() - _st.border, width(), _st.border, _st.borderFg);
} }
st::introCountryIcon.paint(p, width() - st::introCountryIcon.width() - st::introCountryIconPosition.x(), st::introCountryIconPosition.y(), width()); st::introCountryIcon.paint(p, width() - st::introCountryIcon.width() - st::introCountryIconPosition.x(), st::introCountryIconPosition.y(), width());
@ -114,6 +123,30 @@ void CountryInput::paintEvent(QPaintEvent *e) {
p.setFont(_st.font); p.setFont(_st.font);
p.setPen(_st.textFg); p.setPen(_st.textFg);
p.drawText(rect().marginsRemoved(_st.textMargins), _text, _st.textAlign); p.drawText(rect().marginsRemoved(_st.textMargins), _text, _st.textAlign);
if (!_placeholderPath.isEmpty()) {
auto placeholderShiftDegree = 1.;
p.save();
p.setClipRect(r);
auto placeholderTop = anim::interpolate(0, _st.placeholderShift, placeholderShiftDegree);
QRect r(rect().marginsRemoved(_st.textMargins + _st.placeholderMargins));
r.moveTop(r.top() + placeholderTop);
if (rtl()) r.moveLeft(width() - r.left() - r.width());
auto placeholderScale = 1. - (1. - _st.placeholderScale) * placeholderShiftDegree;
auto placeholderFg = anim::color(_st.placeholderFg, _st.placeholderFgActive, 0.);
placeholderFg = anim::color(placeholderFg, _st.placeholderFgError, 0.);
PainterHighQualityEnabler hq(p);
p.setPen(Qt::NoPen);
p.setBrush(placeholderFg);
p.translate(r.topLeft());
p.scale(placeholderScale, placeholderScale);
p.drawPath(_placeholderPath);
p.restore();
}
} }
void CountryInput::mouseMoveEvent(QMouseEvent *e) { void CountryInput::mouseMoveEvent(QMouseEvent *e) {

View file

@ -56,6 +56,7 @@ private:
const style::InputField &_st; const style::InputField &_st;
bool _active = false; bool _active = false;
QString _text; QString _text;
QPainterPath _placeholderPath;
}; };

View file

@ -29,7 +29,8 @@ FadeAnimation::FadeAnimation(TWidget *widget) : _widget(widget) {
bool FadeAnimation::paint(Painter &p) { bool FadeAnimation::paint(Painter &p) {
if (_cache.isNull()) return false; if (_cache.isNull()) return false;
p.setOpacity(_animation.current(getms(), _visible ? 1. : 0.)); auto opacity = _animation.current(getms(), _visible ? 1. : 0.);
p.setOpacity(opacity);
p.drawPixmap(0, 0, _cache); p.drawPixmap(0, 0, _cache);
return true; return true;
} }
@ -64,7 +65,9 @@ void FadeAnimation::stopAnimation() {
if (!_cache.isNull()) { if (!_cache.isNull()) {
_cache = QPixmap(); _cache = QPixmap();
updateCallback(); updateCallback();
if (_visible) {
_widget->showChildren(); _widget->showChildren();
}
if (_finishedCallback) { if (_finishedCallback) {
_finishedCallback(); _finishedCallback();
} }

File diff suppressed because it is too large Load diff

View file

@ -247,8 +247,6 @@ class FlatInput : public QLineEdit {
public: public:
FlatInput(QWidget *parent, const style::FlatInput &st, const QString &ph = QString(), const QString &val = QString()); FlatInput(QWidget *parent, const style::FlatInput &st, const QString &ph = QString(), const QString &val = QString());
void setPlaceholder(const QString &ph);
void setPlaceholderFast(bool fast);
void updatePlaceholder(); void updatePlaceholder();
const QString &placeholder() const; const QString &placeholder() const;
QRect placeholderRect() const; QRect placeholderRect() const;
@ -309,7 +307,6 @@ private:
void updatePlaceholderText(); void updatePlaceholderText();
QString _oldtext, _ph, _fullph; QString _oldtext, _ph, _fullph;
bool _fastph = false;
bool _customUpDown = false; bool _customUpDown = false;
@ -324,17 +321,17 @@ private:
QPoint _touchStart; QPoint _touchStart;
}; };
enum CtrlEnterSubmit { enum class CtrlEnterSubmit {
CtrlEnterSubmitEnter, Enter,
CtrlEnterSubmitCtrlEnter, CtrlEnter,
CtrlEnterSubmitBoth, Both,
}; };
class InputArea : public TWidget { class InputArea : public TWidget {
Q_OBJECT Q_OBJECT
public: public:
InputArea(QWidget *parent, const style::InputArea &st, const QString &ph = QString(), const QString &val = QString()); InputArea(QWidget *parent, const style::InputField &st, const QString &ph = QString(), const QString &val = QString());
void showError(); void showError();
@ -345,9 +342,7 @@ public:
const QString &getLastText() const { const QString &getLastText() const {
return _oldtext; return _oldtext;
} }
void updatePlaceholder(); void finishAnimations();
void step_border(float64 ms, bool timer);
QSize sizeHint() const override; QSize sizeHint() const override;
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
@ -362,30 +357,30 @@ public:
void setCtrlEnterSubmit(CtrlEnterSubmit ctrlEnterSubmit); void setCtrlEnterSubmit(CtrlEnterSubmit ctrlEnterSubmit);
void setTextCursor(const QTextCursor &cursor) { void setTextCursor(const QTextCursor &cursor) {
return _inner.setTextCursor(cursor); return _inner->setTextCursor(cursor);
} }
QTextCursor textCursor() const { QTextCursor textCursor() const {
return _inner.textCursor(); return _inner->textCursor();
} }
void setText(const QString &text) { void setText(const QString &text) {
_inner.setText(text); _inner->setText(text);
updatePlaceholder(); startPlaceholderAnimation();
} }
void clear() { void clear() {
_inner.clear(); _inner->clear();
updatePlaceholder(); startPlaceholderAnimation();
} }
bool hasFocus() const { bool hasFocus() const {
return _inner.hasFocus(); return _inner->hasFocus();
} }
void setFocus() { void setFocus() {
_inner.setFocus(); _inner->setFocus();
} }
void clearFocus() { void clearFocus() {
_inner.clearFocus(); _inner->clearFocus();
} }
public slots: private slots:
void onTouchTimer(); void onTouchTimer();
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded); void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
@ -394,6 +389,8 @@ public slots:
void onUndoAvailable(bool avail); void onUndoAvailable(bool avail);
void onRedoAvailable(bool avail); void onRedoAvailable(bool avail);
void onFocusInner();
signals: signals:
void changed(); void changed();
void submitted(bool ctrlShiftEnter); void submitted(bool ctrlShiftEnter);
@ -405,6 +402,9 @@ signals:
void resized(); void resized();
protected: protected:
void startPlaceholderAnimation();
void startBorderAnimation();
void insertEmoji(EmojiPtr emoji, QTextCursor c); void insertEmoji(EmojiPtr emoji, QTextCursor c);
TWidget *tparent() { TWidget *tparent() {
return qobject_cast<TWidget*>(parentWidget()); return qobject_cast<TWidget*>(parentWidget());
@ -421,10 +421,6 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
private: private:
int32 _maxLength;
bool heightAutoupdated();
void checkContentHeight();
class Inner : public QTextEdit { class Inner : public QTextEdit {
public: public:
Inner(InputArea *parent); Inner(InputArea *parent);
@ -436,7 +432,6 @@ private:
void focusInEvent(QFocusEvent *e) override; void focusInEvent(QFocusEvent *e) override;
void focusOutEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
QMimeData *createMimeDataFromSelection() const override; QMimeData *createMimeDataFromSelection() const override;
@ -450,41 +445,55 @@ private:
}; };
friend class Inner; friend class Inner;
void focusInInner(); bool heightAutoupdated();
void checkContentHeight();
void createPlaceholderPath();
void setErrorShown(bool error);
void focusInInner(bool focusByMouse);
void focusOutInner(); void focusOutInner();
void processDocumentContentsChange(int position, int charsAdded); void processDocumentContentsChange(int position, int charsAdded);
void startBorderAnimation(); const style::InputField &_st;
Inner _inner; int _maxLength = -1;
ChildWidget<Inner> _inner;
QString _oldtext; QString _oldtext;
CtrlEnterSubmit _ctrlEnterSubmit; CtrlEnterSubmit _ctrlEnterSubmit = CtrlEnterSubmit::CtrlEnter;
bool _undoAvailable, _redoAvailable, _inHeightCheck; bool _undoAvailable = false;
bool _redoAvailable = false;
bool _inHeightCheck = false;
bool _customUpDown; bool _customUpDown = false;
QString _placeholder, _placeholderFull; QString _placeholder;
bool _placeholderVisible; QString _placeholderFull;
Animation _a_placeholderFocused; Animation _a_placeholderShifted;
Animation _a_placeholderVisible; bool _placeholderShifted = false;
QPainterPath _placeholderPath;
anim::value a_borderOpacityActive; Animation _a_borderShown;
anim::value a_borderFgActive; int _borderAnimationStart = 0;
anim::value a_borderFgError; Animation _a_borderOpacity;
BasicAnimation _a_border; bool _borderVisible = false;
bool _focused, _error; Animation _a_focused;
Animation _a_error;
const style::InputArea &_st; bool _focused = false;
bool _error = false;
QTimer _touchTimer; QTimer _touchTimer;
bool _touchPress, _touchRightButton, _touchMove; bool _touchPress = false;
bool _touchRightButton = false;
bool _touchMove = false;
QPoint _touchStart; QPoint _touchStart;
bool _correcting; bool _correcting = false;
}; };
@ -503,11 +512,8 @@ public:
const QString &getLastText() const { const QString &getLastText() const {
return _oldtext; return _oldtext;
} }
void updatePlaceholder();
void setPlaceholderHidden(bool forcePlaceholderHidden); void setPlaceholderHidden(bool forcePlaceholderHidden);
void finishPlaceholderAnimation(); void finishAnimations();
void step_border(float64 ms, bool timer);
QSize sizeHint() const override; QSize sizeHint() const override;
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
@ -521,38 +527,41 @@ public:
void customUpDown(bool isCustom); void customUpDown(bool isCustom);
void setTextCursor(const QTextCursor &cursor) { void setTextCursor(const QTextCursor &cursor) {
return _inner.setTextCursor(cursor); return _inner->setTextCursor(cursor);
} }
QTextCursor textCursor() const { QTextCursor textCursor() const {
return _inner.textCursor(); return _inner->textCursor();
} }
void setText(const QString &text) { void setText(const QString &text) {
_inner.setText(text); _inner->setText(text);
updatePlaceholder(); startPlaceholderAnimation();
} }
void clear() { void clear() {
_inner.clear(); _inner->clear();
updatePlaceholder(); startPlaceholderAnimation();
} }
bool hasFocus() const { bool hasFocus() const {
return _inner.hasFocus(); return _inner->hasFocus();
} }
void setFocus() { void setFocus() {
_inner.setFocus(); _inner->setFocus();
QTextCursor c(_inner.textCursor()); auto cursor = _inner->textCursor();
c.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::End);
_inner.setTextCursor(c); _inner->setTextCursor(cursor);
} }
void clearFocus() { void clearFocus() {
_inner.clearFocus(); _inner->clearFocus();
} }
void setCursorPosition(int pos) { void setCursorPosition(int pos) {
QTextCursor c(_inner.textCursor()); auto cursor = _inner->textCursor();
c.setPosition(pos); cursor.setPosition(pos);
_inner.setTextCursor(c); _inner->setTextCursor(cursor);
} }
public slots: public slots:
void selectAll();
private slots:
void onTouchTimer(); void onTouchTimer();
void onDocumentContentsChange(int position, int charsRemoved, int charsAdded); void onDocumentContentsChange(int position, int charsRemoved, int charsAdded);
@ -561,7 +570,7 @@ public slots:
void onUndoAvailable(bool avail); void onUndoAvailable(bool avail);
void onRedoAvailable(bool avail); void onRedoAvailable(bool avail);
void selectAll(); void onFocusInner();
signals: signals:
void changed(); void changed();
@ -573,6 +582,9 @@ signals:
void blurred(); void blurred();
protected: protected:
void startPlaceholderAnimation();
void startBorderAnimation();
void insertEmoji(EmojiPtr emoji, QTextCursor c); void insertEmoji(EmojiPtr emoji, QTextCursor c);
TWidget *tparent() { TWidget *tparent() {
return qobject_cast<TWidget*>(parentWidget()); return qobject_cast<TWidget*>(parentWidget());
@ -589,9 +601,6 @@ protected:
void resizeEvent(QResizeEvent *e) override; void resizeEvent(QResizeEvent *e) override;
private: private:
int32 _maxLength;
bool _forcePlaceholderHidden = false;
class Inner : public QTextEdit { class Inner : public QTextEdit {
public: public:
Inner(InputField *parent); Inner(InputField *parent);
@ -603,7 +612,6 @@ private:
void focusInEvent(QFocusEvent *e) override; void focusInEvent(QFocusEvent *e) override;
void focusOutEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override;
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void contextMenuEvent(QContextMenuEvent *e) override; void contextMenuEvent(QContextMenuEvent *e) override;
QMimeData *createMimeDataFromSelection() const override; QMimeData *createMimeDataFromSelection() const override;
@ -617,40 +625,52 @@ private:
}; };
friend class Inner; friend class Inner;
void focusInInner(); void createPlaceholderPath();
void setErrorShown(bool error);
void focusInInner(bool focusByMouse);
void focusOutInner(); void focusOutInner();
void processDocumentContentsChange(int position, int charsAdded); void processDocumentContentsChange(int position, int charsAdded);
void startBorderAnimation(); const style::InputField &_st;
Inner _inner; int _maxLength = -1;
bool _forcePlaceholderHidden = false;
ChildWidget<Inner> _inner;
QString _oldtext; QString _oldtext;
bool _undoAvailable, _redoAvailable; bool _undoAvailable = false;
bool _redoAvailable = false;
bool _customUpDown; bool _customUpDown = true;
QString _placeholder, _placeholderFull; QString _placeholder;
bool _placeholderVisible; QString _placeholderFull;
Animation _a_placeholderFocused; Animation _a_placeholderShifted;
Animation _a_placeholderVisible; bool _placeholderShifted = false;
QPainterPath _placeholderPath;
anim::value a_borderOpacityActive; Animation _a_borderShown;
anim::value a_borderFgActive; int _borderAnimationStart = 0;
anim::value a_borderFgError; Animation _a_borderOpacity;
BasicAnimation _a_border; bool _borderVisible = false;
bool _focused, _error; Animation _a_focused;
Animation _a_error;
const style::InputField &_st; bool _focused = false;
bool _error = false;
QTimer _touchTimer; QTimer _touchTimer;
bool _touchPress, _touchRightButton, _touchMove; bool _touchPress = false;
bool _touchRightButton = false;
bool _touchMove = false;
QPoint _touchStart; QPoint _touchStart;
bool _correcting; bool _correcting = false;
}; };
class MaskedInputField : public QLineEdit { class MaskedInputField : public QLineEdit {
@ -662,14 +682,8 @@ public:
void showError(); void showError();
bool setPlaceholder(const QString &ph);
void setPlaceholderFast(bool fast);
void updatePlaceholder();
QRect getTextRect() const; QRect getTextRect() const;
void step_border(float64 ms, bool timer);
QSize sizeHint() const override; QSize sizeHint() const override;
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
@ -677,13 +691,16 @@ public:
const QString &getLastText() const { const QString &getLastText() const {
return _oldtext; return _oldtext;
} }
void setPlaceholderHidden(bool forcePlaceholderHidden);
void finishAnimations();
void setText(const QString &text) { void setText(const QString &text) {
QLineEdit::setText(text); QLineEdit::setText(text);
updatePlaceholder(); startPlaceholderAnimation();
} }
void clear() { void clear() {
QLineEdit::clear(); QLineEdit::clear();
updatePlaceholder(); startPlaceholderAnimation();
} }
QMargins getMargins() const { QMargins getMargins() const {
@ -706,6 +723,9 @@ signals:
void blurred(); void blurred();
protected: protected:
void startBorderAnimation();
void startPlaceholderAnimation();
bool event(QEvent *e) override; bool event(QEvent *e) override;
void touchEvent(QTouchEvent *e); void touchEvent(QTouchEvent *e);
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
@ -726,13 +746,14 @@ protected:
} }
void setCorrectedText(QString &now, int &nowCursor, const QString &newText, int newPos); void setCorrectedText(QString &now, int &nowCursor, const QString &newText, int newPos);
virtual void paintPlaceholder(Painter &p, TimeMs ms); virtual void paintAdditionalPlaceholder(Painter &p, TimeMs ms) {
}
style::font phFont() { style::font phFont() {
return _st.font; return _st.font;
} }
void placeholderPreparePaint(Painter &p, TimeMs ms); void placeholderAdditionalPrepare(Painter &p, TimeMs ms);
const QString &placeholder() const; const QString &placeholder() const;
QRect placeholderRect() const; QRect placeholderRect() const;
@ -740,34 +761,43 @@ protected:
const style::InputField &_st; const style::InputField &_st;
private: private:
void startBorderAnimation(); void createPlaceholderPath();
void updatePlaceholderText(); void setErrorShown(bool error);
int32 _maxLength; int _maxLength = -1;
bool _forcePlaceholderHidden = false;
QString _oldtext; QString _oldtext;
int32 _oldcursor; int _oldcursor = 0;
bool _undoAvailable, _redoAvailable; bool _undoAvailable = false;
bool _redoAvailable = false;
bool _customUpDown; bool _customUpDown = false;
QString _placeholder, _placeholderFull; QString _placeholder;
bool _placeholderVisible, _placeholderFast; QString _placeholderFull;
Animation _a_placeholderFocused; Animation _a_placeholderShifted;
Animation _a_placeholderVisible; bool _placeholderShifted = false;
QPainterPath _placeholderPath;
anim::value a_borderOpacityActive; Animation _a_borderShown;
anim::value a_borderFgActive; int _borderAnimationStart = 0;
anim::value a_borderFgError; Animation _a_borderOpacity;
BasicAnimation _a_border; bool _borderVisible = false;
bool _focused, _error; Animation _a_focused;
Animation _a_error;
bool _focused = false;
bool _error = false;
style::margins _textMargins; style::margins _textMargins;
QTimer _touchTimer; QTimer _touchTimer;
bool _touchPress, _touchRightButton, _touchMove; bool _touchPress = false;
bool _touchRightButton = false;
bool _touchMove = false;
QPoint _touchStart; QPoint _touchStart;
}; };
@ -810,10 +840,11 @@ protected:
void keyPressEvent(QKeyEvent *e) override; void keyPressEvent(QKeyEvent *e) override;
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override; void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
void paintPlaceholder(Painter &p, TimeMs ms) override; void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
private: private:
QVector<int> _pattern; QVector<int> _pattern;
QString _additionalPlaceholder;
}; };
@ -838,7 +869,7 @@ public:
protected: protected:
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override; void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
void paintPlaceholder(Painter &p, TimeMs ms) override; void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
private: private:
QString _linkPlaceholder; QString _linkPlaceholder;
@ -855,11 +886,11 @@ protected:
void focusInEvent(QFocusEvent *e) override; void focusInEvent(QFocusEvent *e) override;
void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override; void correctValue(const QString &was, int32 wasCursor, QString &now, int32 &nowCursor) override;
void paintPlaceholder(Painter &p, TimeMs ms) override; void paintAdditionalPlaceholder(Painter &p, TimeMs ms) override;
private: private:
QString _defaultPlaceholder;
QVector<int> _pattern; QVector<int> _pattern;
QString _additionalPlaceholder;
}; };

View file

@ -700,7 +700,7 @@ void MultiSelect::Inner::addItem(std_::unique_ptr<Item> item, AddItemWay way) {
if (way != AddItemWay::SkipAnimation) { if (way != AddItemWay::SkipAnimation) {
_items.back()->showAnimated(); _items.back()->showAnimated();
} else { } else {
_field->finishPlaceholderAnimation(); _field->finishAnimations();
finishHeightAnimation(); finishHeightAnimation();
} }
} }

View file

@ -181,16 +181,20 @@ FlatInput {
phDuration: int; phDuration: int;
} }
InputArea { InputField {
textBg: color; textBg: color;
textFg: color; textFg: color;
textMargins: margins; textMargins: margins;
textAlign: align;
placeholderFg: color; placeholderFg: color;
placeholderFgActive: color; placeholderFgActive: color;
placeholderFgError: color;
placeholderMargins: margins; placeholderMargins: margins;
placeholderAlign: align; placeholderAlign: align;
placeholderScale: double;
placeholderShift: pixels; placeholderShift: pixels;
placeholderFont: font;
duration: int; duration: int;
@ -209,34 +213,6 @@ InputArea {
heightMax: pixels; heightMax: pixels;
} }
InputField {
textBg: color;
textFg: color;
textMargins: margins;
textAlign: align;
placeholderFg: color;
placeholderFgActive: color;
placeholderMargins: margins;
placeholderAlign: align;
placeholderShift: pixels;
duration: int;
borderFg: color;
borderFgActive: color;
borderFgError: color;
border: pixels;
borderActive: pixels;
borderError: pixels;
font: font;
width: pixels;
height: pixels;
}
OutlineButton { OutlineButton {
outlineWidth: pixels; outlineWidth: pixels;
outlineFg: color; outlineFg: color;
@ -602,44 +578,21 @@ attentionLeftOutlineButton: OutlineButton(defaultLeftOutlineButton) {
} }
} }
defaultInputArea: InputArea {
textBg: windowBg;
textFg: windowFg;
textMargins: margins(5px, 6px, 5px, 4px);
placeholderFg: #999999;
placeholderFgActive: #aaaaaa;
placeholderMargins: margins(2px, 0px, 2px, 0px);
placeholderAlign: align(topleft);
placeholderShift: 50px;
duration: 120;
borderFg: #e0e0e0;
borderFgActive: activeLineFg;
borderFgError: #e48383;
border: 1px;
borderActive: 2px;
borderError: 2px;
font: boxTextFont;
heightMin: 32px;
heightMax: 128px;
}
defaultInputField: InputField { defaultInputField: InputField {
textBg: windowBg; textBg: windowBg;
textFg: windowFg; textFg: windowFg;
textMargins: margins(0px, 6px, 0px, 4px); textMargins: margins(0px, 26px, 0px, 4px);
textAlign: align(topleft); textAlign: align(topleft);
placeholderFg: #999999; placeholderFg: windowSubTextFg;
placeholderFgActive: #aaaaaa; placeholderFgActive: windowActiveTextFg;
placeholderMargins: margins(2px, 0px, 2px, 0px); placeholderFgError: attentionButtonFg;
placeholderMargins: margins(0px, 0px, 0px, 0px);
placeholderAlign: align(topleft); placeholderAlign: align(topleft);
placeholderShift: 50px; placeholderScale: 0.9;
duration: 120; placeholderShift: -20px;
placeholderFont: font(semibold 14px);
duration: 150;
borderFg: #e0e0e0; borderFg: #e0e0e0;
borderFgActive: activeLineFg; borderFgActive: activeLineFg;
@ -651,7 +604,8 @@ defaultInputField: InputField {
font: boxTextFont; font: boxTextFont;
height: 32px; heightMin: 52px;
heightMax: 148px;
} }
defaultCheckboxIcon: icon {{ "default_checkbox_check", windowFgActive, point(4px, 7px) }}; defaultCheckboxIcon: icon {{ "default_checkbox_check", windowFgActive, point(4px, 7px) }};
@ -909,3 +863,10 @@ MediaPlayerButton {
rippleAreaSize: pixels; rippleAreaSize: pixels;
ripple: RippleAnimation; ripple: RippleAnimation;
} }
ProfilePeerListItem {
button: OutlineButton;
statusFg: color;
statusFgOver: color;
statusFgActive: color;
}

View file

@ -731,7 +731,7 @@ void Notification::showReplyField() {
_replyArea->show(); _replyArea->show();
_replyArea->setFocus(); _replyArea->setFocus();
_replyArea->setMaxLength(MaxMessageSize); _replyArea->setMaxLength(MaxMessageSize);
_replyArea->setCtrlEnterSubmit(Ui::CtrlEnterSubmitBoth); _replyArea->setCtrlEnterSubmit(Ui::CtrlEnterSubmit::Both);
// Catch mouse press event to activate the window. // Catch mouse press event to activate the window.
Sandbox::installEventFilter(this); Sandbox::installEventFilter(this);

View file

@ -68,11 +68,13 @@ notifyActionsDuration: 200;
notifyHideAllHeight: 36px; notifyHideAllHeight: 36px;
notifyReplyArea: InputArea(defaultInputArea) { notifyReplyArea: InputField(defaultInputField) {
font: normalFont; font: normalFont;
textMargins: margins(8px, 8px, 8px, 6px); textMargins: margins(8px, 8px, 8px, 6px);
heightMin: 36px; heightMin: 36px;
heightMax: 72px; heightMax: 72px;
placeholderScale: 0.;
placeholderFont: normalFont;
border: 0px; border: 0px;
borderActive: 0px; borderActive: 0px;
borderError: 0px; borderError: 0px;

View file

@ -3,4 +3,4 @@ AppVersionStrMajor 0.10
AppVersionStrSmall 0.10.20 AppVersionStrSmall 0.10.20
AppVersionStr 0.10.20 AppVersionStr 0.10.20
AlphaChannel 0 AlphaChannel 0
BetaVersion 10019013 BetaVersion 10019014