new flat boxes started

This commit is contained in:
John Preston 2015-10-03 13:09:09 +03:00
parent bd4d43daaf
commit e3e774176e
62 changed files with 785 additions and 645 deletions

View File

@ -62,6 +62,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_month_day" = "{month} {day}";
"lng_month_day_year" = "{month} {day}, {year}";
"lng_box_ok" = "OK";
"lng_box_cancel" = "CANCEL";
"lng_cancel" = "Cancel";
"lng_continue" = "Continue";
"lng_close" = "Close";
@ -152,8 +155,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_signin_no_email_forgot" = "Since you haven't provided a recovery\ne-mail when setting up your password, your remaining options are either to remember your password or to reset your account.";
"lng_signin_cant_email_forgot" = "If you can't restore access to the e-mail, your remaining options are either to remember your password or to reset your account.";
"lng_signin_reset_account" = "Reset your account";
"lng_sigin_sure_reset" = "Warning!\n\nYou will lose all your chats and messages,\nalong with any media and files you shared!\n\nDo you want to reset your account?";
"lng_sigin_reset" = "Reset";
"lng_signin_sure_reset" = "Warning!\n\nYou will lose all your chats and messages,\nalong with any media and files you shared!\n\nDo you want to reset your account?";
"lng_signin_reset" = "RESET";
"lng_signup_title" = "Information and photo";
"lng_signup_desc" = "Please enter your name and\nupload a photo.";
@ -248,7 +251,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_download_path_choose" = "Choose download path";
"lng_sure_clear_downloads" = "Do you want to remove all downloaded files from temp folder? It is done automatically on logout or program uninstall.";
"lng_download_path_failed" = "File download could not be started. It could happen because of a bad download location.\n\nYou can change download path in Settings.";
"lng_download_path_settings" = "Go to Settings";
"lng_download_path_settings" = "SETTINGS";
"lng_download_finish_failed" = "File download could not be finished.\n\nWould you like to try again?";
"lng_download_path_clearing" = "Clearing..";
"lng_download_path_cleared" = "Cleared!";
@ -305,7 +308,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_cloud_password_bad_email" = "Incorrect e-mail, please try other.";
"lng_cloud_password_about" = "This password will be required when you log in on a new device in addition to the pin code.";
"lng_cloud_password_about_recover" = "Warning! Are you sure you don't want to\nadd a password recovery e-mail?\n\nIf you forget your password, you will\nlose access to your Telegram account.";
"lng_cloud_password_almost" = "A confirmation link was sent\nto the e-mail you provided.\n\nTwo-step verification will be enabled\nas soon as you follow that link.";
"lng_cloud_password_skip_email" = "SKIP E-MAIL";
"lng_cloud_password_almost" = "A confirmation link was sent to the e-mail you provided. Two-step verification will be enabled as soon as you follow that link.";
"lng_cloud_password_was_set" = "Two-step verification enabled.";
"lng_cloud_password_updated" = "Your cloud password was updated.";
"lng_cloud_password_removed" = "Two-step verification was disabled.";
@ -332,19 +336,20 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_settings_reset" = "Terminate all other sessions";
"lng_settings_reset_sure" = "Are you sure you want to terminate\nall other sessions?";
"lng_settings_reset_one_sure" = "Do you want to terminate this session?";
"lng_settings_reset_button" = "Terminate";
"lng_settings_reset_button" = "TERMINATE";
"lng_settings_reset_done" = "Other sessions terminated";
"lng_settings_ask_question" = "Ask a Question";
"lng_settings_ask_sure" = "Please note that Telegram Support is done by volunteers. We try to respond as quickly as possible, but it may take a while.\n\nPlease take a look at the Telegram FAQ: it has important troubleshooting tips and answers to most questions.";
"lng_settings_faq_button" = "Go to FAQ";
"lng_settings_ask_ok" = "Ask";
"lng_settings_faq_button" = "GO TO FAQ";
"lng_settings_ask_ok" = "ASK";
"lng_settings_faq" = "Telegram FAQ";
"lng_settings_logout" = "Log Out";
"lng_sure_logout" = "Are you sure you want to log out?";
"lng_box_logout" = "LOG OUT";
"lng_settings_need_restart" = "You need to restart for applying\nsome of the new settings. Restart now?";
"lng_settings_restart_now" = "Restart";
"lng_settings_restart_later" = "Later";
"lng_settings_need_restart" = "You need to restart for applying some of the new settings. Restart now?";
"lng_settings_restart_now" = "RESTART";
"lng_settings_restart_later" = "LATER";
"lng_sessions_header" = "Current session";
"lng_sessions_other_header" = "Active sessions";
@ -416,12 +421,12 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_participant_filter" = "Search";
"lng_participant_invite" = "Invite";
"lng_participant_invite_sorry" = "Sorry, you can only add the first\n{count} members to a channel personally.\n\nFrom now on, people will need\nto join via your invite link.";
"lng_participant_invite_sorry" = "Sorry, you can only add the first {count:_not_used|# member|# members} to a channel personally.\n\nFrom now on, people will need to join via your invite link.";
"lng_create_group_back" = "Back";
"lng_create_group_next" = "Next";
"lng_create_group_create" = "Create";
"lng_create_group_title" = "New Group";
"lng_create_group_about" = "Groups are ideal for smaller communities, they can have up to {count} members";
"lng_create_group_about" = "Groups are ideal for smaller communities, they can have up to {count:_not_used|# member|# members}";
"lng_create_channel_title" = "New Channel";
"lng_create_channel_about" = "Channels are a tool for broadcasting your messages to unlimited audiences";
"lng_create_public_channel_title" = "Public Channel";
@ -451,8 +456,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_sure_delete_history" = "Are you sure, you want to delete all message history with {contact}?\n\nThis action cannot be undone.";
"lng_sure_delete_group_history" = "Are you sure, you want to delete all message history in «{group}»?\n\nThis action cannot be undone.";
"lng_sure_delete_and_exit" = "Are you sure, you want to delete all message history and leave «{group}»?\n\nThis action cannot be undone.";
"lng_sure_leave_channel" = "Are you sure, you want\nto leave this channel?";
"lng_sure_delete_channel" = "Are you sure, you want\nto delete this channel?\n\nAll members will be removed\nand all messages will be lost.";
"lng_sure_leave_channel" = "Are you sure, you want to leave\nthis channel?";
"lng_sure_delete_channel" = "Are you sure, you want to delete this channel? All members will be removed and all messages will be lost.";
"lng_message_empty" = "Empty Message";
"lng_media_unsupported" = "Media Unsupported";
@ -478,13 +483,13 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_channel_hide_comments" = "Hide comments";
"lng_channel_not_accessible" = "Sorry, this channel is not accessible.";
"lng_channels_too_much_public_existing" = "Sorry, you have created\ntoo many public channels already.\n\nPlease delete one first.";
"lng_channels_too_much_public" = "Sorry, you have created\ntoo many public channels.\n\nYou can either create a private channel\nor delete one of your public channels first.";
"lng_channels_too_much_public_existing" = "Sorry, you have created too many public channels already. Please delete one first.";
"lng_channels_too_much_public" = "Sorry, you have created too many public channels.\n\nYou can either create a private channel\nor delete one of your public channels first.";
"lng_group_invite_bad_link" = "This invite link is broken\nor has expired.";
"lng_group_invite_bad_link" = "This invite link is broken or has expired.";
"lng_group_invite_want_join" = "Do you want to join the group «{title}»?";
"lng_group_invite_want_join_channel" = "Do you want to join the channel «{title}»?";
"lng_group_invite_join" = "Join";
"lng_group_invite_join" = "JOIN";
"lng_group_invite_link" = "Invite link:";
"lng_group_invite_create" = "Create an invite link";
@ -492,7 +497,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_group_invite_create_new" = "Revoke invite link";
"lng_group_invite_about_new" = "Your previous link will be deactivated\nand we'll generate a new invite link for you.";
"lng_group_invite_copied" = "Invite link copied to clipboard.";
"lng_group_invite_no_room" = "Unable to join this group because there are\ntoo many members in it already.";
"lng_group_invite_no_room" = "Unable to join this group because there are too many members in it already.";
"lng_channel_public_link_copied" = "Link copied to clipboard.";
@ -528,6 +533,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_switch_stickers" = "Stickers";
"lng_switch_emoji" = "Emoji";
"lng_box_remove" = "REMOVE";
"lng_custom_stickers" = "Custom stickers";
"lng_stickers_remove_pack" = "Remove «{sticker_pack}»?";
"lng_stickers_add_pack" = "Add {count:_not_used_|# Sticker|# Stickers}";
@ -547,10 +554,10 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_report_spam" = "Report Spam";
"lng_report_spam_hide" = "Hide";
"lng_report_spam_thanks" = "Thank you for your report!";
"lng_report_spam_sure" = "Are you sure you want\nto report spam from this user?";
"lng_report_spam_sure_group" = "Are you sure you want\nto report spam in this group?";
"lng_report_spam_sure_channel" = "Are you sure you want\nto report spam in this channel?";
"lng_report_spam_ok" = "Report";
"lng_report_spam_sure" = "Are you sure you want to report spam from this user?";
"lng_report_spam_sure_group" = "Are you sure you want to report spam in this group?";
"lng_report_spam_sure_channel" = "Are you sure you want to report spam in this channel?";
"lng_report_spam_ok" = "REPORT";
"lng_cant_send_to_not_contact" = "Sorry, you can only send messages to\nmutual contacts at the moment. {more_info}";
"lng_cant_invite_not_contact" = "Sorry, you can only add mutual contacts\nto groups at the moment. {more_info}";
"lng_cant_invite_not_contact_channel" = "Sorry, you can only add mutual contacts\nto channels at the moment. {more_info}";
@ -572,7 +579,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_channel_unmute" = "Unmute";
"lng_open_this_link" = "Open this link?";
"lng_open_link" = "Open";
"lng_open_link" = "OPEN";
"lng_bot_start" = "Start";
"lng_bot_choose_group" = "Choose Group";
@ -662,8 +669,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_forward_share_contact" = "Share contact to {recipient}?";
"lng_forward_send_file_confirm" = "Send «{name}» to {recipient}?";
"lng_forward_send_files_confirm" = "Send selected files to {recipient}?";
"lng_forward" = "Forward";
"lng_forward_send" = "Send";
"lng_forward_send" = "SEND";
"lng_forward_messages" = "{count:_not_used_|Forwarded message|# forwarded messages}";
"lng_forwarding_from" = "{user} and {count:_not_used_|# other|# others}";
"lng_forwarding_from_two" = "{user} and {second_user}";
@ -701,7 +707,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
"lng_selected_cancel_sure_this" = "Do you want to cancel this upload?";
"lng_selected_delete_sure_this" = "Do you want to delete this message?";
"lng_selected_delete_sure" = "Do you want to delete {count:_not_used_|# message|# messages}?";
"lng_selected_delete_confirm" = "Delete";
"lng_box_delete" = "DELETE";
"lng_box_leave" = "LEAVE";
"lng_about_version" = "Version {version}";
"lng_about_text" = "Official free messaging app based on [a href=\"https://core.telegram.org/mtproto\"]MTProto[/a] and\n[a href=\"https://core.telegram.org/api\"]Telegram API[/a] for speed and security\n\nThis software is licensed under [a href=\"https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE\"]GNU GPL[/a] version 3,\nsource code is available on [a href=\"https://github.com/telegramdesktop/tdesktop\"]GitHub[/a].";

View File

