From 2d48cde27afaf01a3ebebd58c4647b745a51dfaa Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 9 Dec 2016 09:19:55 +0300 Subject: [PATCH] Fixed crashes in thumb animation. Fix notifications show. Also allow reporting bots. Also disable last used stickers click. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/report_box.cpp | 8 ++++---- Telegram/SourceFiles/boxes/report_box.h | 4 ++-- Telegram/SourceFiles/boxes/stickers_box.cpp | 11 +++++++---- Telegram/SourceFiles/history/history_media_types.cpp | 3 +-- Telegram/SourceFiles/history/history_media_types.h | 7 +++++-- .../inline_bots/inline_bot_layout_internal.cpp | 3 +-- .../inline_bots/inline_bot_layout_internal.h | 7 +++++-- .../SourceFiles/profile/profile_block_actions.cpp | 9 +++++---- Telegram/SourceFiles/profile/profile_block_actions.h | 9 --------- .../window/notifications_manager_default.cpp | 2 +- Telegram/build/build.bat | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 18968c74c..cd345a1e6 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -495,6 +495,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org "lng_report_title" = "Report channel"; "lng_report_group_title" = "Report group"; +"lng_report_bot_title" = "Report bot"; "lng_report_reason_spam" = "Spam"; "lng_report_reason_violence" = "Violence"; "lng_report_reason_pornography" = "Pornography"; diff --git a/Telegram/SourceFiles/boxes/report_box.cpp b/Telegram/SourceFiles/boxes/report_box.cpp index 0b3c58b72..4a30c7049 100644 --- a/Telegram/SourceFiles/boxes/report_box.cpp +++ b/Telegram/SourceFiles/boxes/report_box.cpp @@ -30,15 +30,15 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "ui/widgets/input_fields.h" #include "mainwindow.h" -ReportBox::ReportBox(ChannelData *channel) : AbstractBox(st::boxWidth) -, _channel(channel) +ReportBox::ReportBox(PeerData *peer) : AbstractBox(st::boxWidth) +, _peer(peer) , _reasonSpam(this, qsl("report_reason"), ReasonSpam, lang(lng_report_reason_spam), true, st::defaultBoxCheckbox) , _reasonViolence(this, qsl("report_reason"), ReasonViolence, lang(lng_report_reason_violence), false, st::defaultBoxCheckbox) , _reasonPornography(this, qsl("report_reason"), ReasonPornography, lang(lng_report_reason_pornography), false, st::defaultBoxCheckbox) , _reasonOther(this, qsl("report_reason"), ReasonOther, lang(lng_report_reason_other), false, st::defaultBoxCheckbox) , _report(this, lang(lng_report_button), st::defaultBoxButton) , _cancel(this, lang(lng_cancel), st::cancelBoxButton) { - setTitleText(lang(_channel->isMegagroup() ? lng_report_group_title : lng_report_title)); + setTitleText(lang(_peer->isUser() ? lng_report_bot_title : (_peer->isMegagroup() ? lng_report_group_title : lng_report_title))); connect(_report, SIGNAL(clicked()), this, SLOT(onReport())); connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose())); @@ -119,7 +119,7 @@ void ReportBox::onReport() { return MTP_inputReportReasonSpam(); } }; - _requestId = MTP::send(MTPaccount_ReportPeer(_channel->input, getReason()), rpcDone(&ReportBox::reportDone), rpcFail(&ReportBox::reportFail)); + _requestId = MTP::send(MTPaccount_ReportPeer(_peer->input, getReason()), rpcDone(&ReportBox::reportDone), rpcFail(&ReportBox::reportFail)); } void ReportBox::reportDone(const MTPBool &result) { diff --git a/Telegram/SourceFiles/boxes/report_box.h b/Telegram/SourceFiles/boxes/report_box.h index 011ac936e..c674c59e2 100644 --- a/Telegram/SourceFiles/boxes/report_box.h +++ b/Telegram/SourceFiles/boxes/report_box.h @@ -32,7 +32,7 @@ class ReportBox : public AbstractBox, public RPCSender { Q_OBJECT public: - ReportBox(ChannelData *channel); + ReportBox(PeerData *peer); private slots: void onReport(); @@ -50,7 +50,7 @@ private: void reportDone(const MTPBool &result); bool reportFail(const RPCError &error); - ChannelData *_channel; + PeerData *_peer; ChildWidget _reasonSpam; ChildWidget _reasonViolence; diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 834af932b..2c7a0e88b 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -959,10 +959,13 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) { } else if (pressed == _selected && _actionSel < 0 && _actionDown < 0) { if (_selected >= 0 && !_inDragArea) { auto &sets = Global::RefStickerSets(); - auto it = sets.find(_rows.at(pressed)->id); - if (it != sets.cend()) { - _selected = -1; - Ui::showLayer(new StickerSetBox(Stickers::inputSetId(*it)), KeepOtherLayers); + auto row = _rows[pressed]; + if (!row->isRecentSet()) { + auto it = sets.find(row->id); + if (it != sets.cend()) { + _selected = -1; + Ui::showLayer(new StickerSetBox(Stickers::inputSetId(*it)), KeepOtherLayers); + } } } } diff --git a/Telegram/SourceFiles/history/history_media_types.cpp b/Telegram/SourceFiles/history/history_media_types.cpp index fc396e637..e47091bf2 100644 --- a/Telegram/SourceFiles/history/history_media_types.cpp +++ b/Telegram/SourceFiles/history/history_media_types.cpp @@ -164,7 +164,6 @@ void HistoryFileMedia::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool void HistoryFileMedia::thumbAnimationCallback() { Ui::repaintHistoryItem(_parent); - checkAnimationFinished(); } void HistoryFileMedia::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { @@ -209,7 +208,7 @@ void HistoryFileMedia::ensureAnimation() const { } } -void HistoryFileMedia::checkAnimationFinished() { +void HistoryFileMedia::checkAnimationFinished() const { if (_animation && !_animation->a_thumbOver.animating() && !_animation->radial.animating()) { if (dataLoaded()) { _animation.reset(); diff --git a/Telegram/SourceFiles/history/history_media_types.h b/Telegram/SourceFiles/history/history_media_types.h index b9c905a99..c58391476 100644 --- a/Telegram/SourceFiles/history/history_media_types.h +++ b/Telegram/SourceFiles/history/history_media_types.h @@ -75,7 +75,7 @@ protected: void thumbAnimationCallback(); void ensureAnimation() const; - void checkAnimationFinished(); + void checkAnimationFinished() const; bool isRadialAnimation(TimeMs ms) const { if (!_animation || !_animation->radial.animating()) return false; @@ -85,7 +85,10 @@ protected: } bool isThumbAnimation(TimeMs ms) const { if (_animation) { - return _animation->a_thumbOver.animating(ms); + if (_animation->a_thumbOver.animating(ms)) { + return true; + } + checkAnimationFinished(); } return false; } diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp index 4932714db..6427b31be 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.cpp @@ -791,7 +791,6 @@ File::~File() { void File::thumbAnimationCallback() { Ui::repaintInlineItem(this); - checkAnimationFinished(); } void File::step_radial(TimeMs ms, bool timer) { @@ -812,7 +811,7 @@ void File::ensureAnimation() const { } } -void File::checkAnimationFinished() { +void File::checkAnimationFinished() const { if (_animation && !_animation->a_thumbOver.animating() && !_animation->radial.animating()) { if (getShownDocument()->loaded()) { _animation.reset(); diff --git a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h index b98f14435..764215014 100644 --- a/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h +++ b/Telegram/SourceFiles/inline_bots/inline_bot_layout_internal.h @@ -246,7 +246,7 @@ private: void step_radial(TimeMs ms, bool timer); void ensureAnimation() const; - void checkAnimationFinished(); + void checkAnimationFinished() const; bool updateStatusText() const; bool isRadialAnimation(TimeMs ms) const { @@ -257,7 +257,10 @@ private: } bool isThumbAnimation(TimeMs ms) const { if (_animation) { - return _animation->a_thumbOver.animating(ms); + if (_animation->a_thumbOver.animating(ms)) { + return true; + } + checkAnimationFinished(); } return false; } diff --git a/Telegram/SourceFiles/profile/profile_block_actions.cpp b/Telegram/SourceFiles/profile/profile_block_actions.cpp index 233706878..75d89a8ae 100644 --- a/Telegram/SourceFiles/profile/profile_block_actions.cpp +++ b/Telegram/SourceFiles/profile/profile_block_actions.cpp @@ -131,6 +131,9 @@ void ActionsWidget::refreshButtons() { } addButton(lang(lng_profile_clear_history), SLOT(onClearHistory())); addButton(lang(lng_profile_delete_conversation), SLOT(onDeleteConversation())); + if (user->botInfo) { + addButton(lang(lng_profile_report), SLOT(onReport()), st::defaultLeftOutlineButton, st::profileBlockOneLineSkip); + } refreshBlockUser(); } else if (auto chat = peer()->asChat()) { if (chat->amCreator()) { @@ -139,7 +142,7 @@ void ActionsWidget::refreshButtons() { addButton(lang(lng_profile_clear_history), SLOT(onClearHistory())); addButton(lang(lng_profile_clear_and_exit), SLOT(onDeleteConversation())); } else if (auto channel = peer()->asChannel()) { - if (!channel->amCreator()) { + if (!channel->amCreator() && (!channel->isMegagroup() || channel->isPublic())) { addButton(lang(lng_profile_report), SLOT(onReport())); } refreshDeleteChannel(); @@ -359,9 +362,7 @@ void ActionsWidget::onLeaveChannelSure() { } void ActionsWidget::onReport() { - if (auto channel = peer()->asChannel()) { - Ui::showLayer(new ReportBox(channel)); - } + Ui::showLayer(new ReportBox(peer())); } } // namespace Profile diff --git a/Telegram/SourceFiles/profile/profile_block_actions.h b/Telegram/SourceFiles/profile/profile_block_actions.h index 014312c42..a3ebf1911 100644 --- a/Telegram/SourceFiles/profile/profile_block_actions.h +++ b/Telegram/SourceFiles/profile/profile_block_actions.h @@ -88,15 +88,6 @@ private: void sendBotCommand(const QString &command); QList _buttons; - //ChildWidget _botHelp = { nullptr }; - //ChildWidget _botSettings = { nullptr }; - //ChildWidget _reportChannel = { nullptr }; - //ChildWidget _leaveChannel = { nullptr }; - //ChildWidget _deleteChannel = { nullptr }; - //ChildWidget _upgradeToSupergroup = { nullptr }; - //ChildWidget _clearHistory = { nullptr }; - //ChildWidget _deleteConversation = { nullptr }; - //ChildWidget _blockUser = { nullptr }; // Hold some button pointers to update / toggle them. bool _hasBotHelp = false; diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 395133446..166c18640 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -412,7 +412,7 @@ void Widget::hideAnimated(float64 duration, const anim::transition &func) { void Widget::updateOpacity() { if (auto manager = ManagerInstance.data()) { - setWindowOpacity(_a_opacity.current(_hiding ? 1. : 0.) * manager->demoMasterOpacity()); + setWindowOpacity(_a_opacity.current(_hiding ? 0. : 1.) * manager->demoMasterOpacity()); } } diff --git a/Telegram/build/build.bat b/Telegram/build/build.bat index 281781a7c..985157502 100644 --- a/Telegram/build/build.bat +++ b/Telegram/build/build.bat @@ -44,7 +44,7 @@ set "ReleasePath=%HomePath%\..\out\Release" set "DeployPath=%ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStrFull%" set "SignPath=%HomePath%\..\..\TelegramPrivate\Sign.bat" set "BinaryName=Telegram" -set "DropboxSymbolsPath=X:\Telegram\symbols" +set "DropboxSymbolsPath=Y:\Telegram\symbols" if not exist %DropboxSymbolsPath% ( echo Dropbox path not found!