Add a tooltip with information about the dice.

This commit is contained in:
John Preston 2020-03-30 15:21:16 +04:00
parent 7b44d107c9
commit 31ba2828af
3 changed files with 20 additions and 0 deletions

View File

@ -1329,6 +1329,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_dialogs_skip_archive_in_search" = "Skip results from archive";
"lng_dialogs_show_archive_in_search" = "With results from archive";
"lng_about_dice" = "Send a 🎲 emoji to any chat to get a random number from Telegram.";
"lng_open_this_link" = "Open this link?";
"lng_open_link" = "Open";
"lng_allow_bot_pass" = "Allow {bot_name} to pass your Telegram name and ID to the web pages you open via this bot?";

View File

@ -13,6 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h"
#include "history/history_item_components.h"
#include "history/view/history_view_element.h"
#include "ui/toast/toast.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
namespace HistoryView {
@ -42,6 +44,20 @@ QSize Dice::size() {
return _start.size();
}
ClickHandlerPtr Dice::link() {
if (_parent->data()->Has<HistoryMessageForwarded>()) {
return nullptr;
}
static auto kHandler = std::make_shared<LambdaClickHandler>([] {
auto config = Ui::Toast::Config();
config.multiline = true;
config.minWidth = st::msgMinWidth;
config.text = tr::lng_about_dice(tr::now);
Ui::Toast::Show(config);
});
return kHandler;
}
void Dice::draw(Painter &p, const QRect &r, bool selected) {
if (const auto value = _end ? 0 : _dice->diceValue()) {
if (const auto document = Lookup(_parent, value)) {

View File

@ -24,6 +24,8 @@ public:
QSize size() override;
void draw(Painter &p, const QRect &r, bool selected) override;
ClickHandlerPtr link() override;
void clearStickerLoopPlayed() override {
}
void unloadHeavyPart() override {