mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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.
|
// Copy to clipboard support.
|
||||||
QString ReplyMarkupClickHandler::copyToClipboardText() const {
|
QString ReplyMarkupClickHandler::copyToClipboardText() const {
|
||||||
if (const auto button = getButton()) {
|
const auto button = getUrlButton();
|
||||||
using Type = HistoryMessageMarkupButton::Type;
|
return button ? QString::fromUtf8(button->data) : QString();
|
||||||
if (button->type == Type::Url || button->type == Type::Auth) {
|
|
||||||
return QString::fromUtf8(button->data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const {
|
QString ReplyMarkupClickHandler::copyToClipboardContextItemText() const {
|
||||||
if (const auto button = getButton()) {
|
const auto button = getUrlButton();
|
||||||
using Type = HistoryMessageMarkupButton::Type;
|
return button ? tr::lng_context_copy_link(tr::now) : QString();
|
||||||
if (button->type == Type::Url || button->type == Type::Auth) {
|
|
||||||
return tr::lng_context_copy_link(tr::now);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds the corresponding button in the items markup struct.
|
// 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);
|
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 {
|
void ReplyMarkupClickHandler::onClickImpl() const {
|
||||||
if (const auto item = _owner->message(_itemId)) {
|
if (const auto item = _owner->message(_itemId)) {
|
||||||
App::activateBotCommand(item, _row, _column);
|
App::activateBotCommand(item, _row, _column);
|
||||||
|
@ -454,6 +455,19 @@ QString ReplyMarkupClickHandler::buttonText() const {
|
||||||
return QString();
|
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() = default;
|
||||||
ReplyKeyboard::Button::Button(Button &&other) = default;
|
ReplyKeyboard::Button::Button(Button &&other) = default;
|
||||||
ReplyKeyboard::Button &ReplyKeyboard::Button::operator=(
|
ReplyKeyboard::Button &ReplyKeyboard::Button::operator=(
|
||||||
|
|
|
@ -251,9 +251,7 @@ public:
|
||||||
int column,
|
int column,
|
||||||
FullMsgId context);
|
FullMsgId context);
|
||||||
|
|
||||||
QString tooltip() const override {
|
QString tooltip() const override;
|
||||||
return _fullDisplayed ? QString() : buttonText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFullDisplayed(bool full) {
|
void setFullDisplayed(bool full) {
|
||||||
_fullDisplayed = full;
|
_fullDisplayed = full;
|
||||||
|
@ -269,6 +267,8 @@ public:
|
||||||
// than the one was used when constructing the handler, but not a big deal.
|
// than the one was used when constructing the handler, but not a big deal.
|
||||||
const HistoryMessageMarkupButton *getButton() const;
|
const HistoryMessageMarkupButton *getButton() const;
|
||||||
|
|
||||||
|
const HistoryMessageMarkupButton *getUrlButton() const;
|
||||||
|
|
||||||
// We hold only FullMsgId, not HistoryItem*, because all click handlers
|
// We hold only FullMsgId, not HistoryItem*, because all click handlers
|
||||||
// are activated async and the item may be already destroyed.
|
// are activated async and the item may be already destroyed.
|
||||||
void setMessageId(const FullMsgId &msgId) {
|
void setMessageId(const FullMsgId &msgId) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue