mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-23 01:27:15 +02:00
parent
5277080115
commit
dc631ef631
2 changed files with 31 additions and 17 deletions
|
@ -413,23 +413,13 @@ ReplyMarkupClickHandler::ReplyMarkupClickHandler(
|
|||
|
||||
// Copy to clipboard support.
|
||||
QString ReplyMarkupClickHandler::copyToClipboardText() const {
|
||||
if (const auto button = getButton()) {
|
||||
using Type = HistoryMessageMarkupButton::Type;
|
||||
if (button->type == Type::Url || button->type == Type::Auth) {
|
||||
return QString::fromUtf8(button->data);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
const auto button = getUrlButton();
|
||||
return button ? QString::fromUtf8(button->data) : QString();
|
||||
}
|
||||
|
||||
QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const {
|
||||
if (const auto button = getButton()) {
|
||||
using Type = HistoryMessageMarkupButton::Type;
|
||||
if (button->type == Type::Url || button->type == Type::Auth) {
|
||||
return tr::lng_context_copy_link(tr::now);
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
const auto button = getUrlButton();
|
||||
return button ? tr::lng_context_copy_link(tr::now) : QString();
|
||||
}
|
||||
|
||||
// Finds the corresponding button in the items markup struct.
|
||||
|
@ -440,6 +430,17 @@ const HistoryMessageMarkupButton *ReplyMarkupClickHandler::getButton() const {
|
|||
return HistoryMessageMarkupButton::Get(_owner, _itemId, _row, _column);
|
||||
}
|
||||
|
||||
auto ReplyMarkupClickHandler::getUrlButton() const
|
||||
-> const HistoryMessageMarkupButton* {
|
||||
if (const auto button = getButton()) {
|
||||
using Type = HistoryMessageMarkupButton::Type;
|
||||
if (button->type == Type::Url || button->type == Type::Auth) {
|
||||
return button;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ReplyMarkupClickHandler::onClickImpl() const {
|
||||
if (const auto item = _owner->message(_itemId)) {
|
||||
App::activateBotCommand(item, _row, _column);
|
||||
|
@ -454,6 +455,19 @@ QString ReplyMarkupClickHandler::buttonText() const {
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString ReplyMarkupClickHandler::tooltip() const {
|
||||
const auto button = getUrlButton();
|
||||
const auto url = button ? QString::fromUtf8(button->data) : QString();
|
||||
const auto text = _fullDisplayed ? QString() : buttonText();
|
||||
if (!url.isEmpty() && !text.isEmpty()) {
|
||||
return QString("%1\n\n%2").arg(text).arg(url);
|
||||
} else if (url.isEmpty() != text.isEmpty()) {
|
||||
return text + url;
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
ReplyKeyboard::Button::Button() = default;
|
||||
ReplyKeyboard::Button::Button(Button &&other) = default;
|
||||
ReplyKeyboard::Button &ReplyKeyboard::Button::operator=(
|
||||
|
|
|
@ -251,9 +251,7 @@ public:
|
|||
int column,
|
||||
FullMsgId context);
|
||||
|
||||
QString tooltip() const override {
|
||||
return _fullDisplayed ? QString() : buttonText();
|
||||
}
|
||||
QString tooltip() const override;
|
||||
|
||||
void setFullDisplayed(bool full) {
|
||||
_fullDisplayed = full;
|
||||
|
@ -269,6 +267,8 @@ public:
|
|||
// than the one was used when constructing the handler, but not a big deal.
|
||||
const HistoryMessageMarkupButton *getButton() const;
|
||||
|
||||
const HistoryMessageMarkupButton *getUrlButton() const;
|
||||
|
||||
// We hold only FullMsgId, not HistoryItem*, because all click handlers
|
||||
// are activated async and the item may be already destroyed.
|
||||
void setMessageId(const FullMsgId &msgId) {
|
||||
|
|
Loading…
Add table
Reference in a new issue