From b0f14d1856b83cafdc177d43fdcf194f95760690 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 3 Dec 2016 15:10:35 +0300 Subject: [PATCH] Closed beta 10019011: various style improvements. --- Telegram/Resources/basic.style | 34 +++----- Telegram/Resources/colors.palette | 17 ++-- Telegram/Resources/langs/lang.strings | 1 + Telegram/Resources/sample.tdesktop-theme | 15 ++-- Telegram/Resources/winrc/Telegram.rc | 8 +- Telegram/Resources/winrc/Updater.rc | 8 +- Telegram/SourceFiles/apiwrap.cpp | 2 - Telegram/SourceFiles/app.cpp | 5 +- Telegram/SourceFiles/application.cpp | 1 + Telegram/SourceFiles/boxes/addcontactbox.cpp | 8 +- Telegram/SourceFiles/boxes/boxes.style | 2 +- Telegram/SourceFiles/boxes/contactsbox.cpp | 34 ++++---- .../SourceFiles/boxes/notifications_box.cpp | 3 +- Telegram/SourceFiles/boxes/photocropbox.cpp | 3 +- Telegram/SourceFiles/boxes/send_files_box.cpp | 32 ++++---- Telegram/SourceFiles/boxes/stickers_box.cpp | 7 +- Telegram/SourceFiles/core/lambda.h | 22 ++++++ Telegram/SourceFiles/core/version.h | 2 +- Telegram/SourceFiles/dialogswidget.cpp | 24 +++--- Telegram/SourceFiles/facades.cpp | 4 +- Telegram/SourceFiles/facades.h | 2 +- Telegram/SourceFiles/history/history.style | 12 +-- .../history/history_media_types.cpp | 79 +++++++++++-------- .../history/history_service_layout.cpp | 7 +- Telegram/SourceFiles/historywidget.cpp | 15 ++-- .../inline_bot_layout_internal.cpp | 7 +- Telegram/SourceFiles/intro/introsignup.cpp | 8 +- Telegram/SourceFiles/mainwindow.cpp | 3 +- .../media/player/media_player_button.cpp | 17 ++-- Telegram/SourceFiles/mediaview.cpp | 18 ++--- Telegram/SourceFiles/overview/overview.style | 2 +- .../SourceFiles/overview/overview_layout.cpp | 37 +++++---- Telegram/SourceFiles/profile/profile.style | 6 +- .../settings/settings_background_widget.cpp | 12 +-- .../SourceFiles/settings/settings_cover.cpp | 12 ++- .../settings/settings_scale_widget.cpp | 2 +- Telegram/SourceFiles/stickers/emoji_pan.cpp | 7 +- Telegram/SourceFiles/stickers/stickers.style | 48 +++++------ .../ui/buttons/history_down_button.cpp | 3 +- .../ui/buttons/peer_avatar_button.cpp | 7 +- .../ui/effects/cross_animation.cpp | 6 +- .../SourceFiles/ui/effects/cross_animation.h | 2 +- .../ui/effects/radial_animation.cpp | 7 +- .../SourceFiles/ui/effects/rect_shadow.cpp | 4 +- .../ui/effects/ripple_animation.cpp | 10 ++- .../SourceFiles/ui/effects/round_checkbox.cpp | 19 ++--- .../ui/effects/send_action_animations.cpp | 9 +-- Telegram/SourceFiles/ui/images.cpp | 31 +++++++- Telegram/SourceFiles/ui/images.h | 3 +- Telegram/SourceFiles/ui/style/style_core.cpp | 13 +-- Telegram/SourceFiles/ui/twidget.h | 34 ++++++++ Telegram/SourceFiles/ui/widgets/checkbox.cpp | 12 ++- .../ui/widgets/continuous_sliders.cpp | 6 +- .../SourceFiles/ui/widgets/input_fields.cpp | 7 +- .../SourceFiles/ui/widgets/multi_select.cpp | 18 +++-- .../SourceFiles/ui/widgets/scroll_area.cpp | 5 +- Telegram/SourceFiles/ui/widgets/widgets.style | 14 ++-- .../SourceFiles/window/window_main_menu.cpp | 14 +++- .../SourceFiles/window/window_main_menu.h | 2 + Telegram/build/version | 2 +- 60 files changed, 441 insertions(+), 313 deletions(-) diff --git a/Telegram/Resources/basic.style b/Telegram/Resources/basic.style index 7d5b8f752..1be52bfde 100644 --- a/Telegram/Resources/basic.style +++ b/Telegram/Resources/basic.style @@ -70,11 +70,6 @@ slideShift: 100px; slideFadeOutBg: #0000003c; slideShadow: icon {{ "slide_shadow", windowShadowFg }}; -btnYesColor: #0080c0; -btnYesHover: #0073ad; -btnNoColor: #8b8b8b; -btnNoHover: #777777; - linkCropLimit: 360px; linkFont: normalFont; linkOverFont: font(fsize underline); @@ -82,8 +77,6 @@ linkOverFont: font(fsize underline); dateRadius: 6px; buttonRadius: 3px; -lnkText: #0f7dc7; - setLittleSkip: 9px; noContactsHeight: 100px; @@ -114,8 +107,8 @@ msgOutBg: #effdde; msgOutBgSelected: #b7dbdb; msgSelectOverlay: #358cd44c; msgStickerOverlay: #358cd47f; -msgInServiceFg: #0e7acd; -msgInServiceFgSelected: #0e7acd; +msgInServiceFg: windowActiveTextFg; +msgInServiceFgSelected: windowActiveTextFg; msgOutServiceFg: #3a8e26; msgOutServiceFgSelected: #367570; msgShadow: 2px; @@ -132,8 +125,8 @@ msgReplyPadding: margins(6px, 6px, 11px, 6px); msgReplyBarPos: point(1px, 0px); msgReplyBarSize: size(2px, 36px); msgReplyBarSkip: 10px; -msgInReplyBarColor: #2fa9e2; -msgInReplyBarSelColor: #2fa9e2; +msgInReplyBarColor: activeLineFg; +msgInReplyBarSelColor: activeLineFg; msgOutReplyBarColor: historyOutIconFg; msgOutReplyBarSelColor: historyOutIconFgSelected; msgImgReplyBarColor: #ffffff; @@ -146,10 +139,6 @@ msgServiceMargin: margins(10px, 10px, 80px, 2px); msgColor: #000000; msgDateColor: #000000; -msgLinkColor: #2a6dc2; -msgPressedLinkColor: #004bad; -msgSkip: 40px; -msgPtr: 8px; msgDateSpace: 12px; msgDateDelta: point(2px, 5px); @@ -165,8 +154,8 @@ msgDateImgCheckSpace: 4px; defaultTextStyle: TextStyle { linkFlags: font(fsize); linkFlagsOver: font(fsize underline); - linkFg: btnYesColor; - linkFgDown: btnYesHover; + linkFg: windowActiveTextFg; + linkFgDown: windowActiveTextFg; monoFg: #777777; selectBg: msgInBgSelected; selectOverlay: msgSelectOverlay; @@ -214,7 +203,7 @@ medviewSaveAsTextStyle: TextStyle(defaultTextStyle) { linkFgDown: #91d9ff; } -mediaPadding: margins(0px, 0px, 0px, 0px);//1px, 1px, 1px, 1px);//2px, 2px, 2px, 2px); +mediaPadding: margins(0px, 0px, 0px, 0px); mediaCaptionSkip: 5px; mediaInBubbleSkip: 5px; mediaThumbSize: 48px; @@ -310,10 +299,11 @@ unreadBarBorder: shadowColor; unreadBarColor: #538bb4; searchedBarHeight: unreadBarHeight; -searchedBarFont: unreadBarFont; -searchedBarBG: #ebeef1; +searchedBarFont: normalFont; +searchedBarBg: windowBgOver; searchedBarBorder: unreadBarBorder; -searchedBarColor: #a2aeb7; +searchedBarFg: windowSubTextFgOver; +searchedBarPosition: point(17px, 7px); simpleCloseIcon: icon {{ "simple_close", #c7c7c7 }}; simpleCloseIconOver: icon {{ "simple_close", #a3a3a3 }}; @@ -346,7 +336,7 @@ dragBg: #ffffff; dragFont: font(28px semibold); dragSubfont: font(20px semibold); dragColor: #777777; -dragDropColor: btnYesColor; +dragDropColor: windowActiveTextFg; dragMargin: margins(0px, 10px, 0px, 10px); dragPadding: margins(20px, 10px, 20px, 10px); diff --git a/Telegram/Resources/colors.palette b/Telegram/Resources/colors.palette index 9a1c2db92..6755f8b66 100644 --- a/Telegram/Resources/colors.palette +++ b/Telegram/Resources/colors.palette @@ -29,11 +29,11 @@ windowSubTextFg: #999999; // gray: fallback for subtext color windowSubTextFgOver: #919191; // gray over light blue: fallback for subtext over color windowBoldFg: #222222; // dark gray: fallback for bold text color windowBoldFgOver: #222222; // dark gray: fallback for over bold text color -windowBgActive: #40ace3; // bright blue: fallback for blue filled active areas +windowBgActive: #40a7e3; // bright blue: fallback for blue filled active areas windowFgActive: #ffffff; // text on bright blue: fallback for text on active areas -windowActiveTextFg: #2687bf; // online blue: fallback for active color +windowActiveTextFg: #168acd; // online blue: fallback for active color windowShadowFg: #000000; // black: fallback for shadow color -windowShadowFgFallback: #cdcdcd; // gray: fallback for shadow without +windowShadowFgFallback: #cdcdcd; // gray: fallback for shadow without opacity imageBg: #000000; imageBgTransparent: #ffffff; @@ -46,11 +46,12 @@ activeButtonFg: windowFgActive; activeButtonFgOver: activeButtonFg; activeButtonSecondaryFg: #cceeff; activeButtonSecondaryFgOver: activeButtonSecondaryFg; +activeLineFg: #37a1de; lightButtonBg: windowBg; lightButtonBgOver: #e3f1fa; lightButtonBgRipple: #c9e4f6; -lightButtonFg: #2b99d5; +lightButtonFg: windowActiveTextFg; lightButtonFgOver: lightButtonFg; attentionButtonFg: #d14e4e; @@ -139,15 +140,15 @@ dialogsNameFg: windowBoldFg; dialogsChatIconFg: dialogsNameFg; dialogsDateFg: windowSubTextFg; dialogsTextFg: windowSubTextFg; -dialogsTextFgService: #4981af; +dialogsTextFgService: windowActiveTextFg; dialogsDraftFg: #dd4b39; -dialogsVerifiedIconBg: #4abcf1; -dialogsVerifiedIconFg: #ffffff; +dialogsVerifiedIconBg: windowBgActive; +dialogsVerifiedIconFg: windowFgActive; dialogsSendingIconFg: #c1c1c1; dialogsSentIconFg: #5dc452; dialogsUnreadBg: windowBgActive; dialogsUnreadBgMuted: #bbbbbb; -dialogsUnreadFg: #ffffff; +dialogsUnreadFg: windowFgActive; dialogsBgOver: windowBgOver; dialogsNameFgOver: windowBoldFgOver; diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 6b6185750..29e8a7a2f 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -146,6 +146,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org "lng_intro_submit" = "SUBMIT"; "lng_photo_caption" = "Caption"; +"lng_photos_comment" = "Comment"; "lng_phone_ph" = "Your phone number"; "lng_phone_title" = "Your Phone"; diff --git a/Telegram/Resources/sample.tdesktop-theme b/Telegram/Resources/sample.tdesktop-theme index 4b410eda0..53d63888a 100644 --- a/Telegram/Resources/sample.tdesktop-theme +++ b/Telegram/Resources/sample.tdesktop-theme @@ -30,9 +30,9 @@ windowSubTextFg: #999999; windowSubTextFgOver: #919191; windowBoldFg: #222222; windowBoldFgOver: #222222; -windowBgActive: #40ace3; +windowBgActive: #40a7e3; windowFgActive: #ffffff; -windowActiveTextFg: #2687bf; +windowActiveTextFg: #168acd; windowShadowFg: #000000; windowShadowFgFallback: #cdcdcd; imageBg: #000000; @@ -44,10 +44,11 @@ activeButtonFg: windowFgActive; activeButtonFgOver: activeButtonFg; activeButtonSecondaryFg: #cceeff; activeButtonSecondaryFgOver: activeButtonSecondaryFg; +activeLineFg: #37a1de; lightButtonBg: windowBg; lightButtonBgOver: #e3f1fa; lightButtonBgRipple: #c9e4f6; -lightButtonFg: #2b99d5; +lightButtonFg: windowActiveTextFg; lightButtonFgOver: lightButtonFg; attentionButtonFg: #d14e4e; attentionButtonFgOver: #d14e4e; @@ -113,15 +114,15 @@ dialogsNameFg: windowBoldFg; dialogsChatIconFg: dialogsNameFg; dialogsDateFg: windowSubTextFg; dialogsTextFg: windowSubTextFg; -dialogsTextFgService: #4981af; +dialogsTextFgService: windowActiveTextFg; dialogsDraftFg: #dd4b39; -dialogsVerifiedIconBg: #4abcf1; -dialogsVerifiedIconFg: #ffffff; +dialogsVerifiedIconBg: windowBgActive; +dialogsVerifiedIconFg: windowFgActive; dialogsSendingIconFg: #c1c1c1; dialogsSentIconFg: #5dc452; dialogsUnreadBg: windowBgActive; dialogsUnreadBgMuted: #bbbbbb; -dialogsUnreadFg: #ffffff; +dialogsUnreadFg: windowFgActive; dialogsBgOver: windowBgOver; dialogsNameFgOver: windowBoldFgOver; dialogsChatIconFgOver: dialogsNameFgOver; diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 4fea641f1..c1afe54b0 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -34,8 +34,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,19,10 - PRODUCTVERSION 0,10,19,10 + FILEVERSION 0,10,19,11 + PRODUCTVERSION 0,10,19,11 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "0.10.19.10" + VALUE "FileVersion", "0.10.19.11" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.19.10" + VALUE "ProductVersion", "0.10.19.11" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index d38f081b9..5ccb3c6cb 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,10,19,10 - PRODUCTVERSION 0,10,19,10 + FILEVERSION 0,10,19,11 + PRODUCTVERSION 0,10,19,11 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "0.10.19.10" + VALUE "FileVersion", "0.10.19.11" VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "0.10.19.10" + VALUE "ProductVersion", "0.10.19.11" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 7184472f3..f9deafa54 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1281,10 +1281,8 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &msgs } ApiWrap::~ApiWrap() { - App::clearHistories(); } - void ApiWrap::stickerSetDisenableDone(const MTPmessages_StickerSetInstallResult &result, mtpRequestId req) { _stickerSetDisenableRequests.remove(req); if (_stickerSetDisenableRequests.isEmpty()) { diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index c66b03def..ad658fd8a 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2165,11 +2165,12 @@ namespace { int32 r = radius * cIntRetinaFactor(), s = st::msgShadow * cIntRetinaFactor(); QImage rect(r * 3, r * 3 + (shadow ? s : 0), QImage::Format_ARGB32_Premultiplied), localCors[4]; { - QPainter p(&rect); + Painter p(&rect); + PainterHighQualityEnabler hq(p); + p.setCompositionMode(QPainter::CompositionMode_Source); p.fillRect(QRect(0, 0, rect.width(), rect.height()), Qt::transparent); p.setCompositionMode(QPainter::CompositionMode_SourceOver); - p.setRenderHint(QPainter::HighQualityAntialiasing); p.setPen(Qt::NoPen); if (shadow) { p.setBrush((*shadow)->b); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 8da1571a0..11ad708df 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -1094,6 +1094,7 @@ AppClass::~AppClass() { Shortcuts::finish(); delete base::take(_window); + App::clearHistories(); Window::Notifications::finish(); diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 8489cfd1e..f88807ea9 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -275,9 +275,11 @@ GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : Ab connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); _photo->setClickedCallback([this] { - auto imgExtensions = cImgExtensions(); - auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); - _setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); + App::CallDelayed(st::defaultActiveButton.ripple.hideDuration, base::lambda_guarded(this, [this] { + auto imgExtensions = cImgExtensions(); + auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); + _setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); + })); }); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 6f02e122a..bef2e0784 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -344,7 +344,7 @@ sharePhotoCheckbox: RoundImageCheckbox(contactsPhotoCheckbox) { } shareNameFont: font(11px); shareNameFg: windowFg; -shareNameActiveFg: btnYesColor; +shareNameActiveFg: windowActiveTextFg; shareNameTop: 6px; shareColumnSkip: 6px; shareActivateDuration: 150; diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index d82c130e8..9ac1c37f5 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -1012,17 +1012,17 @@ void ContactsBox::Inner::paintDisabledCheckUserpic(Painter &p, PeerData *peer, i peer->paintUserpicLeft(p, userpicRadius * 2, userpicLeft, userpicTop, width()); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + { + PainterHighQualityEnabler hq(p); - p.setPen(userpicBorderPen); - p.setBrush(Qt::NoBrush); - p.drawEllipse(userpicEllipse); + p.setPen(userpicBorderPen); + p.setBrush(Qt::NoBrush); + p.drawEllipse(userpicEllipse); - p.setPen(iconBorderPen); - p.setBrush(st::contactsPhotoDisabledCheckFg); - p.drawEllipse(iconEllipse); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + p.setPen(iconBorderPen); + p.setBrush(st::contactsPhotoDisabledCheckFg); + p.drawEllipse(iconEllipse); + } st::contactsPhotoCheckbox.check.check.paint(p, iconEllipse.topLeft(), outerWidth); } @@ -1071,10 +1071,10 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { yTo -= _contacts->size() * _rowHeight; } if (!_byUsername.isEmpty()) { - p.fillRect(0, 0, width(), st::searchedBarHeight, st::searchedBarBG->b); - p.setFont(st::searchedBarFont->f); - p.setPen(st::searchedBarColor->p); - p.drawText(QRect(0, 0, width(), st::searchedBarHeight), lang(lng_search_global_results), style::al_center); + p.fillRect(0, 0, width(), st::searchedBarHeight, st::searchedBarBg); + p.setFont(st::searchedBarFont); + p.setPen(st::searchedBarFg); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_search_global_results), style::al_center); yFrom -= st::searchedBarHeight; yTo -= st::searchedBarHeight; @@ -1135,10 +1135,10 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) { } } if (!_byUsernameFiltered.isEmpty()) { - p.fillRect(0, 0, width(), st::searchedBarHeight, st::searchedBarBG->b); - p.setFont(st::searchedBarFont->f); - p.setPen(st::searchedBarColor->p); - p.drawText(QRect(0, 0, width(), st::searchedBarHeight), lang(lng_search_global_results), style::al_center); + p.fillRect(0, 0, width(), st::searchedBarHeight, st::searchedBarBg); + p.setFont(st::searchedBarFont); + p.setPen(st::searchedBarFg); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_search_global_results), style::al_center); p.translate(0, st::searchedBarHeight); yFrom -= _filtered.size() * _rowHeight + st::searchedBarHeight; diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index 87a73d079..1708903c3 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -221,8 +221,9 @@ void NotificationsBox::prepareNotificationSampleSmall() { sampleImage.fill(st::notificationBg->c); { Painter p(&sampleImage); + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing); auto padding = height / 8; auto userpicSize = height - 2 * padding; diff --git a/Telegram/SourceFiles/boxes/photocropbox.cpp b/Telegram/SourceFiles/boxes/photocropbox.cpp index e5c2ab546..3429a1a76 100644 --- a/Telegram/SourceFiles/boxes/photocropbox.cpp +++ b/Telegram/SourceFiles/boxes/photocropbox.cpp @@ -245,7 +245,8 @@ void PhotoCropBox::paintEvent(QPaintEvent *e) { _mask.fill(Qt::white); { Painter p(&_mask); - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); p.setBrush(Qt::black); p.drawEllipse(_cropx, _cropy, _cropw, _cropw); diff --git a/Telegram/SourceFiles/boxes/send_files_box.cpp b/Telegram/SourceFiles/boxes/send_files_box.cpp index 5f81de915..5f6f32edd 100644 --- a/Telegram/SourceFiles/boxes/send_files_box.cpp +++ b/Telegram/SourceFiles/boxes/send_files_box.cpp @@ -124,7 +124,7 @@ SendFilesBox::SendFilesBox(const QString &filepath, QImage image, CompressConfir SendFilesBox::SendFilesBox(const QStringList &files, CompressConfirm compressed) : AbstractBox(st::boxWideWidth) , _files(files) , _compressConfirm(compressed) -, _caption(this, st::confirmCaptionArea, lang(lng_photo_caption)) +, _caption(this, st::confirmCaptionArea, lang(lng_photos_comment)) , _send(this, lang(lng_send_button), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { updateTitleText(); @@ -245,9 +245,10 @@ void SendFilesBox::paintEvent(QPaintEvent *e) { p.setPen(Qt::NoPen); p.setBrush(st::msgDateImgBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } auto icon = &st::historyFileInPlay; icon->paintInCenter(p, inner); @@ -279,9 +280,10 @@ void SendFilesBox::paintEvent(QPaintEvent *e) { p.setPen(Qt::NoPen); p.setBrush(st::msgFileOutBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } auto &icon = _fileIsImage ? st::historyFileOutImage : st::historyFileOutDocument; icon.paintInCenter(p, inner); @@ -541,10 +543,11 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { p.setPen(Qt::NoPen); p.setBrush(st::msgDateImgBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); - + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } + auto icon = &st::historyFileInPlay; icon->paintInCenter(p, inner); } @@ -580,9 +583,10 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) { p.setPen(Qt::NoPen); p.setBrush(st::msgFileInBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } auto icon = &(_isImage ? st::historyFileInImage : st::historyFileInDocument); icon->paintInCenter(p, inner); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 6c3c15335..00516b519 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -720,9 +720,10 @@ void StickersBox::Inner::paintRow(Painter &p, int index, TimeMs ms) { p.setPen(Qt::NoPen); p.setBrush(st::stickersFeaturedUnreadBg); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); - p.drawEllipse(rtlrect(namex + s->titleWidth + st::stickersFeaturedUnreadSkip, namey + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width())); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(namex + s->titleWidth + st::stickersFeaturedUnreadSkip, namey + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width())); + } } p.setFont(st::contactsStatusFont); diff --git a/Telegram/SourceFiles/core/lambda.h b/Telegram/SourceFiles/core/lambda.h index c82886f2a..24f1c68eb 100644 --- a/Telegram/SourceFiles/core/lambda.h +++ b/Telegram/SourceFiles/core/lambda.h @@ -520,4 +520,26 @@ inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda &&lambda) { return new lambda_slot_wrap(parent, std_::move(lambda)); } +class lambda_slot_once_wrap : public QObject { + Q_OBJECT + +public: + lambda_slot_once_wrap(QObject *parent, lambda &&lambda) : QObject(parent), _lambda(std_::move(lambda)) { + } + +public slots : + void action() { + _lambda(); + delete this; + } + +private: + lambda _lambda; + +}; + +inline lambda_slot_once_wrap *lambda_slot_once(QObject *parent, lambda &&lambda) { + return new lambda_slot_once_wrap(parent, std_::move(lambda)); +} + } // namespace base diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index decb79bc4..5fedef043 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "core/utils.h" -#define BETA_VERSION_MACRO (10019010ULL) +#define BETA_VERSION_MACRO (10019011ULL) constexpr int AppVersion = 10020; constexpr str_const AppVersionStr = "0.10.20"; diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 91b3adfbc..692f49082 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -178,11 +178,11 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO } if (!_peopleResults.isEmpty()) { - p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBG->b); + p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { - p.setFont(st::searchedBarFont->f); - p.setPen(st::searchedBarColor->p); - p.drawText(QRect(0, 0, fullWidth(), st::searchedBarHeight), lang(lng_search_global_results), style::al_center); + p.setFont(st::searchedBarFont); + p.setPen(st::searchedBarFg); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_search_global_results), style::al_center); } p.translate(0, st::searchedBarHeight); @@ -207,11 +207,11 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO searchInPeerPaint(p, fullWidth(), paintingOther); p.translate(0, st::dialogsRowHeight); if (_state == FilteredState && _searchResults.isEmpty()) { - p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBG->b); + p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { - p.setFont(st::searchedBarFont->f); - p.setPen(st::searchedBarColor->p); - p.drawText(QRect(0, 0, fullWidth(), st::searchedBarHeight), lang(lng_dlg_search_for_messages), style::al_center); + p.setFont(st::searchedBarFont); + p.setPen(st::searchedBarFg); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), lang(lng_dlg_search_for_messages), style::al_center); } p.translate(0, st::searchedBarHeight); } @@ -219,11 +219,11 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO if (_state == SearchedState || !_searchResults.isEmpty()) { QString text = lng_search_found_results(lt_count, _searchResults.isEmpty() ? 0 : (_searchedMigratedCount + _searchedCount)); - p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBG->b); + p.fillRect(0, 0, fullWidth(), st::searchedBarHeight, st::searchedBarBg); if (!paintingOther) { - p.setFont(st::searchedBarFont->f); - p.setPen(st::searchedBarColor->p); - p.drawText(QRect(0, 0, fullWidth(), st::searchedBarHeight), text, style::al_center); + p.setFont(st::searchedBarFont); + p.setPen(st::searchedBarFg); + p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), text, style::al_center); } p.translate(0, st::searchedBarHeight); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 919dab857..fe453a2a1 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -38,8 +38,8 @@ Q_DECLARE_METATYPE(Ui::ShowWay); namespace App { -void LambdaDelayed(int duration, base::lambda &&lambda) { - QTimer::singleShot(duration, base::lambda_slot(App::app(), std_::move(lambda)), SLOT(action())); +void CallDelayed(int duration, base::lambda &&lambda) { + QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std_::move(lambda)), SLOT(action())); } void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 03d22ef03..79a0dcce1 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -33,7 +33,7 @@ class ItemBase; namespace App { -void LambdaDelayed(int duration, base::lambda &&lambda); +void CallDelayed(int duration, base::lambda &&lambda); void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo = 0); bool insertBotCommand(const QString &cmd, bool specialGif = false); diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index e3b8d9983..0f28bac07 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -145,7 +145,7 @@ historyPeer3UserpicFg: #e4a861; historyPeer3UserpicPerson: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_person", historyPeer3UserpicFg }}; historyPeer3UserpicChat: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_chat", historyPeer3UserpicFg }}; historyPeer3UserpicChannel: icon {{ size(120px, 120px), historyPeer3UserpicBg }, { "userpic_channel", historyPeer3UserpicFg }}; -historyPeer4NameFg: #348cd4; // blue +historyPeer4NameFg: windowActiveTextFg; // blue historyPeer4UserpicBg: #8fbfe9; historyPeer4UserpicFg: #649fd3; historyPeer4UserpicPerson: icon {{ size(120px, 120px), historyPeer4UserpicBg }, { "userpic_person", historyPeer4UserpicFg }}; @@ -191,8 +191,8 @@ historySendRight: 2px; historyComposeButton: FlatButton { duration: 200; - color: btnYesColor; - overColor: btnYesHover; + color: windowActiveTextFg; + overColor: windowActiveTextFg; bgColor: historyComposeButtonBg; overBgColor: historyComposeButtonBgOver; @@ -266,7 +266,7 @@ historyBotCommandStart: IconButton(historySend) { } historyRecordVoiceFg: historyComposeIconFg; historyRecordVoiceFgOver: historyComposeIconFgOver; -historyRecordVoiceFgActive: #58b2ed; +historyRecordVoiceFgActive: windowBgActive; historyRecordVoice: icon {{ "send_control_record", historyRecordVoiceFg }}; historyRecordVoiceOver: icon {{ "send_control_record", historyRecordVoiceFgOver }}; historyRecordVoiceActive: icon {{ "send_control_record", historyRecordVoiceFgActive }}; @@ -318,8 +318,8 @@ historyInlineBotCancel: IconButton(historyReplyCancel) { reportSpamHide: FlatButton { duration: 200; - color: btnYesColor; - overColor: btnYesHover; + color: windowActiveTextFg; + overColor: windowActiveTextFg; bgColor: transparent; overBgColor: transparent; diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index ac3f7669a..57e839360 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -393,23 +393,30 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, Tim } else { App::roundShadow(p, 0, 0, width, height, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners); } - - auto inWebPage = (_parent->getMedia() != this); - auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large; - auto roundCorners = inWebPage ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None) - | ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None)); - QPixmap pix; - if (loaded) { - pix = _data->full->pixSingle(_pixw, _pixh, width, height, roundRadius, roundCorners); - } else { - pix = _data->thumb->pixBlurredSingle(_pixw, _pixh, width, height, roundRadius, roundCorners); - } QRect rthumb(rtlrect(skipx, skipy, width, height, _width)); - p.drawPixmap(rthumb.topLeft(), pix); - if (selected) { - App::complexOverlayRect(p, rthumb, roundRadius, roundCorners); + QPixmap pix; + if (_parent->toHistoryMessage()) { + auto inWebPage = (_parent->getMedia() != this); + auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large; + auto roundCorners = inWebPage ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None) + | ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None)); + if (loaded) { + pix = _data->full->pixSingle(_pixw, _pixh, width, height, roundRadius, roundCorners); + } else { + pix = _data->thumb->pixBlurredSingle(_pixw, _pixh, width, height, roundRadius, roundCorners); + } + p.drawPixmap(rthumb.topLeft(), pix); + if (selected) { + App::complexOverlayRect(p, rthumb, roundRadius, roundCorners); + } + } else { + if (loaded) { + pix = _data->full->pixCircled(_pixw, _pixh); + } else { + pix = _data->thumb->pixBlurredCircled(_pixw, _pixh); + } + p.drawPixmap(rthumb.topLeft(), pix); } - if (radial || (!loaded && !_data->loading())) { float64 radialOpacity = (radial && loaded && !_data->uploading()) ? _animation->radial.opacity() : 1; QRect inner(rthumb.x() + (rthumb.width() - st::msgFileSize) / 2, rthumb.y() + (rthumb.height() - st::msgFileSize) / 2, st::msgFileSize, st::msgFileSize); @@ -426,9 +433,10 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, Tim p.setOpacity(radialOpacity * p.opacity()); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(radial ? _animation->radial.opacity() : 1); @@ -763,9 +771,10 @@ void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, Tim p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } if (!selected && _animation) { p.setOpacity(1); @@ -1123,9 +1132,10 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, } p.setOpacity(radialOpacity * p.opacity()); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(radialOpacity); auto icon = ([radial, this, selected] { @@ -1170,9 +1180,10 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, p.setBrush(outbg ? (over ? st::msgFileOutBgOver : st::msgFileOutBg) : (over ? st::msgFileInBgOver : st::msgFileInBg)); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } if (radial) { QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); @@ -1279,9 +1290,10 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, p.setPen(Qt::NoPen); p.setBrush(outbg ? (selected ? st::msgFileOutBgSelected : st::msgFileOutBg) : (selected ? st::msgFileInBgSelected : st::msgFileInBg)); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); - p.drawEllipse(rtlrect(nameleft + w + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(nameleft + w + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); + } } } @@ -1747,9 +1759,10 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM } p.setOpacity(radialOpacity * p.opacity()); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(radialOpacity); auto icon = ([this, radial, selected]() -> const style::icon * { diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp index 71eac5a8a..02e8f6e8a 100644 --- a/Telegram/SourceFiles/history/history_service_layout.cpp +++ b/Telegram/SourceFiles/history/history_service_layout.cpp @@ -338,9 +338,10 @@ void paintEmpty(Painter &p, int width, int height) { auto position = QPoint((width - st::historyEmptySize) / 2, ((height - st::historyEmptySize) * 4) / 9); p.setPen(Qt::NoPen); p.setBrush(st::msgServiceBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(rtlrect(position.x(), position.y(), st::historyEmptySize, st::historyEmptySize, width)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(position.x(), position.y(), st::historyEmptySize, st::historyEmptySize, width)); + } st::historyEmptyDog.paint(p, position.x() + (st::historyEmptySize - st::historyEmptyDog.width()) / 2, position.y() + (st::historyEmptySize - st::historyEmptyDog.height()) / 2, width); } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index bc32fcbcb..f6543316d 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3102,7 +3102,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent) } _attachToggle->setClickedCallback([this] { - App::LambdaDelayed(st::historyAttach.ripple.hideDuration, base::lambda_guarded(this, [this] { + App::CallDelayed(st::historyAttach.ripple.hideDuration, base::lambda_guarded(this, [this] { chooseAttach(); })); }); @@ -8736,11 +8736,13 @@ void HistoryWidget::drawRecordButton(Painter &p) { void HistoryWidget::drawRecording(Painter &p) { p.setPen(Qt::NoPen); p.setBrush(st::historyRecordSignalColor); - p.setRenderHint(QPainter::HighQualityAntialiasing); + float64 delta = qMin(float64(a_recordingLevel.current()) / 0x4000, 1.); int32 d = 2 * qRound(st::historyRecordSignalMin + (delta * (st::historyRecordSignalMax - st::historyRecordSignalMin))); - p.drawEllipse(_attachToggle->x() + (_attachEmoji->width() - d) / 2, _attachToggle->y() + (_attachToggle->height() - d) / 2, d, d); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(_attachToggle->x() + (_attachEmoji->width() - d) / 2, _attachToggle->y() + (_attachToggle->height() - d) / 2, d, d); + } QString duration = formatDurationText(_recordingSamples / AudioVoiceMsgFrequency); p.setFont(st::historyRecordFont); @@ -8834,15 +8836,12 @@ void HistoryWidget::paintEvent(QPaintEvent *e) { } } } else { - bool smooth = p.renderHints().testFlag(QPainter::SmoothPixmapTransform); - p.setRenderHint(QPainter::SmoothPixmapTransform); + PainterHighQualityEnabler hq(p); QRect to, from; App::main()->backgroundParams(fill, to, from); to.moveTop(to.top() + fromy); p.drawPixmap(to, pix, from); - - if (!smooth) p.setRenderHint(QPainter::SmoothPixmapTransform, false); } } else { p.drawPixmap(x, fromy + y, cached); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 27c3ffe8d..ff36b1191 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -716,9 +716,10 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } if (radial) { auto radialCircle = inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)); diff --git a/Telegram/SourceFiles/intro/introsignup.cpp b/Telegram/SourceFiles/intro/introsignup.cpp index 3ab0da955..cb04b5286 100644 --- a/Telegram/SourceFiles/intro/introsignup.cpp +++ b/Telegram/SourceFiles/intro/introsignup.cpp @@ -43,9 +43,11 @@ SignupWidget::SignupWidget(QWidget *parent, Widget::Data *data) : Step(parent, d connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest())); _photo->setClickedCallback([this] { - auto imgExtensions = cImgExtensions(); - auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); - _readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); + App::CallDelayed(st::defaultActiveButton.ripple.hideDuration, base::lambda_guarded(this, [this] { + auto imgExtensions = cImgExtensions(); + auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter(); + _readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter); + })); }); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 614656aed..f3f1d265f 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -218,6 +218,7 @@ void MainWindow::clearWidgets() { hideMediaview(); _mediaView->rpcClear(); } + App::clearHistories(); updateGlobalMenu(); } @@ -1492,7 +1493,7 @@ PreLaunchWindow::PreLaunchWindow(QString title) : TWidget(0) { int paddingVertical = (_size / 2); int paddingHorizontal = _size; int borderRadius = (_size / 5); - setStyleSheet(qsl("QPushButton { padding: %1px %2px; background-color: #ffffff; border-radius: %3px; }\nQPushButton#confirm:hover, QPushButton#cancel:hover { background-color: #e3f1fa; color: #2f9fea; }\nQPushButton#confirm { color: #2f9fea; }\nQPushButton#cancel { color: #aeaeae; }\nQLineEdit { border: 1px solid #e0e0e0; padding: 5px; }\nQLineEdit:focus { border: 2px solid #62c0f7; padding: 4px; }").arg(paddingVertical).arg(paddingHorizontal).arg(borderRadius)); + setStyleSheet(qsl("QPushButton { padding: %1px %2px; background-color: #ffffff; border-radius: %3px; }\nQPushButton#confirm:hover, QPushButton#cancel:hover { background-color: #e3f1fa; color: #2f9fea; }\nQPushButton#confirm { color: #2f9fea; }\nQPushButton#cancel { color: #aeaeae; }\nQLineEdit { border: 1px solid #e0e0e0; padding: 5px; }\nQLineEdit:focus { border: 2px solid #37a1de; padding: 4px; }").arg(paddingVertical).arg(paddingHorizontal).arg(borderRadius)); if (!PreLaunchWindowInstance) { PreLaunchWindowInstance = this; } diff --git a/Telegram/SourceFiles/media/player/media_player_button.cpp b/Telegram/SourceFiles/media/player/media_player_button.cpp index eaffe8bff..e51de5b6e 100644 --- a/Telegram/SourceFiles/media/player/media_player_button.cpp +++ b/Telegram/SourceFiles/media/player/media_player_button.cpp @@ -111,8 +111,9 @@ void PlayButtonLayout::paintPlay(Painter &p, const QBrush &brush) { auto playWidth = _st.playOuter.width() - 2 * playLeft; auto playHeight = _st.playOuter.height() - 2 * playTop; + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); QPainterPath pathPlay; pathPlay.moveTo(playLeft, playTop); @@ -120,8 +121,6 @@ void PlayButtonLayout::paintPlay(Painter &p, const QBrush &brush) { pathPlay.lineTo(playLeft, playTop + playHeight); pathPlay.lineTo(playLeft, playTop); p.fillPath(pathPlay, brush); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } void PlayButtonLayout::paintPlayToPause(Painter &p, const QBrush &brush, float64 progress) { @@ -137,7 +136,7 @@ void PlayButtonLayout::paintPlayToPause(Painter &p, const QBrush &brush, float64 auto pauseStroke = 0. + _st.pauseStroke; p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + PainterHighQualityEnabler hq(p); QPointF pathLeftPause[] = { { pauseLeft, pauseTop }, @@ -166,8 +165,6 @@ void PlayButtonLayout::paintPlayToPause(Painter &p, const QBrush &brush, float64 { playLeft + (playWidth / 2.), playTop + (3 * playHeight / 4.) }, }; p.fillPath(interpolatePaths(pathRightPlay, pathRightPause, progress), brush); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } void PlayButtonLayout::paintPlayToCancel(Painter &p, const QBrush &brush, float64 progress) { @@ -185,7 +182,7 @@ void PlayButtonLayout::paintPlayToCancel(Painter &p, const QBrush &brush, float6 auto cancelStroke = (0. + _st.cancelStroke) / sqrt2; p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + PainterHighQualityEnabler hq(p); QPointF pathPlay[] = { { playLeft, playTop }, @@ -216,8 +213,6 @@ void PlayButtonLayout::paintPlayToCancel(Painter &p, const QBrush &brush, float6 { cancelLeft + (cancelWidth / 2.) - cancelStroke, cancelTop + (cancelHeight / 2.) }, }; p.fillPath(interpolatePaths(pathPlay, pathCancel, progress), brush); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } void PlayButtonLayout::paintPauseToCancel(Painter &p, const QBrush &brush, float64 progress) { @@ -236,7 +231,7 @@ void PlayButtonLayout::paintPauseToCancel(Painter &p, const QBrush &brush, float auto cancelStroke = (0. + _st.cancelStroke) / sqrt2; p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + PainterHighQualityEnabler hq(p); QPointF pathLeftPause[] = { { pauseLeft, pauseTop }, @@ -265,8 +260,6 @@ void PlayButtonLayout::paintPauseToCancel(Painter &p, const QBrush &brush, float { cancelLeft, cancelTop + cancelHeight - cancelStroke }, }; p.fillPath(interpolatePaths(pathRightPause, pathRightCancel, progress), brush); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } void PlayButtonLayout::animationCallback() { diff --git a/Telegram/SourceFiles/mediaview.cpp b/Telegram/SourceFiles/mediaview.cpp index e999aaf32..181693324 100644 --- a/Telegram/SourceFiles/mediaview.cpp +++ b/Telegram/SourceFiles/mediaview.cpp @@ -1568,10 +1568,8 @@ void MediaView::paintEvent(QPaintEvent *e) { p.fillRect(imgRect, _transparentBrush); } if (toDraw.width() != _w * cIntRetinaFactor()) { - bool was = (p.renderHints() & QPainter::SmoothPixmapTransform); - if (!was) p.setRenderHint(QPainter::SmoothPixmapTransform, true); + PainterHighQualityEnabler hq(p); p.drawPixmap(QRect(_x, _y, _w, _h), toDraw); - if (!was) p.setRenderHint(QPainter::SmoothPixmapTransform, false); } else { p.drawPixmap(_x, _y, toDraw); } @@ -1591,9 +1589,10 @@ void MediaView::paintEvent(QPaintEvent *e) { p.setOpacity(radialOpacity); p.setBrush(st::radialBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(1); QRect arc(inner.marginsRemoved(QMargins(st::radialLine, st::radialLine, st::radialLine, st::radialLine))); @@ -1807,9 +1806,10 @@ void MediaView::paintDocRadialLoading(Painter &p, bool radial, float64 radialOpa p.setOpacity(_doc->loaded() ? radialOpacity : 1.); p.setBrush(anim::brush(st::msgDateImgBg, st::msgDateImgBgOver, o)); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(1.); auto icon = ([radial, this]() -> const style::icon* { diff --git a/Telegram/SourceFiles/overview/overview.style b/Telegram/SourceFiles/overview/overview.style index 614b4ed65..5739d1af3 100644 --- a/Telegram/SourceFiles/overview/overview.style +++ b/Telegram/SourceFiles/overview/overview.style @@ -63,7 +63,7 @@ overviewPhotoSelectOverlay: #40ace333; overviewVideoBg: #000000; overviewFileThumbBg: #000000; -overviewFileChecked: #2fa9e2; +overviewFileChecked: windowBgActive; overviewFileCheck: #00000066; overviewFileExtPadding: 5px; overviewFileExtTop: 24px; diff --git a/Telegram/SourceFiles/overview/overview_layout.cpp b/Telegram/SourceFiles/overview/overview_layout.cpp index 3c03eafd6..1e21ef809 100644 --- a/Telegram/SourceFiles/overview/overview_layout.cpp +++ b/Telegram/SourceFiles/overview/overview_layout.cpp @@ -402,9 +402,10 @@ void Video::paint(Painter &p, const QRect &clip, TextSelection selection, const p.setBrush(over ? st::msgDateImgBgOver : st::msgDateImgBg); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity((radial && loaded) ? _radial->opacity() : 1); auto icon = ([radial, loaded, selected] { @@ -549,9 +550,10 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const p.setBrush(over ? st::msgFileInBgOver : st::msgFileInBg); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } if (radial) { QRect rinner(inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine))); @@ -597,9 +599,10 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const p.setPen(Qt::NoPen); p.setBrush(selected ? st::msgFileInBgSelected : st::msgFileInBg); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); - p.drawEllipse(rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width)); + } } } } @@ -758,9 +761,10 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con p.setBrush(over ? _st.songOverBg : _st.songIconBg); } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } if (radial) { auto rinner = inner.marginsRemoved(QMargins(st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine, st::msgFileRadialLine)); @@ -834,9 +838,10 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con } p.setOpacity(radialOpacity * p.opacity()); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(radialOpacity); auto icon = ([loaded, this, selected] { @@ -1187,7 +1192,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P top += h; } - p.setPen(st::btnYesColor); + p.setPen(st::windowActiveTextFg); for (int32 i = 0, l = _links.size(); i < l; ++i) { if (clip.intersects(rtlrect(left, top, qMin(w, _links.at(i).width), st::normalFont->height, _width))) { p.setFont(ClickHandler::showAsActive(_links.at(i).lnk) ? st::normalFont->underline() : st::normalFont); diff --git a/Telegram/SourceFiles/profile/profile.style b/Telegram/SourceFiles/profile/profile.style index 2498ae721..3cffea908 100644 --- a/Telegram/SourceFiles/profile/profile.style +++ b/Telegram/SourceFiles/profile/profile.style @@ -125,7 +125,7 @@ profileMemberStatusPosition: point(68px, 31px); profileMemberStatusFg: windowSubTextFg; profileMemberStatusFgOver: windowSubTextFgOver; profileMemberStatusFgActive: windowActiveTextFg; -profileMemberAdminIcon: icon {{ "profile_admin_star", #3babe7, point(4px, 3px) }}; +profileMemberAdminIcon: icon {{ "profile_admin_star", windowBgActive, point(4px, 3px) }}; profileLimitReachedLabel: FlatLabel(defaultFlatLabel) { width: 180px; margin: margins(profileMemberPaddingLeft, 9px, profileMemberPaddingLeft, 6px); @@ -141,6 +141,6 @@ profileReportReasonOther: InputArea(defaultInputArea) { profileVerifiedCheckShift: -3px; profileVerifiedCheck: icon { - { "profile_verified_star", #4abcf1, point(0px, 7px) }, - { "profile_verified_check", #ffffff, point(4px, 11px) } + { "profile_verified_star", windowBgActive, point(0px, 7px) }, + { "profile_verified_check", windowFgActive, point(4px, 11px) } }; diff --git a/Telegram/SourceFiles/settings/settings_background_widget.cpp b/Telegram/SourceFiles/settings/settings_background_widget.cpp index 52b104744..737d87bed 100644 --- a/Telegram/SourceFiles/settings/settings_background_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_background_widget.cpp @@ -69,9 +69,10 @@ void BackgroundRow::paintEvent(QPaintEvent *e) { p.setOpacity(radialOpacity); p.setBrush(st::radialBg); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(inner); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(inner); + } p.setOpacity(1); QRect arc(inner.marginsRemoved(QMargins(st::radialLine, st::radialLine, st::radialLine, st::radialLine))); @@ -143,12 +144,13 @@ void BackgroundRow::updateImage() { QImage back(size, size, QImage::Format_ARGB32_Premultiplied); back.setDevicePixelRatio(cRetinaFactor()); { - QPainter p(&back); + Painter p(&back); + PainterHighQualityEnabler hq(p); + auto &pix = Window::Theme::Background()->image(); int sx = (pix.width() > pix.height()) ? ((pix.width() - pix.height()) / 2) : 0; int sy = (pix.height() > pix.width()) ? ((pix.height() - pix.width()) / 2) : 0; int s = (pix.width() > pix.height()) ? pix.height() : pix.width(); - p.setRenderHint(QPainter::SmoothPixmapTransform); p.drawPixmap(0, 0, st::settingsBackgroundSize, st::settingsBackgroundSize, pix, sx, sy, s, s); } Images::prepareRound(back, ImageRoundRadius::Small); diff --git a/Telegram/SourceFiles/settings/settings_cover.cpp b/Telegram/SourceFiles/settings/settings_cover.cpp index ab20322e5..d923ce09b 100644 --- a/Telegram/SourceFiles/settings/settings_cover.cpp +++ b/Telegram/SourceFiles/settings/settings_cover.cpp @@ -69,6 +69,8 @@ CoverWidget::CoverWidget(QWidget *parent, UserData *self) : BlockWidget(parent, validatePhoto(); refreshNameText(); + + subscribe(Global::RefConnectionTypeChanged(), [this] { refreshStatusText(); }); refreshStatusText(); } @@ -290,8 +292,14 @@ void CoverWidget::refreshStatusText() { } _cancelPhotoUpload.destroy(); - _statusText = lang(lng_status_online); - _statusTextIsOnline = true; + auto state = MTP::dcstate(); + if (state == MTP::ConnectingState || state == MTP::DisconnectedState || state < 0) { + _statusText = lang(lng_status_connecting); + _statusTextIsOnline = false; + } else { + _statusText = lang(lng_status_online); + _statusTextIsOnline = true; + } update(); } diff --git a/Telegram/SourceFiles/settings/settings_scale_widget.cpp b/Telegram/SourceFiles/settings/settings_scale_widget.cpp index 4c8cbf882..f114ea7a1 100644 --- a/Telegram/SourceFiles/settings/settings_scale_widget.cpp +++ b/Telegram/SourceFiles/settings/settings_scale_widget.cpp @@ -127,7 +127,7 @@ void ScaleWidget::onRestartNow() { } void ScaleWidget::onCancel() { - App::LambdaDelayed(st::boxDuration, base::lambda_guarded(this, [this] { + App::CallDelayed(st::boxDuration, base::lambda_guarded(this, [this] { setScale(cRealScale()); })); } diff --git a/Telegram/SourceFiles/stickers/emoji_pan.cpp b/Telegram/SourceFiles/stickers/emoji_pan.cpp index d4d649c3d..20f880cd4 100644 --- a/Telegram/SourceFiles/stickers/emoji_pan.cpp +++ b/Telegram/SourceFiles/stickers/emoji_pan.cpp @@ -994,9 +994,10 @@ void StickerPanInner::paintStickers(Painter &p, const QRect &r) { p.setPen(Qt::NoPen); p.setBrush(st::stickersFeaturedUnreadBg); - p.setRenderHint(QPainter::HighQualityAntialiasing, true); - p.drawEllipse(rtlrect(st::emojiPanHeaderLeft - st::buttonRadius + titleWidth + st::stickersFeaturedUnreadSkip, y + st::stickersTrendingHeaderTop + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width())); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(st::emojiPanHeaderLeft - st::buttonRadius + titleWidth + st::stickersFeaturedUnreadSkip, y + st::stickersTrendingHeaderTop + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width())); + } } p.setFont(st::stickersTrendingSubheaderFont); diff --git a/Telegram/SourceFiles/stickers/stickers.style b/Telegram/SourceFiles/stickers/stickers.style index 17e742b40..b1c2850cb 100644 --- a/Telegram/SourceFiles/stickers/stickers.style +++ b/Telegram/SourceFiles/stickers/stickers.style @@ -94,9 +94,11 @@ stickersReorderFg: #777777; stickersRowDisabledOpacity: 0.4; stickersRowDuration: 200; -stickersSettings: icon {{ "emoji_settings", #b3b3b3 }}; -stickersTrending: icon {{ "emoji_trending", #b3b3b3 }}; -stickersTrendingActive: icon {{ "emoji_trending", #58b2ed }}; +emojiIconFg: #b3b3b3; +emojiIconFgActive: windowBgActive; +stickersSettings: icon {{ "emoji_settings", emojiIconFg }}; +stickersTrending: icon {{ "emoji_trending", emojiIconFg }}; +stickersTrendingActive: icon {{ "emoji_trending", emojiIconFgActive }}; stickersSettingsUnreadSize: 17px; stickersSettingsUnreadPosition: point(4px, 5px); @@ -104,24 +106,24 @@ stickersSettingsUnreadPosition: point(4px, 5px); emojiScroll: FlatScroll(defaultSolidScroll) { deltat: 48px; } -emojiRecent: icon {{ "emoji_recent", #b3b3b3 }}; -emojiRecentActive: icon {{ "emoji_recent", #58b2ed }}; -emojiPeople: icon {{ "emoji_people", #b3b3b3 }}; -emojiPeopleActive: icon {{ "emoji_people", #58b2ed }}; -emojiNature: icon {{ "emoji_nature", #b3b3b3 }}; -emojiNatureActive: icon {{ "emoji_nature", #58b2ed }}; -emojiFood: icon {{ "emoji_food", #b3b3b3 }}; -emojiFoodActive: icon {{ "emoji_food", #58b2ed }}; -emojiActivity: icon {{ "emoji_activity", #b3b3b3 }}; -emojiActivityActive: icon {{ "emoji_activity", #58b2ed }}; -emojiTravel: icon {{ "emoji_travel", #b3b3b3 }}; -emojiTravelActive: icon {{ "emoji_travel", #58b2ed }}; -emojiObjects: icon {{ "emoji_objects", #b3b3b3 }}; -emojiObjectsActive: icon {{ "emoji_objects", #58b2ed }}; -emojiSymbols: icon {{ "emoji_symbols", #b3b3b3 }}; -emojiSymbolsActive: icon {{ "emoji_symbols", #58b2ed }}; -emojiSavedGifs: icon {{ "emoji_gif", #b3b3b3 }}; -emojiSavedGifsActive: icon {{ "emoji_gif", #58b2ed }}; +emojiRecent: icon {{ "emoji_recent", emojiIconFg }}; +emojiRecentActive: icon {{ "emoji_recent", emojiIconFgActive }}; +emojiPeople: icon {{ "emoji_people", emojiIconFg }}; +emojiPeopleActive: icon {{ "emoji_people", emojiIconFgActive }}; +emojiNature: icon {{ "emoji_nature", emojiIconFg }}; +emojiNatureActive: icon {{ "emoji_nature", emojiIconFgActive }}; +emojiFood: icon {{ "emoji_food", emojiIconFg }}; +emojiFoodActive: icon {{ "emoji_food", emojiIconFgActive }}; +emojiActivity: icon {{ "emoji_activity", emojiIconFg }}; +emojiActivityActive: icon {{ "emoji_activity", emojiIconFgActive }}; +emojiTravel: icon {{ "emoji_travel", emojiIconFg }}; +emojiTravelActive: icon {{ "emoji_travel", emojiIconFgActive }}; +emojiObjects: icon {{ "emoji_objects", emojiIconFg }}; +emojiObjectsActive: icon {{ "emoji_objects", emojiIconFgActive }}; +emojiSymbols: icon {{ "emoji_symbols", emojiIconFg }}; +emojiSymbolsActive: icon {{ "emoji_symbols", emojiIconFgActive }}; +emojiSavedGifs: icon {{ "emoji_gif", emojiIconFg }}; +emojiSavedGifsActive: icon {{ "emoji_gif", emojiIconFgActive }}; emojiCategory: IconButton { width: 42px; @@ -161,7 +163,7 @@ emojiColorsSepColor: #d5d5d5; emojiSwitchSkip: 27px; emojiSwitchImgSkip: 21px; -emojiSwitchColor: #42a8db; +emojiSwitchColor: windowActiveTextFg; emojiSwitchStickers: icon {{ "emoji_switch", emojiSwitchColor }}; emojiSwitchEmoji: icon {{ "emoji_switch-flip_horizontal", emojiSwitchColor }}; @@ -175,7 +177,7 @@ stickerPanDeleteOpacity: 0.5; stickerIconPadding: 5px; stickerIconOpacity: 0.7; stickerIconSel: 2px; -stickerIconSelColor: #58b2ed; +stickerIconSelColor: emojiIconFgActive; stickerIconMove: 400; stickerPreviewDuration: 150; stickerPreviewBg: #FFFFFFB0; diff --git a/Telegram/SourceFiles/ui/buttons/history_down_button.cpp b/Telegram/SourceFiles/ui/buttons/history_down_button.cpp index f222c6a69..a3de96871 100644 --- a/Telegram/SourceFiles/ui/buttons/history_down_button.cpp +++ b/Telegram/SourceFiles/ui/buttons/history_down_button.cpp @@ -146,7 +146,7 @@ void EmojiButton::paintEvent(QPaintEvent *e) { p.setPen(pen); p.setBrush(Qt::NoBrush); - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); QRect inner(QPoint((width() - st::historyEmojiCircle.width()) / 2, st::historyEmojiCircleTop), st::historyEmojiCircle); if (loading > 0) { int32 full = FullArcLength; @@ -155,7 +155,6 @@ void EmojiButton::paintEvent(QPaintEvent *e) { } else { p.drawEllipse(inner); } - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } void EmojiButton::setLoading(bool loading) { diff --git a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp index 12caeb0e4..fd62244f6 100644 --- a/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp +++ b/Telegram/SourceFiles/ui/buttons/peer_avatar_button.cpp @@ -52,10 +52,13 @@ void NewAvatarButton::paintEvent(QPaintEvent *e) { p.drawPixmap(0, 0, _image); return; } - p.setRenderHint(QPainter::HighQualityAntialiasing); + p.setPen(Qt::NoPen); p.setBrush((_state & StateOver) ? st::defaultActiveButton.textBgOver : st::defaultActiveButton.textBg); - p.drawEllipse(rect()); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rect()); + } paintRipple(p, 0, 0, getms()); diff --git a/Telegram/SourceFiles/ui/effects/cross_animation.cpp b/Telegram/SourceFiles/ui/effects/cross_animation.cpp index 5222758bb..d1d6d9c4e 100644 --- a/Telegram/SourceFiles/ui/effects/cross_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/cross_animation.cpp @@ -23,8 +23,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org namespace Ui { -void CrossAnimation::paint(QPainter &p, const style::CrossAnimation &st, const style::color &color, int x, int y, int outerWidth, float64 shown) { - p.setRenderHint(QPainter::HighQualityAntialiasing); +void CrossAnimation::paint(Painter &p, const style::CrossAnimation &st, const style::color &color, int x, int y, int outerWidth, float64 shown) { + PainterHighQualityEnabler hq(p); auto deleteScale = shown + st.minScale * (1. - shown); auto deleteSkip = deleteScale * st.skip + (1. - deleteScale) * (st.size / 2); @@ -67,8 +67,6 @@ void CrossAnimation::paint(QPainter &p, const style::CrossAnimation &st, const s path.lineTo(pathDelete[i]); } p.fillPath(path, color); - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } } // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/cross_animation.h b/Telegram/SourceFiles/ui/effects/cross_animation.h index 5112c64e6..33583b783 100644 --- a/Telegram/SourceFiles/ui/effects/cross_animation.h +++ b/Telegram/SourceFiles/ui/effects/cross_animation.h @@ -26,7 +26,7 @@ namespace Ui { class CrossAnimation { public: - static void paint(QPainter &p, const style::CrossAnimation &st, const style::color &color, int x, int y, int outerWidth, float64 shown); + static void paint(Painter &p, const style::CrossAnimation &st, const style::color &color, int x, int y, int outerWidth, float64 shown); }; diff --git a/Telegram/SourceFiles/ui/effects/radial_animation.cpp b/Telegram/SourceFiles/ui/effects/radial_animation.cpp index 7437fbb6e..801dc48bc 100644 --- a/Telegram/SourceFiles/ui/effects/radial_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/radial_animation.cpp @@ -86,9 +86,10 @@ void RadialAnimation::draw(Painter &p, const QRect &inner, int32 thickness, cons if (from < 0) from += FullArcLength; } - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawArc(inner, from, len); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawArc(inner, from, len); + } p.setPen(was); p.setOpacity(o); diff --git a/Telegram/SourceFiles/ui/effects/rect_shadow.cpp b/Telegram/SourceFiles/ui/effects/rect_shadow.cpp index cf0aec82e..92f9dd685 100644 --- a/Telegram/SourceFiles/ui/effects/rect_shadow.cpp +++ b/Telegram/SourceFiles/ui/effects/rect_shadow.cpp @@ -82,13 +82,11 @@ void RectShadow::paint(Painter &p, const QRect &box, int shifty, Sides sides) { if (right && bottom) p.drawPixmap(box.left() + box.width() - minus, box.top() + box.height() - minus + shifty, _corners, _pixsize, _pixsize, _pixsize, _pixsize); if (left && bottom) p.drawPixmap(box.left() - _size + minus, box.top() + box.height() - minus + shifty, _corners, 0, _pixsize, _pixsize, _pixsize); - bool wasSmooth = p.renderHints().testFlag(QPainter::SmoothPixmapTransform); - if (wasSmooth) p.setRenderHint(QPainter::SmoothPixmapTransform, false); + PainterHighQualityEnabler hq(p); if (left) p.drawPixmap(box.left() - countsize + shifty, box.top() + (top ? (minus + shifty) : 0), countsize - shifty, box.height() - (bottom ? (minus - shifty) : 0) - (top ? (minus + shifty) : 0), _left, 0, 0, count - rshifty, 1); if (top) p.drawPixmap(box.left() + (left ? minus : 0), box.top() - countsize + 2 * shifty, box.width() - (right ? minus : 0) - (left ? minus : 0), countsize - 2 * shifty, _top, 0, 0, 1, count - 2 * rshifty); if (right) p.drawPixmap(box.left() + box.width(), box.top() + (top ? (minus + shifty) : 0), countsize - shifty, box.height() - (bottom ? (minus - shifty) : 0) - (top ? (minus + shifty) : 0), _right, rshifty, 0, count - rshifty, 1); if (bottom) p.drawPixmap(box.left() + (left ? minus : 0), box.top() + box.height(), box.width() - (right ? minus : 0) - (left ? minus : 0), countsize, _bottom, 0, 0, 1, count); - if (wasSmooth) p.setRenderHint(QPainter::SmoothPixmapTransform); } style::margins RectShadow::getDimensions(int32 shifty) const { diff --git a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp index b7e2c5255..7a07686a6 100644 --- a/Telegram/SourceFiles/ui/effects/ripple_animation.cpp +++ b/Telegram/SourceFiles/ui/effects/ripple_animation.cpp @@ -97,15 +97,16 @@ void RippleAnimation::Ripple::paint(QPainter &p, const QPixmap &mask, TimeMs ms, _frame.fill(Qt::transparent); { Painter p(&_frame); - p.setRenderHint(QPainter::HighQualityAntialiasing); p.setPen(Qt::NoPen); if (colorOverride) { p.setBrush(*colorOverride); } else { p.setBrush(_st.color); } - p.drawEllipse(_origin, radius, radius); - + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(_origin, radius, radius); + } p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.drawPixmap(0, 0, mask); } @@ -199,7 +200,8 @@ QImage RippleAnimation::maskByDrawer(QSize size, bool filled, base::lambdap; pen.setWidth(_st.width); p.setPen(pen); @@ -239,9 +242,8 @@ void RoundImageCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWid auto to = QRect(userpicLeft, userpicTop, userpicRadius * 2, userpicRadius * 2); auto from = QRect(QPoint(0, 0), _wideCache.size()); - p.setRenderHint(QPainter::SmoothPixmapTransform, true); + PainterHighQualityEnabler hq(p); p.drawPixmapLeft(to, outerWidth, _wideCache, from); - p.setRenderHint(QPainter::SmoothPixmapTransform, false); } else { if (!_wideCache.isNull()) { _wideCache = QPixmap(); @@ -254,7 +256,7 @@ void RoundImageCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWid } if (selectionLevel > 0) { - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + PainterHighQualityEnabler hq(p); p.setOpacity(snap(selectionLevel, 0., 1.)); p.setBrush(Qt::NoBrush); auto pen = _st.selectFg->p; @@ -262,7 +264,6 @@ void RoundImageCheckbox::paint(Painter &p, TimeMs ms, int x, int y, int outerWid p.setPen(pen); p.drawEllipse(rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth)); p.setOpacity(1.); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } auto iconLeft = x + 2 * _st.imageRadius + _st.selectWidth - _st.check.size; diff --git a/Telegram/SourceFiles/ui/effects/send_action_animations.cpp b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp index 8f31333fb..d207ec3c2 100644 --- a/Telegram/SourceFiles/ui/effects/send_action_animations.cpp +++ b/Telegram/SourceFiles/ui/effects/send_action_animations.cpp @@ -58,7 +58,7 @@ private: const TypingAnimation::MetaData TypingAnimation::kMeta = { 0, &TypingAnimation::create }; void TypingAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); p.setPen(Qt::NoPen); p.setBrush(color); auto position = QPointF(x + 0.5, y - 0.5) + st::historySendActionTypingPosition; @@ -76,7 +76,6 @@ void TypingAnimation::paintFrame(Painter &p, const style::color &color, int x, i position.setX(position.x() + st::historySendActionTypingDelta); frameMs = (frameMs + st::historySendActionTypingDuration - st::historySendActionTypingDeltaTime) % st::historySendActionTypingDuration; } - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } class RecordAnimation : public SendActionAnimation::Impl { @@ -104,7 +103,7 @@ private: const RecordAnimation::MetaData RecordAnimation::kMeta = { 0, &RecordAnimation::create }; void RecordAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); auto pen = color->p; pen.setWidth(st::historySendActionRecordStrokeNumerator / st::historySendActionRecordDenominator); pen.setJoinStyle(Qt::RoundJoin); @@ -121,7 +120,6 @@ void RecordAnimation::paintFrame(Painter &p, const style::color &color, int x, i size += st::historySendActionRecordDelta; } p.setOpacity(1.); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } class UploadAnimation : public SendActionAnimation::Impl { @@ -149,7 +147,7 @@ private: const UploadAnimation::MetaData UploadAnimation::kMeta = { 0, &UploadAnimation::create }; void UploadAnimation::paintFrame(Painter &p, const style::color &color, int x, int y, int outerWidth, int frameMs) { - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); auto pen = color->p; pen.setWidth(st::historySendActionUploadStrokeNumerator / st::historySendActionUploadDenominator); pen.setJoinStyle(Qt::RoundJoin); @@ -170,7 +168,6 @@ void UploadAnimation::paintFrame(Painter &p, const style::color &color, int x, i p.translate(st::historySendActionUploadDelta, 0); } p.setOpacity(1.); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); p.translate(-position); } diff --git a/Telegram/SourceFiles/ui/images.cpp b/Telegram/SourceFiles/ui/images.cpp index 0de967d09..ade2ab023 100644 --- a/Telegram/SourceFiles/ui/images.cpp +++ b/Telegram/SourceFiles/ui/images.cpp @@ -44,7 +44,8 @@ const QPixmap &circleMask(int width, int height) { QImage mask(width, height, QImage::Format_ARGB32_Premultiplied); { Painter p(&mask); - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); + p.setCompositionMode(QPainter::CompositionMode_Source); p.fillRect(0, 0, width, height, Qt::transparent); p.setBrush(Qt::white); @@ -78,9 +79,10 @@ QImage prepareBlur(QImage img) { if (withalpha) { QImage imgsmall(w, h, img.format()); { - QPainter p(&imgsmall); + Painter p(&imgsmall); + PainterHighQualityEnabler hq(p); + p.setCompositionMode(QPainter::CompositionMode_Source); - p.setRenderHint(QPainter::SmoothPixmapTransform); p.fillRect(0, 0, w, h, Qt::transparent); p.drawImage(QRect(radius, radius, w - 2 * radius, h - 2 * radius), img, QRect(0, 0, w, h)); } @@ -498,6 +500,29 @@ const QPixmap &Image::pixCircled(int32 w, int32 h) const { return i.value(); } +const QPixmap &Image::pixBlurredCircled(int32 w, int32 h) const { + checkload(); + + if (w <= 0 || !width() || !height()) { + w = width(); + } else if (cRetina()) { + w *= cIntRetinaFactor(); + h *= cIntRetinaFactor(); + } + auto options = Images::Option::Smooth | Images::Option::Circled | Images::Option::Blurred; + auto k = PixKey(w, h, options); + auto i = _sizesCache.constFind(k); + if (i == _sizesCache.cend()) { + auto p = pixNoCache(w, h, options); + if (cRetina()) p.setDevicePixelRatio(cRetinaFactor()); + i = _sizesCache.insert(k, p); + if (!p.isNull()) { + globalAcquiredSize += int64(p.width()) * p.height() * 4; + } + } + return i.value(); +} + const QPixmap &Image::pixBlurred(int32 w, int32 h) const { checkload(); diff --git a/Telegram/SourceFiles/ui/images.h b/Telegram/SourceFiles/ui/images.h index 7049694ff..cf8ca01b4 100644 --- a/Telegram/SourceFiles/ui/images.h +++ b/Telegram/SourceFiles/ui/images.h @@ -187,12 +187,13 @@ public: const QPixmap &pix(int32 w = 0, int32 h = 0) const; const QPixmap &pixRounded(int32 w = 0, int32 h = 0, ImageRoundRadius radius = ImageRoundRadius::None, ImageRoundCorners corners = ImageRoundCorner::All) const; - const QPixmap &pixCircled(int32 w = 0, int32 h = 0) const; const QPixmap &pixBlurred(int32 w = 0, int32 h = 0) const; const QPixmap &pixColored(const style::color &add, int32 w = 0, int32 h = 0) const; const QPixmap &pixBlurredColored(const style::color &add, int32 w = 0, int32 h = 0) const; const QPixmap &pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners = ImageRoundCorner::All) const; const QPixmap &pixBlurredSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners = ImageRoundCorner::All) const; + const QPixmap &pixCircled(int32 w = 0, int32 h = 0) const; + const QPixmap &pixBlurredCircled(int32 w = 0, int32 h = 0) const; QPixmap pixNoCache(int w = 0, int h = 0, Images::Options options = 0, int outerw = -1, int outerh = -1) const; QPixmap pixColoredNoCache(const style::color &add, int32 w = 0, int32 h = 0, bool smooth = false) const; QPixmap pixBlurredColoredNoCache(const style::color &add, int32 w, int32 h = 0) const; diff --git a/Telegram/SourceFiles/ui/style/style_core.cpp b/Telegram/SourceFiles/ui/style/style_core.cpp index 4e4cbcaf1..08659f8cf 100644 --- a/Telegram/SourceFiles/ui/style/style_core.cpp +++ b/Telegram/SourceFiles/ui/style/style_core.cpp @@ -126,12 +126,13 @@ QImage createCircleMask(int size, QColor bg, QColor fg) { auto result = QImage(realSize, realSize, QImage::Format::Format_RGB32); #endif // OS_MAC_OLD { - QPainter pcircle(&result); - pcircle.setRenderHint(QPainter::HighQualityAntialiasing, true); - pcircle.fillRect(0, 0, realSize, realSize, bg); - pcircle.setPen(Qt::NoPen); - pcircle.setBrush(fg); - pcircle.drawEllipse(0, 0, realSize, realSize); + Painter p(&result); + PainterHighQualityEnabler hq(p); + + p.fillRect(0, 0, realSize, realSize, bg); + p.setPen(Qt::NoPen); + p.setBrush(fg); + p.drawEllipse(0, 0, realSize, realSize); } result.setDevicePixelRatio(cRetinaFactor()); return result; diff --git a/Telegram/SourceFiles/ui/twidget.h b/Telegram/SourceFiles/ui/twidget.h index bd225a019..28811b5ea 100644 --- a/Telegram/SourceFiles/ui/twidget.h +++ b/Telegram/SourceFiles/ui/twidget.h @@ -75,6 +75,40 @@ public: void drawPixmapRight(const QPoint &p, int outerw, const QPixmap &pix) { return drawPixmapRight(p.x(), p.y(), outerw, pix); } + +}; + +class PainterHighQualityEnabler { +public: + PainterHighQualityEnabler(Painter &p) : _painter(p) { + auto hints = _painter.renderHints(); + for_const (auto hint, Hints) { + if (!(hints & hint)) { + _hints |= hint; + } + } + if (_hints) { + _painter.setRenderHints(_hints); + } + } + PainterHighQualityEnabler(const PainterHighQualityEnabler &other) = delete; + PainterHighQualityEnabler &operator=(const PainterHighQualityEnabler &other) = delete; + ~PainterHighQualityEnabler() { + if (_hints) { + _painter.setRenderHints(_hints, false); + } + } + +private: + Painter &_painter; + QPainter::RenderHints _hints = 0; + static constexpr QPainter::RenderHint Hints[] = { + QPainter::Antialiasing, + QPainter::SmoothPixmapTransform, + QPainter::TextAntialiasing, + QPainter::HighQualityAntialiasing + }; + }; #define T_WIDGET \ diff --git a/Telegram/SourceFiles/ui/widgets/checkbox.cpp b/Telegram/SourceFiles/ui/widgets/checkbox.cpp index e54375ee1..eaf17f1ae 100644 --- a/Telegram/SourceFiles/ui/widgets/checkbox.cpp +++ b/Telegram/SourceFiles/ui/widgets/checkbox.cpp @@ -141,15 +141,15 @@ void Checkbox::paintEvent(QPaintEvent *e) { paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms, &color); if (_checkRect.intersects(e->rect())) { - p.setRenderHint(QPainter::HighQualityAntialiasing); - auto pen = anim::pen(_st.checkFg, _st.checkFgActive, active); pen.setWidth(_st.thickness); p.setPen(pen); p.setBrush(anim::brush(_st.checkBg, anim::color(_st.checkFg, _st.checkFgActive, active), active)); - p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2., _st.thickness / 2., _st.thickness / 2., _st.thickness / 2.)), st::buttonRadius - (_st.thickness / 2.), st::buttonRadius - (_st.thickness / 2.)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawRoundedRect(QRectF(_checkRect).marginsRemoved(QMarginsF(_st.thickness / 2., _st.thickness / 2., _st.thickness / 2., _st.thickness / 2.)), st::buttonRadius - (_st.thickness / 2.), st::buttonRadius - (_st.thickness / 2.)); + } if (active > 0) { _st.checkIcon.paint(p, QPoint(_st.margin.left(), _st.margin.top()), width()); @@ -247,7 +247,7 @@ void Radiobutton::paintEvent(QPaintEvent *e) { paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms, &color); if (_checkRect.intersects(e->rect())) { - p.setRenderHint(QPainter::HighQualityAntialiasing); + PainterHighQualityEnabler hq(p); auto pen = anim::pen(_st.checkFg, _st.checkFgActive, active); pen.setWidth(_st.thickness); @@ -275,8 +275,6 @@ void Radiobutton::paintEvent(QPaintEvent *e) { // } //} } - - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } if (_checkRect.contains(e->rect())) return; diff --git a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp index 967643ae9..8ceb21c4b 100644 --- a/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp +++ b/Telegram/SourceFiles/ui/widgets/continuous_sliders.cpp @@ -186,8 +186,9 @@ float64 FilledSlider::getOverDuration() const { void FilledSlider::paintEvent(QPaintEvent *e) { Painter p(this); + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing); auto masterOpacity = fadeOpacity(); auto ms = getms(); @@ -233,8 +234,9 @@ float64 MediaSlider::getOverDuration() const { void MediaSlider::paintEvent(QPaintEvent *e) { Painter p(this); + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); - p.setRenderHint(QPainter::HighQualityAntialiasing); p.setOpacity(fadeOpacity()); auto horizontal = isHorizontal(); diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.cpp b/Telegram/SourceFiles/ui/widgets/input_fields.cpp index cd8fdbddd..717406f45 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/input_fields.cpp @@ -1542,13 +1542,14 @@ void FlatInput::paintEvent(QPaintEvent *e) { auto ms = getms(); auto placeholderFocused = _a_placeholderFocused.current(ms, hasFocus() ? 1. : 0.); - p.setRenderHint(QPainter::HighQualityAntialiasing); auto pen = anim::pen(_st.borderColor, _st.borderActive, placeholderFocused); pen.setWidth(_st.borderWidth); p.setPen(pen); p.setBrush(anim::brush(_st.bgColor, _st.bgActive, placeholderFocused)); - p.drawRoundedRect(QRectF(0, 0, width(), height()).marginsRemoved(QMarginsF(_st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2.)), st::buttonRadius - (_st.borderWidth / 2.), st::buttonRadius - (_st.borderWidth / 2.)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawRoundedRect(QRectF(0, 0, width(), height()).marginsRemoved(QMarginsF(_st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2., _st.borderWidth / 2.)), st::buttonRadius - (_st.borderWidth / 2.), st::buttonRadius - (_st.borderWidth / 2.)); + } if (!_st.icon.empty()) { _st.icon.paint(p, 0, 0, width()); diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index f2fa728ba..ce8a7bd47 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -170,19 +170,20 @@ void MultiSelect::Inner::Item::paintOnce(Painter &p, int x, int y, int outerWidt auto clipEnabled = p.hasClipping(); auto clip = clipEnabled ? p.clipRegion() : QRegion(); - p.setRenderHint(QPainter::HighQualityAntialiasing); p.setClipRect(inner); p.setPen(Qt::NoPen); p.setBrush(_active ? _st.textActiveBg : _st.textBg); - p.drawRoundedRect(rtlrect(x, y, _width, _st.height, outerWidth), radius, radius); + { + PainterHighQualityEnabler hq(p); + p.drawRoundedRect(rtlrect(x, y, _width, _st.height, outerWidth), radius, radius); + } if (clipEnabled) { p.setClipRegion(clip); } else { p.setClipping(false); } - p.setRenderHint(QPainter::HighQualityAntialiasing, false); auto overOpacity = _overOpacity.current(ms, _over ? 1. : 0.); if (overOpacity < 1.) { @@ -203,9 +204,10 @@ void MultiSelect::Inner::Item::paintDeleteButton(Painter &p, int x, int y, int o p.setPen(Qt::NoPen); p.setBrush(_color); - p.setRenderHint(QPainter::HighQualityAntialiasing); - p.drawEllipse(rtlrect(x, y, _st.height, _st.height, outerWidth)); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); + { + PainterHighQualityEnabler hq(p); + p.drawEllipse(rtlrect(x, y, _st.height, _st.height, outerWidth)); + } CrossAnimation::paint(p, _st.deleteCross, _st.deleteFg, x, y, outerWidth, overOpacity); @@ -213,15 +215,15 @@ void MultiSelect::Inner::Item::paintDeleteButton(Painter &p, int x, int y, int o } bool MultiSelect::Inner::Item::paintCached(Painter &p, int x, int y, int outerWidth) { + PainterHighQualityEnabler hq(p); + auto opacity = _visibility.current(_hiding ? 0. : 1.); auto scale = opacity + _st.minScale * (1. - opacity); auto height = opacity * _cache.height() / _cache.devicePixelRatio(); auto width = opacity * _cache.width() / _cache.devicePixelRatio(); p.setOpacity(opacity); - p.setRenderHint(QPainter::SmoothPixmapTransform, true); p.drawPixmap(rtlrect(x + (_width - width) / 2., y + (_st.height - height) / 2., width, height, outerWidth), _cache); - p.setRenderHint(QPainter::SmoothPixmapTransform, false); p.setOpacity(1.); return true; } diff --git a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp index 1a7016467..6c152bcc9 100644 --- a/Telegram/SourceFiles/ui/widgets/scroll_area.cpp +++ b/Telegram/SourceFiles/ui/widgets/scroll_area.cpp @@ -139,7 +139,7 @@ void ScrollBar::paintEvent(QPaintEvent *e) { } if (a_fullOpacity.current() == 0.) return; - QPainter p(this); + Painter p(this); auto deltal = _vertical ? _st->deltax : 0, deltar = _vertical ? _st->deltax : 0; auto deltat = _vertical ? 0 : _st->deltax, deltab = _vertical ? 0 : _st->deltax; p.setPen(Qt::NoPen); @@ -148,12 +148,11 @@ void ScrollBar::paintEvent(QPaintEvent *e) { auto bar = anim::color(_st->barColor, _st->barOverColor, a_barOver.current()); bar.setAlpha(anim::interpolate(0, bar.alpha(), a_fullOpacity.current())); if (_st->round) { - p.setRenderHint(QPainter::HighQualityAntialiasing, true); + PainterHighQualityEnabler hq(p); p.setBrush(bg); p.drawRoundedRect(QRect(deltal, deltat, width() - deltal - deltar, height() - deltat - deltab), _st->round, _st->round); p.setBrush(bar); p.drawRoundedRect(_bar, _st->round, _st->round); - p.setRenderHint(QPainter::HighQualityAntialiasing, false); } else { p.fillRect(QRect(deltal, deltat, width() - deltal - deltar, height() - deltat - deltab), bg); p.fillRect(_bar, bar); diff --git a/Telegram/SourceFiles/ui/widgets/widgets.style b/Telegram/SourceFiles/ui/widgets/widgets.style index ee2d1fbe9..881b977d9 100644 --- a/Telegram/SourceFiles/ui/widgets/widgets.style +++ b/Telegram/SourceFiles/ui/widgets/widgets.style @@ -464,9 +464,9 @@ defaultFlatLabel: FlatLabel { } defaultLinkButton: LinkButton { - color: btnYesColor; - overColor: btnYesColor; - downColor: btnYesHover; + color: windowActiveTextFg; + overColor: windowActiveTextFg; + downColor: windowActiveTextFg; font: linkFont; overFont: linkOverFont; } @@ -616,7 +616,7 @@ defaultInputArea: InputArea { duration: 120; borderFg: #e0e0e0; - borderFgActive: #62c0f7; + borderFgActive: activeLineFg; borderFgError: #e48383; border: 1px; @@ -643,7 +643,7 @@ defaultInputField: InputField { duration: 120; borderFg: #e0e0e0; - borderFgActive: #62c0f7; + borderFgActive: activeLineFg; borderFgError: #e48383; border: 1px; @@ -719,8 +719,8 @@ defaultSettingsSlider: SettingsSlider { barFgActive: windowBgActive; labelTop: 17px; labelFont: normalFont; - labelFg: #1485c2; - labelFgActive: #1485c2; + labelFg: windowActiveTextFg; + labelFgActive: windowActiveTextFg; duration: 150; } diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 0e61c8060..d7a38f89d 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -72,6 +72,8 @@ MainMenu::MainMenu(QWidget *parent) : TWidget(parent) _version->setLink(2, MakeShared([] { Ui::showLayer(new AboutBox()); })); subscribe(FileDownload::ImageLoaded(), [this] { update(); }); + subscribe(Global::RefConnectionTypeChanged(), [this] { updateConnectionState(); }); + updateConnectionState(); } void MainMenu::checkSelf() { @@ -110,6 +112,16 @@ void MainMenu::updateControlsGeometry() { _version->moveToLeft(st::mainMenuFooterLeft, height() - st::mainMenuVersionBottom - _version->height()); } +void MainMenu::updateConnectionState() { + auto state = MTP::dcstate(); + if (state == MTP::ConnectingState || state == MTP::DisconnectedState || state < 0) { + _connectionText = lang(lng_status_connecting); + } else { + _connectionText = lang(lng_status_online); + } + update(); +} + void MainMenu::paintEvent(QPaintEvent *e) { Painter p(this); auto clip = e->rect(); @@ -121,7 +133,7 @@ void MainMenu::paintEvent(QPaintEvent *e) { if (auto self = App::self()) { self->nameText.drawLeftElided(p, st::mainMenuCoverTextLeft, st::mainMenuCoverNameTop, width() - 2 * st::mainMenuCoverTextLeft, width()); p.setFont(st::normalFont); - p.drawTextLeft(st::mainMenuCoverTextLeft, st::mainMenuCoverStatusTop, width(), qsl("online")); + p.drawTextLeft(st::mainMenuCoverTextLeft, st::mainMenuCoverStatusTop, width(), _connectionText); } } auto other = QRect(0, st::mainMenuCoverHeight, width(), height() - st::mainMenuCoverHeight).intersected(clip); diff --git a/Telegram/SourceFiles/window/window_main_menu.h b/Telegram/SourceFiles/window/window_main_menu.h index 1a527c271..5d23119d5 100644 --- a/Telegram/SourceFiles/window/window_main_menu.h +++ b/Telegram/SourceFiles/window/window_main_menu.h @@ -49,6 +49,7 @@ protected: private: void checkSelf(); void updateControlsGeometry(); + void updateConnectionState(); ChildWidget _userpicButton = { nullptr }; ChildWidget _menu; @@ -56,6 +57,7 @@ private: ChildWidget _version; bool _showFinished = false; + QString _connectionText; }; diff --git a/Telegram/build/version b/Telegram/build/version index c9c37f675..1daa28362 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -3,4 +3,4 @@ AppVersionStrMajor 0.10 AppVersionStrSmall 0.10.20 AppVersionStr 0.10.20 AlphaChannel 0 -BetaVersion 10019010 +BetaVersion 10019011