From 041e366df7aa16c498ae8ccf7171405ec20a5e70 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 16 Jan 2017 16:27:11 +0300 Subject: [PATCH] Alpha 1.0.1: resize chats list with mouse press-and-drag. Also fixed drag-n-drop images from Firefox in Windows. Also some additional colors added to themes palette: HistoryToDown button now has separate colors. Windows title bar and buttons have separate active/inactive colors. --- Telegram/Resources/colors.palette | 22 +++++++- Telegram/Resources/default.tdesktop-theme | 21 +++++++- Telegram/Resources/winrc/Telegram.rc | 8 +-- Telegram/Resources/winrc/Updater.rc | 8 +-- Telegram/SourceFiles/app.cpp | 8 +-- Telegram/SourceFiles/application.cpp | 4 +- Telegram/SourceFiles/boxes/addcontactbox.cpp | 4 +- Telegram/SourceFiles/core/version.h | 6 +-- .../history/field_autocomplete.cpp | 10 ++-- Telegram/SourceFiles/history/history.style | 6 +-- .../SourceFiles/history/history_message.cpp | 5 +- Telegram/SourceFiles/layerwidget.cpp | 4 ++ Telegram/SourceFiles/localstorage.cpp | 4 +- Telegram/SourceFiles/mainwidget.cpp | 8 +-- .../platform/mac/window_title_mac.mm | 8 +-- .../platform/win/main_window_win.cpp | 23 ++++---- .../platform/win/window_title_win.cpp | 32 +++++++----- .../platform/win/window_title_win.h | 5 +- Telegram/SourceFiles/structs.h | 13 +++-- Telegram/SourceFiles/ui/widgets/widgets.style | 4 +- Telegram/SourceFiles/window/window.style | 52 +++++++++++++++++-- .../window/window_theme_preview.cpp | 2 +- Telegram/build/version | 8 +-- 23 files changed, 185 insertions(+), 80 deletions(-) diff --git a/Telegram/Resources/colors.palette b/Telegram/Resources/colors.palette index 8ccfb57087..024c241137 100644 --- a/Telegram/Resources/colors.palette +++ b/Telegram/Resources/colors.palette @@ -104,15 +104,27 @@ tooltipFg: #5d6c80; tooltipBorderFg: #c9d1db; // custom title bar for Windows and macOS -titleBg: windowBgOver; titleShadow: #00000003; +titleBg: windowBgOver; +titleBgActive: titleBg; +titleButtonBg: titleBg; titleButtonFg: #ababab; titleButtonBgOver: #e5e5e5; titleButtonFgOver: #9a9a9a; +titleButtonBgActive: titleButtonBg; +titleButtonFgActive: titleButtonFg; +titleButtonBgActiveOver: titleButtonBgOver; +titleButtonFgActiveOver: titleButtonFgOver; +titleButtonCloseBg: titleButtonBg; +titleButtonCloseFg: titleButtonFg; titleButtonCloseBgOver: #e81123; titleButtonCloseFgOver: windowFgActive; -titleFgActive: #3e3c3e; +titleButtonCloseBgActive: titleButtonCloseBg; +titleButtonCloseFgActive: titleButtonCloseFg; +titleButtonCloseBgActiveOver: titleButtonCloseBgOver; +titleButtonCloseFgActiveOver: titleButtonCloseFgOver; titleFg: #acacac; +titleFgActive: #3e3c3e; // tray icon trayCounterBg: #f23c34; @@ -383,7 +395,13 @@ toastFg: windowFgActive; reportSpamBg: emojiPanHeaderBg; reportSpamFg: windowFg; +historyToDownBg: windowBg; +historyToDownBgOver: windowBgOver; +historyToDownBgRipple: windowBgRipple; +historyToDownFg: menuIconFg; +historyToDownFgOver: menuIconFgOver; historyToDownShadow: #00000040; + historyComposeAreaBg: msgInBg; historyComposeAreaFg: historyTextInFg; historyComposeAreaFgService: msgInDateFg; diff --git a/Telegram/Resources/default.tdesktop-theme b/Telegram/Resources/default.tdesktop-theme index f567f5cfb3..f89d21451d 100644 --- a/Telegram/Resources/default.tdesktop-theme +++ b/Telegram/Resources/default.tdesktop-theme @@ -89,15 +89,27 @@ sliderBgActive: windowBgActive; tooltipBg: #eef2f5; tooltipFg: #5d6c80; tooltipBorderFg: #c9d1db; -titleBg: windowBgOver; titleShadow: #00000003; +titleBg: windowBgOver; +titleBgActive: titleBg; +titleButtonBg: titleBg; titleButtonFg: #ababab; titleButtonBgOver: #e5e5e5; titleButtonFgOver: #9a9a9a; +titleButtonBgActive: titleButtonBg; +titleButtonFgActive: titleButtonFg; +titleButtonBgActiveOver: titleButtonBgOver; +titleButtonFgActiveOver: titleButtonFgOver; +titleButtonCloseBg: titleButtonBg; +titleButtonCloseFg: titleButtonFg; titleButtonCloseBgOver: #e81123; titleButtonCloseFgOver: windowFgActive; -titleFgActive: #3e3c3e; +titleButtonCloseBgActive: titleButtonCloseBg; +titleButtonCloseFgActive: titleButtonCloseFg; +titleButtonCloseBgActiveOver: titleButtonCloseBgOver; +titleButtonCloseFgActiveOver: titleButtonCloseFgOver; titleFg: #acacac; +titleFgActive: #3e3c3e; trayCounterBg: #f23c34; trayCounterBgMute: #888888; trayCounterFg: #ffffff; @@ -328,6 +340,11 @@ toastBg: #000000b2; toastFg: windowFgActive; reportSpamBg: emojiPanHeaderBg; reportSpamFg: windowFg; +historyToDownBg: windowBg; +historyToDownBgOver: windowBgOver; +historyToDownBgRipple: windowBgRipple; +historyToDownFg: menuIconFg; +historyToDownFgOver: menuIconFgOver; historyToDownShadow: #00000040; historyComposeAreaBg: msgInBg; historyComposeAreaFg: historyTextInFg; diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 845fab54f6..de303e56ee 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 1,0,0,0 - PRODUCTVERSION 1,0,0,0 + FILEVERSION 1,0,1,0 + PRODUCTVERSION 1,0,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -51,10 +51,10 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Telegram Messenger LLP" - VALUE "FileVersion", "1.0.0.0" + VALUE "FileVersion", "1.0.1.0" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.0.0" + VALUE "ProductVersion", "1.0.1.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 193e83ee93..6ede29052a 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 1,0,0,0 - PRODUCTVERSION 1,0,0,0 + FILEVERSION 1,0,1,0 + PRODUCTVERSION 1,0,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,10 +43,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram Messenger LLP" VALUE "FileDescription", "Telegram Updater" - VALUE "FileVersion", "1.0.0.0" + VALUE "FileVersion", "1.0.1.0" VALUE "LegalCopyright", "Copyright (C) 2014-2017" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "1.0.0.0" + VALUE "ProductVersion", "1.0.1.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 652115b0b0..dbb4b9426a 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -407,7 +407,7 @@ namespace { data->inputUser = MTP_inputUser(d.vid, MTP_long(0)); data->setName(lang(lng_deleted), QString(), QString(), QString()); data->setPhoto(MTP_userProfilePhotoEmpty()); - data->access = UserNoAccess; + data->setIsInaccessible(); data->flags = 0; data->setBotInfoVersion(-1); status = &emptyStatus; @@ -430,8 +430,8 @@ namespace { data->input = MTP_inputPeerSelf(); data->inputUser = MTP_inputUserSelf(); } else if (!d.has_access_hash()) { - data->input = MTP_inputPeerUser(d.vid, MTP_long((data->access == UserNoAccess) ? 0 : data->access)); - data->inputUser = MTP_inputUser(d.vid, MTP_long((data->access == UserNoAccess) ? 0 : data->access)); + data->input = MTP_inputPeerUser(d.vid, MTP_long(data->isInaccessible() ? 0 : data->access)); + data->inputUser = MTP_inputUser(d.vid, MTP_long(data->isInaccessible() ? 0 : data->access)); } else { data->input = MTP_inputPeerUser(d.vid, d.vaccess_hash); data->inputUser = MTP_inputUser(d.vid, d.vaccess_hash); @@ -449,7 +449,7 @@ namespace { } data->setName(lang(lng_deleted), QString(), QString(), QString()); data->setPhoto(MTP_userProfilePhotoEmpty()); - data->access = UserNoAccess; + data->setIsInaccessible(); status = &emptyStatus; } else { // apply first_name and last_name from minimal user only if we don't have diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index c0b5a8e341..f8b1a4f1d0 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -1069,8 +1069,8 @@ void AppClass::checkMapVersion() { if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion()) { QString versionFeatures; - if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000000) { - versionFeatures = langNewVersionText();//QString::fromUtf8("\xe2\x80\x94 Appoint admins in your supergroups from members list context menu\n\xe2\x80\x94 Bug fixes and other minor improvements"); + if ((cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000001) { + versionFeatures = QString::fromUtf8("\xe2\x80\x94 Resize chats list with mouse press-and-drag\n\xe2\x80\x94 Drag-n-drop images from Firefox fixed in Windows\n\xe2\x80\x94 Bug fixes and other minor improvements"); } else if (!(cAlphaVersion() || cBetaVersion()) && Local::oldMapVersion() < 1000000) { versionFeatures = langNewVersionText(); } else { diff --git a/Telegram/SourceFiles/boxes/addcontactbox.cpp b/Telegram/SourceFiles/boxes/addcontactbox.cpp index 0089a8b114..7e14687365 100644 --- a/Telegram/SourceFiles/boxes/addcontactbox.cpp +++ b/Telegram/SourceFiles/boxes/addcontactbox.cpp @@ -426,7 +426,7 @@ SetupChannelBox::SetupChannelBox(QWidget*, ChannelData *channel, bool existing) , _existing(existing) , _public(this, qsl("channel_privacy"), 0, lang(channel->isMegagroup() ? lng_create_public_group_title : lng_create_public_channel_title), true, st::defaultBoxCheckbox) , _private(this, qsl("channel_privacy"), 1, lang(channel->isMegagroup() ? lng_create_private_group_title : lng_create_private_channel_title), false, st::defaultBoxCheckbox) -, _aboutPublicWidth(width() - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultBoxCheckbox.textPosition.x()) +, _aboutPublicWidth(st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultBoxCheckbox.textPosition.x()) , _aboutPublic(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_public_group_about : lng_create_public_channel_about), _defaultOptions, _aboutPublicWidth) , _aboutPrivate(st::defaultTextStyle, lang(channel->isMegagroup() ? lng_create_private_group_about : lng_create_private_channel_about), _defaultOptions, _aboutPublicWidth) , _link(this, st::setupChannelLink, QString(), channel->username, true) { @@ -923,7 +923,7 @@ void EditNameTitleBox::onSaveChatDone(const MTPUpdates &updates) { EditChannelBox::EditChannelBox(QWidget*, ChannelData *channel) : _channel(channel) -, _title(this, st::defaultInputField, lang(lng_dlg_new_channel_name), _channel->name) +, _title(this, st::defaultInputField, lang(channel->isMegagroup() ? lng_dlg_new_group_name : lng_dlg_new_channel_name), _channel->name) , _description(this, st::newGroupDescription, lang(lng_create_group_description), _channel->about()) , _sign(this, lang(lng_edit_sign_messages), channel->addsSignature(), st::defaultBoxCheckbox) , _publicLink(this, lang(channel->isPublic() ? lng_profile_edit_public_link : lng_profile_create_public_link), st::boxLinkButton) { diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index d5d0d71d18..505b3cde30 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -24,7 +24,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #define BETA_VERSION_MACRO (0ULL) -constexpr int AppVersion = 1000000; -constexpr str_const AppVersionStr = "1.0"; -constexpr bool AppAlphaVersion = false; +constexpr int AppVersion = 1000001; +constexpr str_const AppVersionStr = "1.0.1"; +constexpr bool AppAlphaVersion = true; constexpr uint64 AppBetaVersion = BETA_VERSION_MACRO; diff --git a/Telegram/SourceFiles/history/field_autocomplete.cpp b/Telegram/SourceFiles/history/field_autocomplete.cpp index 2177270cea..d762e70d0d 100644 --- a/Telegram/SourceFiles/history/field_autocomplete.cpp +++ b/Telegram/SourceFiles/history/field_autocomplete.cpp @@ -204,6 +204,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { bool listAllSuggestions = _filter.isEmpty(); if (_addInlineBots) { for_const (auto user, cRecentInlineBots()) { + if (user->isInaccessible()) continue; if (!listAllSuggestions && filterNotPassedByUsername(user)) continue; mrows.push_back(user); ++recentInlineBots; @@ -216,13 +217,15 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { if (App::api()) App::api()->requestFullPeer(_chat); } else if (!_chat->participants.isEmpty()) { for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) { - UserData *user = i.key(); + auto user = i.key(); + if (user->isInaccessible()) continue; if (!listAllSuggestions && filterNotPassedByName(user)) continue; if (indexOfInFirstN(mrows, user, recentInlineBots) >= 0) continue; ordered.insertMulti(App::onlineForSort(user, now), user); } } for_const (auto user, _chat->lastAuthors) { + if (user->isInaccessible()) continue; if (!listAllSuggestions && filterNotPassedByName(user)) continue; if (indexOfInFirstN(mrows, user, recentInlineBots) >= 0) continue; mrows.push_back(user); @@ -231,7 +234,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { } } if (!ordered.isEmpty()) { - for (QMultiMap::const_iterator i = ordered.cend(), b = ordered.cbegin(); i != b;) { + for (auto i = ordered.cend(), b = ordered.cbegin(); i != b;) { --i; mrows.push_back(i.value()); } @@ -243,6 +246,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) { } else { mrows.reserve(mrows.size() + _channel->mgInfo->lastParticipants.size()); for_const (auto user, _channel->mgInfo->lastParticipants) { + if (user->isInaccessible()) continue; if (!listAllSuggestions && filterNotPassedByName(user)) continue; if (indexOfInFirstN(mrows, user, recentInlineBots) >= 0) continue; mrows.push_back(user); @@ -627,7 +631,7 @@ void FieldAutocompleteInner::paintEvent(QPaintEvent *e) { p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive); p.drawText(mentionleft + namewidth + st::mentionPadding.right(), i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first); if (!second.isEmpty()) { - p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); + p.setPen(selected ? st::mentionFgOver : st::mentionFg); p.drawText(mentionleft + namewidth + st::mentionPadding.right() + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second); } } else if (!_hrows->isEmpty()) { diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 2434b636d2..1f82cc9c7e 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -44,8 +44,8 @@ historyResizeWidth: 6px; historyPaddingBottom: 8px; historyToDownPosition: point(12px, 10px); -historyToDownAbove: icon {{ "history_down_arrow", menuIconFg, point(17px, 23px) }}; -historyToDownAboveOver: icon {{ "history_down_arrow", menuIconFgOver, point(17px, 23px) }}; +historyToDownAbove: icon {{ "history_down_arrow", historyToDownFg, point(17px, 23px) }}; +historyToDownAboveOver: icon {{ "history_down_arrow", historyToDownFgOver, point(17px, 23px) }}; historyToDownPaddingTop: 10px; historyToDown: TwoIconButton { width: 52px; @@ -60,7 +60,7 @@ historyToDown: TwoIconButton { rippleAreaPosition: point(5px, 15px); rippleAreaSize: 42px; ripple: RippleAnimation(defaultRippleAnimation) { - color: windowBgRipple; + color: historyToDownBgRipple; } } historyToDownBadgeFont: semiboldFont; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 6ef97a19de..3ad0ce77df 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -1272,7 +1272,8 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, T p.setTextPalette(outbg ? st::outTextPalette : st::inTextPalette); - if (auto keyboard = inlineReplyKeyboard()) { + auto keyboard = inlineReplyKeyboard(); + if (keyboard) { int h = st::msgBotKbButton.margin + keyboard->naturalHeight(); height -= h; int top = height + st::msgBotKbButton.margin - marginBottom(); @@ -1290,7 +1291,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, T auto top = marginTop(); auto r = QRect(left, top, width, height - top - marginBottom()); - auto skipTail = isAttachedToNext() || (_media && _media->skipBubbleTail()); + auto skipTail = isAttachedToNext() || (_media && _media->skipBubbleTail()) || (keyboard != nullptr); auto displayTail = skipTail ? HistoryLayout::BubbleTail::None : (outbg && !Adaptive::ChatWide()) ? HistoryLayout::BubbleTail::Right : HistoryLayout::BubbleTail::Left; HistoryLayout::paintBubble(p, r, _history->width, selected, outbg, displayTail); diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index 9c90f2d8c6..f845a0315c 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -425,6 +425,7 @@ void LayerStackWidget::onLayerClosed(LayerWidget *layer) { if (_layers.size() == 1) { hideCurrent(); } else { + if (layer->inFocusChain()) setFocus(); layer->hide(); _layers.pop_back(); layer = currentLayer(); @@ -527,6 +528,7 @@ void LayerStackWidget::showBox(object_ptr box) { _layers.pop_front(); removingLayer->setClosing(); + if (removingLayer->inFocusChain()) setFocus(); removingLayer->hide(); removingLayer->deleteLater(); } @@ -616,6 +618,7 @@ void LayerStackWidget::appendBox(object_ptr box) { LayerWidget *LayerStackWidget::pushBox(object_ptr box) { auto oldLayer = currentLayer(); if (oldLayer) { + if (oldLayer->inFocusChain()) setFocus(); oldLayer->hide(); } auto layer = object_ptr(this, std_::move(box)); @@ -649,6 +652,7 @@ void LayerStackWidget::prependBox(object_ptr box) { void LayerStackWidget::clearLayers() { for (auto layer : base::take(_layers)) { layer->setClosing(); + if (layer->inFocusChain()) setFocus(); layer->hide(); layer->deleteLater(); } diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index 62ee61140c..718dc5b05b 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -3885,8 +3885,8 @@ PeerData *_readPeer(FileReadDescriptor &from, int32 fileVersion = 0) { user->input = MTP_inputPeerSelf(); user->inputUser = MTP_inputUserSelf(); } else { - user->input = MTP_inputPeerUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access)); - user->inputUser = MTP_inputUser(MTP_int(peerToUser(user->id)), MTP_long((user->access == UserNoAccess) ? 0 : user->access)); + user->input = MTP_inputPeerUser(MTP_int(peerToUser(user->id)), MTP_long(user->isInaccessible() ? 0 : user->access)); + user->inputUser = MTP_inputUser(MTP_int(peerToUser(user->id)), MTP_long(user->isInaccessible() ? 0 : user->access)); } user->setUserpic(photoLoc.isNull() ? ImagePtr() : ImagePtr(photoLoc)); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index eb7d2b7e73..1ee9c53698 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -191,7 +191,7 @@ MainWidget::MainWidget(QWidget *parent) : TWidget(parent) 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()->canWrite()) || (p->isUser() && p->asUser()->access == UserNoAccess)) { + if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->isInaccessible())) { Ui::show(Box(lang(lng_forward_cant))); return false; } @@ -226,7 +226,7 @@ bool MainWidget::onForward(const PeerId &peer, ForwardWhatMessages what) { bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QString &text) { PeerData *p = App::peer(peer); - if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->access == UserNoAccess)) { + if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->isInaccessible())) { Ui::show(Box(lang(lng_share_cant))); return false; } @@ -246,7 +246,7 @@ bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QStrin bool MainWidget::onInlineSwitchChosen(const PeerId &peer, const QString &botAndQuery) { PeerData *p = App::peer(peer); - if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->access == UserNoAccess)) { + if (!peer || (p->isChannel() && !p->asChannel()->canPublish() && p->asChannel()->isBroadcast()) || (p->isChat() && !p->asChat()->canWrite()) || (p->isUser() && p->asUser()->isInaccessible())) { Ui::show(Box(lang(lng_inline_switch_cant))); return false; } @@ -2062,7 +2062,7 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambdaasUser()) { callback(lang(lng_profile_delete_conversation), std_::move(deleteAndLeaveHandler)); callback(lang(lng_profile_clear_history), std_::move(clearHistoryHandler)); - if (user->access != UserNoAccess && user != App::self()) { + if (!user->isInaccessible() && user != App::self()) { auto blockSubscription = MakeShared(); auto blockAction = callback(lang(user->isBlocked() ? (user->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (user->botInfo ? lng_profile_block_bot : lng_profile_block_user)), [user, blockSubscription] { auto willBeBlocked = !user->isBlocked(); diff --git a/Telegram/SourceFiles/platform/mac/window_title_mac.mm b/Telegram/SourceFiles/platform/mac/window_title_mac.mm index a14ecbba72..a18750a1ee 100644 --- a/Telegram/SourceFiles/platform/mac/window_title_mac.mm +++ b/Telegram/SourceFiles/platform/mac/window_title_mac.mm @@ -59,11 +59,11 @@ TitleWidget::TitleWidget(MainWindow *parent, int height) : Window::TitleWidget(p void TitleWidget::paintEvent(QPaintEvent *e) { Painter p(this); - p.fillRect(rect(), st::titleBg); + auto active = isActiveWindow(); + p.fillRect(rect(), active ? st::titleBgActive : st::titleBg); - p.setPen(isActiveWindow() ? st::titleFgActive : st::titleFg); p.setFont(_font); - + p.setPen(active ? st::titleFgActive : st::titleFg); p.drawText(rect(), static_cast(parentWidget())->titleText(), style::al_center); } @@ -121,7 +121,7 @@ QImage PreviewWindowSystemButton(QColor inner, QColor border) { void PreviewWindowTitle(Painter &p, const style::palette &palette, QRect body, int titleHeight, int outerWidth) { auto titleRect = QRect(body.x(), body.y() - titleHeight, body.width(), titleHeight); p.fillRect(titleRect, QColor(0, 0, 0)); - p.fillRect(titleRect, st::titleBg[palette]); + p.fillRect(titleRect, st::titleBgActive[palette]); p.fillRect(titleRect.x(), titleRect.y() + titleRect.height() - st::lineWidth, titleRect.width(), st::lineWidth, st::titleShadow[palette]); auto useSystemFont = false; diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index c250fc2f9f..3524c95745 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -661,16 +661,19 @@ int32 MainWindow::screenNameChecksum(const QString &name) const { } void MainWindow::psRefreshTaskbarIcon() { - QWidget *w = new QWidget(this); - w->setWindowFlags(static_cast(Qt::Tool) | Qt::FramelessWindowHint); - w->setGeometry(x() + 1, y() + 1, 1, 1); - QPalette p(w->palette()); - p.setColor(QPalette::Background, st::titleBg->c); - QWindow *wnd = w->windowHandle(); - w->setPalette(p); - w->show(); - w->activateWindow(); - delete w; + auto refresher = object_ptr(this); + auto guard = base::scope_guard([&refresher] { + refresher.destroy(); + }); + refresher->setWindowFlags(static_cast(Qt::Tool) | Qt::FramelessWindowHint); + refresher->setGeometry(x() + 1, y() + 1, 1, 1); + auto palette = refresher->palette(); + palette.setColor(QPalette::Background, (isActiveWindow() ? st::titleBgActive : st::titleBg)->c); + refresher->setPalette(palette); + refresher->show(); + refresher->activateWindow(); + + updateIconCounters(); } void MainWindow::psTrayMenuUpdated() { diff --git a/Telegram/SourceFiles/platform/win/window_title_win.cpp b/Telegram/SourceFiles/platform/win/window_title_win.cpp index 12046a56c3..51cd75d8c1 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.cpp +++ b/Telegram/SourceFiles/platform/win/window_title_win.cpp @@ -32,14 +32,14 @@ TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent) , _maximizeRestore(this, st::titleButtonMaximize) , _close(this, st::titleButtonClose) , _shadow(this, st::titleShadow) -, _maximized(parent->window()->windowState() & Qt::WindowMaximized) { +, _maximizedState(parent->window()->windowState() & Qt::WindowMaximized) { _minimize->setClickedCallback([this]() { window()->setWindowState(Qt::WindowMinimized); _minimize->clearState(); }); _minimize->setPointerCursor(false); _maximizeRestore->setClickedCallback([this]() { - window()->setWindowState(_maximized ? Qt::WindowNoState : Qt::WindowMaximized); + window()->setWindowState(_maximizedState ? Qt::WindowNoState : Qt::WindowMaximized); _maximizeRestore->clearState(); }); _maximizeRestore->setPointerCursor(false); @@ -55,12 +55,18 @@ TitleWidget::TitleWidget(QWidget *parent) : Window::TitleWidget(parent) void TitleWidget::init() { connect(window()->windowHandle(), SIGNAL(windowStateChanged(Qt::WindowState)), this, SLOT(onWindowStateChanged(Qt::WindowState))); - _maximized = (window()->windowState() & Qt::WindowMaximized); - updateMaximizeRestoreButton(); + _maximizedState = (window()->windowState() & Qt::WindowMaximized); + _activeState = isActiveWindow(); + updateButtonsState(); } void TitleWidget::paintEvent(QPaintEvent *e) { - Painter(this).fillRect(rect(), st::titleBg); + auto active = isActiveWindow(); + if (_activeState != active) { + _activeState = active; + updateButtonsState(); + } + Painter(this).fillRect(rect(), active ? st::titleBgActive : st::titleBg); } void TitleWidget::updateControlsPosition() { @@ -84,18 +90,20 @@ void TitleWidget::onWindowStateChanged(Qt::WindowState state) { if (state == Qt::WindowMinimized) return; auto maximized = (state == Qt::WindowMaximized); - if (_maximized != maximized) { - _maximized = maximized; - updateMaximizeRestoreButton(); + if (_maximizedState != maximized) { + _maximizedState = maximized; + updateButtonsState(); } } -void TitleWidget::updateMaximizeRestoreButton() { - if (_maximized) { - _maximizeRestore->setIconOverride(&st::titleButtonRestoreIcon, &st::titleButtonRestoreIconOver); +void TitleWidget::updateButtonsState() { + _minimize->setIconOverride(_activeState ? &st::titleButtonMinimizeIconActive : nullptr, _activeState ? &st::titleButtonMinimizeIconActiveOver : nullptr); + if (_maximizedState) { + _maximizeRestore->setIconOverride(_activeState ? &st::titleButtonRestoreIconActive : &st::titleButtonRestoreIcon, _activeState ? &st::titleButtonRestoreIconActiveOver : &st::titleButtonRestoreIconOver); } else { - _maximizeRestore->setIconOverride(nullptr, nullptr); + _maximizeRestore->setIconOverride(_activeState ? &st::titleButtonMaximizeIconActive : nullptr, _activeState ? &st::titleButtonMaximizeIconActiveOver : nullptr); } + _close->setIconOverride(_activeState ? &st::titleButtonCloseIconActive : nullptr, _activeState ? &st::titleButtonCloseIconActiveOver : nullptr); } Window::HitTestResult TitleWidget::hitTest(const QPoint &p) const { diff --git a/Telegram/SourceFiles/platform/win/window_title_win.h b/Telegram/SourceFiles/platform/win/window_title_win.h index d6d7c3ddd3..d034dcb19e 100644 --- a/Telegram/SourceFiles/platform/win/window_title_win.h +++ b/Telegram/SourceFiles/platform/win/window_title_win.h @@ -57,7 +57,7 @@ protected: void resizeEvent(QResizeEvent *e) override; private: - void updateMaximizeRestoreButton(); + void updateButtonsState(); void updateControlsPosition(); object_ptr _minimize; @@ -65,7 +65,8 @@ private: object_ptr _close; object_ptr _shadow; - bool _maximized = false; + bool _maximizedState = false; + bool _activeState = false; }; diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index c25a3ef126..4451413766 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -366,8 +366,6 @@ private: }; -static const uint64 UserNoAccess = 0xFFFFFFFFFFFFFFFFULL; - class BotCommand { public: BotCommand(const QString &command, const QString &description) : command(command), _description(description) { @@ -407,7 +405,6 @@ struct BotInfo { class PhotoData; class UserData : public PeerData { public: - UserData(const PeerId &id) : PeerData(id) { } void setPhoto(const MTPUserProfilePhoto &photo); @@ -432,8 +429,14 @@ public: bool isBotInlineGeo() const { return flags & MTPDuser::Flag::f_bot_inline_geo; } + bool isInaccessible() const { + return (access == NoAccess); + } + void setIsInaccessible() { + access = NoAccess; + } bool canWrite() const { - return access != UserNoAccess; + return !isInaccessible(); } bool isContact() const { return (contact > 0); @@ -507,6 +510,8 @@ private: BlockStatus _blockStatus = BlockStatus::Unknown; int _commonChatsCount = 0; + static constexpr const uint64 NoAccess = 0xFFFFFFFFFFFFFFFFULL; + }; class ChatData : public PeerData { diff --git a/Telegram/SourceFiles/ui/widgets/widgets.style b/Telegram/SourceFiles/ui/widgets/widgets.style index 65ccb44864..dec96a5ccc 100644 --- a/Telegram/SourceFiles/ui/widgets/widgets.style +++ b/Telegram/SourceFiles/ui/widgets/widgets.style @@ -818,11 +818,11 @@ defaultTooltip: Tooltip { historyToDownBelow: icon { { "history_down_shadow", historyToDownShadow }, - { "history_down_circle", windowBg, point(4px, 4px) }, + { "history_down_circle", historyToDownBg, point(4px, 4px) }, }; historyToDownBelowOver: icon { { "history_down_shadow", historyToDownShadow }, - { "history_down_circle", windowBgOver, point(4px, 4px) }, + { "history_down_circle", historyToDownBgOver, point(4px, 4px) }, }; contactsAddIconBelow: icon { { "history_down_shadow", historyToDownShadow }, diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index 3a5b5da0fb..d5b830e192 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -145,34 +145,78 @@ titleButtonMinimize: IconButton { width: 24px; height: 21px; - icon: icon {{ "title_button_minimize", titleButtonFg, point(4px, 4px) }}; + icon: icon { + { size(24px, 21px), titleButtonBg }, + { "title_button_minimize", titleButtonFg, point(4px, 4px) }, + }; iconOver: icon { { size(24px, 21px), titleButtonBgOver }, { "title_button_minimize", titleButtonFgOver, point(4px, 4px) }, }; iconPosition: point(0px, 0px); } +titleButtonMinimizeIconActive: icon { + { size(24px, 21px), titleButtonBgActive }, + { "title_button_minimize", titleButtonFgActive, point(4px, 4px) }, +}; +titleButtonMinimizeIconActiveOver: icon { + { size(24px, 21px), titleButtonBgActiveOver }, + { "title_button_minimize", titleButtonFgActiveOver, point(4px, 4px) }, +}; titleButtonMaximize: IconButton(titleButtonMinimize) { - icon: icon {{ "title_button_maximize", titleButtonFg, point(4px, 4px) }}; + icon: icon { + { size(24px, 21px), titleButtonBg }, + { "title_button_maximize", titleButtonFg, point(4px, 4px) }, + }; iconOver: icon { { size(24px, 21px), titleButtonBgOver }, { "title_button_maximize", titleButtonFgOver, point(4px, 4px) }, }; } -titleButtonRestoreIcon: icon {{ "title_button_restore", titleButtonFg, point(4px, 4px) }}; +titleButtonMaximizeIconActive: icon { + { size(24px, 21px), titleButtonBgActive }, + { "title_button_maximize", titleButtonFgActive, point(4px, 4px) }, +}; +titleButtonMaximizeIconActiveOver: icon { + { size(24px, 21px), titleButtonBgActiveOver }, + { "title_button_maximize", titleButtonFgActiveOver, point(4px, 4px) }, +}; +titleButtonRestoreIcon: icon { + { size(24px, 21px), titleButtonBg }, + { "title_button_restore", titleButtonFg, point(4px, 4px) }, +}; titleButtonRestoreIconOver: icon { { size(24px, 21px), titleButtonBgOver }, { "title_button_restore", titleButtonFgOver, point(4px, 4px) }, }; +titleButtonRestoreIconActive: icon { + { size(24px, 21px), titleButtonBgActive }, + { "title_button_restore", titleButtonFgActive, point(4px, 4px) }, +}; +titleButtonRestoreIconActiveOver: icon { + { size(24px, 21px), titleButtonBgActiveOver }, + { "title_button_restore", titleButtonFgActiveOver, point(4px, 4px) }, +}; titleButtonClose: IconButton(titleButtonMinimize) { width: 25px; - icon: icon {{ "title_button_close", titleButtonFg, point(5px, 4px) }}; + icon: icon { + { size(25px, 21px), titleButtonCloseBg }, + { "title_button_close", titleButtonCloseFg, point(5px, 4px) }, + }; iconOver: icon { { size(25px, 21px), titleButtonCloseBgOver }, { "title_button_close", titleButtonCloseFgOver, point(5px, 4px) }, }; } +titleButtonCloseIconActive: icon { + { size(25px, 21px), titleButtonCloseBgActive }, + { "title_button_close", titleButtonCloseFgActive, point(5px, 4px) }, +}; +titleButtonCloseIconActiveOver: icon { + { size(25px, 21px), titleButtonCloseBgActiveOver }, + { "title_button_close", titleButtonCloseFgActiveOver, point(5px, 4px) }, +}; // Legacy top bar. topBarHeight: 54px; diff --git a/Telegram/SourceFiles/window/window_theme_preview.cpp b/Telegram/SourceFiles/window/window_theme_preview.cpp index ed9caea8f4..82c49ac8ad 100644 --- a/Telegram/SourceFiles/window/window_theme_preview.cpp +++ b/Telegram/SourceFiles/window/window_theme_preview.cpp @@ -902,7 +902,7 @@ int DefaultPreviewTitleHeight() { void DefaultPreviewWindowTitle(Painter &p, const style::palette &palette, QRect body, int outerWidth) { auto titleRect = QRect(body.x(), body.y() - st::titleHeight, body.width(), st::titleHeight); p.fillRect(titleRect, QColor(0, 0, 0)); - p.fillRect(titleRect, st::titleBg[palette]); + p.fillRect(titleRect, st::titleBgActive[palette]); auto right = st::titleButtonClose.width; st::titleButtonClose.icon[palette].paint(p, titleRect.x() + titleRect.width() - right + st::titleButtonClose.iconPosition.x(), titleRect.y() + st::titleButtonClose.iconPosition.y(), outerWidth); right += st::titleButtonMaximize.width; diff --git a/Telegram/build/version b/Telegram/build/version index b983a8192a..108edb2064 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,6 +1,6 @@ -AppVersion 1000000 +AppVersion 1000001 AppVersionStrMajor 1.0 -AppVersionStrSmall 1.0 -AppVersionStr 1.0.0 -AlphaChannel 0 +AppVersionStrSmall 1.0.1 +AppVersionStr 1.0.1 +AlphaChannel 1 BetaVersion 0