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 <QGuiApplication>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QToolTip>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
@@ -100,6 +101,11 @@ LiteHtmlHelpViewer::LiteHtmlHelpViewer(QWidget *parent)
|
|||||||
&QLiteHtmlWidget::contextMenuRequested,
|
&QLiteHtmlWidget::contextMenuRequested,
|
||||||
this,
|
this,
|
||||||
&LiteHtmlHelpViewer::showContextMenu);
|
&LiteHtmlHelpViewer::showContextMenu);
|
||||||
|
connect(m_viewer, &QLiteHtmlWidget::linkHighlighted, this, [this](const QUrl &url) {
|
||||||
|
m_highlightedLink = url;
|
||||||
|
if (!url.isValid())
|
||||||
|
QToolTip::hideText();
|
||||||
|
});
|
||||||
auto layout = new QVBoxLayout;
|
auto layout = new QVBoxLayout;
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -284,6 +290,12 @@ bool LiteHtmlHelpViewer::eventFilter(QObject *src, QEvent *e)
|
|||||||
goForward(1);
|
goForward(1);
|
||||||
return true;
|
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);
|
return HelpViewer::eventFilter(src, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "helpviewer.h"
|
#include "helpviewer.h"
|
||||||
#include "openpagesmanager.h"
|
|
||||||
|
|
||||||
#include <qlitehtmlwidget.h>
|
#include <qlitehtmlwidget.h>
|
||||||
|
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
@@ -68,6 +68,7 @@ private:
|
|||||||
QLiteHtmlWidget *m_viewer;
|
QLiteHtmlWidget *m_viewer;
|
||||||
std::vector<HistoryItem> m_backItems;
|
std::vector<HistoryItem> m_backItems;
|
||||||
std::vector<HistoryItem> m_forwardItems;
|
std::vector<HistoryItem> m_forwardItems;
|
||||||
|
QUrl m_highlightedLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user