mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show shared link long URL tooltips.
This commit is contained in:
parent
c8aacbdb9f
commit
3c19d7b302
5 changed files with 36 additions and 7 deletions
|
@ -2838,7 +2838,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
}
|
||||
}
|
||||
}
|
||||
auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
||||
const auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
||||
if (lnkChanged || dragState.cursor != _mouseCursorState) {
|
||||
Ui::Tooltip::Hide();
|
||||
}
|
||||
|
|
|
@ -449,6 +449,21 @@ bool ListWidget::itemVisible(not_null<const BaseLayout*> item) {
|
|||
return true;
|
||||
}
|
||||
|
||||
QString ListWidget::tooltipText() const {
|
||||
if (const auto link = ClickHandler::getActive()) {
|
||||
return link->tooltip();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QPoint ListWidget::tooltipPos() const {
|
||||
return _mousePosition;
|
||||
}
|
||||
|
||||
bool ListWidget::tooltipWindowActive() const {
|
||||
return Ui::AppInFocus() && Ui::InFocusChain(window());
|
||||
}
|
||||
|
||||
void ListWidget::openPhoto(not_null<PhotoData*> photo, FullMsgId id) {
|
||||
_controller->parentController()->openPhoto(photo, id);
|
||||
}
|
||||
|
@ -1293,6 +1308,7 @@ void ListWidget::leaveEventHook(QEvent *e) {
|
|||
}
|
||||
}
|
||||
ClickHandler::clearActive();
|
||||
Ui::Tooltip::Hide();
|
||||
if (!ClickHandler::getPressed() && _cursor != style::cur_default) {
|
||||
_cursor = style::cur_default;
|
||||
setCursor(_cursor);
|
||||
|
@ -1361,7 +1377,13 @@ void ListWidget::mouseActionUpdate(const QPoint &globalPosition) {
|
|||
dragState = _overLayout->getState(_overState.cursor, request);
|
||||
lnkhost = _overLayout;
|
||||
}
|
||||
ClickHandler::setActive(dragState.link, lnkhost);
|
||||
const auto lnkChanged = ClickHandler::setActive(dragState.link, lnkhost);
|
||||
if (lnkChanged || dragState.cursor != _mouseCursorState) {
|
||||
Ui::Tooltip::Hide();
|
||||
}
|
||||
if (dragState.link) {
|
||||
Ui::Tooltip::Show(1000, this);
|
||||
}
|
||||
|
||||
if (_mouseAction == MouseAction::None) {
|
||||
_mouseCursorState = dragState.cursor;
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/widgets/tooltip.h"
|
||||
#include "info/media/info_media_widget.h"
|
||||
#include "info/media/info_media_common.h"
|
||||
#include "overview/overview_layout_delegate.h"
|
||||
|
@ -53,7 +54,8 @@ class ListProvider;
|
|||
|
||||
class ListWidget final
|
||||
: public Ui::RpWidget
|
||||
, public Overview::Layout::Delegate {
|
||||
, public Overview::Layout::Delegate
|
||||
, public Ui::AbstractTooltipShower {
|
||||
public:
|
||||
ListWidget(
|
||||
QWidget *parent,
|
||||
|
@ -83,6 +85,11 @@ public:
|
|||
void repaintItem(not_null<const BaseLayout*> item) override;
|
||||
bool itemVisible(not_null<const BaseLayout*> item) override;
|
||||
|
||||
// AbstractTooltipShower interface
|
||||
QString tooltipText() const override;
|
||||
QPoint tooltipPos() const override;
|
||||
bool tooltipWindowActive() const override;
|
||||
|
||||
void openPhoto(not_null<PhotoData*> photo, FullMsgId id) override;
|
||||
void openDocument(
|
||||
not_null<DocumentData*> document,
|
||||
|
|
|
@ -1516,7 +1516,7 @@ Link::Link(
|
|||
const auto createHandler = [](const QString &url) {
|
||||
return UrlClickHandler::IsSuspicious(url)
|
||||
? std::make_shared<HiddenUrlClickHandler>(url)
|
||||
: std::make_shared<UrlClickHandler>(url);
|
||||
: std::make_shared<UrlClickHandler>(url, false);
|
||||
};
|
||||
_page = media ? media->webpage() : nullptr;
|
||||
if (_page) {
|
||||
|
|
|
@ -438,11 +438,11 @@ private:
|
|||
bool _thumbnailBlurred = true;
|
||||
|
||||
struct LinkEntry {
|
||||
LinkEntry() : width(0) {
|
||||
}
|
||||
LinkEntry() = default;
|
||||
LinkEntry(const QString &url, const QString &text);
|
||||
|
||||
QString text;
|
||||
int32 width;
|
||||
int width = 0;
|
||||
std::shared_ptr<TextClickHandler> lnk;
|
||||
};
|
||||
QVector<LinkEntry> _links;
|
||||
|
|
Loading…
Add table
Reference in a new issue