@ -91,6 +91,40 @@ dialogsSearchField: InputField(defaultInputField) {
width: 240px;
height: 34px;
}
boxWidth: 320px;
boxWideWidth: 364px;
boxPadding: margins(26px, 30px, 26px, 16px);
boxMaxListHeight: 600px;
boxFontSize: 13px;
boxTextFont: font(boxFontSize);
boxTitleFont: font(boxFontSize semibold);
boxButtonFont: font(boxFontSize semibold);
boxTitleHeight: 54px;
defaultBoxButton: BoxButton {
textFg: #2f9fea;
textFgOver: #2f9fea;
textBg: white;
textBgOver: #edf7ff;
width: -24px;
height: 36px;
textTop: 9px;
font: boxButtonFont;
duration: 200;
}
cancelBoxButton: BoxButton(defaultBoxButton) {
textFg: #aeaeae;
}
attentionBoxButton: BoxButton(defaultBoxButton) {
textFg: #ea4b2f;
textFgOver: #ea4b2f;
textBgOver: #fff0ed;
}
boxButtonPadding: margins(12px, 16px, 22px, 16px);
titleBG: #6389a8;
titleColor: #0f8dcc;//rgb(20, 136, 210);
titleHeight: 39px;
@ -936,6 +970,9 @@ defaultTextStyle: textStyle {
selectOverlay: msgSelectOverlay;
lineHeight: 0px;
}
boxTextStyle: textStyle(defaultTextStyle) {
lineHeight: 22px;
}
serviceTextStyle: textStyle(defaultTextStyle) {
lnkFlags: msgServiceFont;
lnkOverFlags: font(fsize semibold underline);
@ -1207,18 +1244,14 @@ layerHideDuration: 200;
layerPadding: margins(10px, 10px, 10px, 10px);
boxFont: font(16px);
boxPadding: margins(18px, 18px, 18px, 18px);
boxVerticalMargin: 10px;
boxWidth: 364px;
boxMaxListHeight: 600px;
boxBG: white;
boxGrayTitle: #777;
boxTitlePos: point(20px, 15px);
boxTitleFont: font(17px);
boxTitleHeight: 52px;
old_boxTitlePos: point(20px, 15px);
old_boxTitleFont: font(17px);
old_boxTitleHeight: 52px;
confirmMaxHeight: 320px;
confirmCompressedSkip: 10px;
@ -1229,6 +1262,9 @@ inpAddContact: flatInput(inpDefGray) {
textMrg: margins(10px, 5px, 10px, 5px);
font: font(15px);
}
contactUserIcon: sprite(120px, 90px, 18px, 18px);
contactPhoneIcon: sprite(138px, 90px, 18px, 18px);
contactAddIcon: sprite(307px, 248px, 22px, 16px);
btnNewGroup: iconedButton(btnDefIconed) {
icon: sprite(189px, 118px, 18px, 17px);
@ -1280,7 +1316,6 @@ notifyHeight: 80px;
notifyDeltaX: 6px;
notifyDeltaY: 7px;
cropBoxWidth: 364px;
cropPointSize: 10px;
cropMinSize: 20px;
@ -1331,10 +1366,11 @@ btnShareContact: flatButton(btnDefNext, btnDefBig) {
overFont: font(17px);
}
profileMinBtnPadding: 10px;
inviteCheckIcon: sprite(187px, 61px, 18px, 14px);
inviteCheckActiveIcon: sprite(187px, 75px, 18px, 14px);
membersPadding: margins(0px, 10px, 0px, 10px);
forwardWidth: 364px;
forwardMargins: margins(30px, 10px, 30px, 10px);
forwardFont: font(16px);
forwardBg: rgba(0, 0, 0, 76);
@ -1431,7 +1467,7 @@ newGroupName: flatInput(inpDefGray) {
newGroupLink: flatInput(inpDefFlat) {
width: 340px;
height: 42px;
font: font(15px);
font: boxTextFont;
textMrg: margins(12px, 4px, 12px, 4px);
bgColor: transparent;
bgActive: transparent;
@ -1559,7 +1595,7 @@ aboutCloseButton: flatButton(contactsClose) {
downTextTop: 16px;
}
btnInfoClose: flatButton(aboutCloseButton) {
width: boxWidth;
width: boxWideWidth;
}
emojiTextFont: font(16px);
@ -1839,7 +1875,6 @@ stickerIconPadding: 5px;
stickerIconOpacity: 0.7;
stickerIconSel: 2px;
stickerIconSelColor: #58b2ed;
stickerIconRecent: sprite(342px, 50px, 21px, 22px);
stickerIconLeft: sprite(342px, 72px, 40px, 1px);
stickerIconRight: sprite(342px, 73px, 40px, 1px);
stickerIconMove: 400;
@ -2114,7 +2149,7 @@ sessionsHeight: 440px;
sessionHeight: 70px;
sessionPadding: margins(20px, 10px, 20px, 0);
sessionsCloseButton: flatButton(aboutCloseButton) {
width: boxWidth;
width: boxWideWidth;
}
sessionNameFont: msgNameFont;
sessionActiveFont: msgDateFont;

View File

@ -268,6 +268,21 @@ botKeyboardButton {
downTextTop: number;
}
BoxButton {
textFg: color;
textFgOver: color;
textBg: color; // rect of textBg with rounded rect of textBgOver upon it
textBgOver: color;
width: number;
height: number;
textTop: number;
font: font;
duration: number;
}
InputField {
textFg: color;
textMargins: margins;

View File

@ -93,7 +93,15 @@ namespace {
QPixmap *sprite = 0, *emojis = 0, *emojisLarge = 0;
QPixmap *corners[RoundCornersCount][4] = { { 0 } };
struct CornersPixmaps {
CornersPixmaps() {
memset(p, 0, sizeof(p));
}
QPixmap *p[4];
};
CornersPixmaps corners[RoundCornersCount];
typedef QMap<uint32, CornersPixmaps> CornersMap;
CornersMap cornersMap;
QImage *cornersMask[4] = { 0 };
typedef QMap<uint64, QPixmap> EmojisMap;
@ -1887,9 +1895,11 @@ namespace App {
cors[1] = rect.copy(r * 2, 0, r, r);
cors[2] = rect.copy(0, r * 2, r, r + (shadow ? s : 0));
cors[3] = rect.copy(r * 2, r * 2, r, r + (shadow ? s : 0));
for (int i = 0; i < 4; ++i) {
::corners[index][i] = new QPixmap(QPixmap::fromImage(cors[i], Qt::ColorOnly));
::corners[index][i]->setDevicePixelRatio(cRetinaFactor());
if (index != NoneCorners) {
for (int i = 0; i < 4; ++i) {
::corners[index].p[i] = new QPixmap(QPixmap::fromImage(cors[i], Qt::ColorOnly));
::corners[index].p[i]->setDevicePixelRatio(cRetinaFactor());
}
}
}
@ -1916,7 +1926,7 @@ namespace App {
}
QImage mask[4];
prepareCorners(MaskCorners, st::msgRadius, st::white, 0, mask);
prepareCorners(NoneCorners, st::msgRadius, st::white, 0, mask);
for (int i = 0; i < 4; ++i) {
::cornersMask[i] = new QImage(mask[i].convertToFormat(QImage::Format_ARGB32_Premultiplied));
::cornersMask[i]->setDevicePixelRatio(cRetinaFactor());
@ -1968,10 +1978,16 @@ namespace App {
::emojisLarge = 0;
for (int32 j = 0; j < 4; ++j) {
for (int32 i = 0; i < RoundCornersCount; ++i) {
delete ::corners[i][j]; ::corners[i][j] = 0;
delete ::corners[i].p[j]; ::corners[i].p[j] = 0;
}
delete ::cornersMask[j]; ::cornersMask[j] = 0;
}
for (CornersMap::const_iterator i = ::cornersMap.cbegin(), e = ::cornersMap.cend(); i != e; ++i) {
for (int32 j = 0; j < 4; ++j) {
delete i->p[j];
}
}
::cornersMap.clear();
mainEmojisMap.clear();
otherEmojisMap.clear();
@ -2394,13 +2410,8 @@ namespace App {
QImage **cornersMask() {
return ::cornersMask;
}
QPixmap **corners(RoundCorners index) {
return ::corners[index];
}
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg, RoundCorners index, const style::color *sh) {
QPixmap **c = ::corners[index];
int32 cw = c[0]->width() / cIntRetinaFactor(), ch = c[0]->height() / cIntRetinaFactor();
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg, const CornersPixmaps &c, const style::color *sh) {
int32 cw = c.p[0]->width() / cIntRetinaFactor(), ch = c.p[0]->height() / cIntRetinaFactor();
if (w < 2 * cw || h < 2 * ch) return;
if (w > 2 * cw) {
p.fillRect(QRect(x + cw, y, w - 2 * cw, ch), bg->b);
@ -2410,20 +2421,41 @@ namespace App {
if (h > 2 * ch) {
p.fillRect(QRect(x, y + ch, w, h - 2 * ch), bg->b);
}
p.drawPixmap(QPoint(x, y), *c[0]);
p.drawPixmap(QPoint(x + w - cw, y), *c[1]);
p.drawPixmap(QPoint(x, y + h - ch), *c[2]);
p.drawPixmap(QPoint(x + w - cw, y + h - ch), *c[3]);
p.drawPixmap(QPoint(x, y), *c.p[0]);
p.drawPixmap(QPoint(x + w - cw, y), *c.p[1]);
p.drawPixmap(QPoint(x, y + h - ch), *c.p[2]);
p.drawPixmap(QPoint(x + w - cw, y + h - ch), *c.p[3]);
}
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg, RoundCorners index, const style::color *sh) {
roundRect(p, x, y, w, h, bg, ::corners[index], sh);
}
void roundShadow(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &sh, RoundCorners index) {
QPixmap **c = App::corners(index);
int32 cw = c[0]->width() / cIntRetinaFactor(), ch = c[0]->height() / cIntRetinaFactor();
const CornersPixmaps &c = ::corners[index];
int32 cw = c.p[0]->width() / cIntRetinaFactor(), ch = c.p[0]->height() / cIntRetinaFactor();
p.fillRect(x + cw, y + h, w - 2 * cw, st::msgShadow, sh->b);
p.fillRect(x, y + h - ch, cw, st::msgShadow, sh->b);
p.fillRect(x + w - cw, y + h - ch, cw, st::msgShadow, sh->b);
p.drawPixmap(x, y + h - ch + st::msgShadow, *c[2]);
p.drawPixmap(x + w - cw, y + h - ch + st::msgShadow, *c[3]);
p.drawPixmap(x, y + h - ch + st::msgShadow, *c.p[2]);
p.drawPixmap(x + w - cw, y + h - ch + st::msgShadow, *c.p[3]);
}
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg) {
uint32 colorKey = ((uint32(bg->c.alpha()) & 0xFF) << 24) | ((uint32(bg->c.red()) & 0xFF) << 16) | ((uint32(bg->c.green()) & 0xFF) << 8) | ((uint32(bg->c.blue()) & 0xFF) << 24);
CornersMap::const_iterator i = cornersMap.find(colorKey);
if (i == cornersMap.cend()) {
QImage images[4];
prepareCorners(NoneCorners, st::msgRadius, bg, 0, images);
CornersPixmaps pixmaps;
for (int j = 0; j < 4; ++j) {
pixmaps.p[j] = new QPixmap(QPixmap::fromImage(images[j], Qt::ColorOnly));
pixmaps.p[j]->setDevicePixelRatio(cRetinaFactor());
}
i = cornersMap.insert(colorKey, pixmaps);
}
roundRect(p, x, y, w, h, bg, i.value(), 0);
}
void initBackground(int32 id, const QImage &p, bool nowrite) {

View File

@ -44,7 +44,7 @@ struct ReplyMarkup {
};
enum RoundCorners {
MaskCorners = 0x00, // for images
NoneCorners = 0x00, // for images
BlackCorners,
ServiceCorners,
ServiceSelectedCorners,
@ -260,7 +260,6 @@ namespace App {
void openLocalUrl(const QString &url);
QImage **cornersMask();
QPixmap **corners(RoundCorners index);
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg, RoundCorners index, const style::color *sh = 0);
inline void roundRect(Painter &p, const QRect &rect, const style::color &bg, RoundCorners index, const style::color *sh = 0) {
return roundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg, index, sh);
@ -269,6 +268,10 @@ namespace App {
inline void roundShadow(Painter &p, const QRect &rect, const style::color &sh, RoundCorners index) {
return roundShadow(p, rect.x(), rect.y(), rect.width(), rect.height(), sh, index);
}
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, const style::color &bg);
inline void roundRect(Painter &p, const QRect &rect, const style::color &bg) {
return roundRect(p, rect.x(), rect.y(), rect.width(), rect.height(), bg);
}
void initBackground(int32 id = DefaultChatBackground, const QImage &p = QImage(), bool nowrite = false);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 KiB

After

Width:  |  Height:  |  Size: 234 KiB

View File

@ -32,8 +32,8 @@ _text(this, lang(lng_about_text), st::aboutLabel, st::aboutTextStyle) {
_version.move(0, st::aboutVersionTop);
_text.move(0, st::aboutTextTop);
_headerWidth = st::aboutHeaderFont->m.width(qsl("Telegram "));
_subheaderWidth = st::aboutSubheaderFont->m.width(qsl("Desktop"));
_headerWidth = st::aboutHeaderFont->width(qsl("Telegram "));
_subheaderWidth = st::aboutSubheaderFont->width(qsl("Desktop"));
_done.move(0, height() - _done.height());

View File

@ -24,8 +24,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "mainwidget.h"
#include "window.h"
AbstractBox::AbstractBox() : _maxHeight(0), _hiding(false), a_opacity(0, 1) {
resize(st::boxWidth, 0);
AbstractBox::AbstractBox(int32 w) : _maxHeight(0), _hiding(false), a_opacity(0, 1) {
resize(w, 0);
}
void AbstractBox::prepare() {
@ -65,20 +65,20 @@ bool AbstractBox::paint(QPainter &p) {
void AbstractBox::paintTitle(Painter &p, const QString &title, bool withShadow) {
if (withShadow) {
// paint shadow
p.fillRect(0, st::boxTitleHeight, width(), st::scrollDef.topsh, st::scrollDef.shColor->b);
p.fillRect(0, st::old_boxTitleHeight, width(), st::scrollDef.topsh, st::scrollDef.shColor->b);
}
// paint box title
p.setFont(st::boxTitleFont->f);
p.setFont(st::old_boxTitleFont->f);
p.setPen(st::black->p);
p.drawTextLeft(st::boxTitlePos.x(), st::boxTitlePos.y(), width(), title);
p.drawTextLeft(st::old_boxTitlePos.x(), st::old_boxTitlePos.y(), width(), title);
}
void AbstractBox::paintGrayTitle(QPainter &p, const QString &title) {
// draw box title
p.setFont(st::boxFont->f);
p.setPen(st::boxGrayTitle->p);
p.drawText(QRect(st::boxTitlePos.x(), st::boxTitlePos.y(), width() - 2 * st::boxTitlePos.x(), st::boxFont->height), title, style::al_top);
p.drawText(QRect(st::old_boxTitlePos.x(), st::old_boxTitlePos.y(), width() - 2 * st::old_boxTitlePos.x(), st::boxFont->height), title, style::al_top);
}
void AbstractBox::paintEvent(QPaintEvent *e) {
@ -134,7 +134,7 @@ void AbstractBox::startHide() {
}
ScrollableBox::ScrollableBox(const style::flatScroll &scroll) : AbstractBox(),
_scroll(this, scroll), _innerPtr(0), _topSkip(st::boxTitleHeight), _bottomSkip(0) {
_scroll(this, scroll), _innerPtr(0), _topSkip(st::old_boxTitleHeight), _bottomSkip(0) {
}
void ScrollableBox::resizeEvent(QResizeEvent *e) {

View File

@ -24,7 +24,7 @@ class AbstractBox : public LayeredWidget {
public:
AbstractBox();
AbstractBox(int32 w = st::boxWideWidth);
void parentResized();
void animStep(float64 ms);
void keyPressEvent(QKeyEvent *e);
@ -73,7 +73,7 @@ public:
protected:
void init(QWidget *inner, int32 bottomSkip = 0, int32 topSkip = st::boxTitleHeight);
void init(QWidget *inner, int32 bottomSkip = 0, int32 topSkip = st::old_boxTitleHeight);
virtual void hideAll();
virtual void showAll();
@ -92,4 +92,4 @@ public:
ItemListBox(const style::flatScroll &scroll);
};
};

View File

@ -63,15 +63,15 @@ void AddContactBox::initBox() {
if (_peer) {
if (_peer->isUser()) {
_boxTitle = lang(_peer == App::self() ? lng_edit_self_title : lng_edit_contact_title);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 2 * _firstInput.height() + 1 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 2 * _firstInput.height() + 1 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
} else if (_peer->isChat()) {
_boxTitle = lang(lng_edit_group_title);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 1 * _firstInput.height() + st::addContactPadding.bottom() + _addButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 1 * _firstInput.height() + st::addContactPadding.bottom() + _addButton.height());
}
} else {
bool readyToAdd = !_phoneInput.text().isEmpty() && (!_firstInput.text().isEmpty() || !_lastInput.text().isEmpty());
_boxTitle = lang(readyToAdd ? lng_confirm_contact_data : lng_enter_contact_data);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 3 * _firstInput.height() + 2 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 3 * _firstInput.height() + 2 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
}
_retryButton.hide();
@ -169,7 +169,7 @@ void AddContactBox::paintEvent(QPaintEvent *e) {
} else {
// draw box text
p.setPen(st::black->p);
p.setFont(st::boxTitleFont->f);
p.setFont(st::old_boxTitleFont->f);
int32 h = size().height() - st::boxPadding.top() * 2 - _retryButton.height() - st::boxPadding.bottom();
p.drawText(QRect(st::boxPadding.left(), st::boxPadding.top(), width() - st::boxPadding.left() - st::boxPadding.right(), h), lng_contact_not_joined(lt_name, _sentName), style::al_topleft);
}
@ -183,11 +183,11 @@ void AddContactBox::paintEvent(QPaintEvent *e) {
void AddContactBox::resizeEvent(QResizeEvent *e) {
if (_invertOrder) {
_lastInput.setGeometry(st::addContactPadding.left(), st::boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _lastInput.height());
_lastInput.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _lastInput.height());
_firstInput.setGeometry(st::addContactPadding.left(), _lastInput.y() + _lastInput.height() + st::addContactDelta, _lastInput.width(), _lastInput.height());
_phoneInput.setGeometry(st::addContactPadding.left(), _firstInput.y() + _firstInput.height() + st::addContactDelta, _lastInput.width(), _lastInput.height());
} else {
_firstInput.setGeometry(st::addContactPadding.left(), st::boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _firstInput.height());
_firstInput.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _firstInput.height());
_lastInput.setGeometry(st::addContactPadding.left(), _firstInput.y() + _firstInput.height() + st::addContactDelta, _firstInput.width(), _firstInput.height());
_phoneInput.setGeometry(st::addContactPadding.left(), _lastInput.y() + _lastInput.height() + st::addContactDelta, _lastInput.width(), _lastInput.height());
}
@ -309,7 +309,7 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
_lastInput.hide();
_phoneInput.hide();
_retryButton.show();
int32 theight = st::boxTitleFont->m.boundingRect(0, 0, width() - st::boxPadding.left() - st::boxPadding.right(), 1, Qt::TextWordWrap, lng_contact_not_joined(lt_name, _sentName)).height();
int32 theight = st::old_boxTitleFont->m.boundingRect(0, 0, width() - st::boxPadding.left() - st::boxPadding.right(), 1, Qt::TextWordWrap, lng_contact_not_joined(lt_name, _sentName)).height();
int32 h = st::boxPadding.top() * 2 + theight + _retryButton.height() + st::boxPadding.bottom();
setMaxHeight(h);
update();
@ -342,7 +342,7 @@ void AddContactBox::onRetry() {
_phoneInput.setDisabled(false);
_retryButton.hide();
_firstInput.setFocus();
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 3 * _firstInput.height() + 2 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 3 * _firstInput.height() + 2 * st::addContactDelta + st::addContactPadding.bottom() + _addButton.height());
update();
}
@ -473,7 +473,7 @@ QRect EditChannelBox::descriptionRect() const {
}
void EditChannelBox::updateMaxHeight() {
int32 h = st::boxTitleHeight + st::newGroupPadding.top() + _title.height();
int32 h = st::old_boxTitleHeight + st::newGroupPadding.top() + _title.height();
h += st::newGroupDescriptionSkip + st::newGroupDescriptionPadding.top() + _description.height() + st::newGroupDescriptionPadding.bottom();
h += st::newGroupPublicLinkSkip + _publicLink.height();
h += st::newGroupPadding.bottom() + _saveButton.height();
@ -497,7 +497,7 @@ bool EditChannelBox::eventFilter(QObject *obj, QEvent *e) {
void EditChannelBox::resizeEvent(QResizeEvent *e) {
_title.resize(width() - st::newGroupPadding.left() - st::newGroupPadding.right(), _title.height());
_title.moveToLeft(st::newGroupPadding.left(), st::boxTitleHeight + st::newGroupPadding.top(), width());
_title.moveToLeft(st::newGroupPadding.left(), st::old_boxTitleHeight + st::newGroupPadding.top(), width());
_description.moveToLeft(st::newGroupPadding.left() + st::newGroupDescriptionPadding.left(), _title.y() + _title.height() + st::newGroupDescriptionSkip + st::newGroupDescriptionPadding.top(), width());

View File

@ -32,9 +32,9 @@ _done(this, lang(lng_about_done), st::langsCloseButton) {
int32 opts[] = { 60, 300, 3600, 18000 }, cnt = sizeof(opts) / sizeof(opts[0]);
resizeMaxHeight(st::langsWidth, st::boxTitleHeight + st::langsPadding.top() + st::langsPadding.bottom() + cnt * (st::langPadding.top() + st::rbDefFlat.height + st::langPadding.bottom()) + _done.height());
resizeMaxHeight(st::langsWidth, st::old_boxTitleHeight + st::langsPadding.top() + st::langsPadding.bottom() + cnt * (st::langPadding.top() + st::rbDefFlat.height + st::langPadding.bottom()) + _done.height());
int32 y = st::boxTitleHeight + st::langsPadding.top();
int32 y = st::old_boxTitleHeight + st::langsPadding.top();
_options.reserve(cnt);
for (int32 i = 0; i < cnt; ++i) {
int32 v = opts[i];

View File

@ -31,42 +31,38 @@ TextParseOptions _confirmBoxTextOptions = {
Qt::LayoutDirectionAuto, // dir
};
ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const QString &cancelText, const style::flatButton &doneStyle, const style::flatButton &cancelStyle) : _infoMsg(false),
_confirm(this, doneText.isEmpty() ? lang(lng_continue) : doneText, doneStyle),
_cancel(this, cancelText.isEmpty() ? lang(lng_cancel) : cancelText, cancelStyle),
_close(this, QString(), st::btnInfoClose),
_text(100) {
ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const style::BoxButton &doneStyle, const QString &cancelText, const style::BoxButton &cancelStyle) : AbstractBox(st::boxWidth),
_informative(false),
_text(100),
_confirm(this, doneText.isEmpty() ? lang(lng_box_ok) : doneText, doneStyle),
_cancel(this, cancelText.isEmpty() ? lang(lng_box_cancel) : cancelText, cancelStyle) {
init(text);
}
ConfirmBox::ConfirmBox(const QString &text, bool noDone, const QString &cancelText) : _infoMsg(true),
_confirm(this, QString(), st::btnSelectDone),
_cancel(this, QString(), st::btnSelectCancel),
_close(this, cancelText.isEmpty() ? lang(lng_close) : cancelText, st::btnInfoClose),
_text(100) {
ConfirmBox::ConfirmBox(const QString &text, const QString &doneText, const style::BoxButton &doneStyle, bool informative) : AbstractBox(st::boxWidth),
_informative(true),
_text(100),
_confirm(this, doneText.isEmpty() ? lang(lng_box_ok) : doneText, doneStyle),
_cancel(this, QString(), st::cancelBoxButton) {
init(text);
}
void ConfirmBox::init(const QString &text) {
_text.setText(st::boxFont, text, (_infoMsg ? _confirmBoxTextOptions : _textPlainOptions));
_text.setText(st::boxTextFont, text, _informative ? _confirmBoxTextOptions : _textPlainOptions);
_textWidth = st::boxWidth + 10 - st::boxPadding.left() - st::boxPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxFont->height);
setMaxHeight(st::boxPadding.top() + _textHeight + st::boxPadding.bottom() + (_infoMsg ? _close.height() : _confirm.height()));
textstyleSet(&st::boxTextStyle);
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
setMaxHeight(st::boxPadding.top() + _textHeight + st::boxPadding.bottom() + st::boxButtonPadding.top() + _confirm.height() + st::boxButtonPadding.bottom());
textstyleRestore();
if (_infoMsg) {
_confirm.hide();
connect(&_confirm, SIGNAL(clicked()), this, SIGNAL(confirmed()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onCancel()));
if (_informative) {
_cancel.hide();
connect(&_close, SIGNAL(clicked()), this, SLOT(onCancel()));
setMouseTracking(_text.hasLinks());
} else {
_close.hide();
connect(&_confirm, SIGNAL(clicked()), this, SIGNAL(confirmed()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(onCancel()));
connect(this, SIGNAL(confirmed()), this, SLOT(onCancel()));
}
setMouseTracking(_text.hasLinks());
prepare();
}
@ -121,7 +117,9 @@ void ConfirmBox::updateLink() {
void ConfirmBox::updateHover() {
QPoint m(mapFromGlobal(_lastMousePos));
bool wasMy = (_myLink == textlnkOver());
textstyleSet(&st::boxTextStyle);
_myLink = _text.link(m.x() - st::boxPadding.left(), m.y() - st::boxPadding.top(), _textWidth, (_text.maxWidth() < width()) ? style::al_center : style::al_left);
textstyleRestore();
if (_myLink != textlnkOver()) {
if (wasMy || _myLink || rect().contains(m)) {
textlnkOver(_myLink);
@ -138,12 +136,11 @@ void ConfirmBox::closePressed() {
void ConfirmBox::hideAll() {
_confirm.hide();
_cancel.hide();
_close.hide();
}
void ConfirmBox::showAll() {
if (_infoMsg) {
_close.show();
if (_informative) {
_confirm.show();
} else {
_confirm.show();
_cancel.show();
@ -162,27 +159,16 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
QPainter p(this);
if (paint(p)) return;
if (!_infoMsg) {
// paint shadows
p.fillRect(0, height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
// paint button sep
p.fillRect(st::btnSelectCancel.width, height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
}
// draw box title / text
p.setFont(st::boxFont->f);
p.setPen(st::black->p);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, (_text.maxWidth() < width()) ? style::al_center : style::al_left);
textstyleSet(&st::boxTextStyle);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, style::al_left);
textstyleRestore();
}
void ConfirmBox::resizeEvent(QResizeEvent *e) {
if (_infoMsg) {
_close.move(0, st::boxPadding.top() + _textHeight + st::boxPadding.bottom());
} else {
_confirm.move(width() - _confirm.width(), st::boxPadding.top() + _textHeight + st::boxPadding.bottom());
_cancel.move(0, st::boxPadding.top() + _textHeight + st::boxPadding.bottom());
}
_confirm.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _confirm.height(), width());
_cancel.moveToRight(st::boxButtonPadding.right() + _confirm.width() + st::boxButtonPadding.left(), _confirm.y(), width());
}
ConfirmLinkBox::ConfirmLinkBox(const QString &url) : ConfirmBox(lang(lng_open_this_link) + qsl("\n\n") + url, lang(lng_open_link)), _url(url) {
@ -198,16 +184,16 @@ void ConfirmLinkBox::onOpenLink() {
App::wnd()->hideLayer();
}
MaxInviteBox::MaxInviteBox(const QString &link) :
_close(this, lang(lng_close), st::btnInfoClose),
_text(st::boxFont, lng_participant_invite_sorry(lt_count, QString::number(cMaxGroupCount())), _confirmBoxTextOptions),
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth),
_close(this, lang(lng_box_ok), st::defaultBoxButton),
_text(st::boxTextFont, lng_participant_invite_sorry(lt_count, cMaxGroupCount()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxPadding.right()),
_link(link), _linkOver(false),
a_goodOpacity(0, 0), a_good(animFunc(this, &MaxInviteBox::goodAnimStep)) {
setMouseTracking(true);
_textWidth = st::boxWidth + 10 - st::boxPadding.left() - st::boxPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxFont->height);
setMaxHeight(st::boxPadding.top() + _textHeight + st::newGroupLinkPadding.top() + st::newGroupLink.height + st::newGroupLinkPadding.bottom() + _close.height());
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxPadding.right();
_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
setMaxHeight(st::boxPadding.top() + _textHeight + st::newGroupLinkPadding.top() + st::newGroupLink.height + st::newGroupLinkPadding.bottom() + _close.height() + st::boxButtonPadding.bottom());
connect(&_close, SIGNAL(clicked()), this, SLOT(onClose()));
@ -269,9 +255,8 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
if (paint(p)) return;
// draw box title / text
p.setFont(st::boxFont->f);
p.setPen(st::black->p);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, (_text.maxWidth() < width()) ? style::al_center : style::al_left);
_text.drawElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, 16, style::al_left);
QTextOption option(style::al_left);
option.setWrapMode(QTextOption::WrapAnywhere);
@ -288,6 +273,6 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
}
void MaxInviteBox::resizeEvent(QResizeEvent *e) {
_close.move(0, height() - _close.height());
_close.moveToRight(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _close.height(), width());
_invitationLink = QRect(st::newGroupPadding.left(), st::boxPadding.top() + _textHeight + st::newGroupLinkPadding.top() + (st::newGroupLink.height / 2) - st::newGroupLinkFont->height, width() - st::newGroupPadding.left() - st::newGroupPadding.right(), 2 * st::newGroupLinkFont->height);
}

View File

@ -19,13 +19,13 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "abstractbox.h"
class InformBox;
class ConfirmBox : public AbstractBox {
Q_OBJECT
public:
ConfirmBox(const QString &text, const QString &doneText = QString(), const QString &cancelText = QString(), const style::flatButton &doneStyle = st::btnSelectDone, const style::flatButton &cancelStyle = st::btnSelectCancel);
ConfirmBox(const QString &text, bool noDone, const QString &cancelText = QString());
ConfirmBox(const QString &text, const QString &doneText = QString(), const style::BoxButton &doneStyle = st::defaultBoxButton, const QString &cancelText = QString(), const style::BoxButton &cancelStyle = st::cancelBoxButton);
void keyPressEvent(QKeyEvent *e);
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
@ -53,12 +53,13 @@ protected:
private:
ConfirmBox(const QString &text, const QString &doneText, const style::BoxButton &doneStyle, bool informative);
friend class InformBox;
void init(const QString &text);
bool _infoMsg;
bool _informative;
FlatButton _confirm, _cancel;
BottomButton _close;
Text _text;
int32 _textWidth, _textHeight;
@ -66,6 +67,14 @@ private:
QPoint _lastMousePos;
TextLinkPtr _myLink;
BoxButton _confirm, _cancel;
};
class InformBox : public ConfirmBox {
public:
InformBox(const QString &text, const QString &doneText = QString(), const style::BoxButton &doneStyle = st::defaultBoxButton) : ConfirmBox(text, doneText, doneStyle, true) {
}
};
class ConfirmLinkBox : public ConfirmBox {
@ -108,7 +117,7 @@ private:
void updateSelected(const QPoint &cursorGlobalPosition);
bool goodAnimStep(float64 ms);
BottomButton _close;
BoxButton _close;
Text _text;
int32 _textWidth, _textHeight;

View File

@ -69,7 +69,7 @@ void ConnectionBox::showAll() {
_tcpProxyRadio.show();
_tryIPv6.show();
int32 h = st::boxTitleHeight + st::connectionSkip + _autoRadio.height() + st::connectionSkip + _httpProxyRadio.height() + st::connectionSkip + _tcpProxyRadio.height() + st::connectionSkip + st::lineWidth + st::connectionSkip + _tryIPv6.height() + st::connectionSkip;
int32 h = st::old_boxTitleHeight + st::connectionSkip + _autoRadio.height() + st::connectionSkip + _httpProxyRadio.height() + st::connectionSkip + _tcpProxyRadio.height() + st::connectionSkip + st::lineWidth + st::connectionSkip + _tryIPv6.height() + st::connectionSkip;
if (_httpProxyRadio.checked() || _tcpProxyRadio.checked()) {
h += 2 * st::boxPadding.top() + 2 * _hostInput.height();
_hostInput.show();
@ -113,7 +113,7 @@ void ConnectionBox::paintEvent(QPaintEvent *e) {
}
void ConnectionBox::resizeEvent(QResizeEvent *e) {
_autoRadio.move(st::boxPadding.left(), st::boxTitleHeight + st::connectionSkip);
_autoRadio.move(st::boxPadding.left(), st::old_boxTitleHeight + st::connectionSkip);
_httpProxyRadio.move(st::boxPadding.left(), _autoRadio.y() + _autoRadio.height() + st::connectionSkip);
int32 inputy = 0;

View File

@ -322,15 +322,15 @@ void ContactsInner::paintDialog(Painter &p, PeerData *peer, ContactData *data, b
if (uname && !data->inchat && !data->check && !_lastQuery.isEmpty() && peer->userName().startsWith(_lastQuery, Qt::CaseInsensitive)) {
int32 availw = width() - (left + st::profileListPhotoSize + st::profileListPadding.width() * 2);
QString first = '@' + peer->userName().mid(0, _lastQuery.size()), second = peer->userName().mid(_lastQuery.size());
int32 w = st::profileSubFont->m.width(first);
int32 w = st::profileSubFont->width(first);
if (w >= availw || second.isEmpty()) {
p.setPen(st::profileOnlineColor->p);
p.drawText(left + st::profileListPhotoSize + st::profileListPadding.width(), st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, st::profileSubFont->m.elidedText(first, Qt::ElideRight, availw));
p.drawText(left + st::profileListPhotoSize + st::profileListPadding.width(), st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, st::profileSubFont->elided(first, availw));
} else {
p.setPen(st::profileOnlineColor->p);
p.drawText(left + st::profileListPhotoSize + st::profileListPadding.width(), st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, first);
p.setPen(st::profileOfflineColor->p);
p.drawText(left + st::profileListPhotoSize + st::profileListPadding.width() + w, st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, st::profileSubFont->m.elidedText(second, Qt::ElideRight, availw - w));
p.drawText(left + st::profileListPhotoSize + st::profileListPadding.width() + w, st::profileListPadding.height() + st::profileListPhotoSize - st::profileListStatusBottom, st::profileSubFont->elided(second, availw - w));
}
} else {
if (data->inchat || data->check) {
@ -1300,7 +1300,7 @@ void ContactsBox::paintEvent(QPaintEvent *e) {
if (!addingAdmin) {
p.setPen(st::newGroupLimitFg);
p.drawTextLeft(st::boxTitlePos.x() + st::boxTitleFont->m.width(title) + st::addContactDelta, st::boxTitlePos.y(), width(), QString("%1 / %2").arg(_inner.selectedCount()).arg(cMaxGroupCount()));
p.drawTextLeft(st::old_boxTitlePos.x() + st::old_boxTitleFont->width(title) + st::addContactDelta, st::old_boxTitlePos.y(), width(), QString("%1 / %2").arg(_inner.selectedCount()).arg(cMaxGroupCount()));
// paint button sep
p.fillRect(st::btnSelectCancel.width, size().height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
@ -1421,7 +1421,7 @@ bool ContactsBox::creationFail(const RPCError &error) {
_filter.notaBene();
return true;
} else if (error.type() == "PEER_FLOOD") {
App::wnd()->replaceLayer(new ConfirmBox(lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
App::wnd()->replaceLayer(new InformBox(lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
return true;
}
return false;
@ -1430,7 +1430,7 @@ bool ContactsBox::creationFail(const RPCError &error) {
MembersInner::MembersInner(ChannelData *channel, MembersFilter filter) : _channel(channel), _filter(filter),
_kickText(lang(lng_profile_kick)),
_time(0),
_kickWidth(st::normalFont->m.width(_kickText)),
_kickWidth(st::normalFont->width(_kickText)),
_sel(-1),
_kickSel(-1),
_kickDown(-1),
@ -1667,6 +1667,7 @@ QMap<UserData*, bool> MembersInner::already() const {
}
void MembersInner::clearSel() {
updateSelectedRow();
_sel = _kickSel = _kickDown = -1;
_lastMousePos = QCursor::pos();
updateSel();
@ -1938,8 +1939,7 @@ void MembersBox::onAdd() {
}
ContactsBox *box = new ContactsBox(_inner.channel(), _inner.filter(), _inner.already());
if (_inner.filter() == MembersFilterRecent) {
App::wnd()->hideLayer(true);
App::wnd()->showLayer(box, true);
App::wnd()->showLayer(box);
} else {
_addBox = box;
connect(_addBox, SIGNAL(adminAdded()), this, SLOT(onAdminAdded()));
@ -1971,6 +1971,7 @@ void MembersBox::showAll() {
}
void MembersBox::showDone() {
_inner.clearSel();
setFocus();
}
@ -1978,7 +1979,7 @@ NewGroupBox::NewGroupBox() : AbstractBox(),
_group(this, qsl("group_type"), 0, lang(lng_create_group_title), true),
_channel(this, qsl("group_type"), 1, lang(lng_create_channel_title)),
_aboutGroupWidth(width() - st::newGroupPadding.left() - st::newGroupPadding.right() - st::rbDefFlat.textLeft),
_aboutGroup(st::normalFont, lng_create_group_about(lt_count, QString::number(cMaxGroupCount())), _defaultOptions, _aboutGroupWidth),
_aboutGroup(st::normalFont, lng_create_group_about(lt_count, cMaxGroupCount()), _defaultOptions, _aboutGroupWidth),
_aboutChannel(st::normalFont, lang(lng_create_channel_about), _defaultOptions, _aboutGroupWidth),
_next(this, lang(lng_create_group_next), st::btnSelectDone),
_cancel(this, lang(lng_cancel), st::btnSelectCancel) {
@ -2304,7 +2305,7 @@ bool GroupInfoBox::creationFail(const RPCError &error) {
_name.notaBene();
return true;
} else if (error.type() == "PEER_FLOOD") {
App::wnd()->replaceLayer(new ConfirmBox(lng_cant_invite_not_contact_channel(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
App::wnd()->replaceLayer(new InformBox(lng_cant_invite_not_contact_channel(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
return true;
}
return false;
@ -2315,8 +2316,7 @@ void GroupInfoBox::exportDone(const MTPExportedChatInvite &result) {
if (result.type() == mtpc_chatInviteExported) {
_createdChannel->invitationUrl = qs(result.c_chatInviteExported().vlink);
}
App::wnd()->hideLayer(true);
App::wnd()->showLayer(new SetupChannelBox(_createdChannel), true);
App::wnd()->showLayer(new SetupChannelBox(_createdChannel));
}
void GroupInfoBox::onDescriptionResized() {
@ -2395,7 +2395,7 @@ a_goodOpacity(0, 0), a_good(animFunc(this, &SetupChannelBox::goodAnimStep)) {
_checkRequestId = MTP::send(MTPchannels_CheckUsername(_channel->inputChannel, MTP_string("preston")), RPCDoneHandlerPtr(), rpcFail(&SetupChannelBox::onFirstCheckFail));
_link.setTextMargin(style::margins(st::newGroupLink.textMrg.left() + st::newGroupLink.font->m.width(_linkPlaceholder), st::newGroupLink.textMrg.top(), st::newGroupLink.textMrg.right(), st::newGroupLink.textMrg.bottom()));
_link.setTextMargin(style::margins(st::newGroupLink.textMrg.left() + st::newGroupLink.font->width(_linkPlaceholder), st::newGroupLink.textMrg.top(), st::newGroupLink.textMrg.right(), st::newGroupLink.textMrg.bottom()));
_aboutPublicHeight = _aboutPublic.countHeight(_aboutPublicWidth);
setMaxHeight(st::newGroupPadding.top() + _public.height() + _aboutPublicHeight + st::newGroupSkip + _private.height() + _aboutPrivate.countHeight(_aboutPublicWidth)/* + st::newGroupSkip + _comments.height() + _aboutComments.countHeight(_aboutPublicWidth)*/ + st::newGroupPadding.bottom() + st::newGroupLinkPadding.top() + _link.height() + st::newGroupLinkPadding.bottom() + _save.height());
@ -2569,7 +2569,7 @@ bool SetupChannelBox::goodAnimStep(float64 ms) {
void SetupChannelBox::closePressed() {
if (!_existing) {
App::wnd()->showLayer(new ContactsBox(_channel), true);
App::wnd()->showLayer(new ContactsBox(_channel));
}
}
@ -2654,7 +2654,7 @@ void SetupChannelBox::onPrivacyChange() {
if (_public.checked()) {
if (_tooMuchUsernames) {
_private.setChecked(true);
App::wnd()->replaceLayer(new ConfirmBox(lang(lng_channels_too_much_public), true));
App::wnd()->replaceLayer(new InformBox(lang(lng_channels_too_much_public)));
return;
}
_link.show();
@ -2715,8 +2715,7 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
QString err(error.type());
if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") {
if (_existing) {
App::wnd()->hideLayer(true);
App::wnd()->showLayer(new ConfirmBox(lang(lng_channels_too_much_public_existing), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else {
_tooMuchUsernames = true;
_private.setChecked(true);
@ -2744,8 +2743,7 @@ bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
QString err(error.type());
if (err == "CHANNELS_ADMIN_PUBLIC_TOO_MUCH") {
if (_existing) {
App::wnd()->hideLayer(true);
App::wnd()->showLayer(new ConfirmBox(lang(lng_channels_too_much_public_existing), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_channels_too_much_public_existing)));
} else {
_tooMuchUsernames = true;
_private.setChecked(true);

View File

@ -274,6 +274,7 @@ public:
bool isLoaded() const {
return !_loading;
}
void clearSel();
QMap<UserData*, bool> already() const;
@ -298,7 +299,6 @@ public slots:
private:
void updateSelectedRow();
void clearSel();
MemberData *data(int32 index);
void membersReceived(const MTPchannels_ChannelParticipants &result, mtpRequestId req);

View File

@ -70,7 +70,7 @@ void DownloadPathBox::showAll() {
_saveButton.show();
_cancelButton.show();
int32 h = st::boxTitleHeight + st::downloadSkip + _defaultRadio.height() + st::downloadSkip + _tempRadio.height() + st::downloadSkip + _dirRadio.height();
int32 h = st::old_boxTitleHeight + st::downloadSkip + _defaultRadio.height() + st::downloadSkip + _tempRadio.height() + st::downloadSkip + _dirRadio.height();
if (_dirRadio.checked()) h += st::boxPadding.top() + _dirInput.height();
h += st::downloadSkip + _saveButton.height();
@ -91,7 +91,7 @@ void DownloadPathBox::paintEvent(QPaintEvent *e) {
}
void DownloadPathBox::resizeEvent(QResizeEvent *e) {
_defaultRadio.move(st::boxPadding.left(), st::boxTitleHeight + st::downloadSkip);
_defaultRadio.move(st::boxPadding.left(), st::old_boxTitleHeight + st::downloadSkip);
_tempRadio.move(st::boxPadding.left(), _defaultRadio.y() + _defaultRadio.height() + st::downloadSkip);
_dirRadio.move(st::boxPadding.left(), _tempRadio.y() + _tempRadio.height() + st::downloadSkip);
int32 inputy = _dirRadio.y() + _dirRadio.height() + st::boxPadding.top();

View File

@ -32,7 +32,7 @@ _done(this, lang(lng_about_done), st::langsCloseButton) {
bool haveTestLang = (cLang() == languageTest);
int32 y = st::boxTitleHeight + st::langsPadding.top();
int32 y = st::old_boxTitleHeight + st::langsPadding.top();
_langs.reserve(languageCount + (haveTestLang ? 1 : 0));
if (haveTestLang) {
_langs.push_back(new FlatRadiobutton(this, qsl("lang"), languageTest, qsl("Custom Lang"), (cLang() == languageTest), st::langButton));
@ -54,7 +54,7 @@ _done(this, lang(lng_about_done), st::langsCloseButton) {
connect(_langs.back(), SIGNAL(changed()), this, SLOT(onChange()));
}
resizeMaxHeight(st::langsWidth, st::boxTitleHeight + st::langsPadding.top() + st::langsPadding.bottom() + (languageCount + (haveTestLang ? 1 : 0)) * (st::langPadding.top() + st::rbDefFlat.height + st::langPadding.bottom()) + _done.height());
resizeMaxHeight(st::langsWidth, st::old_boxTitleHeight + st::langsPadding.top() + st::langsPadding.bottom() + (languageCount + (haveTestLang ? 1 : 0)) * (st::langPadding.top() + st::rbDefFlat.height + st::langPadding.bottom()) + _done.height());
connect(&_done, SIGNAL(clicked()), this, SLOT(onClose()));
@ -80,16 +80,16 @@ void LanguageBox::mousePressEvent(QMouseEvent *e) {
for (int32 i = 1; i < languageCount; ++i) {
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[i] + qsl(".strings"), LangLoaderRequest(lngkeys_cnt));
if (!loader.errors().isEmpty()) {
App::wnd()->showLayer(new ConfirmBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" error :(\n\nError: ") + loader.errors(), true, lang(lng_close)));
App::wnd()->showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" error :(\n\nError: ") + loader.errors()));
return;
} else if (!loader.warnings().isEmpty()) {
QString warn = loader.warnings();
if (warn.size() > 256) warn = warn.mid(0, 254) + qsl("..");
App::wnd()->showLayer(new ConfirmBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" warnings :(\n\nWarnings: ") + warn, true, lang(lng_close)));
App::wnd()->showLayer(new InformBox(qsl("Lang \"") + LanguageCodes[i] + qsl("\" warnings :(\n\nWarnings: ") + warn));
return;
}
}
App::wnd()->showLayer(new ConfirmBox(qsl("Everything seems great in all %1 languages!").arg(languageCount - 1), true, lang(lng_close)));
App::wnd()->showLayer(new InformBox(qsl("Everything seems great in all %1 languages!").arg(languageCount - 1)));
}
}
@ -112,16 +112,16 @@ void LanguageBox::onChange() {
if (_langs[i]->checked() && langId != cLang()) {
LangLoaderResult result;
if (langId > 0) {
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[langId] + qsl(".strings"), LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_continue));
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[langId] + qsl(".strings"), LangLoaderRequest(lng_sure_save_language, lng_box_cancel, lng_box_ok));
result = loader.found();
} else if (langId == languageTest) {
LangLoaderPlain loader(cLangFile(), LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_continue));
LangLoaderPlain loader(cLangFile(), LangLoaderRequest(lng_sure_save_language, lng_box_cancel, lng_box_ok));
result = loader.found();
}
QString text = result.value(lng_sure_save_language, langOriginal(lng_sure_save_language)),
save = result.value(lng_continue, langOriginal(lng_continue)),
cancel = result.value(lng_cancel, langOriginal(lng_cancel));
ConfirmBox *box = new ConfirmBox(text, save, cancel);
save = result.value(lng_box_ok, langOriginal(lng_box_ok)),
cancel = result.value(lng_box_cancel, langOriginal(lng_box_cancel));
ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel);
connect(box, SIGNAL(confirmed()), this, SLOT(onSave()));
connect(box, SIGNAL(closed()), this, SLOT(onRestore()));
App::wnd()->replaceLayer(box);

View File

@ -25,8 +25,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "localstorage.h"
PasscodeBox::PasscodeBox(bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(false),
_setRequest(0), _hasRecovery(false), _aboutHeight(0),
_about(st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right()),
_setRequest(0), _hasRecovery(false), _skipEmailWarning(false), _aboutHeight(0),
_about(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right()),
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
_oldPasscode(this, st::inpAddContact, lang(lng_passcode_enter_old)),
@ -40,8 +40,8 @@ _recover(this, lang(lng_signin_recover)) {
}
PasscodeBox::PasscodeBox(const QByteArray &newSalt, const QByteArray &curSalt, bool hasRecovery, const QString &hint, bool turningOff) : _replacedBy(0), _turningOff(turningOff), _cloudPwd(true),
_setRequest(0), _newSalt(newSalt), _curSalt(curSalt), _hasRecovery(hasRecovery), _hint(hint), _aboutHeight(0),
_about(st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right()),
_setRequest(0), _newSalt(newSalt), _curSalt(curSalt), _hasRecovery(hasRecovery), _skipEmailWarning(false), _hint(hint), _aboutHeight(0),
_about(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right()),
_saveButton(this, lang(_turningOff ? lng_passcode_remove_button : lng_settings_save), st::btnSelectDone),
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
_oldPasscode(this, st::inpAddContact, lang(lng_cloud_password_enter_old)),
@ -57,24 +57,24 @@ _recover(this, lang(lng_signin_recover)) {
void PasscodeBox::init() {
_about.setRichText(st::usernameFont, lang(_cloudPwd ? lng_cloud_password_about : lng_passcode_about));
if (!_hint.isEmpty()) _hintText.setText(st::usernameFont, lng_signin_hint(lt_password_hint, _hint));
_aboutHeight = _about.countHeight(st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right());
_aboutHeight = _about.countHeight(st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right());
_oldPasscode.setEchoMode(QLineEdit::Password);
_newPasscode.setEchoMode(QLineEdit::Password);
_reenterPasscode.setEchoMode(QLineEdit::Password);
if (_turningOff) {
_oldPasscode.show();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_remove : lng_passcode_remove);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 1 * _oldPasscode.height() + st::usernameSkip + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 1 * _oldPasscode.height() + st::usernameSkip + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
} else {
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
if (has) {
_oldPasscode.show();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_change : lng_passcode_change);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 3 * _oldPasscode.height() + st::usernameSkip * 2 + 1 * st::addContactDelta + (_cloudPwd ? _passwordHint.height() + st::addContactDelta : 0) + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 3 * _oldPasscode.height() + st::usernameSkip * 2 + 1 * st::addContactDelta + (_cloudPwd ? _passwordHint.height() + st::addContactDelta : 0) + _aboutHeight + (_hasRecovery ? ((st::usernameSkip + _recover.height()) / 2) : 0) + st::addContactPadding.bottom() + _saveButton.height());
} else {
_oldPasscode.hide();
_boxTitle = lang(_cloudPwd ? lng_cloud_password_create : lng_passcode_create);
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + 2 * _oldPasscode.height() + st::usernameSkip + 1 * st::addContactDelta + (_cloudPwd ? _passwordHint.height() + st::addContactDelta : 0) + _aboutHeight + (_cloudPwd ? st::addContactDelta + _recoverEmail.height() + st::usernameSkip : st::addContactPadding.bottom()) + _saveButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + 2 * _oldPasscode.height() + st::usernameSkip + 1 * st::addContactDelta + (_cloudPwd ? _passwordHint.height() + st::addContactDelta : 0) + _aboutHeight + (_cloudPwd ? st::addContactDelta + _recoverEmail.height() + st::usernameSkip : st::addContactPadding.bottom()) + _saveButton.height());
}
}
@ -220,7 +220,7 @@ void PasscodeBox::paintEvent(QPaintEvent *e) {
void PasscodeBox::resizeEvent(QResizeEvent *e) {
bool has = _cloudPwd ? (!_curSalt.isEmpty()) : cHasPasscode();
_oldPasscode.setGeometry(st::addContactPadding.left(), st::boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _oldPasscode.height());
_oldPasscode.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _oldPasscode.height());
_newPasscode.setGeometry(st::addContactPadding.left(), _oldPasscode.y() + ((_turningOff || has) ? (_oldPasscode.height() + st::usernameSkip) : 0), _oldPasscode.width(), _oldPasscode.height());
_reenterPasscode.setGeometry(st::addContactPadding.left(), _newPasscode.y() + _newPasscode.height() + st::addContactDelta, _newPasscode.width(), _newPasscode.height());
_passwordHint.setGeometry(st::addContactPadding.left(), _reenterPasscode.y() + _reenterPasscode.height() + st::usernameSkip, _reenterPasscode.width(), _reenterPasscode.height());
@ -241,18 +241,21 @@ void PasscodeBox::resizeEvent(QResizeEvent *e) {
}
void PasscodeBox::showDone() {
if (_oldPasscode.isHidden()) {
if (_skipEmailWarning && !_recoverEmail.isHidden()) {
_recoverEmail.setFocus();
} else if (_oldPasscode.isHidden()) {
_newPasscode.setFocus();
} else {
_oldPasscode.setFocus();
}
_skipEmailWarning = false;
}
void PasscodeBox::setPasswordDone(const MTPBool &result) {
_setRequest = 0;
emit reloadPassword();
ConfirmBox *box = new ConfirmBox(lang(_reenterPasscode.isHidden() ? lng_cloud_password_removed : (_oldPasscode.isHidden() ? lng_cloud_password_was_set : lng_cloud_password_updated)), true, lang(lng_about_done));
App::wnd()->showLayer(box, true);
ConfirmBox *box = new InformBox(lang(_reenterPasscode.isHidden() ? lng_cloud_password_removed : (_oldPasscode.isHidden() ? lng_cloud_password_was_set : lng_cloud_password_updated)));
App::wnd()->showLayer(box);
}
bool PasscodeBox::setPasswordFail(const RPCError &error) {
@ -280,8 +283,7 @@ bool PasscodeBox::setPasswordFail(const RPCError &error) {
_recoverEmail.notaBene();
update();
} else if (err == "EMAIL_UNCONFIRMED") {
ConfirmBox *box = new ConfirmBox(lang(lng_cloud_password_almost), true, lang(lng_about_done));
App::wnd()->showLayer(box, true);
App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_almost)));
emit reloadPassword();
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
if (_oldPasscode.isHidden()) return false;
@ -349,7 +351,8 @@ void PasscodeBox::onSave(bool force) {
return;
}
if (!_recoverEmail.isHidden() && email.isEmpty() && !force) {
_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover));
_skipEmailWarning = true;
_replacedBy = new ConfirmBox(lang(lng_cloud_password_about_recover), lang(lng_cloud_password_skip_email), st::attentionBoxButton);
connect(_replacedBy, SIGNAL(confirmed()), this, SLOT(onForceNoMail()));
connect(_replacedBy, SIGNAL(destroyed(QObject*)), this, SLOT(onBoxDestroyed(QObject*)));
App::wnd()->replaceLayer(_replacedBy);
@ -459,11 +462,11 @@ bool PasscodeBox::recoverStartFail(const RPCError &error) {
}
RecoverBox::RecoverBox(const QString &pattern) :
_submitRequest(0), _pattern(st::usernameFont->m.elidedText(lng_signin_recover_hint(lt_recover_email, pattern), Qt::ElideRight, st::boxWidth - st::addContactPadding.left() - st::addContactPadding.right())),
_submitRequest(0), _pattern(st::usernameFont->elided(lng_signin_recover_hint(lt_recover_email, pattern), st::boxWideWidth - st::addContactPadding.left() - st::addContactPadding.right())),
_saveButton(this, lang(lng_passcode_submit), st::btnSelectDone),
_cancelButton(this, lang(lng_cancel), st::btnSelectCancel),
_recoverCode(this, st::inpAddContact, lang(lng_signin_code)) {
setMaxHeight(st::boxTitleHeight + st::addContactPadding.top() + st::usernameSkip + _recoverCode.height() + st::usernameSkip + st::addContactPadding.bottom() + _saveButton.height());
setMaxHeight(st::old_boxTitleHeight + st::addContactPadding.top() + st::usernameSkip + _recoverCode.height() + st::usernameSkip + st::addContactPadding.bottom() + _saveButton.height());
connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSubmit()));
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
@ -521,7 +524,7 @@ void RecoverBox::paintEvent(QPaintEvent *e) {
}
void RecoverBox::resizeEvent(QResizeEvent *e) {
_recoverCode.setGeometry(st::addContactPadding.left(), st::boxTitleHeight + st::addContactPadding.top() + st::usernameSkip, width() - st::addContactPadding.left() - st::addContactPadding.right(), _recoverCode.height());
_recoverCode.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top() + st::usernameSkip, width() - st::addContactPadding.left() - st::addContactPadding.right(), _recoverCode.height());
int32 buttonTop = height() - _cancelButton.height();
_cancelButton.move(0, buttonTop);
@ -553,8 +556,7 @@ void RecoverBox::codeSubmitDone(bool recover, const MTPauth_Authorization &resul
_submitRequest = 0;
emit reloadPassword();
ConfirmBox *box = new ConfirmBox(lang(lng_cloud_password_removed), true, lang(lng_about_done));
App::wnd()->showLayer(box, true);
App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_removed)));
}
bool RecoverBox::codeSubmitFail(const RPCError &error) {
@ -563,8 +565,7 @@ bool RecoverBox::codeSubmitFail(const RPCError &error) {
const QString &err = error.type();
if (err == "PASSWORD_EMPTY") {
emit reloadPassword();
ConfirmBox *box = new ConfirmBox(lang(lng_cloud_password_removed), true, lang(lng_about_done));
App::wnd()->showLayer(box, true);
App::wnd()->showLayer(new InformBox(lang(lng_cloud_password_removed)));
return true;
} else if (err == "PASSWORD_RECOVERY_NA") {
onClose();

View File

@ -69,7 +69,7 @@ private:
mtpRequestId _setRequest;
QByteArray _newSalt, _curSalt;
bool _hasRecovery;
bool _hasRecovery, _skipEmailWarning;
QString _hint;
int32 _aboutHeight;

View File

@ -43,7 +43,7 @@ PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) :
connect(this, SIGNAL(ready(const QImage &)), this, SLOT(onReady(const QImage &)));
}
int32 s = st::cropBoxWidth - st::boxPadding.left() - st::boxPadding.right();
int32 s = st::boxWideWidth - st::boxPadding.left() - st::boxPadding.right();
_thumb = QPixmap::fromImage(img.scaled(s, s, Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly);
_thumbw = _thumb.width();
_thumbh = _thumb.height();
@ -55,11 +55,11 @@ PhotoCropBox::PhotoCropBox(const QImage &img, const PeerId &peer, bool upload) :
_cropx = (_thumbw - _cropw) / 2;
_cropy = (_thumbh - _cropw) / 2;
_thumbx = (st::cropBoxWidth - _thumbw) / 2;
_thumbx = (st::boxWideWidth - _thumbw) / 2;
_thumby = st::boxPadding.top() * 2 + st::boxFont->height;
setMouseTracking(true);
resizeMaxHeight(st::cropBoxWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.top() + st::boxPadding.bottom() + _sendButton.height());
resizeMaxHeight(st::boxWideWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.top() + st::boxPadding.bottom() + _sendButton.height());
}
void PhotoCropBox::mousePressEvent(QMouseEvent *e) {

View File

@ -59,7 +59,7 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedi
_thumbw = 10;
}
}
resizeMaxHeight(st::boxWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::boxPadding.bottom() + _compressed.height() + _sendButton.height());
resizeMaxHeight(st::boxWideWidth, _thumbh + st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::boxPadding.bottom() + _compressed.height() + _sendButton.height());
_thumb = QPixmap::fromImage(_thumb.toImage().scaled(_thumbw * cIntRetinaFactor(), _thumbh * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::ColorOnly);
_thumb.setDevicePixelRatio(cRetinaFactor());
@ -84,12 +84,12 @@ PhotoSendBox::PhotoSendBox(const ReadyLocalMedia &img) : _img(new ReadyLocalMedi
_thumb = QPixmap::fromImage(_thumb.toImage().scaledToWidth(_thumbw * cIntRetinaFactor(), Qt::SmoothTransformation), Qt::ColorOnly);
_thumb.setDevicePixelRatio(cRetinaFactor());
}
resizeMaxHeight(st::boxWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
resizeMaxHeight(st::boxWideWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
_name = _img->filename;
_namew = st::mediaFont->m.width(_name);
_namew = st::mediaFont->width(_name);
_size = formatSizeText(_img->filesize);
_textw = qMax(_namew, st::mediaFont->m.width(_size));
_textw = qMax(_namew, st::mediaFont->width(_size));
}
prepare();
}
@ -106,11 +106,11 @@ _phone(phone), _fname(fname), _lname(lname), _replyTo(replyTo) {
_compressed.hide();
_name = lng_full_name(lt_first_name, _fname, lt_last_name, _lname);
_namew = st::mediaFont->m.width(_name);
_namew = st::mediaFont->width(_name);
_size = _phone;
_textw = qMax(_namew, st::mediaFont->m.width(_size));
_textw = qMax(_namew, st::mediaFont->width(_size));
resizeMaxHeight(st::boxWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
resizeMaxHeight(st::boxWideWidth, st::boxPadding.top() + st::boxFont->height + st::boxPadding.bottom() + st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom() + st::boxPadding.bottom() + _sendButton.height());
prepare();
}
@ -161,7 +161,7 @@ void PhotoSendBox::paintEvent(QPaintEvent *e) {
p.setFont(st::mediaFont->f);
p.setPen(st::black->c);
if (twidth < _namew) {
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->m.elidedText(_name, Qt::ElideRight, twidth));
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(_name, twidth));
} else {
p.drawText(x + tleft, y + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, _name);
}

View File

@ -69,7 +69,7 @@ void SessionsInner::onTerminate() {
_terminating = i.key();
if (_terminateBox) _terminateBox->deleteLater();
_terminateBox = new ConfirmBox(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button));
_terminateBox = new ConfirmBox(lang(lng_settings_reset_one_sure), lang(lng_settings_reset_button), st::attentionBoxButton);
connect(_terminateBox, SIGNAL(confirmed()), this, SLOT(onTerminateSure()));
connect(_terminateBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoTerminateBox(QObject*)));
App::wnd()->replaceLayer(_terminateBox);
@ -161,7 +161,7 @@ _terminateAll(this, lang(lng_sessions_terminate_all)), _terminateBox(0), _shortP
connect(App::wnd(), SIGNAL(newAuthorization()), this, SLOT(onNewAuthorization()));
connect(&_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations()));
init(&_inner, _done.height(), st::boxTitleHeight + st::sessionHeight + st::boxTitleHeight);
init(&_inner, _done.height(), st::old_boxTitleHeight + st::sessionHeight + st::old_boxTitleHeight);
_inner.resize(width(), st::noContactsHeight);
prepare();
@ -173,7 +173,7 @@ _terminateAll(this, lang(lng_sessions_terminate_all)), _terminateBox(0), _shortP
void SessionsBox::resizeEvent(QResizeEvent *e) {
ScrollableBox::resizeEvent(e);
_done.move(0, height() - _done.height());
_terminateAll.moveToRight(st::sessionPadding.left(), st::boxTitleHeight + st::sessionHeight + st::boxTitlePos.y() + st::boxTitleFont->ascent - st::linkFont->ascent, width());
_terminateAll.moveToRight(st::sessionPadding.left(), st::old_boxTitleHeight + st::sessionHeight + st::old_boxTitlePos.y() + st::old_boxTitleFont->ascent - st::linkFont->ascent, width());
}
void SessionsBox::hideAll() {
@ -202,7 +202,7 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
if (paint(p)) return;
paintTitle(p, lang(lng_sessions_header), true);
p.translate(0, st::boxTitleHeight);
p.translate(0, st::old_boxTitleHeight);
if (_loading) {
p.setFont(st::noContactsFont->f);
@ -231,10 +231,10 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
p.setFont(st::sessionInfoFont->f);
p.setPen(st::sessionInfoColor->p);
p.drawText(QRect(st::sessionPadding.left(), st::boxTitleHeight + st::boxTitlePos.y(), width() - st::sessionPadding.left() - st::sessionPadding.right(), _scroll.height()), lang(lng_sessions_other_desc), style::al_topleft);
p.drawText(QRect(st::sessionPadding.left(), st::old_boxTitleHeight + st::old_boxTitlePos.y(), width() - st::sessionPadding.left() - st::sessionPadding.right(), _scroll.height()), lang(lng_sessions_other_desc), style::al_topleft);
// paint shadow
p.fillRect(0, height() - st::sessionsCloseButton.height - st::scrollDef.bottomsh - st::sessionHeight - st::boxTitleHeight, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
p.fillRect(0, height() - st::sessionsCloseButton.height - st::scrollDef.bottomsh - st::sessionHeight - st::old_boxTitleHeight, width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
} else {
paintTitle(p, lang(lng_sessions_other_header), false);
}
@ -245,7 +245,7 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
_loading = false;
_shortPollRequest = 0;
int32 availCurrent = st::boxWidth - st::sessionPadding.left() - st::sessionTerminateSkip;
int32 availCurrent = st::boxWideWidth - st::sessionPadding.left() - st::sessionTerminateSkip;
int32 availOther = availCurrent - st::sessionTerminate.iconPos.x();// -st::sessionTerminate.width - st::sessionTerminateSkip;
_list.clear();
@ -282,7 +282,7 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
}
data.name = appName;
if (!appVer.isEmpty()) data.name += ' ' + appVer;
data.nameWidth = st::sessionNameFont->m.width(data.name);
data.nameWidth = st::sessionNameFont->width(data.name);
QString country = qs(d.vcountry), platform = qs(d.vplatform);
//CountriesByISO2::const_iterator j = countries.constFind(country);
@ -297,18 +297,18 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
data.active = QString();
data.activeWidth = 0;
if (data.nameWidth > availCurrent) {
data.name = st::sessionNameFont->m.elidedText(data.name, Qt::ElideRight, availCurrent);
data.nameWidth = st::sessionNameFont->m.width(data.name);
data.name = st::sessionNameFont->elided(data.name, availCurrent);
data.nameWidth = st::sessionNameFont->width(data.name);
}
data.infoWidth = st::sessionInfoFont->m.width(data.info);
data.infoWidth = st::sessionInfoFont->width(data.info);
if (data.infoWidth > availCurrent) {
data.info = st::sessionInfoFont->m.elidedText(data.info, Qt::ElideRight, availCurrent);
data.infoWidth = st::sessionInfoFont->m.width(data.info);
data.info = st::sessionInfoFont->elided(data.info, availCurrent);
data.infoWidth = st::sessionInfoFont->width(data.info);
}
data.ipWidth = st::sessionInfoFont->m.width(data.ip);
data.ipWidth = st::sessionInfoFont->width(data.ip);
if (data.ipWidth > availCurrent) {
data.ip = st::sessionInfoFont->m.elidedText(data.ip, Qt::ElideRight, availCurrent);
data.ipWidth = st::sessionInfoFont->m.width(data.ip);
data.ip = st::sessionInfoFont->elided(data.ip, availCurrent);
data.ipWidth = st::sessionInfoFont->width(data.ip);
}
_current = data;
} else {
@ -322,21 +322,21 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
} else {
data.active = lastDate.toString(qsl("d.MM.yy"));
}
data.activeWidth = st::sessionActiveFont->m.width(data.active);
data.activeWidth = st::sessionActiveFont->width(data.active);
int32 availForName = availOther - st::sessionPadding.right() - data.activeWidth;
if (data.nameWidth > availForName) {
data.name = st::sessionNameFont->m.elidedText(data.name, Qt::ElideRight, availForName);
data.nameWidth = st::sessionNameFont->m.width(data.name);
data.name = st::sessionNameFont->elided(data.name, availForName);
data.nameWidth = st::sessionNameFont->width(data.name);
}
data.infoWidth = st::sessionInfoFont->m.width(data.info);
data.infoWidth = st::sessionInfoFont->width(data.info);
if (data.infoWidth > availOther) {
data.info = st::sessionInfoFont->m.elidedText(data.info, Qt::ElideRight, availOther);
data.infoWidth = st::sessionInfoFont->m.width(data.info);
data.info = st::sessionInfoFont->elided(data.info, availOther);
data.infoWidth = st::sessionInfoFont->width(data.info);
}
data.ipWidth = st::sessionInfoFont->m.width(data.ip);
data.ipWidth = st::sessionInfoFont->width(data.ip);
if (data.ipWidth > availOther) {
data.ip = st::sessionInfoFont->m.elidedText(data.ip, Qt::ElideRight, availOther);
data.ipWidth = st::sessionInfoFont->m.width(data.ip);
data.ip = st::sessionInfoFont->elided(data.ip, availOther);
data.ipWidth = st::sessionInfoFont->width(data.ip);
}
_list.push_back(data);
@ -359,7 +359,7 @@ void SessionsBox::gotAuthorizations(const MTPaccount_Authorizations &result) {
void SessionsBox::onTerminateAll() {
if (_terminateBox) _terminateBox->deleteLater();
_terminateBox = new ConfirmBox(lang(lng_settings_reset_sure), lang(lng_settings_reset_button));
_terminateBox = new ConfirmBox(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton);
connect(_terminateBox, SIGNAL(confirmed()), this, SLOT(onTerminateAllSure()));
connect(_terminateBox, SIGNAL(destroyed(QObject*)), this, SLOT(onNoTerminateBox(QObject*)));
App::wnd()->replaceLayer(_terminateBox);

View File

@ -58,7 +58,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
if (d.vset.type() == mtpc_stickerSet) {
const MTPDstickerSet &s(d.vset.c_stickerSet());
_setTitle = qs(s.vtitle);
_title = st::boxTitleFont->m.elidedText(_setTitle, Qt::ElideRight, width() - st::btnStickersClose.width - st::boxTitlePos.x());
_title = st::old_boxTitleFont->elided(_setTitle, width() - st::btnStickersClose.width - st::old_boxTitlePos.x());
_setShortName = qs(s.vshort_name);
_setId = s.vid.v;
_setAccess = s.vaccess_hash.v;
@ -69,7 +69,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
}
if (_pack.isEmpty()) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_not_found), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found)));
} else {
int32 rows = _pack.size() / StickerPanPerRow + ((_pack.size() % StickerPanPerRow) ? 1 : 0);
resize(st::stickersPadding + StickerPanPerRow * st::stickersSize.width(), rows * st::stickersSize.height() + st::stickersAddOrShare);
@ -87,7 +87,7 @@ bool StickerSetInner::failedSet(const RPCError &error) {
_loaded = true;
App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_not_found), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found)));
return true;
}
@ -134,7 +134,7 @@ void StickerSetInner::installDone(const MTPBool &result) {
bool StickerSetInner::installFailed(const RPCError &error) {
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_not_found), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_stickers_not_found)));
return true;
}
@ -261,7 +261,7 @@ void StickerSetBox::onAddStickers() {
void StickerSetBox::onShareStickers() {
QString url = qsl("https://telegram.me/addstickers/") + _inner.shortName();
QApplication::clipboard()->setText(url);
App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_copied), true), true);
App::wnd()->showLayer(new InformBox(lang(lng_stickers_copied)));
}
void StickerSetBox::onUpdateButtons() {

View File

@ -27,14 +27,14 @@ UsernameBox::UsernameBox() :
_saveButton(this, lang(lng_settings_save), st::usernameDone),
_cancelButton(this, lang(lng_cancel), st::usernameCancel),
_usernameInput(this, st::inpAddContact, qsl("@username"), App::self()->username),
_saveRequest(0), _checkRequest(0), _about(st::usernameWidth - 2 * st::boxTitlePos.x()) {
_saveRequest(0), _checkRequest(0), _about(st::usernameWidth - 2 * st::old_boxTitlePos.x()) {
_about.setRichText(st::usernameFont, lang(lng_username_about));
_goodText = App::self()->username.isEmpty() ? QString() : lang(lng_username_available);
initBox();
}
void UsernameBox::initBox() {
resizeMaxHeight(st::usernameWidth, st::boxTitleHeight + st::addContactPadding.top() + _usernameInput.height() + st::addContactPadding.bottom() + _about.countHeight(st::usernameWidth - 2 * st::boxTitlePos.x()) + st::usernameSkip + _saveButton.height());
resizeMaxHeight(st::usernameWidth, st::old_boxTitleHeight + st::addContactPadding.top() + _usernameInput.height() + st::addContactPadding.bottom() + _about.countHeight(st::usernameWidth - 2 * st::old_boxTitlePos.x()) + st::usernameSkip + _saveButton.height());
connect(&_saveButton, SIGNAL(clicked()), this, SLOT(onSave()));
connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(onClose()));
@ -85,20 +85,20 @@ void UsernameBox::paintEvent(QPaintEvent *e) {
if (!_errorText.isEmpty()) {
p.setPen(st::setErrColor->p);
p.setFont(st::setErrFont->f);
int32 w = st::setErrFont->m.width(_errorText);
int32 w = st::setErrFont->width(_errorText);
p.drawText((width() - w) / 2, _usernameInput.y() + _usernameInput.height() + ((st::usernameSkip - st::setErrFont->height) / 2) + st::setErrFont->ascent, _errorText);
} else if (!_goodText.isEmpty()) {
p.setPen(st::setGoodColor->p);
p.setFont(st::setErrFont->f);
int32 w = st::setErrFont->m.width(_goodText);
int32 w = st::setErrFont->width(_goodText);
p.drawText((width() - w) / 2, _usernameInput.y() + _usernameInput.height() + ((st::usernameSkip - st::setErrFont->height) / 2) + st::setErrFont->ascent, _goodText);
}
p.setPen(st::usernameColor->p);
_about.draw(p, st::boxTitlePos.x(), _usernameInput.y() + _usernameInput.height() + st::usernameSkip, width() - 2 * st::boxTitlePos.x());
_about.draw(p, st::old_boxTitlePos.x(), _usernameInput.y() + _usernameInput.height() + st::usernameSkip, width() - 2 * st::old_boxTitlePos.x());
}
void UsernameBox::resizeEvent(QResizeEvent *e) {
_usernameInput.setGeometry(st::addContactPadding.left(), st::boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _usernameInput.height());
_usernameInput.setGeometry(st::addContactPadding.left(), st::old_boxTitleHeight + st::addContactPadding.top(), width() - st::addContactPadding.left() - st::addContactPadding.right(), _usernameInput.height());
int32 buttonTop = height() - _cancelButton.height();
_cancelButton.move(0, buttonTop);

View File

@ -115,13 +115,13 @@ void DialogsInner::paintRegion(Painter &p, const QRegion &region, bool paintingO
}
QString first = (_hashtagFilter.size() < 2) ? QString() : ('#' + hashtagResults.at(from).mid(0, _hashtagFilter.size() - 1)), second = (_hashtagFilter.size() < 2) ? ('#' + hashtagResults.at(from)) : hashtagResults.at(from).mid(_hashtagFilter.size() - 1);
int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second);
int32 firstwidth = st::mentionFont->width(first), secondwidth = st::mentionFont->width(second);
if (htagwidth < firstwidth + secondwidth) {
if (htagwidth < firstwidth + st::mentionFont->elidew) {
first = st::mentionFont->m.elidedText(first + second, Qt::ElideRight, htagwidth);
first = st::mentionFont->elided(first + second, htagwidth);
second = QString();
} else {
second = st::mentionFont->m.elidedText(second, Qt::ElideRight, htagwidth - firstwidth);
second = st::mentionFont->elided(second, htagwidth - firstwidth);
}
}
@ -251,19 +251,19 @@ void DialogsInner::peopleResultPaint(PeerData *peer, Painter &p, int32 w, bool a
QString username = peer->userName();
if (!act && username.toLower().startsWith(peopleQuery)) {
QString first = '@' + username.mid(0, peopleQuery.size()), second = username.mid(peopleQuery.size());
int32 w = st::dlgHistFont->m.width(first);
int32 w = st::dlgHistFont->width(first);
if (w >= tr.width()) {
p.setPen(st::dlgSystemColor->p);
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText(first, Qt::ElideRight, tr.width()));
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided(first, tr.width()));
} else {
p.setPen(st::dlgSystemColor->p);
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, first);
p.setPen(st::dlgTextColor->p);
p.drawText(tr.left() + w, tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText(second, Qt::ElideRight, tr.width() - w));
p.drawText(tr.left() + w, tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided(second, tr.width() - w));
}
} else {
p.setPen((act ? st::dlgActiveColor : st::dlgSystemColor)->p);
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText('@' + username, Qt::ElideRight, tr.width()));
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided('@' + username, tr.width()));
}
p.setPen((act ? st::dlgActiveColor : st::dlgNameColor)->p);
@ -293,7 +293,7 @@ void DialogsInner::searchInPeerPaint(Painter &p, int32 w, bool onlyBackground) c
QRect tr(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, namewidth, st::dlgFont->height);
p.setFont(st::dlgHistFont->f);
p.setPen(st::dlgTextColor->p);
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText(lang(lng_dlg_search_chat), Qt::ElideRight, tr.width()));
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided(lang(lng_dlg_search_chat), tr.width()));
p.setPen(st::dlgNameColor->p);
_searchInPeer->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
@ -484,7 +484,7 @@ void DialogsInner::dlgUpdated(DialogRow *row) {
}
}
void DialogsInner::dlgUpdated(History *history) {
void DialogsInner::dlgUpdated(History *history, MsgId msgId) {
if (_state == DefaultState) {
DialogRow *row = 0;
DialogsList::RowByPeer::iterator i = dialogs.list.rowByPeer.find(history->peer->id);
@ -518,7 +518,7 @@ void DialogsInner::dlgUpdated(History *history) {
if (!searchResults.isEmpty()) {
int32 cnt = 0, add = searchedOffset();
for (SearchResults::const_iterator i = searchResults.cbegin(), e = searchResults.cend(); i != e; ++i) {
if ((*i)->_item->history() == history) {
if ((*i)->_item->history() == history && (*i)->_item->id == msgId) {
update(0, add + cnt * st::dlgHeight, fullWidth(), st::dlgHeight);
break;
}
@ -1558,8 +1558,8 @@ void DialogsWidget::dlgUpdated(DialogRow *row) {
_inner.dlgUpdated(row);
}
void DialogsWidget::dlgUpdated(History *row) {
_inner.dlgUpdated(row);
void DialogsWidget::dlgUpdated(History *row, MsgId msgId) {
_inner.dlgUpdated(row, msgId);
}
void DialogsWidget::dialogsToUp() {

View File

@ -57,7 +57,7 @@ public:
void createDialog(History *history);
void moveDialogToTop(const History::DialogLinks &links);
void dlgUpdated(DialogRow *row);
void dlgUpdated(History *row);
void dlgUpdated(History *row, MsgId msgId);
void removePeer(PeerData *peer);
void removeContact(UserData *user);
@ -200,7 +200,7 @@ public:
void loadDialogs();
void createDialog(History *history);
void dlgUpdated(DialogRow *row);
void dlgUpdated(History *row);
void dlgUpdated(History *row, MsgId msgId);
void dialogsToUp();

View File

@ -1772,9 +1772,9 @@ void EmojiPanel::updateText() {
}
} else {
QString switchText = lang((_setId != NoneStickerSetId) ? lng_switch_emoji : lng_switch_stickers);
availw -= st::emojiSwitchSkip + st::emojiPanHeaderFont->m.width(switchText);
availw -= st::emojiSwitchSkip + st::emojiPanHeaderFont->width(switchText);
}
_text = st::emojiPanHeaderFont->m.elidedText(_fullText, Qt::ElideRight, availw);
_text = st::emojiPanHeaderFont->elided(_fullText, availw);
update();
}
@ -1805,7 +1805,7 @@ void EmojiPanel::paintEvent(QPaintEvent *e) {
EmojiSwitchButton::EmojiSwitchButton(QWidget *parent, bool toStickers) : Button(parent),
_toStickers(toStickers), _text(lang(_toStickers ? lng_switch_stickers : lng_switch_emoji)),
_textWidth(st::emojiPanHeaderFont->m.width(_text)) {
_textWidth(st::emojiPanHeaderFont->width(_text)) {
int32 w = st::emojiSwitchSkip + _textWidth + (st::emojiSwitchSkip - st::emojiSwitchImgSkip);
setCursor(style::cur_pointer);
resize(w, st::emojiPanHeader);
@ -2613,7 +2613,7 @@ void EmojiPan::onRemoveSet(quint64 setId) {
StickerSets::const_iterator it = cStickerSets().constFind(setId);
if (it != cStickerSets().cend() && !(it->flags & MTPDstickerSet_flag_official)) {
_removingSetId = it->id;
ConfirmBox *box = new ConfirmBox(lng_stickers_remove_pack(lt_sticker_pack, it->title));
ConfirmBox *box = new ConfirmBox(lng_stickers_remove_pack(lt_sticker_pack, it->title), lang(lng_box_remove));
connect(box, SIGNAL(confirmed()), this, SLOT(onRemoveSetSure()));
connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onDelayedHide()));
App::wnd()->showLayer(box);
@ -2662,7 +2662,7 @@ MentionsInner::MentionsInner(MentionsDropdown *parent, MentionRows *rows, Hashta
void MentionsInner::paintEvent(QPaintEvent *e) {
QPainter p(this);
int32 atwidth = st::mentionFont->m.width('@'), hashwidth = st::mentionFont->m.width('#');
int32 atwidth = st::mentionFont->width('@'), hashwidth = st::mentionFont->width('#');
int32 mentionleft = 2 * st::mentionPadding.left() + st::mentionPhotoSize;
int32 mentionwidth = width() - mentionleft - 2 * st::mentionPadding.right();
int32 htagleft = st::btnAttachPhoto.width + st::taMsgField.textMrg.left() - st::dlgShadow, htagwidth = width() - st::mentionPadding.right() - htagleft - st::mentionScroll.width;
@ -2683,19 +2683,19 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
if (!_rows->isEmpty()) {
UserData *user = _rows->at(i);
QString first = (_parent->filter().size() < 2) ? QString() : ('@' + user->username.mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('@' + user->username) : user->username.mid(_parent->filter().size() - 1);
int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second), unamewidth = firstwidth + secondwidth, namewidth = user->nameText.maxWidth();
int32 firstwidth = st::mentionFont->width(first), secondwidth = st::mentionFont->width(second), unamewidth = firstwidth + secondwidth, namewidth = user->nameText.maxWidth();
if (mentionwidth < unamewidth + namewidth) {
namewidth = (mentionwidth * namewidth) / (namewidth + unamewidth);
unamewidth = mentionwidth - namewidth;
if (firstwidth < unamewidth + st::mentionFont->elidew) {
if (firstwidth < unamewidth) {
first = st::mentionFont->m.elidedText(first, Qt::ElideRight, unamewidth);
first = st::mentionFont->elided(first, unamewidth);
} else if (!second.isEmpty()) {
first = st::mentionFont->m.elidedText(first + second, Qt::ElideRight, unamewidth);
first = st::mentionFont->elided(first + second, unamewidth);
second = QString();
}
} else {
second = st::mentionFont->m.elidedText(second, Qt::ElideRight, unamewidth - firstwidth);
second = st::mentionFont->elided(second, unamewidth - firstwidth);
}
}
user->photo->load();
@ -2712,13 +2712,13 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
} else if (!_hrows->isEmpty()) {
QString hrow = _hrows->at(i);
QString first = (_parent->filter().size() < 2) ? QString() : ('#' + hrow.mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('#' + hrow) : hrow.mid(_parent->filter().size() - 1);
int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second);
int32 firstwidth = st::mentionFont->width(first), secondwidth = st::mentionFont->width(second);
if (htagwidth < firstwidth + secondwidth) {
if (htagwidth < firstwidth + st::mentionFont->elidew) {
first = st::mentionFont->m.elidedText(first + second, Qt::ElideRight, htagwidth);
first = st::mentionFont->elided(first + second, htagwidth);
second = QString();
} else {
second = st::mentionFont->m.elidedText(second, Qt::ElideRight, htagwidth - firstwidth);
second = st::mentionFont->elided(second, htagwidth - firstwidth);
}
}
@ -2747,13 +2747,13 @@ void MentionsInner::paintEvent(QPaintEvent *e) {
int32 addleft = 0, widthleft = mentionwidth;
QString first = (_parent->filter().size() < 2) ? QString() : ('/' + toHighlight.mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('/' + toHighlight) : toHighlight.mid(_parent->filter().size() - 1);
int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second);
int32 firstwidth = st::mentionFont->width(first), secondwidth = st::mentionFont->width(second);
if (widthleft < firstwidth + secondwidth) {
if (widthleft < firstwidth + st::mentionFont->elidew) {
first = st::mentionFont->m.elidedText(first + second, Qt::ElideRight, widthleft);
first = st::mentionFont->elided(first + second, widthleft);
second = QString();
} else {
second = st::mentionFont->m.elidedText(second, Qt::ElideRight, widthleft - firstwidth);
second = st::mentionFont->elided(second, widthleft - firstwidth);
}
}
p.setFont(st::mentionFont->f);

View File

@ -431,8 +431,6 @@ private:
};
class EmojiSwitchButton : public Button {
Q_OBJECT
public:
EmojiSwitchButton(QWidget *parent, bool toStickers); // otherwise toEmoji

View File

@ -199,7 +199,7 @@ void CountryInput::onFinishCountry() {
}
void CountryInput::setText(const QString &newText) {
_text = _st.font->m.elidedText(newText, Qt::ElideRight, width() - _st.textMrg.left() - _st.textMrg.right());
_text = _st.font->elided(newText, width() - _st.textMrg.left() - _st.textMrg.right());
}
CountryInput::~CountryInput() {
@ -315,7 +315,7 @@ void CountryList::paintEvent(QPaintEvent *e) {
}
p.setFont(_st.font->f);
p.setPen(_st.color->p);
p.drawText(textRect, _st.font->m.elidedText(QString::fromUtf8((*countriesNow)[i]->name), Qt::ElideRight, width() - 2 * _st.margin - _st.codeWidth), QTextOption(style::al_left));
p.drawText(textRect, _st.font->elided(QString::fromUtf8((*countriesNow)[i]->name), width() - 2 * _st.margin - _st.codeWidth), QTextOption(style::al_left));
p.setFont(_st.codeFont->f);
p.setPen(_st.codeColor->p);
p.drawText(textRect, QString("+") + (*countriesNow)[i]->code, QTextOption(style::al_right));
@ -495,8 +495,8 @@ void CountrySelect::paintEvent(QPaintEvent *e) {
// draw box title / text
p.setPen(st::black->p);
p.setFont(st::boxTitleFont->f);
p.drawText(_innerLeft + st::boxTitlePos.x(), _innerTop + st::boxTitlePos.y() + st::boxTitleFont->ascent, lang(lng_country_select));
p.setFont(st::old_boxTitleFont->f);
p.drawText(_innerLeft + st::old_boxTitlePos.x(), _innerTop + st::old_boxTitlePos.y() + st::old_boxTitleFont->ascent, lang(lng_country_select));
}
}
}

View File

@ -69,7 +69,7 @@ void FlatButton::setAutoFontSize(int32 padding, const QString &txt) {
}
int32 FlatButton::textWidth() const {
return _st.font->m.width(_text);
return _st.font->width(_text);
}
void FlatButton::resizeEvent(QResizeEvent *e) {
@ -77,7 +77,7 @@ void FlatButton::resizeEvent(QResizeEvent *e) {
_autoFont = _st.font;
for (int32 s = _st.font->f.pixelSize(); s >= st::fsize; --s) {
_autoFont = style::font(s, _st.font->flags(), _st.font->family());
if (2 * _autoFontPadding + _autoFont->m.width(_textForAutoSize) <= width()) {
if (2 * _autoFontPadding + _autoFont->width(_textForAutoSize) <= width()) {
break;
}
}
@ -149,7 +149,7 @@ void BottomButton::paintEvent(QPaintEvent *e) {
LinkButton::LinkButton(QWidget *parent, const QString &text, const style::linkButton &st) : Button(parent), _text(text), _st(st) {
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
resize(_st.font->m.width(_text), _st.font->height);
resize(_st.font->width(_text), _st.font->height);
setCursor(style::cur_pointer);
}
@ -162,7 +162,7 @@ void LinkButton::paintEvent(QPaintEvent *e) {
void LinkButton::setText(const QString &text) {
_text = text;
resize(_st.font->m.width(_text), _st.font->height);
resize(_st.font->width(_text), _st.font->height);
update();
}
@ -177,9 +177,9 @@ IconedButton::IconedButton(QWidget *parent, const style::iconedButton &st, const
_text(text), _st(st), _width(_st.width), a_opacity(_st.opacity), a_bg(_st.bgColor->c), _opacity(1) {
if (_width < 0) {
_width = _st.font->m.width(text) - _width;
_width = _st.font->width(text) - _width;
} else if (!_width) {
_width = _st.font->m.width(text) + _st.height - _st.font->height;
_width = _st.font->width(text) + _st.height - _st.font->height;
}
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
resize(_width, _st.height);
@ -195,9 +195,9 @@ void IconedButton::setText(const QString &text) {
if (_text != text) {
_text = text;
if (_st.width < 0) {
_width = _st.font->m.width(text) - _st.width;
_width = _st.font->width(text) - _st.width;
} else if (!_st.width) {
_width = _st.font->m.width(text) + _st.height - _st.font->height;
_width = _st.font->width(text) + _st.height - _st.font->height;
}
resize(_width, _st.height);
update();
@ -291,3 +291,70 @@ void MaskedButton::paintEvent(QPaintEvent *e) {
p.drawPixmap(t, App::sprite(), i);
}
}
BoxButton::BoxButton(QWidget *parent, const QString &text, const style::BoxButton &st) : Button(parent),
_text(text), _fullText(text), _textWidth(st.font->width(text)),
_st(st),
a_textBgOverOpacity(0), a_textFg(st.textFg->c), _a_over(animFunc(this, &BoxButton::animStep_over)) {
if (_st.width <= 0) {
resize(_textWidth - _st.width, _st.height);
} else if (_st.width < _textWidth + (_st.height - _st.font->height)) {
_text = _st.font->elided(_fullText, qMax(_st.width - (_st.height - _st.font->height), 1.));
_textWidth = _st.font->width(_text);
}
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
setCursor(style::cur_pointer);
setAttribute(Qt::WA_OpaquePaintEvent);
}
void BoxButton::paintEvent(QPaintEvent *e) {
Painter p(this);
p.fillRect(rect(), _st.textBg->b);
float64 o = a_textBgOverOpacity.current();
if (o > 0) {
p.setOpacity(o);
App::roundRect(p, rect(), _st.textBgOver);
p.setOpacity(1);
p.setPen(a_textFg.current());
} else {
p.setPen(_st.textFg);
}
p.setFont(_st.font);
p.drawText((width() - _textWidth) / 2, _st.textTop + _st.font->ascent, _text);
}
bool BoxButton::animStep_over(float64 ms) {
float64 dt = ms / _st.duration;
bool res = true;
if (dt >= 1) {
a_textFg.finish();
a_textBgOverOpacity.finish();
res = false;
} else {
a_textFg.update(dt, anim::linear);
a_textBgOverOpacity.update(dt, anim::linear);
}
update();
return res;
}
void BoxButton::onStateChange(int oldState, ButtonStateChangeSource source) {
float64 textBgOverOpacity = (_state & StateOver) ? 1 : 0;
style::color textFg = (_state & StateOver) ? (_st.textFgOver) : _st.textFg;
a_textBgOverOpacity.start(textBgOverOpacity);
a_textFg.start(textFg->c);
if (source == ButtonByUser || source == ButtonByPress) {
_a_over.stop();
a_textBgOverOpacity.finish();
a_textFg.finish();
update();
} else {
_a_over.start();
}
}

View File

@ -136,3 +136,30 @@ public:
void paintEvent(QPaintEvent *e);
};
class BoxButton : public Button {
Q_OBJECT
public:
BoxButton(QWidget *parent, const QString &text, const style::BoxButton &st);
void paintEvent(QPaintEvent *e);
bool animStep_over(float64 ms);
public slots:
void onStateChange(int oldState, ButtonStateChangeSource source);
private:
QString _text, _fullText;
int32 _textWidth;
const style::BoxButton &_st;
anim::fvalue a_textBgOverOpacity;
anim::cvalue a_textFg;
Animation _a_over;
};

View File

@ -27,7 +27,7 @@ FlatCheckbox::FlatCheckbox(QWidget *parent, const QString &text, bool checked, c
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
setCursor(_st.cursor);
int32 w = _st.width, h = _st.height;
if (w <= 0) w = _st.textLeft + _st.font->m.width(_text) + 2;
if (w <= 0) w = _st.textLeft + _st.font->width(_text) + 2;
if (h <= 0) h = qMax(_st.font->height, _st.imageRect.pxHeight());
resize(QSize(w, h));
}

View File

@ -191,8 +191,8 @@ void FlatInput::focusOutEvent(QFocusEvent *e) {
void FlatInput::resizeEvent(QResizeEvent *e) {
int32 availw = width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1;
if (_st.font->m.width(_fullph) > availw) {
_ph = _st.font->m.elidedText(_fullph, Qt::ElideRight, availw);
if (_st.font->width(_fullph) > availw) {
_ph = _st.font->elided(_fullph, availw);
} else {
_ph = _fullph;
}
@ -455,7 +455,7 @@ _replacingEmojis(false) {
_inner.setFont(_st->font->f);
_inner.setAlignment(cRtl() ? Qt::AlignRight : Qt::AlignLeft);
_placeholder = _st->font->m.elidedText(_placeholderFull, Qt::ElideRight, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);
_placeholder = _st->font->elided(_placeholderFull, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);
QPalette p(palette());
p.setColor(QPalette::Text, _st->textFg->c);
@ -1057,7 +1057,7 @@ void InputField::InputFieldInner::paintEvent(QPaintEvent *e) {
}
void InputField::resizeEvent(QResizeEvent *e) {
_placeholder = _st->font->m.elidedText(_placeholderFull, Qt::ElideRight, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);
_placeholder = _st->font->elided(_placeholderFull, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);
_inner.setGeometry(rect().marginsRemoved(_st->textMargins));
TWidget::resizeEvent(e);
}

View File

@ -806,7 +806,7 @@ const QString &FlatTextarea::getLastText() const {
void FlatTextarea::setPlaceholder(const QString &ph) {
_ph = ph;
_phelided = _st.font->m.elidedText(_ph, Qt::ElideRight, width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1);
_phelided = _st.font->elided(_ph, width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1);
if (_phVisible) update();
}
@ -893,7 +893,7 @@ void FlatTextarea::keyPressEvent(QKeyEvent *e) {
}
void FlatTextarea::resizeEvent(QResizeEvent *e) {
_phelided = _st.font->m.elidedText(_ph, Qt::ElideRight, width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1);
_phelided = _st.font->elided(_ph, width() - _st.textMrg.left() - _st.textMrg.right() - _st.phPos.x() - 1);
QTextEdit::resizeEvent(e);
checkContentHeight();
}

View File

@ -35,7 +35,7 @@ void PhoneInput::paintEvent(QPaintEvent *e) {
if (!ph.isEmpty()) {
p.setClipRect(rect());
QRect phRect(placeholderRect());
int tw = phFont()->m.width(t);
int tw = phFont()->width(t);
if (tw < phRect.width()) {
phRect.setLeft(phRect.left() + tw);
phPrepare(p);

View File

@ -41,8 +41,8 @@ namespace style {
height = m.height();
ascent = m.ascent();
descent = m.descent();
spacew = m.width(QLatin1Char(' '));
elidew = m.width(QLatin1Char('.')) * 3;
spacew = width(QLatin1Char(' '));
elidew = width(QLatin1Char('.')) * 3;
}
Font FontData::bold(bool set) const {

View File

@ -104,8 +104,17 @@ namespace style {
class FontData {
public:
int32 width(const QString &str, int32 from, int32 to) {
return m.width(str.mid(from, to));
int32 width(const QString &str) const {
return m.width(str);
}
int32 width(const QString &str, int32 from, int32 to) const {
return width(str.mid(from, to));
}
int32 width(QChar ch) const {
return m.width(ch);
}
QString elided(const QString &str, int32 width, Qt::TextElideMode mode = Qt::ElideRight) const {
return m.elidedText(str, mode, width);
}
Font bold(bool set = true) const;

View File

@ -330,7 +330,7 @@ public:
} else {
QUrl url(original), good(url.isValid() ? url.toEncoded() : "");
QString readable = good.isValid() ? good.toDisplayString() : original;
result = _t->_font->m.elidedText(readable, Qt::ElideRight, st::linkCropLimit);
result = _t->_font->elided(readable, st::linkCropLimit);
fullDisplayed = (result == readable) ? 1 : 0;
}
}
@ -1569,7 +1569,7 @@ public:
line.length = lineLength;
eShapeLine(line);
int32 elideWidth = _f->m.width(_Elide);
int32 elideWidth = _f->width(_Elide);
_wLeft = _w - elideWidth - _elideRemoveFromEnd;
int firstItem = engine.findItem(line.from), lastItem = engine.findItem(line.from + line.length - 1);

View File

@ -190,7 +190,7 @@ void DialogRow::paint(Painter &p, int32 w, bool act, bool sel, bool onlyBackgrou
} else {
dt = lastDate.toString(qsl("d.MM.yy"));
}
int32 dtWidth = st::dlgDateFont->m.width(dt);
int32 dtWidth = st::dlgDateFont->width(dt);
rectForName.setWidth(rectForName.width() - dtWidth - st::dlgDateSkip);
p.setFont(st::dlgDateFont->f);
p.setPen((act ? st::dlgActiveDateColor : st::dlgDateColor)->p);
@ -216,7 +216,7 @@ void DialogRow::paint(Painter &p, int32 w, bool act, bool sel, bool onlyBackgrou
int32 lastWidth = namewidth, unread = history->unreadCount;
if (unread) {
QString unreadStr = QString::number(unread);
int32 unreadWidth = st::dlgUnreadFont->m.width(unreadStr);
int32 unreadWidth = st::dlgUnreadFont->width(unreadStr);
int32 unreadRectWidth = unreadWidth + 2 * st::dlgUnreadPaddingHor;
int32 unreadRectHeight = st::dlgUnreadFont->height + 2 * st::dlgUnreadPaddingVer;
int32 unreadRectLeft = w - st::dlgPaddingHor - unreadRectWidth;
@ -274,7 +274,7 @@ void FakeDialogRow::paint(Painter &p, int32 w, bool act, bool sel, bool onlyBack
} else {
dt = lastDate.toString(qsl("d.MM.yy"));
}
int32 dtWidth = st::dlgDateFont->m.width(dt);
int32 dtWidth = st::dlgDateFont->width(dt);
rectForName.setWidth(rectForName.width() - dtWidth - st::dlgDateSkip);
p.setFont(st::dlgDateFont->f);
p.setPen((act ? st::dlgActiveDateColor : st::dlgDateColor)->p);
@ -395,6 +395,12 @@ bool History::updateTyping(uint64 ms, uint32 dots, bool force) {
changed = true;
}
}
if (changed && App::main()) {
if (!dialogs.isEmpty()) App::main()->dlgUpdated(dialogs[0]);
if (App::main()->historyPeer() == peer) {
App::main()->topBar()->update();
}
}
return changed;
}
@ -1291,10 +1297,7 @@ bool Histories::animStep(float64) {
uint64 ms = getms(true);
for (TypingHistories::iterator i = typing.begin(), e = typing.end(); i != e;) {
uint32 typingFrame = (ms - i.value()) / 150;
if (i.key()->updateTyping(ms, typingFrame)) {
App::main()->dlgUpdated(i.key());
App::main()->topBar()->update();
}
i.key()->updateTyping(ms, typingFrame);
if (i.key()->typing.isEmpty() && i.key()->sendActions.isEmpty()) {
i = typing.erase(i);
} else {
@ -1712,23 +1715,19 @@ HistoryItem *History::addNewItem(HistoryBlock *to, bool newBlock, HistoryItem *a
}
void History::unregTyping(UserData *from) {
bool update = false;
uint64 updateAtMs = 0;
TypingUsers::iterator i = typing.find(from);
if (i != typing.end()) {
updateAtMs = getms(true);
i.value() = updateAtMs;
update = true;
}
SendActionUsers::iterator j = sendActions.find(from);
if (j != sendActions.end()) {
if (!updateAtMs) updateAtMs = getms(true);
j.value().until = updateAtMs;
update = true;
}
if (updateAtMs) {
updateTyping(updateAtMs, 0, true);
App::main()->topBar()->update();
}
}
@ -2129,9 +2128,8 @@ MsgId History::inboxRead(MsgId upTo) {
if (!upTo) upTo = msgIdForRead();
inboxReadBefore = qMax(inboxReadBefore, upTo + 1);
if (!dialogs.isEmpty()) {
if (App::main()) App::main()->dlgUpdated(dialogs[0]);
}
if (!dialogs.isEmpty() && App::main()) App::main()->dlgUpdated(dialogs[0]);
showFrom = 0;
App::wnd()->notifyClear(this);
clearNotifications();
@ -2192,7 +2190,7 @@ void History::setUnreadCount(int32 newUnreadCount, bool psUpdate) {
App::histories().unreadMuted += newMute ? unreadCount : (-unreadCount);
mute = newMute;
if (App::wnd()) App::wnd()->updateCounter();
if (App::main()) App::main()->dlgUpdated(this);
if (!dialogs.isEmpty() && App::main()) App::main()->dlgUpdated(dialogs[0]);
}
}
@ -2709,6 +2707,11 @@ void HistoryItem::destroy() {
if (history()->lastMsg == this) {
history()->fixLastMessage(wasAtBottom);
}
if (history()->lastKeyboardId == id) {
history()->lastKeyboardId = 0;
history()->lastKeyboardFrom = 0;
if (App::main()) App::main()->updateBotKeyboard();
}
HistoryMedia *m = getMedia(true);
MediaOverviewType t = m ? mediaToOverviewType(m->type()) : OverviewCount;
if (t != OverviewCount) {
@ -3170,9 +3173,9 @@ HistoryVideo::HistoryVideo(const MTPDvideo &video, const QString &caption, Histo
_size = formatDurationAndSizeText(data->duration, data->size);
if (!_openWithWidth) {
_downloadWidth = st::mediaSaveButton.font->m.width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->m.width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->m.width(lang(lng_media_cancel));
_downloadWidth = st::mediaSaveButton.font->width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->width(lang(lng_media_cancel));
_buttonWidth = (st::mediaSaveButton.width > 0) ? st::mediaSaveButton.width : ((_downloadWidth > _openWithWidth ? (_downloadWidth > _cancelWidth ? _downloadWidth : _cancelWidth) : _openWithWidth) - st::mediaSaveButton.width);
}
@ -3479,7 +3482,7 @@ void HistoryVideo::draw(Painter &p, const HistoryItem *parent, bool selected, in
int32 texty = skipy + st::mediaPadding.top() + st::mediaThumbSize - st::mediaDetailsShift - st::mediaFont->height;
p.drawText(tleft, texty + st::mediaFont->ascent, statusText);
if (parent->isMediaUnread()) {
int32 w = st::mediaFont->m.width(statusText);
int32 w = st::mediaFont->width(statusText);
if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= twidth) {
p.setRenderHint(QPainter::HighQualityAntialiasing, true);
p.setPen(Qt::NoPen);
@ -3551,9 +3554,9 @@ HistoryAudio::HistoryAudio(const MTPDaudio &audio) : HistoryMedia()
_size = formatDurationAndSizeText(data->duration, data->size);
if (!_openWithWidth) {
_downloadWidth = st::mediaSaveButton.font->m.width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->m.width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->m.width(lang(lng_media_cancel));
_downloadWidth = st::mediaSaveButton.font->width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->width(lang(lng_media_cancel));
_buttonWidth = (st::mediaSaveButton.width > 0) ? st::mediaSaveButton.width : ((_downloadWidth > _openWithWidth ? (_downloadWidth > _cancelWidth ? _downloadWidth : _cancelWidth) : _openWithWidth) - st::mediaSaveButton.width);
}
}
@ -3712,7 +3715,7 @@ void HistoryAudio::draw(Painter &p, const HistoryItem *parent, bool selected, in
int32 texty = skipy + st::mediaPadding.top() + st::mediaThumbSize - st::mediaDetailsShift - st::mediaFont->height;
p.drawText(tleft, texty + st::mediaFont->ascent, statusText);
if (parent->isMediaUnread()) {
int32 w = st::mediaFont->m.width(statusText);
int32 w = st::mediaFont->width(statusText);
if (w + st::mediaUnreadSkip + st::mediaUnreadSize <= twidth) {
p.setRenderHint(QPainter::HighQualityAntialiasing, true);
p.setPen(Qt::NoPen);
@ -3849,15 +3852,15 @@ HistoryDocument::HistoryDocument(DocumentData *document) : HistoryMedia()
, _dldDone(0)
, _uplDone(0)
{
_namew = st::mediaFont->m.width(_name.isEmpty() ? qsl("Document") : _name);
_namew = st::mediaFont->width(_name.isEmpty() ? qsl("Document") : _name);
_size = document->song() ? formatDurationAndSizeText(document->song()->duration, data->size) : formatSizeText(data->size);
_height = _minh = st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom();
if (!_openWithWidth) {
_downloadWidth = st::mediaSaveButton.font->m.width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->m.width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->m.width(lang(lng_media_cancel));
_downloadWidth = st::mediaSaveButton.font->width(lang(lng_media_download));
_openWithWidth = st::mediaSaveButton.font->width(lang(lng_media_open_with));
_cancelWidth = st::mediaSaveButton.font->width(lang(lng_media_cancel));
_buttonWidth = (st::mediaSaveButton.width > 0) ? st::mediaSaveButton.width : ((_downloadWidth > _openWithWidth ? (_downloadWidth > _cancelWidth ? _downloadWidth : _cancelWidth) : _openWithWidth) - st::mediaSaveButton.width);
}
@ -4073,7 +4076,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, bool selected,
p.setFont(st::mediaFont->f);
p.setPen(st::black->c);
if (twidth < _namew) {
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->m.elidedText(_name, Qt::ElideRight, twidth));
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(_name, twidth));
} else {
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, _name);
}
@ -4185,7 +4188,7 @@ void HistoryDocument::drawInPlaylist(Painter &p, const HistoryItem *parent, bool
p.setFont(st::mediaFont->f);
p.setPen(st::black->c);
if (twidth < _namew) {
p.drawText(tleft, st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->m.elidedText(_name, Qt::ElideRight, twidth));
p.drawText(tleft, st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(_name, twidth));
} else {
p.drawText(tleft, st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, _name);
}
@ -4513,7 +4516,7 @@ HistoryContact::HistoryContact(int32 userId, const QString &first, const QString
_maxw = st::mediaMaxWidth;
name.setText(st::mediaFont, lng_full_name(lt_first_name, first, lt_last_name, last).trimmed(), _textNameOptions);
phonew = st::mediaFont->m.width(phone);
phonew = st::mediaFont->width(phone);
if (contact) {
contact->photo->load();
@ -4530,7 +4533,7 @@ HistoryContact::HistoryContact(int32 userId, const QString &fullname, const QStr
_maxw = st::mediaMaxWidth;
name.setText(st::mediaFont, fullname.trimmed(), _textNameOptions);
phonew = st::mediaFont->m.width(phone);
phonew = st::mediaFont->width(phone);
if (contact) {
contact->photo->load();
@ -4685,7 +4688,7 @@ void HistoryContact::draw(Painter &p, const HistoryItem *parent, bool selected,
p.setFont(st::mediaFont->f);
p.setPen(st::black->c);
if (twidth < phonew) {
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->m.elidedText(phone, Qt::ElideRight, twidth));
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(phone, twidth));
} else {
p.drawText(tleft, skipy + st::mediaPadding.top() + st::mediaNameTop + st::mediaFont->ascent, phone);
}
@ -4734,7 +4737,7 @@ HistoryWebPage::HistoryWebPage(WebPageData *data) : HistoryMedia()
void HistoryWebPage::initDimensions(const HistoryItem *parent) {
if (data->pendingTill) {
_maxw = _minh = _height = 0;
//_maxw = st::webPageLeft + st::linkFont->m.width(lang((data->pendingTill < 0) ? lng_attach_failed : lng_profile_loading));
//_maxw = st::webPageLeft + st::linkFont->width(lang((data->pendingTill < 0) ? lng_attach_failed : lng_profile_loading));
//_minh = st::replyHeight;
//_height = _minh;
return;
@ -4796,7 +4799,7 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
}
_docName = documentName(data->doc);
_docSize = data->doc->song() ? formatDurationAndSizeText(data->doc->song()->duration, data->doc->size) : formatSizeText(data->doc->size);
_docNameWidth = st::mediaFont->m.width(_docName.isEmpty() ? qsl("Document") : _docName);
_docNameWidth = st::mediaFont->width(_docName.isEmpty() ? qsl("Document") : _docName);
if (parent == animated.msg) {
_maxw = st::webPageLeft + (animated.w / cIntRetinaFactor()) + parent->skipBlockWidth();
@ -4812,7 +4815,7 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
}
if (!data->siteName.isEmpty()) {
_siteNameWidth = st::webPageTitleFont->m.width(data->siteName);
_siteNameWidth = st::webPageTitleFont->width(data->siteName);
if (_asArticle) {
_maxw = qMax(_maxw, int32(st::webPageLeft + _siteNameWidth + st::webPagePhotoDelta + st::webPagePhotoSize));
} else {
@ -4854,7 +4857,7 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
}
if (data->type == WebPageVideo && data->duration) {
_duration = formatDurationText(data->duration);
_durationWidth = st::msgDateFont->m.width(_duration);
_durationWidth = st::msgDateFont->width(_duration);
}
_height = _minh;
}
@ -4924,7 +4927,7 @@ void HistoryWebPage::draw(Painter &p, const HistoryItem *parent, bool selected,
}
p.setFont(st::webPageTitleFont->f);
p.setPen(semibold->p);
p.drawText(0, st::webPageTitleFont->ascent, (availw >= _siteNameWidth) ? data->siteName : st::webPageTitleFont->m.elidedText(data->siteName, Qt::ElideRight, availw));
p.drawText(0, st::webPageTitleFont->ascent, (availw >= _siteNameWidth) ? data->siteName : st::webPageTitleFont->elided(data->siteName, availw));
p.translate(0, st::webPageTitleFont->height);
--articleLines;
}
@ -5103,7 +5106,7 @@ void HistoryWebPage::draw(Painter &p, const HistoryItem *parent, bool selected,
p.setFont(st::mediaFont->f);
p.setPen(st::black->c);
if (twidth < _docNameWidth) {
p.drawText(tleft, st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->m.elidedText(_docName, Qt::ElideRight, twidth));
p.drawText(tleft, st::mediaNameTop + st::mediaFont->ascent, st::mediaFont->elided(_docName, twidth));
} else {
p.drawText(tleft, st::mediaNameTop + st::mediaFont->ascent, _docName);
}
@ -5876,12 +5879,12 @@ void HistoryImageLink::draw(Painter &p, const HistoryItem *parent, bool selected
p.setPen(st::msgDateImgColor->p);
int32 titleWidth = width - 2 * st::msgDateImgPadding.x();
if (!data->duration.isEmpty()) {
int32 durationWidth = st::msgDateFont->m.width(data->duration);
int32 durationWidth = st::msgDateFont->width(data->duration);
p.drawText(skipx + width - st::msgDateImgPadding.x() - durationWidth, skipy + st::msgDateImgPadding.y() + st::msgDateFont->ascent, data->duration);
titleWidth -= durationWidth + st::msgDateImgPadding.x();
}
if (!data->title.isEmpty()) {
p.drawText(skipx + st::msgDateImgPadding.x(), skipy + st::msgDateImgPadding.y() + st::msgDateFont->ascent, st::msgDateFont->m.elidedText(data->title, Qt::ElideRight, titleWidth));
p.drawText(skipx + st::msgDateImgPadding.x(), skipy + st::msgDateImgPadding.y() + st::msgDateFont->ascent, st::msgDateFont->elided(data->title, titleWidth));
}
}
}
@ -6103,10 +6106,10 @@ QString formatViewsCount(int32 views) {
void HistoryMessage::initTime() {
_timeText = date.toString(cTimeFormat());
_timeWidth = st::msgDateFont->m.width(_timeText);
_timeWidth = st::msgDateFont->width(_timeText);
_viewsText = (_views >= 0) ? formatViewsCount(_views) : QString();
_viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->m.width(_viewsText);
_viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->width(_viewsText);
}
void HistoryMessage::initMedia(const MTPMessageMedia *media, QString &currentText) {
@ -6377,7 +6380,7 @@ void HistoryMessage::setViewsCount(int32 count) {
int32 was = _viewsWidth;
_views = count;
_viewsText = (_views >= 0) ? formatViewsCount(_views) : QString();
_viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->m.width(_viewsText);
_viewsWidth = _viewsText.isEmpty() ? 0 : st::msgDateFont->width(_viewsText);
if (was == _viewsWidth) {
if (App::main()) App::main()->msgUpdated(history()->peer->id, this);
} else {
@ -6738,7 +6741,7 @@ HistoryForwarded::HistoryForwarded(History *history, HistoryBlock *block, const
, fwdDate(::date(msg.vfwd_date))
, fwdFrom(App::peer(peerFromMTP(msg.vfwd_from_id)))
, fwdFromVersion(fwdFrom->nameVersion)
, fromWidth(st::msgServiceFont->m.width(lang(lng_forwarded_from)) + st::msgServiceFont->spacew)
, fromWidth(st::msgServiceFont->width(lang(lng_forwarded_from)) + st::msgServiceFont->spacew)
{
fwdNameUpdated();
}
@ -6747,7 +6750,7 @@ HistoryForwarded::HistoryForwarded(History *history, HistoryBlock *block, MsgId
, fwdDate(msg->dateForwarded())
, fwdFrom(msg->fromForwarded())
, fwdFromVersion(fwdFrom->nameVersion)
, fromWidth(st::msgServiceFont->m.width(lang(lng_forwarded_from)) + st::msgServiceFont->spacew)
, fromWidth(st::msgServiceFont->width(lang(lng_forwarded_from)) + st::msgServiceFont->spacew)
{
fwdNameUpdated();
}
@ -6793,7 +6796,7 @@ void HistoryForwarded::drawForwardedFrom(Painter &p, int32 x, int32 y, int32 w,
p.setFont(serviceName->f);
fwdFromName.drawElided(p, x + fromWidth, y, w - fromWidth);
} else {
p.drawText(x, y + serviceFont->ascent, serviceFont->m.elidedText(lang(lng_forwarded_from), Qt::ElideRight, w));
p.drawText(x, y + serviceFont->ascent, serviceFont->elided(lang(lng_forwarded_from), w));
}
}
@ -6986,7 +6989,7 @@ QString HistoryReply::selectedText(uint32 selection) const {
void HistoryReply::initDimensions() {
if (!replyToMsg) {
_maxReplyWidth = st::msgReplyBarSkip + st::msgDateFont->m.width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message)) + st::msgPadding.left() + st::msgPadding.right();
_maxReplyWidth = st::msgReplyBarSkip + st::msgDateFont->width(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message)) + st::msgPadding.left() + st::msgPadding.right();
}
HistoryMessage::initDimensions();
if (replyToMsg) {
@ -7117,7 +7120,7 @@ void HistoryReply::drawReplyTo(Painter &p, int32 x, int32 y, int32 w, bool selec
} else {
p.setPen(date->p);
}
p.drawText(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->m.elidedText(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message), Qt::ElideRight, w - st::msgReplyBarSkip));
p.drawText(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(lang(replyToMsgId ? lng_profile_loading : lng_deleted_message), w - st::msgReplyBarSkip));
}
}
}

View File

@ -1104,7 +1104,7 @@ int32 HistoryInner::recountHeight(HistoryItem *resizedItem) {
int32 tw = scrollArea->width() - st::msgMargin.left() - st::msgMargin.right();
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right();
int32 mw = qMax(botInfo->text.maxWidth(), st::msgNameFont->m.width(lang(lng_bot_description)));
int32 mw = qMax(botInfo->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description)));
if (tw > mw) tw = mw;
botDescWidth = tw;
@ -1138,7 +1138,7 @@ void HistoryInner::updateBotInfo(bool recount) {
int32 tw = scrollArea->width() - st::msgMargin.left() - st::msgMargin.right();
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
tw -= st::msgPadding.left() + st::msgPadding.right();
int32 mw = qMax(botInfo->text.maxWidth(), st::msgNameFont->m.width(lang(lng_bot_description)));
int32 mw = qMax(botInfo->text.maxWidth(), st::msgNameFont->width(lang(lng_bot_description)));
if (tw > mw) tw = mw;
botDescWidth = tw;
@ -1837,7 +1837,8 @@ void BotKeyboard::mouseReleaseEvent(QMouseEvent *e) {
updateSelected();
if (_sel == down && down >= 0) {
int row = (down / MatrixRowShift), col = down % MatrixRowShift;
App::sendBotCommand(_btns.at(row).at(col).cmd, _wasForMsgId.msg);
QString cmd(_btns.at(row).at(col).cmd);
App::sendBotCommand(cmd, _wasForMsgId.msg);
}
}
@ -2032,11 +2033,10 @@ HistoryHider::HistoryHider(MainWidget *parent, bool forwardSelected) : QWidget(p
, _sharedContact(0)
, _forwardSelected(forwardSelected)
, _sendPath(false)
, forwardButton(this, lang(lng_forward), st::btnSelectDone)
, cancelButton(this, lang(lng_cancel), st::btnSelectCancel)
, _send(this, lang(lng_forward_send), st::defaultBoxButton)
, _cancel(this, lang(lng_box_cancel), st::cancelBoxButton)
, offered(0)
, aOpacity(0, 1)
, aOpacityFunc(anim::easeOutCirc)
, a_opacity(0, 1)
, hiding(false)
, _forwardRequest(0)
, toTextWidth(0)
@ -2049,11 +2049,10 @@ HistoryHider::HistoryHider(MainWidget *parent, UserData *sharedContact) : QWidge
, _sharedContact(sharedContact)
, _forwardSelected(false)
, _sendPath(false)
, forwardButton(this, lang(lng_forward_send), st::btnSelectDone)
, cancelButton(this, lang(lng_cancel), st::btnSelectCancel)
, _send(this, lang(lng_forward_send), st::defaultBoxButton)
, _cancel(this, lang(lng_box_cancel), st::cancelBoxButton)
, offered(0)
, aOpacity(0, 1)
, aOpacityFunc(anim::easeOutCirc)
, a_opacity(0, 1)
, hiding(false)
, _forwardRequest(0)
, toTextWidth(0)
@ -2066,11 +2065,10 @@ HistoryHider::HistoryHider(MainWidget *parent) : QWidget(parent)
, _sharedContact(0)
, _forwardSelected(false)
, _sendPath(true)
, forwardButton(this, lang(lng_forward_send), st::btnSelectDone)
, cancelButton(this, lang(lng_cancel), st::btnSelectCancel)
, _send(this, lang(lng_forward_send), st::defaultBoxButton)
, _cancel(this, lang(lng_box_cancel), st::cancelBoxButton)
, offered(0)
, aOpacity(0, 1)
, aOpacityFunc(anim::easeOutCirc)
, a_opacity(0, 1)
, hiding(false)
, _forwardRequest(0)
, toTextWidth(0)
@ -2080,11 +2078,11 @@ HistoryHider::HistoryHider(MainWidget *parent) : QWidget(parent)
}
void HistoryHider::init() {
connect(&forwardButton, SIGNAL(clicked()), this, SLOT(forward()));
connect(&cancelButton, SIGNAL(clicked()), this, SLOT(startHide()));
connect(&_send, SIGNAL(clicked()), this, SLOT(forward()));
connect(&_cancel, SIGNAL(clicked()), this, SLOT(startHide()));
connect(App::wnd()->getTitle(), SIGNAL(hiderClicked()), this, SLOT(startHide()));
_chooseWidth = st::forwardFont->m.width(lang(lng_forward_choose));
_chooseWidth = st::forwardFont->width(lang(lng_forward_choose));
resizeEvent(0);
anim::start(this);
@ -2094,17 +2092,15 @@ bool HistoryHider::animStep(float64 ms) {
float64 dt = ms / 200;
bool res = true;
if (dt >= 1) {
aOpacity.finish();
a_opacity.finish();
if (hiding) {
QTimer::singleShot(0, this, SLOT(deleteLater()));
}
res = false;
} else {
aOpacity.update(dt, aOpacityFunc);
a_opacity.update(dt, anim::linear);
}
App::wnd()->getTitle()->setHideLevel(aOpacity.current());
forwardButton.setOpacity(aOpacity.current());
cancelButton.setOpacity(aOpacity.current());
App::wnd()->getTitle()->setHideLevel(a_opacity.current());
update();
return res;
}
@ -2116,9 +2112,9 @@ bool HistoryHider::withConfirm() const {
void HistoryHider::paintEvent(QPaintEvent *e) {
Painter p(this);
if (!hiding || !cacheForAnim.isNull() || !offered) {
p.setOpacity(aOpacity.current() * st::layerAlpha);
p.fillRect(0, st::titleShadow, width(), height() - st::titleShadow, st::layerBG->b);
p.setOpacity(aOpacity.current());
p.setOpacity(a_opacity.current() * st::layerAlpha);
p.fillRect(rect(), st::layerBG->b);
p.setOpacity(a_opacity.current());
}
if (cacheForAnim.isNull() || !offered) {
p.setFont(st::forwardFont->f);
@ -2128,14 +2124,8 @@ void HistoryHider::paintEvent(QPaintEvent *e) {
// fill bg
p.fillRect(box, st::boxBG->b);
// paint shadows
p.fillRect(box.x(), box.y() + box.height() - st::btnSelectCancel.height - st::scrollDef.bottomsh, box.width(), st::scrollDef.bottomsh, st::scrollDef.shColor->b);
// paint button sep
p.fillRect(box.x() + st::btnSelectCancel.width, box.y() + box.height() - st::btnSelectCancel.height, st::lineWidth, st::btnSelectCancel.height, st::btnSelectSep->b);
p.setPen(st::black->p);
toText.drawElided(p, box.left() + (box.width() - toTextWidth) / 2, box.top() + st::boxPadding.top(), toTextWidth + 1);
toText.drawElided(p, box.left() + st::boxPadding.left(), box.top() + st::boxPadding.top(), toTextWidth + 2);
} else {
int32 w = st::forwardMargins.left() + _chooseWidth + st::forwardMargins.right(), h = st::forwardMargins.top() + st::forwardFont->height + st::forwardMargins.bottom();
App::roundRect(p, (width() - w) / 2, (height() - h) / 2, w, h, st::forwardBg, ForwardCorners);
@ -2179,7 +2169,9 @@ void HistoryHider::startHide() {
if (cWideMode()) {
if (offered) cacheForAnim = myGrab(this, box);
if (_forwardRequest) MTP::cancel(_forwardRequest);
aOpacity.start(0);
a_opacity.start(0);
_send.hide();
_cancel.hide();
anim::start(this);
} else {
QTimer::singleShot(0, this, SLOT(deleteLater()));
@ -2209,24 +2201,27 @@ MainWidget *HistoryHider::parent() {
}
void HistoryHider::resizeEvent(QResizeEvent *e) {
int32 w = st::forwardWidth, h = st::boxPadding.top() + st::forwardFont->height + st::boxPadding.bottom();
int32 w = st::boxWidth, h = st::boxPadding.top() + st::boxPadding.bottom();
if (offered) {
forwardButton.show();
cancelButton.show();
h += forwardButton.height() + st::scrollDef.bottomsh;
if (!hiding) {
_send.show();
_cancel.show();
}
h += st::boxTextFont->height + st::boxButtonPadding.top() + _send.height() + st::boxButtonPadding.bottom();
} else {
forwardButton.hide();
cancelButton.hide();
h += st::forwardFont->height;
_send.hide();
_cancel.hide();
}
box = QRect((width() - w) / 2, (height() - h) / 2, w, h);
cancelButton.move(box.x(), box.y() + h - cancelButton.height());
forwardButton.move(box.x() + box.width() - forwardButton.width(), cancelButton.y());
_send.moveToRight(width() - (box.x() + box.width()) + st::boxButtonPadding.right(), box.y() + h - st::boxButtonPadding.bottom() - _send.height(), width());
_cancel.moveToRight(width() - (box.x() + box.width()) + st::boxButtonPadding.right() + _send.width() + st::boxButtonPadding.left(), _send.y(), width());
}
bool HistoryHider::offerPeer(PeerId peer) {
if (!peer) {
offered = 0;
toText.setText(st::boxFont, QString());
toText.setText(st::boxTextFont, QString());
toTextWidth = 0;
resizeEvent(0);
return false;
@ -2255,7 +2250,7 @@ bool HistoryHider::offerPeer(PeerId peer) {
return false;
}
toText.setText(st::boxFont, phrase, _textNameOptions);
toText.setText(st::boxTextFont, phrase, _textNameOptions);
toTextWidth = toText.maxWidth();
if (toTextWidth > box.width() - st::boxPadding.left() - st::boxPadding.right()) {
toTextWidth = box.width() - st::boxPadding.left() - st::boxPadding.right();
@ -2342,7 +2337,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
, _recording(false), _inRecord(false), _inField(false), _inReply(false)
, a_recordingLevel(0, 0), _recordingSamples(0)
, a_recordOver(0, 0), a_recordDown(0, 0), a_recordCancel(st::recordCancel->c, st::recordCancel->c)
, _recordCancelWidth(st::recordFont->m.width(lang(lng_record_cancel)))
, _recordCancelWidth(st::recordFont->width(lang(lng_record_cancel)))
, _kbShown(false)
, _kbWasHidden(false)
, _kbReplyTo(0)
@ -2842,7 +2837,7 @@ void HistoryWidget::fastShowAtEnd(History *h) {
clearAllLoadRequests();
_showAtMsgId = ShowAtTheEndMsgId;
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
if (h->isReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop)) {
@ -2854,6 +2849,9 @@ void HistoryWidget::fastShowAtEnd(History *h) {
}
void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
MsgId wasMsgId = _showAtMsgId;
History *wasHistory = _history;
if (_history) {
if (_peer->id == peerId) {
_history->lastWidth = 0;
@ -2881,7 +2879,9 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
historyLoaded();
}
emit peerShown(_peer);
App::main()->dlgUpdated(wasHistory, wasMsgId);
emit historyShown(_history, _showAtMsgId);
App::main()->topBar()->update();
update();
return;
@ -2915,8 +2915,6 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
if (_history->unreadBar) {
_history->unreadBar->destroy();
}
App::main()->dlgUpdated(_history);
_history = 0;
}
@ -2994,9 +2992,6 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
firstLoadMessages();
doneShow();
}
if (_history) {
App::main()->dlgUpdated(_history);
}
App::main()->peerUpdated(_peer);
@ -3038,7 +3033,9 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
if (App::wnd()) App::wnd()->setInnerFocus();
emit peerShown(_peer);
App::main()->dlgUpdated(wasHistory, wasMsgId);
emit historyShown(_history, _showAtMsgId);
App::main()->topBar()->update();
update();
}
@ -3422,7 +3419,7 @@ bool HistoryWidget::messagesFailed(const RPCError &error, mtpRequestId requestId
if (error.type() == qstr("CHANNEL_PRIVATE")) {
App::main()->showDialogs();
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_not_accessible), true));
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
return true;
}
@ -3541,7 +3538,8 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
calcNextReplyReturn();
}
_showAtMsgId = _delayedShowAtMsgId;
setMsgId(_delayedShowAtMsgId);
_histInited = false;
if (_history->isChannel() && wasOnlyImportant != _history->asChannelHistory()->onlyImportant()) {
@ -3877,7 +3875,7 @@ bool HistoryWidget::joinFail(const RPCError &error, mtpRequestId req) {
if (_unblockRequest == req) _unblockRequest = 0;
if (error.type() == qstr("CHANNEL_PRIVATE")) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_not_accessible), true));
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
return true;
}
return false;
@ -3943,10 +3941,23 @@ void HistoryWidget::onSendPaths(const PeerId &peer) {
uploadMedias(cSendPaths(), ToPrepareDocument);
}
History *HistoryWidget::history() const {
return _history;
}
PeerData *HistoryWidget::peer() const {
return _peer;
}
void HistoryWidget::setMsgId(MsgId showAtMsgId) { // sometimes _showAtMsgId is set directly
if (_showAtMsgId != showAtMsgId) {
MsgId wasMsgId = _showAtMsgId;
_showAtMsgId = showAtMsgId;
App::main()->dlgUpdated(_history, wasMsgId);
emit historyShown(_history, _showAtMsgId);
}
}
MsgId HistoryWidget::msgId() const {
return _showAtMsgId;
}
@ -4637,7 +4648,7 @@ void HistoryWidget::updateOnlineDisplay(int32 x, int32 w) {
}
if (_titlePeerText != text) {
_titlePeerText = text;
_titlePeerTextWidth = st::dlgHistFont->m.width(_titlePeerText);
_titlePeerTextWidth = st::dlgHistFont->width(_titlePeerText);
if (App::main()) {
App::main()->topBar()->update();
}
@ -5078,7 +5089,7 @@ void HistoryWidget::onAudioFailed(const FullMsgId &newId) {
}
void HistoryWidget::onReportSpamClicked() {
ConfirmBox *box = new ConfirmBox(lang(_peer->isUser() ? lng_report_spam_sure : (_peer->isChat() ? lng_report_spam_sure_group : lng_report_spam_sure_channel)), lang(lng_report_spam_ok));
ConfirmBox *box = new ConfirmBox(lang(_peer->isUser() ? lng_report_spam_sure : (_peer->isChat() ? lng_report_spam_sure_group : lng_report_spam_sure_channel)), lang(lng_report_spam_ok), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onReportSpamSure()));
App::wnd()->showLayer(box);
_clearPeer = _peer;
@ -5323,7 +5334,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
} else if (initial && _showAtMsgId > 0) {
HistoryItem *item = App::histItemById(_channel, _showAtMsgId);
if (!item || item->detached()) {
_showAtMsgId = 0;
setMsgId(0);
_histInited = false;
return updateListSize(addToY, initial);
} else {
@ -5354,7 +5365,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (item) {
toY = qMax(firstItemY + item->y + item->block()->y - _fixedInScrollMsgTop, 0);
} else {
_showAtMsgId = ShowAtUnreadMsgId;
setMsgId(ShowAtUnreadMsgId);
_fixedInScrollMsgId = 0;
_fixedInScrollMsgTop = 0;
_histInited = false;
@ -5370,7 +5381,7 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
if (toY < _scroll.scrollTopMax() + st::unreadBarHeight) {
_history->addUnreadBar();
if (_history->unreadBar) {
_showAtMsgId = ShowAtUnreadMsgId;
setMsgId(ShowAtUnreadMsgId);
_histInited = false;
return updateListSize(0, true);
}
@ -6131,7 +6142,7 @@ void HistoryWidget::drawField(Painter &p) {
} else {
p.setFont(st::msgDateFont->f);
p.setPen(st::msgInDateColor->p);
p.drawText(replyLeft, backy + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->m.elidedText(lang(lng_profile_loading), Qt::ElideRight, width() - replyLeft - _replyForwardPreviewCancel.width() - st::msgReplyPadding.right()));
p.drawText(replyLeft, backy + st::msgReplyPadding.top() + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(lang(lng_profile_loading), width() - replyLeft - _replyForwardPreviewCancel.width() - st::msgReplyPadding.right()));
}
}
} else if (from && text) {
@ -6204,7 +6215,7 @@ void HistoryWidget::drawRecording(Painter &p) {
p.setPen(st::black->p);
p.drawText(_attachPhoto.x() + _attachEmoji.width(), _attachPhoto.y() + st::recordTextTop + st::recordFont->ascent, duration);
int32 left = _attachPhoto.x() + _attachEmoji.width() + st::recordFont->m.width(duration) + ((_send.width() - st::btnRecordAudio.pxWidth()) / 2);
int32 left = _attachPhoto.x() + _attachEmoji.width() + st::recordFont->width(duration) + ((_send.width() - st::btnRecordAudio.pxWidth()) / 2);
int32 right = width() - _send.width();
p.setPen(a_recordCancel.current());
@ -6271,7 +6282,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
}
} else {
style::font font(st::msgServiceFont);
int32 w = font->m.width(lang(lng_willbe_history)) + st::msgPadding.left() + st::msgPadding.right(), h = font->height + st::msgServicePadding.top() + st::msgServicePadding.bottom() + 2;
int32 w = font->width(lang(lng_willbe_history)) + st::msgPadding.left() + st::msgPadding.right(), h = font->height + st::msgServicePadding.top() + st::msgServicePadding.bottom() + 2;
QRect tr((width() - w) / 2, (height() - _field.height() - 2 * st::sendPadding - h) / 2, w, h);
App::roundRect(p, tr, App::msgServiceBg(), ServiceCorners);

View File

@ -351,11 +351,9 @@ private:
UserData *_sharedContact;
bool _forwardSelected, _sendPath;
FlatButton forwardButton;
FlatButton cancelButton;
BoxButton _send, _cancel;
PeerData *offered;
anim::fvalue aOpacity;
anim::transition aOpacityFunc;
anim::fvalue a_opacity;
QRect box;
bool hiding;
@ -456,7 +454,9 @@ public:
void shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, int32 userId = 0);
History *history() const;
PeerData *peer() const;
void setMsgId(MsgId showAtMsgId);
MsgId msgId() const;
HistoryItem *atTopImportantMsg(int32 &bottomUnderScrollTop) const;
@ -541,7 +541,7 @@ public:
signals:
void cancelled();
void peerShown(PeerData *);
void historyShown(History *history, MsgId atMsgId);
public slots:

View File

@ -249,7 +249,7 @@ bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
}
void IntroPwdCheck::recoverStarted(const MTPauth_PasswordRecovery &result) {
_emailPattern = st::introFont->m.elidedText(lng_signin_recover_hint(lt_recover_email, qs(result.c_auth_passwordRecovery().vemail_pattern)), Qt::ElideRight, textRect.width());
_emailPattern = st::introFont->elided(lng_signin_recover_hint(lt_recover_email, qs(result.c_auth_passwordRecovery().vemail_pattern)), textRect.width());
update();
}
@ -283,14 +283,14 @@ void IntroPwdCheck::onToRecover() {
}
update();
} else {
ConfirmBox *box = new ConfirmBox(lang(lng_signin_no_email_forgot), true);
ConfirmBox *box = new InformBox(lang(lng_signin_no_email_forgot));
App::wnd()->showLayer(box);
connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset()));
}
}
void IntroPwdCheck::onToPassword() {
ConfirmBox *box = new ConfirmBox(lang(lng_signin_no_email_forgot), true);
ConfirmBox *box = new InformBox(lang(lng_signin_cant_email_forgot));
App::wnd()->showLayer(box);
connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset()));
}
@ -312,7 +312,7 @@ void IntroPwdCheck::onToReset() {
void IntroPwdCheck::onReset() {
if (sentRequest) return;
ConfirmBox *box = new ConfirmBox(lang(lng_sigin_sure_reset), lang(lng_sigin_reset), QString(), st::btnRedDone);
ConfirmBox *box = new ConfirmBox(lang(lng_signin_sure_reset), lang(lng_signin_reset), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onResetSure()));
App::wnd()->showLayer(box);
}

View File

@ -49,7 +49,7 @@ _next(this, lang(lng_start_msgs), st::btnIntroNext) {
_changeLang.show();
}
_headerWidth = st::introHeaderFont->m.width(qsl("Telegram Desktop"));
_headerWidth = st::introHeaderFont->width(qsl("Telegram Desktop"));
setGeometry(parent->innerRect());

View File

@ -19,7 +19,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
#include "gui/boxshadow.h"
class LayeredWidget : public QWidget {
class LayeredWidget : public TWidget {
Q_OBJECT
public:

View File

@ -96,7 +96,7 @@ void TopBarWidget::onDeleteContact() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0;
UserData *u = p ? p->asUser() : 0;
if (u) {
ConfirmBox *box = new ConfirmBox(lng_sure_delete_contact(lt_contact, p->name));
ConfirmBox *box = new ConfirmBox(lng_sure_delete_contact(lt_contact, p->name), lang(lng_box_delete));
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteContactSure()));
App::wnd()->showLayer(box);
}
@ -116,7 +116,7 @@ void TopBarWidget::onDeleteAndExit() {
PeerData *p = App::main() ? App::main()->profilePeer() : 0;
ChatData *c = p ? p->asChat() : 0;
if (c) {
ConfirmBox *box = new ConfirmBox(lng_sure_delete_and_exit(lt_group, p->name));
ConfirmBox *box = new ConfirmBox(lng_sure_delete_and_exit(lt_group, p->name), lang(lng_box_leave), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteAndExitSure()));
App::wnd()->showLayer(box);
}
@ -359,7 +359,7 @@ void TopBarWidget::showSelected(uint32 selCount, bool canDelete) {
_selCount = selCount;
_canDelete = canDelete;
_selStr = (_selCount > 0) ? lng_selected_count(lt_count, _selCount) : QString();
_selStrWidth = st::btnDefLink.font->m.width(_selStr);
_selStrWidth = st::btnDefLink.font->width(_selStr);
setCursor((!p && _selCount) ? style::cur_default : style::cur_pointer);
showAll();
}
@ -400,7 +400,7 @@ _failDifferenceTimeout(1), _lastUpdateTime(0), _handlingChannelDifference(false)
connect(_api, SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*)));
connect(this, SIGNAL(peerUpdated(PeerData*)), &history, SLOT(peerUpdated(PeerData*)));
connect(&_topBar, SIGNAL(clicked()), this, SLOT(onTopBarClick()));
connect(&history, SIGNAL(peerShown(PeerData*)), this, SLOT(onPeerShown(PeerData*)));
connect(&history, SIGNAL(historyShown(History*,MsgId)), this, SLOT(onHistoryShown(History*,MsgId)));
connect(&updateNotifySettingTimer, SIGNAL(timeout()), this, SLOT(onUpdateNotifySettings()));
connect(this, SIGNAL(showPeerAsync(quint64,qint32)), this, SLOT(showPeerHistory(quint64,qint32)), Qt::QueuedConnection);
if (audioPlayer()) {
@ -444,7 +444,7 @@ _failDifferenceTimeout(1), _lastUpdateTime(0), _handlingChannelDifference(false)
bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) {
PeerData *p = App::peer(peer);
if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && (p->asChat()->haveLeft || p->asChat()->isForbidden)) || (p->isUser() && p->asUser()->access == UserNoAccess)) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_forward_cant), true));
App::wnd()->showLayer(new InformBox(lang(lng_forward_cant)));
return false;
}
history.cancelReply();
@ -655,7 +655,7 @@ void MainWidget::noHider(HistoryHider *destroyed) {
_forwardConfirm->startHide();
_forwardConfirm = 0;
}
onPeerShown(history.peer());
onHistoryShown(history.history(), history.msgId());
if (profile || overview || (history.peer() && history.peer()->id)) {
dialogs.enableShadow(false);
QPixmap animCache = myGrab(this, QRect(0, _playerHeight + st::topBarHeight, _dialogsWidth, height() - _playerHeight - st::topBarHeight)),
@ -700,7 +700,7 @@ void MainWidget::hiderLayer(HistoryHider *h) {
dialogs.enableShadow();
_topBar.enableShadow();
onPeerShown(0);
onHistoryShown(0, 0);
if (overview) {
overview->hide();
} else if (profile) {
@ -721,7 +721,7 @@ void MainWidget::forwardLayer(int32 forwardSelected) {
void MainWidget::deleteLayer(int32 selectedCount) {
QString str((selectedCount < 0) ? lang(selectedCount < -1 ? lng_selected_cancel_sure_this : lng_selected_delete_sure_this) : lng_selected_delete_sure(lt_count, selectedCount));
ConfirmBox *box = new ConfirmBox((selectedCount < 0) ? str : str.arg(selectedCount), lang(lng_selected_delete_confirm));
ConfirmBox *box = new ConfirmBox((selectedCount < 0) ? str : str.arg(selectedCount), lang(lng_box_delete));
if (selectedCount < 0) {
connect(box, SIGNAL(confirmed()), overview ? overview : static_cast<QWidget*>(&history), SLOT(onDeleteContextSure()));
} else {
@ -741,7 +741,7 @@ bool MainWidget::selectingPeer(bool withConfirm) {
void MainWidget::offerPeer(PeerId peer) {
App::wnd()->hideLayer();
if (_hider->offerPeer(peer) && !cWideMode()) {
_forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward));
_forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward_send));
connect(_forwardConfirm, SIGNAL(confirmed()), _hider, SLOT(forward()));
connect(_forwardConfirm, SIGNAL(cancelled()), this, SLOT(onForwardCancel()));
connect(_forwardConfirm, SIGNAL(destroyed(QObject*)), this, SLOT(onForwardCancel(QObject*)));
@ -879,7 +879,7 @@ bool MainWidget::addParticipantFail(UserData *user, const RPCError &error) {
} else if (error.type() == "PEER_FLOOD") {
text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)));
}
App::wnd()->showLayer(new ConfirmBox(text, true));
App::wnd()->showLayer(new InformBox(text));
return false;
}
@ -893,7 +893,7 @@ bool MainWidget::addParticipantsFail(const RPCError &error) {
} else if (error.type() == "PEER_FLOOD") {
text = lng_cant_invite_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)));
}
App::wnd()->showLayer(new ConfirmBox(text, true));
App::wnd()->showLayer(new InformBox(text));
return false;
}
@ -1015,7 +1015,7 @@ bool MainWidget::sendMessageFail(const RPCError &error) {
if (mtpIsFlood(error)) return false;
if (error.type() == qsl("PEER_FLOOD")) {
App::wnd()->showLayer(new ConfirmBox(lng_cant_send_to_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info))), true));
App::wnd()->showLayer(new InformBox(lng_cant_send_to_not_contact(lt_more_info, textcmdLink(qsl("https://telegram.org/faq?_hash=can-39t-send-messages-to-non-contacts"), lang(lng_cant_more_info)))));
return true;
}
return false;
@ -2631,11 +2631,13 @@ QRect MainWidget::historyRect() const {
}
void MainWidget::dlgUpdated(DialogRow *row) {
if (!row) return;
dialogs.dlgUpdated(row);
}
void MainWidget::dlgUpdated(History *row) {
dialogs.dlgUpdated(row);
void MainWidget::dlgUpdated(History *row, MsgId msgId) {
if (!row) return;
dialogs.dlgUpdated(row, msgId);
}
void MainWidget::windowShown() {
@ -2757,7 +2759,7 @@ void MainWidget::hideAll() {
void MainWidget::showAll() {
if (cPasswordRecovered()) {
cSetPasswordRecovered(false);
App::wnd()->showLayer(new ConfirmBox(lang(lng_signin_password_removed), true, lang(lng_continue)));
App::wnd()->showLayer(new InformBox(lang(lng_signin_password_removed)));
}
if (cWideMode()) {
if (_hider) {
@ -2783,7 +2785,7 @@ void MainWidget::showAll() {
if (_hider) {
_hider->hide();
if (!_forwardConfirm && _hider->wasOffered()) {
_forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward));
_forwardConfirm = new ConfirmBox(_hider->offeredText(), lang(lng_forward_send));
connect(_forwardConfirm, SIGNAL(confirmed()), _hider, SLOT(forward()));
connect(_forwardConfirm, SIGNAL(cancelled()), this, SLOT(onForwardCancel()));
App::wnd()->showLayer(_forwardConfirm, true);
@ -2922,8 +2924,8 @@ void MainWidget::onTopBarClick() {
}
}
void MainWidget::onPeerShown(PeerData *peer) {
if ((cWideMode() || !selectingPeer()) && (profile || overview || (peer && peer->id))) {
void MainWidget::onHistoryShown(History *history, MsgId atMsgId) {
if ((cWideMode() || !selectingPeer()) && (profile || overview || history)) {
_topBar.show();
} else {
_topBar.hide();
@ -2932,6 +2934,7 @@ void MainWidget::onPeerShown(PeerData *peer) {
if (animating()) {
_topBar.hide();
}
dlgUpdated(history, atMsgId);
}
void MainWidget::searchInPeer(PeerData *peer) {
@ -3609,7 +3612,7 @@ bool MainWidget::usernameResolveFail(QString name, const RPCError &error) {
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
if (error.code() == 400) {
App::wnd()->showLayer(new ConfirmBox(lng_username_not_found(lt_user, name), true));
App::wnd()->showLayer(new InformBox(lng_username_not_found(lt_user, name)));
}
return true;
}
@ -3646,7 +3649,7 @@ bool MainWidget::inviteCheckFail(const RPCError &error) {
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
if (error.code() == 400) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_group_invite_bad_link), true));
App::wnd()->showLayer(new InformBox(lang(lng_group_invite_bad_link)));
}
return true;
}
@ -3684,7 +3687,7 @@ bool MainWidget::inviteImportFail(const RPCError &error) {
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
if (error.code() == 400) {
App::wnd()->showLayer(new ConfirmBox(lang(error.type() == qsl("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link), true), App::wnd()->layerShown());
App::wnd()->showLayer(new InformBox(lang(error.type() == qsl("USERS_TOO_MUCH") ? lng_group_invite_no_room : lng_group_invite_bad_link)));
}
return true;
}
@ -4281,7 +4284,14 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
// update before applying skipped
PeerId id = peerFromMTP(d.vpeer);
App::feedOutboxRead(id, d.vmax_id.v);
if (history.peer() && history.peer()->id == id) history.update();
if (history.peer() && history.peer()->id == id) {
history.update();
}
if (History *h = App::historyLoaded(id)) {
if (h->lastMsg->out() && h->lastMsg->id <= d.vmax_id.v) {
dlgUpdated(h, h->lastMsg->id);
}
}
ptsApplySkippedUpdates();
} break;
@ -4494,7 +4504,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateServiceNotification: {
const MTPDupdateServiceNotification &d(update.c_updateServiceNotification());
if (d.vpopup.v) {
App::wnd()->showLayer(new ConfirmBox(qs(d.vmessage), true));
App::wnd()->showLayer(new InformBox(qs(d.vmessage)));
App::wnd()->serviceNotification(qs(d.vmessage), d.vmedia);
} else {
App::wnd()->serviceNotification(qs(d.vmessage), d.vmedia);

View File

@ -219,7 +219,7 @@ public:
void createDialog(History *history);
void dlgUpdated(DialogRow *row);
void dlgUpdated(History *row);
void dlgUpdated(History *row, MsgId msgId);
void windowShown();
@ -443,7 +443,7 @@ public slots:
void showPeerHistory(quint64 peer, qint32 msgId, bool back = false);
void onTopBarClick();
void onPeerShown(PeerData *peer);
void onHistoryShown(History *history, MsgId atMsgId);
void searchInPeer(PeerData *peer);

View File

@ -229,11 +229,11 @@ void MediaView::updateDocSize() {
} else {
_docSize = formatSizeText(_doc->size);
}
_docSizeWidth = st::mvFont->m.width(_docSize);
_docSizeWidth = st::mvFont->width(_docSize);
int32 maxw = st::mvDocSize.width() - st::mvDocBlue.pxWidth() - st::mvDocPadding * 3;
if (_docSizeWidth > maxw) {
_docSize = st::mvFont->m.elidedText(_docSize, Qt::ElideRight, maxw);
_docSizeWidth = st::mvFont->m.width(_docSize);
_docSize = st::mvFont->elided(_docSize, maxw);
_docSizeWidth = st::mvFont->width(_docSize);
}
}
@ -292,10 +292,10 @@ void MediaView::updateControls() {
if (_from) {
_fromName.setText(st::mvFont, _from->name);
_nameNav = myrtlrect(st::mvTextLeft, height() - st::mvTextTop, qMin(_fromName.maxWidth(), width() / 3), st::mvFont->height);
_dateNav = myrtlrect(st::mvTextLeft + _nameNav.width() + st::mvTextSkip, height() - st::mvTextTop, st::mvFont->m.width(_dateText), st::mvFont->height);
_dateNav = myrtlrect(st::mvTextLeft + _nameNav.width() + st::mvTextSkip, height() - st::mvTextTop, st::mvFont->width(_dateText), st::mvFont->height);
} else {
_nameNav = QRect();
_dateNav = myrtlrect(st::mvTextLeft, height() - st::mvTextTop, st::mvFont->m.width(_dateText), st::mvFont->height);
_dateNav = myrtlrect(st::mvTextLeft, height() - st::mvTextTop, st::mvFont->width(_dateText), st::mvFont->height);
}
updateHeader();
if (_photo || (_history && _overview == OverviewPhotos)) {
@ -912,18 +912,18 @@ void MediaView::displayDocument(DocumentData *doc, HistoryItem *item) { // empty
_docName = (!_doc || _doc->name.isEmpty()) ? lang(_doc ? (_doc->type == StickerDocument ? lng_in_dlg_sticker : lng_mediaview_doc_image) : lng_message_empty) : _doc->name;
int32 lastDot = _docName.lastIndexOf('.');
_docExt = _doc ? ((lastDot < 0 || lastDot + 2 > _docName.size()) ? _docName : _docName.mid(lastDot + 1)) : QString();
_docNameWidth = st::mvDocNameFont->m.width(_docName);
_docNameWidth = st::mvDocNameFont->width(_docName);
if (_docNameWidth > maxw) {
_docName = st::mvDocNameFont->m.elidedText(_docName, Qt::ElideMiddle, maxw);
_docNameWidth = st::mvDocNameFont->m.width(_docName);
_docName = st::mvDocNameFont->elided(_docName, maxw, Qt::ElideMiddle);
_docNameWidth = st::mvDocNameFont->width(_docName);
}
int32 extmaxw = (st::mvDocBlue.pxWidth() - st::mvDocExtPadding * 2);
_docExtWidth = st::mvDocExtFont->m.width(_docExt);
_docExtWidth = st::mvDocExtFont->width(_docExt);
if (_docExtWidth > extmaxw) {
_docExt = st::mvDocNameFont->m.elidedText(_docExt, Qt::ElideMiddle, extmaxw);
_docExtWidth = st::mvDocNameFont->m.width(_docExt);
_docExt = st::mvDocNameFont->elided(_docExt, extmaxw, Qt::ElideMiddle);
_docExtWidth = st::mvDocNameFont->width(_docExt);
}
_docRadialFirst = _docRadialLast = _docRadialStart = 0;
@ -1953,75 +1953,13 @@ void MediaView::updateHeader() {
}
}
_headerHasLink = (_overview != OverviewCount) && _history;
int32 hwidth = st::mvThickFont->m.width(_headerText);
int32 hwidth = st::mvThickFont->width(_headerText);
if (hwidth > width() / 3) {
hwidth = width() / 3;
_headerText = st::mvThickFont->m.elidedText(_headerText, Qt::ElideMiddle, hwidth);
_headerText = st::mvThickFont->elided(_headerText, hwidth, Qt::ElideMiddle);
}
_headerNav = myrtlrect(st::mvTextLeft, height() - st::mvHeaderTop, hwidth, st::mvThickFont->height);
}
//
//void MediaView::updatePolaroid() {
// if (_doc) {
// _polaroidIn = _polaroidOut = QRect(0, 0, _avail.width(), _avail.height() - st::medviewBottomBar);
// int32 minus1 = width() - _delete.x(), minus2 = _overview.x() + st::medviewHeaderFont->m.width(_header) - st::medviewOverview.width;
// if (minus2 > minus1) minus1 = minus2;
//
// int32 dateWidth = st::medviewDateFont->m.width(_dateText), maxWidth = width() - 2 * minus1;
// if (_from) {
// int32 nameWidth = _fromName.maxWidth();
// if (maxWidth < dateWidth) {
// maxWidth = dateWidth;
// }
// if (nameWidth > maxWidth) {
// nameWidth = maxWidth;
// }
// _nameNav = QRect((_avail.width() - nameWidth) / 2, _avail.y() + _avail.height() - ((st::medviewPolaroid.bottom() + st::medviewBottomBar) / 2) + st::medviewNameTop, nameWidth, st::medviewNameFont->height);
// _dateNav = QRect((_avail.width() - dateWidth) / 2, _avail.y() + _avail.height() - ((st::medviewPolaroid.bottom() + st::medviewBottomBar) / 2) + st::medviewDateTop, dateWidth, st::medviewDateFont->height);
// } else {
// _nameNav = QRect(_avail.x() - 1, _avail.y() - 1, 0, 0);
// _dateNav = QRect((_avail.width() - dateWidth) / 2, _avail.y() + _avail.height() - ((st::medviewPolaroid.bottom() + st::medviewBottomBar) / 2) + ((st::medviewNameTop + st::medviewDateTop) / 2), dateWidth, st::medviewDateFont->height);
// }
// } else {
// int32 pminw = qMin(st::medviewPolaroidMin.width(), int(_avail.width() - 2 * st::medviewNavBarWidth));
//
// int32 pl = _x - st::medviewPolaroid.left(), plw = st::medviewPolaroid.left();
// if (pl < st::medviewNavBarWidth) pl = st::medviewNavBarWidth;
// int32 pr = _x + _w + st::medviewPolaroid.right(), prw = st::medviewPolaroid.right();
// if (pr > _avail.width() - st::medviewNavBarWidth) pr = _avail.width() - st::medviewNavBarWidth;
//
// if (_w + st::medviewPolaroid.left() + st::medviewPolaroid.right() < pminw) {
// pl = (_avail.width() - pminw) / 2;
// plw = _x - pl;
// pr = pl + pminw;
// prw = pr - (_x + _w);
// }
//
// int32 pminh = qMin(st::medviewPolaroidMin.height(), int(_avail.height() - st::medviewBottomBar));
//
// int32 pt = _y - st::medviewPolaroid.top(), pth = st::medviewPolaroid.top();
// if (pt < 0) pt = 0;
// int32 pb = _y + _h + st::medviewPolaroid.bottom(), pbh = st::medviewPolaroid.bottom();
// if (pb > _avail.height() - st::medviewBottomBar) pb = _avail.height() - st::medviewBottomBar;
//
// if (_h + st::medviewPolaroid.top() + st::medviewPolaroid.bottom() < pminh) {
// pt = (_avail.height() - st::medviewBottomBar - pminh) / 2;
// pth = _y - pt;
// pb = pt + pminh;
// pbh = pb - (_y + _h);
// }
//
// _polaroidOut = QRect(pl, pt, pr - pl, pb - pt);
// _polaroidIn = QRect(pl + plw, pt + pth, pr - pl - prw - plw, pb - pt - pbh - pth);
//
// int32 nameWidth = _fromName.maxWidth(), maxWidth = _polaroidOut.width() - st::medviewPolaroid.left() - st::medviewPolaroid.right(), dateWidth = st::medviewDateFont->m.width(_dateText);
// if (nameWidth > maxWidth) {
// nameWidth = maxWidth;
// }
// _nameNav = QRect(_polaroidIn.x() + ((_polaroidIn.width() - nameWidth) / 2), _polaroidOut.y() + _polaroidOut.height() - st::medviewPolaroid.bottom() + st::medviewNameTop, nameWidth, st::medviewNameFont->height);
// _dateNav = QRect(_polaroidIn.x() + ((_polaroidIn.width() - dateWidth) / 2), _polaroidOut.y() + _polaroidOut.height() - st::medviewPolaroid.bottom() + st::medviewDateTop, dateWidth, st::medviewDateFont->height);
// }
//}
QColor MediaView::overColor(const QColor &a, float64 ca, const QColor &b, float64 cb) {
QColor res;

View File

@ -728,36 +728,29 @@ textSerializeFull += '\ttypes.reserve(20); vtypes.reserve(20); stages.reserve(20
textSerializeFull += '\ttypes.push_back(mtpTypeId(cons)); vtypes.push_back(mtpTypeId(vcons)); stages.push_back(0); flags.push_back(0);\n\n';
textSerializeFull += '\tconst mtpPrime *start = from;\n';
textSerializeFull += '\tmtpTypeId type = cons, vtype = vcons;\n';
textSerializeFull += '\tint32 stage = 0, flag = 0;\n';
textSerializeFull += '\ttry {\n';
textSerializeFull += '\t\twhile (!types.isEmpty()) {\n';
textSerializeFull += '\t\t\ttype = types.back();\n';
textSerializeFull += '\t\t\tvtype = vtypes.back();\n';
textSerializeFull += '\t\t\tstage = stages.back();\n';
textSerializeFull += '\t\t\tflag = flags.back();\n';
textSerializeFull += '\t\t\tif (!type) {\n';
textSerializeFull += '\t\t\t\tif (from >= end) {\n';
textSerializeFull += '\t\t\t\t\tthrow Exception("from >= end");\n';
textSerializeFull += '\t\t\t\t} else if (stage) {\n';
textSerializeFull += '\t\t\t\t\tthrow Exception("unknown type on stage > 0");\n';
textSerializeFull += '\t\t\t\t}\n';
textSerializeFull += '\t\t\t\ttypes.back() = type = *from;\n';
textSerializeFull += '\t\t\t\tstart = ++from;\n';
textSerializeFull += '\t\t\t}\n\n';
textSerializeFull += '\t\t\tint32 lev = level + types.size() - 1;\n';
textSerializeFull += '\t\t\tTextSerializers::const_iterator it = _serializers.constFind(type);\n';
textSerializeFull += '\t\t\tif (it != _serializers.cend()) {\n';
textSerializeFull += '\t\t\t\t(*it.value())(to, stage, lev, types, vtypes, stages, flags, start, end, flag);\n';
textSerializeFull += '\t\t\t} else {\n';
textSerializeFull += '\t\t\t\tmtpTextSerializeCore(to, from, end, type, lev, vtype);\n';
textSerializeFull += '\t\t\t\ttypes.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();\n';
textSerializeFull += '\t\t\t\t}\n';
textSerializeFull += '\tint32 stage = 0, flag = 0;\n\n';
textSerializeFull += '\twhile (!types.isEmpty()) {\n';
textSerializeFull += '\t\ttype = types.back();\n';
textSerializeFull += '\t\tvtype = vtypes.back();\n';
textSerializeFull += '\t\tstage = stages.back();\n';
textSerializeFull += '\t\tflag = flags.back();\n';
textSerializeFull += '\t\tif (!type) {\n';
textSerializeFull += '\t\t\tif (from >= end) {\n';
textSerializeFull += '\t\t\t\tthrow Exception("from >= end");\n';
textSerializeFull += '\t\t\t} else if (stage) {\n';
textSerializeFull += '\t\t\t\tthrow Exception("unknown type on stage > 0");\n';
textSerializeFull += '\t\t\t}\n';
textSerializeFull += '\t\t\ttypes.back() = type = *from;\n';
textSerializeFull += '\t\t\tstart = ++from;\n';
textSerializeFull += '\t\t}\n\n';
textSerializeFull += '\t\tint32 lev = level + types.size() - 1;\n';
textSerializeFull += '\t\tTextSerializers::const_iterator it = _serializers.constFind(type);\n';
textSerializeFull += '\t\tif (it != _serializers.cend()) {\n';
textSerializeFull += '\t\t\t(*it.value())(to, stage, lev, types, vtypes, stages, flags, start, end, flag);\n';
textSerializeFull += '\t\t} else {\n';
textSerializeFull += '\t\t\tmtpTextSerializeCore(to, from, end, type, lev, vtype);\n';
textSerializeFull += '\t\t\ttypes.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();\n';
textSerializeFull += '\t\t}\n';
textSerializeFull += '\t} catch (Exception &e) {\n';
textSerializeFull += '\t\tto.add("[ERROR] ");\n';
textSerializeFull += '\t\tto.add("(").add(e.what()).add("), cons: 0x").add(mtpWrapNumber(type, 16));\n';
textSerializeFull += '\t\tif (vtype) to.add(", vcons: 0x").add(mtpWrapNumber(vtype));\n';
textSerializeFull += '\t\tto.add(", ").add(mb(start, (end - start) * sizeof(mtpPrime)).str());\n';
textSerializeFull += '\t}\n';
textSerializeFull += '}\n';

View File

@ -206,7 +206,7 @@ typedef QMap<mtpRequestId, mtpResponse> mtpResponseMap;
class mtpErrorUnexpected : public Exception {
public:
mtpErrorUnexpected(mtpTypeId typeId, const QString &type) : Exception(QString("MTP Unexpected type id %1 read in %2").arg(typeId).arg(type), false) { // maybe api changed?..
mtpErrorUnexpected(mtpTypeId typeId, const QString &type) : Exception(QString("MTP Unexpected type id #%1 read in %2").arg(uint32(typeId), 0, 16).arg(type), false) { // maybe api changed?..
}
};
@ -1005,7 +1005,11 @@ void mtpTextSerializeCore(MTPStringLogger &to, const mtpPrime *&from, const mtpP
inline QString mtpTextSerialize(const mtpPrime *&from, const mtpPrime *end) {
MTPStringLogger to;
mtpTextSerializeType(to, from, end, mtpc_core_message);
try {
mtpTextSerializeType(to, from, end, mtpc_core_message);
} catch (Exception &e) {
to.add("[ERROR] (").add(e.what()).add(")");
}
return QString::fromUtf8(to.p, to.size);
}

View File

@ -7467,36 +7467,30 @@ void mtpTextSerializeType(MTPStringLogger &to, const mtpPrime *&from, const mtpP
const mtpPrime *start = from;
mtpTypeId type = cons, vtype = vcons;
int32 stage = 0, flag = 0;
try {
while (!types.isEmpty()) {
type = types.back();
vtype = vtypes.back();
stage = stages.back();
flag = flags.back();
if (!type) {
if (from >= end) {
throw Exception("from >= end");
} else if (stage) {
throw Exception("unknown type on stage > 0");
}
types.back() = type = *from;
start = ++from;
}
int32 lev = level + types.size() - 1;
TextSerializers::const_iterator it = _serializers.constFind(type);
if (it != _serializers.cend()) {
(*it.value())(to, stage, lev, types, vtypes, stages, flags, start, end, flag);
} else {
mtpTextSerializeCore(to, from, end, type, lev, vtype);
types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();
}
while (!types.isEmpty()) {
type = types.back();
vtype = vtypes.back();
stage = stages.back();
flag = flags.back();
if (!type) {
if (from >= end) {
throw Exception("from >= end");
} else if (stage) {
throw Exception("unknown type on stage > 0");
}
types.back() = type = *from;
start = ++from;
}
int32 lev = level + types.size() - 1;
TextSerializers::const_iterator it = _serializers.constFind(type);
if (it != _serializers.cend()) {
(*it.value())(to, stage, lev, types, vtypes, stages, flags, start, end, flag);
} else {
mtpTextSerializeCore(to, from, end, type, lev, vtype);
types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back();
}
} catch (Exception &e) {
to.add("[ERROR] ");
to.add("(").add(e.what()).add("), cons: 0x").add(mtpWrapNumber(type, 16));
if (vtype) to.add(", vcons: 0x").add(mtpWrapNumber(vtype));
to.add(", ").add(mb(start, (end - start) * sizeof(mtpPrime)).str());
}
}

View File

@ -116,7 +116,7 @@ OverviewInner::CachedLink::CachedLink(HistoryItem *item) : titleWidth(0), page(0
}
}
}
titleWidth = st::webPageTitleFont->m.width(title);
titleWidth = st::webPageTitleFont->width(title);
}
int32 OverviewInner::CachedLink::countHeight(int32 w) {
@ -1187,7 +1187,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
p.setPen(st::black->p);
p.setFont(st::webPageTitleFont->f);
if (!lnk->title.isEmpty()) {
p.drawText(left, top + st::webPageTitleFont->ascent, (_linksWidth - left < lnk->titleWidth) ? st::webPageTitleFont->m.elidedText(lnk->title, Qt::ElideRight, _linksWidth - left) : lnk->title);
p.drawText(left, top + st::webPageTitleFont->ascent, (_linksWidth - left < lnk->titleWidth) ? st::webPageTitleFont->elided(lnk->title, _linksWidth - left) : lnk->title);
top += st::webPageTitleFont->height;
}
p.setFont(st::msgFont->f);
@ -1200,7 +1200,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
for (int32 j = 0, c = lnk->urls.size(); j < c; ++j) {
bool sel = (_mousedItem == _items[i].msgid && j + 1 == _lnkOverIndex);
if (sel) p.setFont(st::msgFont->underline()->f);
p.drawText(left, top + st::msgFont->ascent, (_linksWidth - left < lnk->urls[j].width) ? st::msgFont->m.elidedText(lnk->urls[j].text, Qt::ElideRight, _linksWidth - left) : lnk->urls[j].text);
p.drawText(left, top + st::msgFont->ascent, (_linksWidth - left < lnk->urls[j].width) ? st::msgFont->elided(lnk->urls[j].text, _linksWidth - left) : lnk->urls[j].text);
if (sel) p.setFont(st::msgFont->f);
top += st::msgFont->height;
}
@ -1257,7 +1257,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
int32 left = st::msgServiceMargin.left(), width = _width - st::msgServiceMargin.left() - st::msgServiceMargin.left(), height = st::msgServiceFont->height + st::msgServicePadding.top() + st::msgServicePadding.bottom();
if (width < 1) return;
int32 strwidth = st::msgServiceFont->m.width(str) + st::msgServicePadding.left() + st::msgServicePadding.right();
int32 strwidth = st::msgServiceFont->width(str) + st::msgServicePadding.left() + st::msgServicePadding.right();
QRect trect(QRect(left, st::msgServiceMargin.top(), width, height).marginsAdded(-st::msgServicePadding));
left += (width - strwidth) / 2;

View File

@ -154,7 +154,7 @@ private:
struct Link {
Link() : width(0) {
}
Link(const QString &url, const QString &text) : url(url), text(text), width(st::msgFont->m.width(text)) {
Link(const QString &url, const QString &text) : url(url), text(text), width(st::msgFont->width(text)) {
}
QString url, text;
int32 width;

View File

@ -201,7 +201,7 @@ void PlayerWidget::updateDownTime() {
QString time = formatDurationText(qRound(_downDuration * _downProgress) / _downFrequency);
if (time != _time) {
_time = time;
_timeWidth = st::linkFont->m.width(_time);
_timeWidth = st::linkFont->width(_time);
rtlupdate(_infoRect);
}
}
@ -583,7 +583,7 @@ void PlayerWidget::updateState(SongMsgId playing, AudioPlayerState playingState,
if (time != _time || showPause != _showPause) {
if (_time != time) {
_time = time;
_timeWidth = st::linkFont->m.width(_time);
_timeWidth = st::linkFont->width(_time);
}
_showPause = showPause;
if (duration != _duration || position != _position || loaded != _loaded) {

View File

@ -75,7 +75,7 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const Pee
// participants
_pHeight(st::profileListPhotoSize + st::profileListPadding.height() * 2),
_kickWidth(st::linkFont->m.width(lang(lng_profile_kick))),
_kickWidth(st::linkFont->width(lang(lng_profile_kick))),
_selectedRow(-1), _lastPreload(0), _contactId(0),
_kickOver(0), _kickDown(0), _kickConfirm(0),
@ -276,7 +276,7 @@ void ProfileInner::onUpdatePhoto() {
void ProfileInner::onClearHistory() {
if (_peerChannel) return;
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : lng_sure_delete_group_history(lt_group, _peer->name));
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : lng_sure_delete_group_history(lt_group, _peer->name), lang(lng_box_delete), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onClearHistorySure()));
App::wnd()->showLayer(box);
}
@ -287,7 +287,7 @@ void ProfileInner::onClearHistorySure() {
}
void ProfileInner::onDeleteConversation() {
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : (_peer->isChat() ? lng_sure_delete_and_exit(lt_group, _peer->name) : lang(lng_sure_leave_channel)));
ConfirmBox *box = new ConfirmBox(_peer->isUser() ? lng_sure_delete_history(lt_contact, _peer->name) : (_peer->isChat() ? lng_sure_delete_and_exit(lt_group, _peer->name) : lang(lng_sure_leave_channel)), lang(_peer->isUser() ? lng_box_delete : lng_box_leave), _peer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteConversationSure()));
App::wnd()->showLayer(box);
}
@ -308,7 +308,7 @@ void ProfileInner::onDeleteConversationSure() {
void ProfileInner::onDeleteChannel() {
if (!_peerChannel) return;
ConfirmBox *box = new ConfirmBox(lang(lng_sure_delete_channel), lang(lng_selected_delete_confirm), QString(), st::btnRedDone);
ConfirmBox *box = new ConfirmBox(lang(lng_sure_delete_channel), lang(lng_box_delete), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onDeleteChannelSure()));
App::wnd()->showLayer(box);
}
@ -398,7 +398,7 @@ void ProfileInner::onInvitationLink() {
if (!_peerChat && !_peerChannel) return;
QApplication::clipboard()->setText(_peerChat ? _peerChat->invitationUrl : (_peerChannel ? _peerChannel->invitationUrl : QString()));
App::wnd()->showLayer(new ConfirmBox(lang(lng_group_invite_copied), true));
App::wnd()->showLayer(new InformBox(lang(lng_group_invite_copied)));
}
void ProfileInner::onPublicLink() {
@ -406,7 +406,7 @@ void ProfileInner::onPublicLink() {
if (_peerChannel->isPublic()) {
QApplication::clipboard()->setText(qsl("https://telegram.me/") + _peerChannel->username);
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_public_link_copied), true));
App::wnd()->showLayer(new InformBox(lang(lng_channel_public_link_copied)));
} else {
App::wnd()->showLayer(new SetupChannelBox(_peerChannel, true));
}
@ -716,7 +716,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
top += st::profileButtonTop;
if (_peerChat && _peerChat->isForbidden) {
int32 w = st::btnShareContact.font->m.width(lang(lng_profile_chat_unaccessible));
int32 w = st::btnShareContact.font->width(lang(lng_profile_chat_unaccessible));
p.setFont(st::btnShareContact.font->f);
p.setPen(st::profileOfflineColor->p);
p.drawText(_left + (_width - w) / 2, top + st::btnShareContact.textTop + st::btnShareContact.font->ascent, lang(lng_profile_chat_unaccessible));
@ -952,7 +952,7 @@ void ProfileInner::mouseReleaseEvent(QMouseEvent *e) {
updateSelected();
if (_kickDown && _kickDown == _kickOver) {
_kickConfirm = _kickOver;
ConfirmBox *box = new ConfirmBox(lng_profile_sure_kick(lt_user, _kickOver->firstName));
ConfirmBox *box = new ConfirmBox(lng_profile_sure_kick(lt_user, _kickOver->firstName), lang(lng_box_remove));
connect(box, SIGNAL(confirmed()), this, SLOT(onKickConfirm()));
App::wnd()->showLayer(box);
}
@ -1142,10 +1142,10 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
top += st::profileHeaderSkip;
// invite link stuff
int32 _inviteLinkTextWidth(st::linkFont->m.width(lang(lng_group_invite_link)) + st::linkFont->spacew);
int32 _inviteLinkTextWidth(st::linkFont->width(lang(lng_group_invite_link)) + st::linkFont->spacew);
if (_amCreator && (!_peerChannel || !_peerChannel->isPublic())) {
if (!_invitationText.isEmpty()) {
_invitationLink.setText(st::linkFont->m.elidedText(_invitationText, Qt::ElideRight, _width - _inviteLinkTextWidth));
_invitationLink.setText(st::linkFont->elided(_invitationText, _width - _inviteLinkTextWidth));
}
if ((_peerChat && !_peerChat->invitationUrl.isEmpty()) || (_peerChannel && !_peerChannel->invitationUrl.isEmpty())) {
_invitationLink.move(_left + _inviteLinkTextWidth, top);

View File

@ -157,7 +157,7 @@ void _placeCounter(QImage &img, int size, int count, style::color bg, style::col
fontSize = 16;
}
style::font f(fontSize);
int32 w = f->m.width(cnt), d, r;
int32 w = f->width(cnt), d, r;
if (size == 22) {
d = (cntSize < 2) ? 3 : 2;
r = (cntSize < 2) ? 6 : 5;

View File

@ -144,10 +144,10 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
_dpiAutoScale(this, lng_settings_scale_auto(lt_cur, scaleLabel(cScreenScale())), (cConfigScale() == dbisAuto)),
_dpiSlider(this, st::dpiSlider, dbisScaleCount - 1, cEvalScale(cConfigScale()) - 1),
_dpiWidth1(st::dpiFont1->m.width(scaleLabel(dbisOne))),
_dpiWidth2(st::dpiFont2->m.width(scaleLabel(dbisOneAndQuarter))),
_dpiWidth3(st::dpiFont3->m.width(scaleLabel(dbisOneAndHalf))),
_dpiWidth4(st::dpiFont4->m.width(scaleLabel(dbisTwo))),
_dpiWidth1(st::dpiFont1->width(scaleLabel(dbisOne))),
_dpiWidth2(st::dpiFont2->width(scaleLabel(dbisOneAndQuarter))),
_dpiWidth3(st::dpiFont3->width(scaleLabel(dbisOneAndHalf))),
_dpiWidth4(st::dpiFont4->width(scaleLabel(dbisTwo))),
// chat options
_replaceEmojis(this, lang(lng_settings_replace_emojis), cReplaceEmojis()),
@ -157,12 +157,12 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
_ctrlEnterSend(this, qsl("send_key"), 1, lang((cPlatform() == dbipMac) ? lng_settings_send_cmdenter : lng_settings_send_ctrlenter), cCtrlEnter()),
_dontAskDownloadPath(this, lang(lng_download_path_dont_ask), !cAskDownloadPath()),
_downloadPathWidth(st::linkFont->m.width(lang(lng_download_path_label)) + st::linkFont->spacew),
_downloadPathEdit(this, cDownloadPath().isEmpty() ? lang(lng_download_path_default) : ((cDownloadPath() == qsl("tmp")) ? lang(lng_download_path_temp) : st::linkFont->m.elidedText(QDir::toNativeSeparators(cDownloadPath()), Qt::ElideRight, st::setWidth - st::setVersionLeft - _downloadPathWidth))),
_downloadPathWidth(st::linkFont->width(lang(lng_download_path_label)) + st::linkFont->spacew),
_downloadPathEdit(this, cDownloadPath().isEmpty() ? lang(lng_download_path_default) : ((cDownloadPath() == qsl("tmp")) ? lang(lng_download_path_temp) : st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth))),
_downloadPathClear(this, lang(lng_download_path_clear)),
_tempDirClearingWidth(st::linkFont->m.width(lang(lng_download_path_clearing))),
_tempDirClearedWidth(st::linkFont->m.width(lang(lng_download_path_cleared))),
_tempDirClearFailedWidth(st::linkFont->m.width(lang(lng_download_path_clear_failed))),
_tempDirClearingWidth(st::linkFont->width(lang(lng_download_path_clearing))),
_tempDirClearedWidth(st::linkFont->width(lang(lng_download_path_cleared))),
_tempDirClearFailedWidth(st::linkFont->width(lang(lng_download_path_clear_failed))),
// chat background
_backFromGallery(this, lang(lng_settings_bg_from_gallery)),
@ -173,22 +173,22 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
// local storage
_localStorageClear(this, lang(lng_local_storage_clear)),
_localStorageHeight(1),
_storageClearingWidth(st::linkFont->m.width(lang(lng_local_storage_clearing))),
_storageClearedWidth(st::linkFont->m.width(lang(lng_local_storage_cleared))),
_storageClearFailedWidth(st::linkFont->m.width(lang(lng_local_storage_clear_failed))),
_storageClearingWidth(st::linkFont->width(lang(lng_local_storage_clearing))),
_storageClearedWidth(st::linkFont->width(lang(lng_local_storage_cleared))),
_storageClearFailedWidth(st::linkFont->width(lang(lng_local_storage_clear_failed))),
// advanced
_passcodeEdit(this, lang(cHasPasscode() ? lng_passcode_change : lng_passcode_turn_on)),
_passcodeTurnOff(this, lang(lng_passcode_turn_off)),
_autoLock(this, (cAutoLock() % 3600) ? lng_passcode_autolock_minutes(lt_count, cAutoLock() / 60) : lng_passcode_autolock_hours(lt_count, cAutoLock() / 3600)),
_autoLockText(lang(psIdleSupported() ? lng_passcode_autolock_away : lng_passcode_autolock_inactive) + ' '),
_autoLockWidth(st::linkFont->m.width(_autoLockText)),
_autoLockWidth(st::linkFont->width(_autoLockText)),
_passwordEdit(this, lang(lng_cloud_password_set)),
_passwordTurnOff(this, lang(lng_passcode_turn_off)),
_hasPasswordRecovery(false),
_connectionType(this, lang(lng_connection_auto_connecting)),
_connectionTypeText(lang(lng_connection_type) + ' '),
_connectionTypeWidth(st::linkFont->m.width(_connectionTypeText)),
_connectionTypeWidth(st::linkFont->width(_connectionTypeText)),
_showSessions(this, lang(lng_settings_show_sessions)),
_askQuestion(this, lang(lng_settings_ask_question)),
_telegramFAQ(this, lang(lng_settings_faq)),
@ -248,9 +248,9 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
connect(&_dpiSlider, SIGNAL(changed(int32)), this, SLOT(onScaleChange()));
_curVersionText = lng_settings_current_version(lt_version, QString::fromWCharArray(AppVersionStr) + (cDevVersion() ? " dev" : "")) + ' ';
_curVersionWidth = st::linkFont->m.width(_curVersionText);
_curVersionWidth = st::linkFont->width(_curVersionText);
_newVersionText = lang(lng_settings_update_ready) + ' ';
_newVersionWidth = st::linkFont->m.width(_newVersionText);
_newVersionWidth = st::linkFont->width(_newVersionText);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE
connect(App::app(), SIGNAL(updateChecking()), this, SLOT(onUpdateChecking()));
@ -921,7 +921,7 @@ void SettingsInner::gotPassword(const MTPaccount_Password &result) {
if (!pattern.isEmpty()) _waitingConfirm = lng_cloud_password_waiting(lt_email, pattern);
} break;
}
_waitingConfirm = st::linkFont->m.elidedText(_waitingConfirm, Qt::ElideRight, st::setWidth - _passwordTurnOff.width());
_waitingConfirm = st::linkFont->elided(_waitingConfirm, st::setWidth - _passwordTurnOff.width());
_passwordEdit.setText(lang(_curPasswordSalt.isEmpty() ? lng_cloud_password_set : lng_cloud_password_edit));
showAll();
update();
@ -1175,7 +1175,7 @@ void SettingsInner::onShowSessions() {
void SettingsInner::onAskQuestion() {
if (!App::self()) return;
ConfirmBox *box = new ConfirmBox(lang(lng_settings_ask_sure), lang(lng_settings_ask_ok), lang(lng_settings_faq_button));
ConfirmBox *box = new ConfirmBox(lang(lng_settings_ask_sure), lang(lng_settings_ask_ok), st::defaultBoxButton, lang(lng_settings_faq_button));
connect(box, SIGNAL(confirmed()), this, SLOT(onAskQuestionSure()));
connect(box, SIGNAL(cancelPressed()), this, SLOT(onTelegramFAQ()));
App::wnd()->showLayer(box);
@ -1204,17 +1204,17 @@ void SettingsInner::chooseCustomLang() {
QByteArray arr;
if (filedialogGetOpenFile(file, arr, qsl("Choose language .strings file"), qsl("Language files (*.strings)"))) {
_testlang = QFileInfo(file).absoluteFilePath();
LangLoaderPlain loader(_testlang, LangLoaderRequest(lng_sure_save_language, lng_cancel, lng_continue));
LangLoaderPlain loader(_testlang, LangLoaderRequest(lng_sure_save_language, lng_box_cancel, lng_box_ok));
if (loader.errors().isEmpty()) {
LangLoaderResult result = loader.found();
QString text = result.value(lng_sure_save_language, langOriginal(lng_sure_save_language)),
save = result.value(lng_continue, langOriginal(lng_continue)),
cancel = result.value(lng_cancel, langOriginal(lng_cancel));
ConfirmBox *box = new ConfirmBox(text, save, cancel);
save = result.value(lng_box_ok, langOriginal(lng_box_ok)),
cancel = result.value(lng_box_cancel, langOriginal(lng_box_cancel));
ConfirmBox *box = new ConfirmBox(text, save, st::defaultBoxButton, cancel);
connect(box, SIGNAL(confirmed()), this, SLOT(onSaveTestLang()));
App::wnd()->showLayer(box);
} else {
App::wnd()->showLayer(new ConfirmBox("Custom lang failed :(\n\nError: " + loader.errors(), true, lang(lng_close)));
App::wnd()->showLayer(new InformBox("Custom lang failed :(\n\nError: " + loader.errors()));
}
}
}
@ -1438,7 +1438,7 @@ void SettingsInner::setScale(DBIScale newScale) {
_dpiSlider.setSelected(newScale - 1);
}
if (cEvalScale(cConfigScale()) != cEvalScale(cRealScale())) {
ConfirmBox *box = new ConfirmBox(lang(lng_settings_need_restart), lang(lng_settings_restart_now), lang(lng_settings_restart_later));
ConfirmBox *box = new ConfirmBox(lang(lng_settings_need_restart), lang(lng_settings_restart_now), st::defaultBoxButton, lang(lng_settings_restart_later));
connect(box, SIGNAL(confirmed()), this, SLOT(onRestartNow()));
App::wnd()->showLayer(box);
}
@ -1626,7 +1626,7 @@ void SettingsInner::onDownloadPathEdited() {
} else if (cDownloadPath() == qsl("tmp")) {
path = lang(lng_download_path_temp);
} else {
path = st::linkFont->m.elidedText(QDir::toNativeSeparators(cDownloadPath()), Qt::ElideRight, st::setWidth - st::setVersionLeft - _downloadPathWidth);
path = st::linkFont->elided(QDir::toNativeSeparators(cDownloadPath()), st::setWidth - st::setVersionLeft - _downloadPathWidth);
}
_downloadPathEdit.setText(path);
showAll();

View File

@ -960,7 +960,7 @@ void PeerLink::onClick(Qt::MouseButton button) const {
if (button == Qt::LeftButton && App::main()) {
if (peer() && peer()->isChannel() && App::main()->historyPeer() != peer()) {
if (!peer()->asChannel()->isPublic() && !peer()->asChannel()->amIn()) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_channel_not_accessible), true));
App::wnd()->showLayer(new InformBox(lang(lng_channel_not_accessible)));
} else {
App::main()->showPeerHistory(peer()->id, ShowAtUnreadMsgId);
}

View File

@ -27,7 +27,7 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
SysBtn::SysBtn(QWidget *parent, const style::sysButton &st, const QString &text) : Button(parent),
_st(st), a_color(_st.color->c), _overLevel(0), _text(text) {
int32 w = _st.size.width() + (_text.isEmpty() ? 0 : ((_st.size.width() - _st.img.pxWidth()) / 2 + st::titleTextButton.font->m.width(_text)));
int32 w = _st.size.width() + (_text.isEmpty() ? 0 : ((_st.size.width() - _st.img.pxWidth()) / 2 + st::titleTextButton.font->width(_text)));
resize(w, _st.size.height());
setCursor(style::cur_default);
connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
@ -35,7 +35,7 @@ _st(st), a_color(_st.color->c), _overLevel(0), _text(text) {
void SysBtn::setText(const QString &text) {
_text = text;
int32 w = _st.size.width() + (_text.isEmpty() ? 0 : ((_st.size.width() - _st.img.pxWidth()) / 2 + st::titleTextButton.font->m.width(_text)));
int32 w = _st.size.width() + (_text.isEmpty() ? 0 : ((_st.size.width() - _st.img.pxWidth()) / 2 + st::titleTextButton.font->width(_text)));
resize(w, _st.size.height());
}

View File

@ -42,7 +42,7 @@ ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const Q
void ConnectingWidget::set(const QString &text, const QString &reconnect) {
_text = text;
_textWidth = st::linkFont->m.width(_text) + st::linkFont->spacew;
_textWidth = st::linkFont->width(_text) + st::linkFont->spacew;
int32 _reconnectWidth = 0;
if (reconnect.isEmpty()) {
_reconnect.hide();
@ -187,7 +187,7 @@ void NotifyWindow::updateNotifyDisplay() {
QDateTime now(QDateTime::currentDateTime()), lastTime(item->date);
QDate nowDate(now.date()), lastDate(lastTime.date());
QString dt = lastTime.toString(cTimeFormat());
int32 dtWidth = st::dlgHistFont->m.width(dt);
int32 dtWidth = st::dlgHistFont->width(dt);
rectForName.setWidth(rectForName.width() - dtWidth - st::dlgDateSkip);
p.setFont(st::dlgDateFont->f);
p.setPen(st::dlgDateColor->p);
@ -212,7 +212,7 @@ void NotifyWindow::updateNotifyDisplay() {
p.drawText(r.left(), r.top() + st::dlgHistFont->ascent, lng_forward_messages(lt_count, fwdCount));
}
} else {
static QString notifyText = st::dlgHistFont->m.elidedText(lang(lng_notification_preview), Qt::ElideRight, itemWidth);
static QString notifyText = st::dlgHistFont->elided(lang(lng_notification_preview), itemWidth);
p.setPen(st::dlgSystemColor->p);
p.drawText(st::notifyPhotoPos.x() + st::notifyPhotoSize + st::notifyTextLeft, st::notifyItemTop + st::msgNameFont->height + st::dlgHistFont->ascent, notifyText);
}
@ -222,7 +222,7 @@ void NotifyWindow::updateNotifyDisplay() {
history->peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
} else {
p.setFont(st::msgNameFont->f);
static QString notifyTitle = st::msgNameFont->m.elidedText(qsl("Telegram Desktop"), Qt::ElideRight, rectForName.width());
static QString notifyTitle = st::msgNameFont->elided(qsl("Telegram Desktop"), rectForName.width());
p.drawText(rectForName.left(), rectForName.top() + st::msgNameFont->ascent, notifyTitle);
}
}
@ -770,7 +770,8 @@ void Window::showDocument(DocumentData *doc, HistoryItem *item) {
_mediaView->setFocus();
}
void Window::showLayer(LayeredWidget *w, bool fast) {
void Window::showLayer(LayeredWidget *w, bool forceFast) {
bool fast = forceFast || layerShown();
hideLayer(true);
layerBG = new BackgroundWidget(this, w);
if (fast) {
@ -1059,7 +1060,7 @@ void Window::onShowNewChannel() {
void Window::onLogout() {
if (isHidden()) showFromTray();
ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout));
ConfirmBox *box = new ConfirmBox(lang(lng_sure_logout), lang(lng_box_logout), st::attentionBoxButton);
connect(box, SIGNAL(confirmed()), this, SLOT(onLogoutSure()));
App::wnd()->showLayer(box);
}
@ -1638,7 +1639,7 @@ void Window::placeSmallCounter(QImage &img, int size, int count, style::color bg
fontSize = (cntSize < 2) ? 22 : 22;
}
style::font f(fontSize);
int32 w = f->m.width(cnt), d, r;
int32 w = f->width(cnt), d, r;
if (size == 16) {
d = (cntSize < 2) ? 2 : 1;
r = (cntSize < 2) ? 4 : 3;
@ -1687,7 +1688,7 @@ QImage Window::iconWithCounter(int size, int count, style::color bg, bool smallI
fontSize = (cntSize < 2) ? 22 : ((cntSize < 3) ? 20 : 16);
}
style::font f(fontSize);
int32 w = f->m.width(cnt), d, r;
int32 w = f->width(cnt), d, r;
if (size == 16) {
d = (cntSize < 2) ? 5 : ((cntSize < 3) ? 2 : 1);
r = (cntSize < 2) ? 8 : ((cntSize < 3) ? 7 : 3);

View File

@ -178,7 +178,7 @@ public:
void showPhoto(PhotoData *photo, HistoryItem *item);
void showPhoto(PhotoData *photo, PeerData *item);
void showDocument(DocumentData *doc, HistoryItem *item);
void showLayer(LayeredWidget *w, bool fast = false);
void showLayer(LayeredWidget *w, bool forceFast = false);
void replaceLayer(LayeredWidget *w);
void hideLayer(bool fast = false);
bool hideInnerLayer();