forked from qt-creator/qt-creator
litehtml viewer: Show link targets in tool tip
Like done for the other backends. Fixes: QTCREATORBUG-23027 Change-Id: Idc1f7ee2f6240e6c488a9d7d65ead3be6846d303 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QToolTip>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
|
||||
@@ -100,6 +101,11 @@ LiteHtmlHelpViewer::LiteHtmlHelpViewer(QWidget *parent)
|
||||
&QLiteHtmlWidget::contextMenuRequested,
|
||||
this,
|
||||
&LiteHtmlHelpViewer::showContextMenu);
|
||||
connect(m_viewer, &QLiteHtmlWidget::linkHighlighted, this, [this](const QUrl &url) {
|
||||
m_highlightedLink = url;
|
||||
if (!url.isValid())
|
||||
QToolTip::hideText();
|
||||
});
|
||||
auto layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -284,6 +290,12 @@ bool LiteHtmlHelpViewer::eventFilter(QObject *src, QEvent *e)
|
||||
goForward(1);
|
||||
return true;
|
||||
}
|
||||
} else if (e->type() == QEvent::ToolTip) {
|
||||
auto he = static_cast<QHelpEvent *>(e);
|
||||
if (m_highlightedLink.isValid())
|
||||
QToolTip::showText(he->globalPos(),
|
||||
m_highlightedLink.toDisplayString(),
|
||||
m_viewer->viewport());
|
||||
}
|
||||
return HelpViewer::eventFilter(src, e);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "helpviewer.h"
|
||||
#include "openpagesmanager.h"
|
||||
|
||||
#include <qlitehtmlwidget.h>
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QUrl>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -68,6 +68,7 @@ private:
|
||||
QLiteHtmlWidget *m_viewer;
|
||||
std::vector<HistoryItem> m_backItems;
|
||||
std::vector<HistoryItem> m_forwardItems;
|
||||
QUrl m_highlightedLink;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user