From b6be1f4d9ff5fedb55422ad2e21d47bd1ab6dff6 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Tue, 29 Dec 2020 03:27:24 +0300 Subject: [PATCH] Show bot callback data in a tooltip --- Telegram/SourceFiles/history/history_item_components.cpp | 8 ++++++++ Telegram/SourceFiles/history/history_item_components.h | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 60473da4e..d3b57b58d 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -460,6 +460,14 @@ QString ReplyMarkupClickHandler::buttonText() const { return QString(); } +// Returns the full text of the corresponding button. +QString ReplyMarkupClickHandler::buttonDataString() const { + if (const auto button = getButton()) { + return QString(button->data); + } + return QString(); +} + ReplyKeyboard::Button::Button() = default; ReplyKeyboard::Button::Button(Button &&other) = default; ReplyKeyboard::Button &ReplyKeyboard::Button::operator=( diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 5e720fb20..b07f003d4 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -252,7 +252,7 @@ public: FullMsgId context); QString tooltip() const override { - return _fullDisplayed ? QString() : buttonText(); + return _fullDisplayed ? buttonDataString() : buttonText() + "\n" + buttonDataString(); } void setFullDisplayed(bool full) { @@ -288,6 +288,9 @@ private: // Returns the full text of the corresponding button. QString buttonText() const; + // Returns the data of the corresponding button as a string. + QString buttonDataString() const; + }; class ReplyKeyboard {