From 0227b5f2fae1298dde3f6a389afe33c81b405a57 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 27 Jun 2020 19:27:27 +0300 Subject: [PATCH] Removed Notify::inlineKeyboardMoved as completely unused code. --- Telegram/SourceFiles/facades.cpp | 12 ------------ Telegram/SourceFiles/facades.h | 4 ---- .../SourceFiles/history/history_inner_widget.cpp | 15 --------------- .../SourceFiles/history/history_inner_widget.h | 4 ---- Telegram/SourceFiles/history/history_item.cpp | 1 + .../SourceFiles/history/history_item_components.h | 3 --- Telegram/SourceFiles/history/history_widget.cpp | 8 -------- Telegram/SourceFiles/history/history_widget.h | 1 - .../history/view/history_view_message.cpp | 14 -------------- Telegram/SourceFiles/mainwidget.cpp | 4 ---- Telegram/SourceFiles/mainwidget.h | 1 - 11 files changed, 1 insertion(+), 66 deletions(-) diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index a73bd093c..17091be05 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -289,18 +289,6 @@ bool skipPaintEvent(QWidget *widget, QPaintEvent *event) { namespace Notify { -void inlineKeyboardMoved( - not_null item, - int oldKeyboardTop, - int newKeyboardTop) { - if (const auto m = CheckMainWidget(&item->history()->session())) { - m->notify_inlineKeyboardMoved( - item, - oldKeyboardTop, - newKeyboardTop); - } -} - bool switchInlineBotButtonReceived( not_null session, const QString &query, diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index 4dd0e4deb..353d26352 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -76,10 +76,6 @@ enum ClipStopperType { namespace Notify { -void inlineKeyboardMoved( - not_null item, - int oldKeyboardTop, - int newKeyboardTop); bool switchInlineBotButtonReceived( not_null session, const QString &query, diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 7e941ae86..df1e6f2e0 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2986,21 +2986,6 @@ void HistoryInner::notifyMigrateUpdated() { _migrated = _history->migrateFrom(); } -int HistoryInner::moveScrollFollowingInlineKeyboard( - const HistoryItem *item, - int oldKeyboardTop, - int newKeyboardTop) { - if (const auto view = item ? item->mainView() : nullptr) { - if (view->isUnderCursor()) { - const auto top = itemTop(item); - if (top >= oldKeyboardTop) { - return newKeyboardTop - oldKeyboardTop; - } - } - } - return 0; -} - void HistoryInner::applyDragSelection() { applyDragSelection(&_selected); } diff --git a/Telegram/SourceFiles/history/history_inner_widget.h b/Telegram/SourceFiles/history/history_inner_widget.h index a97a38d1c..630bfdfc6 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.h +++ b/Telegram/SourceFiles/history/history_inner_widget.h @@ -114,10 +114,6 @@ public: void notifyIsBotChanged(); void notifyMigrateUpdated(); - // When inline keyboard has moved because of the edition of its item we want - // to move scroll position so that mouse points to the same button row. - int moveScrollFollowingInlineKeyboard(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop); - // Ui::AbstractTooltipShower interface. QString tooltipText() const override; QPoint tooltipPos() const override; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 78f4cc86b..5cac457a0 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -206,6 +206,7 @@ void HistoryItem::finishEdition(int oldKeyboardTop) { } } + // Should be completely redesigned as the oldTop no longer exists. //if (oldKeyboardTop >= 0) { // #TODO edit bot message // if (auto keyboard = Get()) { // keyboard->oldTop = oldKeyboardTop; diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index c523bad10..f18026ac5 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -213,9 +213,6 @@ struct HistoryMessageReplyMarkup : public RuntimeComponent inlineKeyboard; - // If >= 0 it holds the y coord of the inlineKeyboard before the last edition. - int oldTop = -1; - private: void createFromButtonRows(const QVector &v); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d54a27e88..89879b90b 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1524,14 +1524,6 @@ void HistoryWidget::onRecordUpdate(quint16 level, qint32 samples) { } } -void HistoryWidget::notify_inlineKeyboardMoved(not_null item, int oldKeyboardTop, int newKeyboardTop) { - if (_history == item->history() || _migrated == item->history()) { - if (const auto move = _list->moveScrollFollowingInlineKeyboard(item, oldKeyboardTop, newKeyboardTop)) { - _addToScroll = move; - } - } -} - bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) { if (samePeerBot) { if (_history) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 5e7042668..7f4ada7a6 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -275,7 +275,6 @@ public: PeerData *ui_getPeerForMouseAction(); - void notify_inlineKeyboardMoved(not_null item, int oldKeyboardTop, int newKeyboardTop); bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); ~HistoryWidget(); diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 180050360..6d484ca5c 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1957,20 +1957,6 @@ QSize Message::performCountCurrentSize(int newWidth) { const auto item = message(); const auto newHeight = resizeContentGetHeight(newWidth); - const auto keyboard = item->inlineReplyKeyboard(); - if (const auto markup = item->Get()) { - const auto oldTop = markup->oldTop; - if (oldTop >= 0) { - markup->oldTop = -1; - if (keyboard) { - const auto height = st::msgBotKbButton.margin + keyboard->naturalHeight(); - const auto keyboardTop = newHeight - height + st::msgBotKbButton.margin - marginBottom(); - if (keyboardTop != oldTop) { - Notify::inlineKeyboardMoved(item, oldTop, keyboardTop); - } - } - } - } return { newWidth, newHeight }; } diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index f69d55efd..cb4b08f3b 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -604,10 +604,6 @@ void MainWidget::onFilesOrForwardDrop( } } -void MainWidget::notify_inlineKeyboardMoved(not_null item, int oldKeyboardTop, int newKeyboardTop) { - _history->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); -} - bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) { return _history->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index d33942f21..ccf8b650e 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -230,7 +230,6 @@ public: MsgId msgId); PeerData *ui_getPeerForMouseAction(); - void notify_inlineKeyboardMoved(not_null item, int oldKeyboardTop, int newKeyboardTop); bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); using FloatDelegate::floatPlayerAreaUpdated;