Show URL tooltip in inline bot results.

This commit is contained in:
John Preston 2019-07-04 11:23:39 +02:00
parent d479442a63
commit 89fb121caf
3 changed files with 29 additions and 2 deletions

View File

@ -189,7 +189,9 @@ ClickHandlerPtr ItemBase::getResultUrlHandler() const {
ClickHandlerPtr ItemBase::getResultContentUrlHandler() const {
if (!_result->_content_url.isEmpty()) {
return std::make_shared<UrlClickHandler>(_result->_content_url);
return std::make_shared<UrlClickHandler>(
_result->_content_url,
false);
}
return ClickHandlerPtr();
}

View File

@ -131,6 +131,17 @@ int Inner::countHeight() {
return result + st::stickerPanPadding;
}
QString Inner::tooltipText() const {
if (const auto lnk = ClickHandler::getActive()) {
return lnk->tooltip();
}
return QString();
}
QPoint Inner::tooltipPos() const {
return _lastMousePos;
}
Inner::~Inner() = default;
void Inner::paintEvent(QPaintEvent *e) {
@ -248,6 +259,7 @@ void Inner::mouseMoveEvent(QMouseEvent *e) {
void Inner::leaveEventHook(QEvent *e) {
clearSelection();
Ui::Tooltip::Hide();
}
void Inner::leaveToChildEvent(QEvent *e, QWidget *child) {
@ -683,6 +695,10 @@ void Inner::updateSelected() {
}
if (ClickHandler::setActive(lnk, lnkhost)) {
setCursor(lnk ? style::cur_pointer : style::cur_default);
Ui::Tooltip::Hide();
}
if (lnk) {
Ui::Tooltip::Show(1000, this);
}
}

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "ui/abstract_button.h"
#include "ui/widgets/tooltip.h"
#include "ui/effects/animations.h"
#include "ui/effects/panel_animation.h"
#include "base/timer.h"
@ -48,7 +49,11 @@ struct CacheEntry {
Results results;
};
class Inner : public TWidget, public Context, private base::Subscriber {
class Inner
: public TWidget
, public Ui::AbstractTooltipShower
, public Context
, private base::Subscriber {
Q_OBJECT
public:
@ -76,6 +81,10 @@ public:
_resultSelectedCallback = std::move(callback);
}
// Ui::AbstractTooltipShower interface.
QString tooltipText() const override;
QPoint tooltipPos() const override;
~Inner();
protected: